2024-04-09 06:29:15

by SEO HOYOUNG

[permalink] [raw]
Subject: [PATCH v2] scsi: ufs: core: changing the status to check inflight

ufshcd_cmd_inflight() is used to check whether or not a command is
in progress.
Make it skip commands that have already completed by changing the
!blk_mq_request_started(rq) check into blk_mq_rq_state(rq)
!= MQ_RQ_IN_FLIGHT.
We cannot rely on lrbp->cmd since lrbp->cmd is not cleared when
a command completes.

v1 -> v2: convert the two return statements into a single return statement
And modified comment of commit

Link: https://lore.kernel.org/linux-scsi/[email protected]/
Signed-off-by: SEO HOYOUNG <[email protected]>
---
drivers/ufs/core/ufshcd.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 21429eec1b82..c940f52d9003 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -3082,16 +3082,7 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
*/
bool ufshcd_cmd_inflight(struct scsi_cmnd *cmd)
{
- struct request *rq;
-
- if (!cmd)
- return false;
-
- rq = scsi_cmd_to_rq(cmd);
- if (!blk_mq_request_started(rq))
- return false;
-
- return true;
+ return cmd && (blk_mq_rq_state(scsi_cmd_to_rq(cmd)) == MQ_RQ_IN_FLIGHT);
}

/*
--
2.26.0



2024-04-09 17:47:15

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH v2] scsi: ufs: core: changing the status to check inflight

On 4/8/24 23:32, SEO HOYOUNG wrote:
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 21429eec1b82..c940f52d9003 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -3082,16 +3082,7 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
> */
> bool ufshcd_cmd_inflight(struct scsi_cmnd *cmd)
> {
> - struct request *rq;
> -
> - if (!cmd)
> - return false;
> -
> - rq = scsi_cmd_to_rq(cmd);
> - if (!blk_mq_request_started(rq))
> - return false;
> -
> - return true;
> + return cmd && (blk_mq_rq_state(scsi_cmd_to_rq(cmd)) == MQ_RQ_IN_FLIGHT);
> }

There are superfluous parentheses in the above return statement. It is
unusual in Linux kernel code to surround equality tests with
parentheses.

Anyway:

Reviewed-by: Bart Van Assche <[email protected]>