diff mbox series

[1/2] scsi: core: Extend struct scsi_exec_args

Message ID 20230202220412.561487-2-bvanassche@acm.org
State New
Headers show
Series Simplify ufshcd_execute_start_stop() | expand

Commit Message

Bart Van Assche Feb. 2, 2023, 10:04 p.m. UTC
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(-)

Comments

Mike Christie Feb. 3, 2023, 3:08 p.m. UTC | #1
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>
John Garry Feb. 6, 2023, 9:50 a.m. UTC | #2
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 */
>   };
>
Bart Van Assche Feb. 6, 2023, 9:14 p.m. UTC | #3
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.
John Garry Feb. 7, 2023, 8:30 a.m. UTC | #4
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
diff mbox series

Patch

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 */
 };