[RFC,2/4] ufs: Remove a check from ufshcd_queuecommand()

Message ID 20210619005228.28569-3-bvanassche@acm.org
State New
Headers show
Series
  • UFS patches for Linux kernel v5.14
Related show

Commit Message

Bart Van Assche June 19, 2021, 12:52 a.m.
scsi_add_host() allocates shost->can_queue tags. ufshcd_init() sets
shost->can_queue to hba->nutrs. In other words, we know that tag values
will be in the range [0, hba->nutrs). Remove a check that verifies what
we already know. This check was introduced by commit 14497328b6a6 ("scsi:
ufs: verify command tag validity").

Cc: Gilad Broner <gbroner@codeaurora.org>
Cc: Yaniv Gardi <ygardi@codeaurora.org>
Cc: Subhash Jadavani <subhashj@codeaurora.org>
Cc: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ufs/ufshcd.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

Comments

Avri Altman June 21, 2021, 8:22 a.m. | #1
> scsi_add_host() allocates shost->can_queue tags. ufshcd_init() sets

> shost->can_queue to hba->nutrs. In other words, we know that tag values

> will be in the range [0, hba->nutrs). Remove a check that verifies what

> we already know. This check was introduced by commit 14497328b6a6

> ("scsi:

> ufs: verify command tag validity").

> 

> Cc: Gilad Broner <gbroner@codeaurora.org>

> Cc: Yaniv Gardi <ygardi@codeaurora.org>

> Cc: Subhash Jadavani <subhashj@codeaurora.org>

> Cc: Dolev Raviv <draviv@codeaurora.org>

> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

> ---

>  drivers/scsi/ufs/ufshcd.c | 14 ++------------

>  1 file changed, 2 insertions(+), 12 deletions(-)

> 

> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c

> index c230d2a6a55c..71c720d940a3 100644

> --- a/drivers/scsi/ufs/ufshcd.c

> +++ b/drivers/scsi/ufs/ufshcd.c

> @@ -2701,21 +2701,11 @@ static void ufshcd_init_lrb(struct ufs_hba *hba,

> struct ufshcd_lrb *lrb, int i)

>   */

>  static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd

> *cmd)

>  {

> +       struct ufs_hba *hba = shost_priv(host);

> +       int tag = cmd->request->tag;

>         struct ufshcd_lrb *lrbp;

> -       struct ufs_hba *hba;

> -       int tag;

>         int err = 0;

> 

> -       hba = shost_priv(host);

> -

> -       tag = cmd->request->tag;

> -       if (!ufshcd_valid_tag(hba, tag)) {

> -               dev_err(hba->dev,

> -                       "%s: invalid command tag %d: cmd=0x%p, cmd-

> >request=0x%p",

> -                       __func__, tag, cmd, cmd->request);

> -               BUG();

> -       }

While at it, maybe remove ufshcd_valid_tag altogether?

Thanks,
Avri
> -

>         if (!down_read_trylock(&hba->clk_scaling_lock))

>                 return SCSI_MLQUEUE_HOST_BUSY;
Bart Van Assche June 21, 2021, 5:31 p.m. | #2
On 6/21/21 1:22 AM, Avri Altman wrote:
> While at it, maybe remove ufshcd_valid_tag altogether?


I Will do that.

Thanks,

Bart.

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index c230d2a6a55c..71c720d940a3 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2701,21 +2701,11 @@  static void ufshcd_init_lrb(struct ufs_hba *hba, struct ufshcd_lrb *lrb, int i)
  */
 static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 {
+	struct ufs_hba *hba = shost_priv(host);
+	int tag = cmd->request->tag;
 	struct ufshcd_lrb *lrbp;
-	struct ufs_hba *hba;
-	int tag;
 	int err = 0;
 
-	hba = shost_priv(host);
-
-	tag = cmd->request->tag;
-	if (!ufshcd_valid_tag(hba, tag)) {
-		dev_err(hba->dev,
-			"%s: invalid command tag %d: cmd=0x%p, cmd->request=0x%p",
-			__func__, tag, cmd, cmd->request);
-		BUG();
-	}
-
 	if (!down_read_trylock(&hba->clk_scaling_lock))
 		return SCSI_MLQUEUE_HOST_BUSY;