All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Simplify ufshcd_execute_start_stop()
@ 2023-02-02 22:04 Bart Van Assche
  2023-02-02 22:04 ` [PATCH 1/2] scsi: core: Extend struct scsi_exec_args Bart Van Assche
  2023-02-02 22:04 ` [PATCH 2/2] scsi: ufs: Simplify ufshcd_execute_start_stop() Bart Van Assche
  0 siblings, 2 replies; 8+ messages in thread
From: Bart Van Assche @ 2023-02-02 22:04 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Avri Altman, Adrian Hunter, linux-scsi, Bart Van Assche

Hi Martin,

This patch series simplifies ufshcd_execute_start_stop() by using the new
scsi_execute_cmd() function instead of open-coding it. Please consider this
patch for the next merge window.

Thanks,

Bart.

Bart Van Assche (2):
  scsi: core: Extend struct scsi_exec_args
  scsi: ufs: Simplify ufshcd_execute_start_stop()

 drivers/scsi/scsi_lib.c    |  3 ++-
 drivers/ufs/core/ufshcd.c  | 36 +++++++++---------------------------
 include/scsi/scsi_device.h |  2 ++
 3 files changed, 13 insertions(+), 28 deletions(-)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] scsi: core: Extend struct scsi_exec_args
  2023-02-02 22:04 [PATCH 0/2] Simplify ufshcd_execute_start_stop() Bart Van Assche
@ 2023-02-02 22:04 ` Bart Van Assche
  2023-02-03 15:08   ` Mike Christie
  2023-02-06  9:50   ` John Garry
  2023-02-02 22:04 ` [PATCH 2/2] scsi: ufs: Simplify ufshcd_execute_start_stop() Bart Van Assche
  1 sibling, 2 replies; 8+ messages in thread
From: Bart Van Assche @ 2023-02-02 22:04 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Avri Altman, Adrian Hunter, linux-scsi,
	Bart Van Assche, Mike Christie, James E.J. Bottomley

Allow SCSI LLDs to specify RQF_* and SCMD_* flags.

Cc: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_lib.c    | 3 ++-
 include/scsi/scsi_device.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index abe93ec8b7d0..5feb8be6d956 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -229,8 +229,9 @@ 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;
+	req->rq_flags |= args->rq_flags | RQF_QUIET;
 
 	/*
 	 * head injection *required* here otherwise quiesce won't work
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 7e95ec45138f..79260e98774f 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -462,6 +462,8 @@ 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 */
+	req_flags_t rq_flags;		/* RQF flags */
+	unsigned int scmd_flags;	/* SCMD flags */
 	int *resid;			/* residual length */
 };
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] scsi: ufs: Simplify ufshcd_execute_start_stop()
  2023-02-02 22:04 [PATCH 0/2] Simplify ufshcd_execute_start_stop() Bart Van Assche
  2023-02-02 22:04 ` [PATCH 1/2] scsi: core: Extend struct scsi_exec_args Bart Van Assche
@ 2023-02-02 22:04 ` Bart Van Assche
  2023-02-03 15:09   ` Mike Christie
  1 sibling, 1 reply; 8+ messages in thread
From: Bart Van Assche @ 2023-02-02 22:04 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Jaegeuk Kim, Avri Altman, Adrian Hunter, linux-scsi,
	Bart Van Assche, Mike Christie, James E.J. Bottomley, Bean Huo,
	Stanley Chu, Asutosh Das, Jinyoung Choi

Use scsi_execute_cmd() instead of open-coding it.

Cc: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ufs/core/ufshcd.c | 36 +++++++++---------------------------
 1 file changed, 9 insertions(+), 27 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 89a78a0f794c..bf3cb12ef02f 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -9121,34 +9121,16 @@ 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_PM | 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,
+		.rq_flags = RQF_PM,
+		.scmd_flags = SCMD_FAIL_IF_RECOVERING,
+	};
 
-	return ret;
+	return scsi_execute_cmd(sdev, cdb, REQ_OP_DRV_IN, /*buffer=*/NULL, 0,
+			 /*timeout=*/HZ, /*retries=*/0, &args);
 }
 
 /**

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] scsi: core: Extend struct scsi_exec_args
  2023-02-02 22:04 ` [PATCH 1/2] scsi: core: Extend struct scsi_exec_args Bart Van Assche
@ 2023-02-03 15:08   ` Mike Christie
  2023-02-06  9:50   ` John Garry
  1 sibling, 0 replies; 8+ messages in thread
From: Mike Christie @ 2023-02-03 15:08 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Avri Altman, Adrian Hunter, linux-scsi,
	James E.J. Bottomley

On 2/2/23 4:04 PM, Bart Van Assche wrote:
> Allow SCSI LLDs to specify RQF_* and SCMD_* flags.
> 
> Cc: Mike Christie <michael.christie@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/scsi_lib.c    | 3 ++-
>  include/scsi/scsi_device.h | 2 ++
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 

Reviewed-by: Mike Christie <michael.christie@oracle.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] scsi: ufs: Simplify ufshcd_execute_start_stop()
  2023-02-02 22:04 ` [PATCH 2/2] scsi: ufs: Simplify ufshcd_execute_start_stop() Bart Van Assche
@ 2023-02-03 15:09   ` Mike Christie
  0 siblings, 0 replies; 8+ messages in thread
From: Mike Christie @ 2023-02-03 15:09 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Avri Altman, Adrian Hunter, linux-scsi,
	James E.J. Bottomley, Bean Huo, Stanley Chu, Asutosh Das,
	Jinyoung Choi

On 2/2/23 4:04 PM, Bart Van Assche wrote:
> Use scsi_execute_cmd() instead of open-coding it.
> 
> Cc: Mike Christie <michael.christie@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---

Reviewed-by: Mike Christie <michael.christie@oracle.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] scsi: core: Extend struct scsi_exec_args
  2023-02-02 22:04 ` [PATCH 1/2] scsi: core: Extend struct scsi_exec_args Bart Van Assche
  2023-02-03 15:08   ` Mike Christie
@ 2023-02-06  9:50   ` John Garry
  2023-02-06 21:14     ` Bart Van Assche
  1 sibling, 1 reply; 8+ messages in thread
From: John Garry @ 2023-02-06  9:50 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Avri Altman, Adrian Hunter, linux-scsi,
	Mike Christie, James E.J. Bottomley

On 02/02/2023 22:04, Bart Van Assche wrote:
> Allow SCSI LLDs to specify RQF_* and SCMD_* flags.

As I see, if BLK_MQ_REQ_PM is set for scsi_exec_args.req_flags, then 
RQF_PM gets set automatically in blk_mq_rq_ctx_init() for 
request.rq_flags. Christoph previously mentioned that we are required to 
set both (BLK_MQ_REQ_PM and RQF_PM). So where does it matter that we 
need to set RQF_PM (that setting BLK_MQ_REQ_PM doesn't cover)?

It would be nice to mention the reason in the commit description.

Thanks,
John

> 
> Cc: Mike Christie <michael.christie@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/scsi_lib.c    | 3 ++-
>   include/scsi/scsi_device.h | 2 ++
>   2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index abe93ec8b7d0..5feb8be6d956 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -229,8 +229,9 @@ 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;
> +	req->rq_flags |= args->rq_flags | RQF_QUIET;
>   
>   	/*
>   	 * head injection *required* here otherwise quiesce won't work
> diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
> index 7e95ec45138f..79260e98774f 100644
> --- a/include/scsi/scsi_device.h
> +++ b/include/scsi/scsi_device.h
> @@ -462,6 +462,8 @@ 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 */
> +	req_flags_t rq_flags;		/* RQF flags */
> +	unsigned int scmd_flags;	/* SCMD flags */
>   	int *resid;			/* residual length */
>   };
>   


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] scsi: core: Extend struct scsi_exec_args
  2023-02-06  9:50   ` John Garry
@ 2023-02-06 21:14     ` Bart Van Assche
  2023-02-07  8:30       ` John Garry
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Van Assche @ 2023-02-06 21:14 UTC (permalink / raw)
  To: John Garry, Martin K . Petersen
  Cc: Jaegeuk Kim, Avri Altman, Adrian Hunter, linux-scsi,
	Mike Christie, James E.J. Bottomley

On 2/6/23 01:50, John Garry wrote:
> On 02/02/2023 22:04, Bart Van Assche wrote:
>> Allow SCSI LLDs to specify RQF_* and SCMD_* flags.
> 
> As I see, if BLK_MQ_REQ_PM is set for scsi_exec_args.req_flags, then 
> RQF_PM gets set automatically in blk_mq_rq_ctx_init() for 
> request.rq_flags. Christoph previously mentioned that we are required to 
> set both (BLK_MQ_REQ_PM and RQF_PM). So where does it matter that we 
> need to set RQF_PM (that setting BLK_MQ_REQ_PM doesn't cover)?

I will rework this patch such that both flags are set instead of only 
one of the two.

Thanks,

Bart.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] scsi: core: Extend struct scsi_exec_args
  2023-02-06 21:14     ` Bart Van Assche
@ 2023-02-07  8:30       ` John Garry
  0 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2023-02-07  8:30 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: Jaegeuk Kim, Avri Altman, Adrian Hunter, linux-scsi,
	Mike Christie, James E.J. Bottomley

On 06/02/2023 21:14, Bart Van Assche wrote:
>> On 02/02/2023 22:04, Bart Van Assche wrote:
>>> Allow SCSI LLDs to specify RQF_* and SCMD_* flags.
>>
>> As I see, if BLK_MQ_REQ_PM is set for scsi_exec_args.req_flags, then 
>> RQF_PM gets set automatically in blk_mq_rq_ctx_init() for 
>> request.rq_flags. Christoph previously mentioned that we are required 
>> to set both (BLK_MQ_REQ_PM and RQF_PM). So where does it matter that 
>> we need to set RQF_PM (that setting BLK_MQ_REQ_PM doesn't cover)?
> 
> I will rework this patch such that both flags are set instead of only 
> one of the two.

You are setting both flags (BLK_MQ_REQ_PM and RQF_PM) in this series, 
which is what I was curious about. However that is not a change in 
behavior for ufshcd_execute_start_stop().

Thanks,
John

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-02-07  8:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02 22:04 [PATCH 0/2] Simplify ufshcd_execute_start_stop() Bart Van Assche
2023-02-02 22:04 ` [PATCH 1/2] scsi: core: Extend struct scsi_exec_args Bart Van Assche
2023-02-03 15:08   ` Mike Christie
2023-02-06  9:50   ` John Garry
2023-02-06 21:14     ` Bart Van Assche
2023-02-07  8:30       ` John Garry
2023-02-02 22:04 ` [PATCH 2/2] scsi: ufs: Simplify ufshcd_execute_start_stop() Bart Van Assche
2023-02-03 15:09   ` Mike Christie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.