From patchwork Fri Feb 10 19:32:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 652637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5650C05027 for ; Fri, 10 Feb 2023 19:33:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233034AbjBJTda (ORCPT ); Fri, 10 Feb 2023 14:33:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233324AbjBJTd0 (ORCPT ); Fri, 10 Feb 2023 14:33:26 -0500 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A993F6E8A2 for ; Fri, 10 Feb 2023 11:33:24 -0800 (PST) Received: by mail-pj1-f43.google.com with SMTP id o13so6264865pjg.2 for ; Fri, 10 Feb 2023 11:33:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=szdaICogbPof18r939EFJ5SC6zk5rCW2yG+y+ESrn/0=; b=SQPDhzdj0DoBm7oPfXarmH9dWb210835wNDYAgwq4FPjDCJN+lIgFBTRqsKr22ieIl MqSFG/wqADiivRM8O7cEFUO8F4WRpSctvB7bErWQnjCTMwUhnHN0W+xqRaFI+UwG7HkF 9/NvKfqqYoFbsuwU0FmacoajN4Gy7/FjmugIMaPhREje9ZgMmLNJkSLPMDr50brrvn40 +pOb693msuOLxkSELLGqCc0yuwXUV2yepU+UrKn9l+ygnPuIs7CKJIYXY3HQeJtFheSp e3DMTUHXWtfzXHlm9NsBiJxamZVOxQz70TIVJ3/u4drkpnf66es9/jM3gHSagxias4H8 370Q== X-Gm-Message-State: AO0yUKUwT4JSMJRmjLycIQsPPpg64tUDTbRHXjVhkRTCs5msrhCXBH7R 2wpGmjmXan1jEptJSwVbOhs= X-Google-Smtp-Source: AK7set87Cvct75aaNrzn93zR1r+FTrYyf0ATFqcR+ZFHbtWpjiMyufZkSyCBHf8VMoNyqDZVk5RxtQ== X-Received: by 2002:a17:902:e881:b0:195:e9d4:5380 with SMTP id w1-20020a170902e88100b00195e9d45380mr18015036plg.56.1676057604111; Fri, 10 Feb 2023 11:33:24 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:a834:2664:42:db8b]) by smtp.gmail.com with ESMTPSA id w9-20020a1709029a8900b0019605d48707sm3718356plp.114.2023.02.10.11.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Feb 2023 11:33:23 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Avri Altman , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Mike Christie , John Garry , "James E.J. Bottomley" Subject: [PATCH v3 1/3] scsi: core: Extend struct scsi_exec_args Date: Fri, 10 Feb 2023 11:32:56 -0800 Message-Id: <20230210193258.4004923-2-bvanassche@acm.org> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog In-Reply-To: <20230210193258.4004923-1-bvanassche@acm.org> References: <20230210193258.4004923-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Allow SCSI LLDs to specify SCMD_* flags. Cc: Mike Christie Cc: John Garry Reviewed-by: John Garry Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_lib.c | 1 + include/scsi/scsi_device.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index abe93ec8b7d0..b7c569a42aa4 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -229,6 +229,7 @@ int scsi_execute_cmd(struct scsi_device *sdev, const unsigned char *cmd, scmd->cmd_len = COMMAND_SIZE(cmd[0]); memcpy(scmd->cmnd, cmd, scmd->cmd_len); scmd->allowed = retries; + scmd->flags |= args->scmd_flags; req->timeout = timeout; req->rq_flags |= RQF_QUIET; diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 7e95ec45138f..de310f21406c 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -462,6 +462,7 @@ struct scsi_exec_args { unsigned int sense_len; /* sense buffer len */ struct scsi_sense_hdr *sshdr; /* decoded sense header */ blk_mq_req_flags_t req_flags; /* BLK_MQ_REQ flags */ + int scmd_flags; /* SCMD flags */ int *resid; /* residual length */ }; From patchwork Fri Feb 10 19:32:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 652636 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DC04C636D4 for ; Fri, 10 Feb 2023 19:33:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233267AbjBJTdt (ORCPT ); Fri, 10 Feb 2023 14:33:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233326AbjBJTdr (ORCPT ); Fri, 10 Feb 2023 14:33:47 -0500 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E12407A7DA for ; Fri, 10 Feb 2023 11:33:36 -0800 (PST) Received: by mail-pj1-f45.google.com with SMTP id rm7-20020a17090b3ec700b0022c05558d22so6473392pjb.5 for ; Fri, 10 Feb 2023 11:33:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oNLbUoc1DwNvxadZVXUht7Ag1uof9AiKGaYGg+xiuDc=; b=vevs1mDsJQTYi18BRHp32kxluqMwR0rN9rdnIPHTCi2cvNleTqxMUdHWkr/b2SD+y6 kj3pbejRJ9W5J9tUR8F3lUPUc5u5gpXdtE6DFlyrltfB+se1qApoQVqpqv4aPWyFfjAJ /luotb2SSCr/zWq5qfPC/PlHn5UaQ6S7KxwrVGTpykBq19E+TdtvlpTfJ48e7sEdLLOG VsHlp2yxunD7xT1Fm7CG16JGQioDiAvVf44a0OBvzjppJelsNZh+/fa7Xs7bkErxNZo6 DO1JCLBFP9d/cxxWSFJex9Em2z3mDXBHwwhGs4L/1R3BgKEdCRPbnORfFqOxzUQ/HPX+ hTlQ== X-Gm-Message-State: AO0yUKUqaZj1gNv4lWZp29aUSfcy40fZZ+SnSCmMag+M+RWEl8qEad9r tlDQe/avod0RcABAWbJAoPPqYuJRh7I= X-Google-Smtp-Source: AK7set8KA+zvdeDo7bPWWPKhr1ouheyg38xx5xQ1BjO9Ys0cvsFBwCWdqBqykPlligFKC12NN1dZjg== X-Received: by 2002:a17:902:ee4d:b0:198:dbd8:3cd0 with SMTP id 13-20020a170902ee4d00b00198dbd83cd0mr8582569plo.27.1676057616171; Fri, 10 Feb 2023 11:33:36 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:a834:2664:42:db8b]) by smtp.gmail.com with ESMTPSA id w9-20020a1709029a8900b0019605d48707sm3718356plp.114.2023.02.10.11.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Feb 2023 11:33:35 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Avri Altman , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Mike Christie , John Garry , "James E.J. Bottomley" , Bean Huo , Stanley Chu , Asutosh Das , Jinyoung Choi Subject: [PATCH v3 2/3] scsi: ufs: Rely on the block layer for setting RQF_PM Date: Fri, 10 Feb 2023 11:32:57 -0800 Message-Id: <20230210193258.4004923-3-bvanassche@acm.org> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog In-Reply-To: <20230210193258.4004923-1-bvanassche@acm.org> References: <20230210193258.4004923-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Do not set RQF_PM explicitly since scsi_alloc_request() sets it indirectly if BLK_MQ_REQ_PM is set. The call chain for the code that sets RQF_PM is as follows: scsi_alloc_request() blk_mq_alloc_request() __blk_mq_alloc_requests() blk_mq_rq_ctx_init() if (data->flags & BLK_MQ_REQ_PM) data->rq_flags |= RQF_PM; Cc: Mike Christie Cc: John Garry Reviewed-by: John Garry Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 0cfe112ff8c3..293933806ffa 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -9141,7 +9141,7 @@ static int ufshcd_execute_start_stop(struct scsi_device *sdev, scmd->allowed = 0/*retries*/; scmd->flags |= SCMD_FAIL_IF_RECOVERING; req->timeout = 1 * HZ; - req->rq_flags |= RQF_PM | RQF_QUIET; + req->rq_flags |= RQF_QUIET; blk_execute_rq(req, /*at_head=*/true); From patchwork Fri Feb 10 19:32:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 653091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12063C636D4 for ; Fri, 10 Feb 2023 19:34:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233088AbjBJTeC (ORCPT ); Fri, 10 Feb 2023 14:34:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232057AbjBJTeB (ORCPT ); Fri, 10 Feb 2023 14:34:01 -0500 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E00E763109 for ; Fri, 10 Feb 2023 11:33:46 -0800 (PST) Received: by mail-pj1-f47.google.com with SMTP id nn4-20020a17090b38c400b00233a6f118d0so3938830pjb.2 for ; Fri, 10 Feb 2023 11:33:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ldMhpi7kDZItu84d8Djynn4N63PPrLSrS9wk11Cp5LI=; b=5V2uYB2hS9RJTCBtG1I1rLwe2YOvdjP2rWDAmmEs+MRPBtuH+k8v53mW3AFV08Nd1c iA3gGzCfDjNsCEM4rv19WH0925v5XbkcZ49zgVySPtDpA/tnsPcSIVMCbU70Zd5WPIaU nOWFSEqZZoGKKQsXeskTtWW0lAFoxQnk7dKhJgIPMri41ElQAd7kMfIRygN2LLTu0pF2 q7VMws3Jr7C5lw7gTLNvPM/TwFQr2bVqd21fyD7/JrnPji3JoGWBMpWf8cKY6XPOD3Gn piNJtwkglfgq60ZfwjprzTZygwoUT+d1pLuJI81IS18q06uawCYbI1eVtkn3HfTNJB4O U5nw== X-Gm-Message-State: AO0yUKWibwBdVKAidBPlezhtG4AvYx7LnMuK8IP3Ud8fGL2q2dbvdnQ/ TuSPsegpHZHRW54a9BjxTLo= X-Google-Smtp-Source: AK7set9fQe3byqj8YLGYSgx86NytngEhtiISlzJaLDtveNzL2dhu6Gj1Zh1eDNkQqsjf6f125rwwLQ== X-Received: by 2002:a17:903:283:b0:199:494b:4223 with SMTP id j3-20020a170903028300b00199494b4223mr7683739plr.66.1676057626279; Fri, 10 Feb 2023 11:33:46 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:a834:2664:42:db8b]) by smtp.gmail.com with ESMTPSA id w9-20020a1709029a8900b0019605d48707sm3718356plp.114.2023.02.10.11.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Feb 2023 11:33:45 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Avri Altman , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Mike Christie , John Garry , "James E.J. Bottomley" , Bean Huo , Stanley Chu , Asutosh Das , Jinyoung Choi Subject: [PATCH v3 3/3] scsi: ufs: Simplify ufshcd_execute_start_stop() Date: Fri, 10 Feb 2023 11:32:58 -0800 Message-Id: <20230210193258.4004923-4-bvanassche@acm.org> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog In-Reply-To: <20230210193258.4004923-1-bvanassche@acm.org> References: <20230210193258.4004923-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use scsi_execute_cmd() instead of open-coding it. Cc: Mike Christie Cc: John Garry Reviewed-by: John Garry Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 293933806ffa..cb59f6b55cfd 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -9125,34 +9125,15 @@ static int ufshcd_execute_start_stop(struct scsi_device *sdev, enum ufs_dev_pwr_mode pwr_mode, struct scsi_sense_hdr *sshdr) { - unsigned char cdb[6] = { START_STOP, 0, 0, 0, pwr_mode << 4, 0 }; - struct request *req; - struct scsi_cmnd *scmd; - int ret; - - req = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, - BLK_MQ_REQ_PM); - if (IS_ERR(req)) - return PTR_ERR(req); - - scmd = blk_mq_rq_to_pdu(req); - scmd->cmd_len = COMMAND_SIZE(cdb[0]); - memcpy(scmd->cmnd, cdb, scmd->cmd_len); - scmd->allowed = 0/*retries*/; - scmd->flags |= SCMD_FAIL_IF_RECOVERING; - req->timeout = 1 * HZ; - req->rq_flags |= RQF_QUIET; - - blk_execute_rq(req, /*at_head=*/true); - - if (sshdr) - scsi_normalize_sense(scmd->sense_buffer, scmd->sense_len, - sshdr); - ret = scmd->result; - - blk_mq_free_request(req); + const unsigned char cdb[6] = { START_STOP, 0, 0, 0, pwr_mode << 4, 0 }; + const struct scsi_exec_args args = { + .sshdr = sshdr, + .req_flags = BLK_MQ_REQ_PM, + .scmd_flags = SCMD_FAIL_IF_RECOVERING, + }; - return ret; + return scsi_execute_cmd(sdev, cdb, REQ_OP_DRV_IN, /*buffer=*/NULL, + /*bufflen=*/0, /*timeout=*/HZ, /*retries=*/0, &args); } /**