mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: mcq: Limit the amount of inflight requests
@ 2023-03-30 13:11 Avri Altman
  2023-03-30 14:06 ` Johannes Thumshirn
  2023-03-30 16:39 ` Bart Van Assche
  0 siblings, 2 replies; 5+ messages in thread
From: Avri Altman @ 2023-03-30 13:11 UTC (permalink / raw)
  To: James E . J . Bottomley, Martin K . Petersen
  Cc: Asutosh Das, quic_cang, linux-scsi, linux-kernel, Avri Altman

in UFS, each request is designated via the triplet <iid, lun, task tag>.

In UFS4.0 the Initiator ID field is 8 bits wide, comprised of the
EXT_IID and IID fields. Together with the task tag (single byte), they
limit the driver's hw queues capacity.

Signed-off-by: Avri Altman <avri.altman@wdc.com>
---
 drivers/ufs/core/ufshcd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 35a3bd95c5e4..d529c42a682a 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -8468,6 +8468,10 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba)
 	if (ret)
 		goto err;
 
+	if (WARN_ONCE(hba->nutrs * hba->nr_hw_queues > (1 << 16) - 1,
+		     "there can be at most 1<<16 inflight requests\n"))
+		goto err;
+
 	/*
 	 * Previously allocated memory for nutrs may not be enough in MCQ mode.
 	 * Number of supported tags in MCQ mode may be larger than SDB mode.
-- 
2.17.1


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

* Re: [PATCH] scsi: ufs: mcq: Limit the amount of inflight requests
  2023-03-30 13:11 [PATCH] scsi: ufs: mcq: Limit the amount of inflight requests Avri Altman
@ 2023-03-30 14:06 ` Johannes Thumshirn
  2023-03-30 18:28   ` Avri Altman
  2023-03-30 16:39 ` Bart Van Assche
  1 sibling, 1 reply; 5+ messages in thread
From: Johannes Thumshirn @ 2023-03-30 14:06 UTC (permalink / raw)
  To: Avri Altman, James E . J . Bottomley, Martin K . Petersen
  Cc: Asutosh Das, quic_cang, linux-scsi, linux-kernel

On 30.03.23 15:11, Avri Altman wrote:
> +	if (WARN_ONCE(hba->nutrs * hba->nr_hw_queues > (1 << 16) - 1,
> +		     "there can be at most 1<<16 inflight requests\n"))
> +		goto err;

Hmm why not SZ_64K - 1?

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

* Re: [PATCH] scsi: ufs: mcq: Limit the amount of inflight requests
  2023-03-30 13:11 [PATCH] scsi: ufs: mcq: Limit the amount of inflight requests Avri Altman
  2023-03-30 14:06 ` Johannes Thumshirn
@ 2023-03-30 16:39 ` Bart Van Assche
  2023-03-30 18:39   ` Avri Altman
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2023-03-30 16:39 UTC (permalink / raw)
  To: Avri Altman, James E . J . Bottomley, Martin K . Petersen
  Cc: Asutosh Das, quic_cang, linux-scsi, linux-kernel

On 3/30/23 06:11, Avri Altman wrote:
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 35a3bd95c5e4..d529c42a682a 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -8468,6 +8468,10 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba)
>   	if (ret)
>   		goto err;
>   
> +	if (WARN_ONCE(hba->nutrs * hba->nr_hw_queues > (1 << 16) - 1,
> +		     "there can be at most 1<<16 inflight requests\n"))
> +		goto err;
> +
>   	/*
>   	 * Previously allocated memory for nutrs may not be enough in MCQ mode.
>   	 * Number of supported tags in MCQ mode may be larger than SDB mode.

Hi Avri,

WARN*() should only be used to report kernel bugs. hba->nutrs * 
hba->nr_hw_queues being too large is not a kernel bug but a 
configuration issue.

Instead of failing MCQ allocation, shouldn't 
ufshcd_mcq_decide_queue_depth() be modified such that it restricts 
hba->nutrs to a value that can be supported?

Thanks,

Bart.

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

* RE: [PATCH] scsi: ufs: mcq: Limit the amount of inflight requests
  2023-03-30 14:06 ` Johannes Thumshirn
@ 2023-03-30 18:28   ` Avri Altman
  0 siblings, 0 replies; 5+ messages in thread
From: Avri Altman @ 2023-03-30 18:28 UTC (permalink / raw)
  To: Johannes Thumshirn, James E . J . Bottomley, Martin K . Petersen
  Cc: Asutosh Das, quic_cang, linux-scsi, linux-kernel

 
> On 30.03.23 15:11, Avri Altman wrote:
> > +	if (WARN_ONCE(hba->nutrs * hba->nr_hw_queues > (1 << 16) - 1,
> > +		     "there can be at most 1<<16 inflight requests\n"))
> > +		goto err;
> 
> Hmm why not SZ_64K - 1?
But of course.

Thanks,
Avri

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

* RE: [PATCH] scsi: ufs: mcq: Limit the amount of inflight requests
  2023-03-30 16:39 ` Bart Van Assche
@ 2023-03-30 18:39   ` Avri Altman
  0 siblings, 0 replies; 5+ messages in thread
From: Avri Altman @ 2023-03-30 18:39 UTC (permalink / raw)
  To: Bart Van Assche, James E . J . Bottomley, Martin K . Petersen
  Cc: Asutosh Das, quic_cang, linux-scsi, linux-kernel

 
> On 3/30/23 06:11, Avri Altman wrote:
> > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> > index 35a3bd95c5e4..d529c42a682a 100644
> > --- a/drivers/ufs/core/ufshcd.c
> > +++ b/drivers/ufs/core/ufshcd.c
> > @@ -8468,6 +8468,10 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba)
> >       if (ret)
> >               goto err;
> >
> > +     if (WARN_ONCE(hba->nutrs * hba->nr_hw_queues > (1 << 16) - 1,
> > +                  "there can be at most 1<<16 inflight requests\n"))
> > +             goto err;
> > +
> >       /*
> >        * Previously allocated memory for nutrs may not be enough in MCQ
> mode.
> >        * Number of supported tags in MCQ mode may be larger than SDB
> mode.
> 
> Hi Avri,
> 
> WARN*() should only be used to report kernel bugs. hba->nutrs *
> hba->nr_hw_queues being too large is not a kernel bug but a
> configuration issue.
Will replace with an appropriate dev_info and a clarifying comment.

> 
> Instead of failing MCQ allocation, shouldn't
> ufshcd_mcq_decide_queue_depth() be modified such that it restricts
> hba->nutrs to a value that can be supported?
The driver's capacity is the product of  hba->nutrs * hba->nr_hw_queues,
Where the latter is being established only later in ufshcd_mcq_init.

Thanks,
Avri
> 
> Thanks,
> 
> Bart.

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

end of thread, other threads:[~2023-03-30 18:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 13:11 [PATCH] scsi: ufs: mcq: Limit the amount of inflight requests Avri Altman
2023-03-30 14:06 ` Johannes Thumshirn
2023-03-30 18:28   ` Avri Altman
2023-03-30 16:39 ` Bart Van Assche
2023-03-30 18:39   ` Avri Altman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®