scsi: ufs: mcq: Limit the amount of inflight requests
Subsystems (2)
Avri Altman
reviewerPATCH v2 1/1 scsi: ufs: mcq: Limit the amount of inflight requests
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.
---
v1 -> v2:
Attend Johannes's and Bart's comments
--- drivers/ufs/core/ufshcd.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/ufs/core/ufshcd.c +5 -0
@@ -8468,6 +8468,11 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba)if (ret) goto err; +if (hba->nutrs * hba->nr_hw_queues >SZ_64K -1 ) { +dev_info (hba->dev,"there can be at most 64K 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.
Signature · 1 line
2.17.1
Looks good code wise, though I have 0 clue of UFS.
Hi Avri,
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Avri-Altman/scsi-ufs-mcq-Limit-the-amount-of-inflight-requests/20230331-155149 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next patch link: https://lore.kernel.org/r/20230331074650.75-1-avri.altman%40wdc.com patch subject: [PATCH v2] scsi: ufs: mcq: Limit the amount of inflight requests config: parisc-randconfig-m031-20230329 (https://download.01.org/0day-ci/archive/20230401/[email protected]/config) compiler: hppa-linux-gcc (GCC) 12.1.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Link: https://lore.kernel.org/r/[email protected]/
New smatch warnings:drivers/ufs/core/ufshcd.c:8473 ufshcd_alloc_mcq() warn: missing error code 'ret'
Old smatch warnings:drivers/ufs/core/ufshcd.c:5412 ufshcd_uic_cmd_compl() error: we previously assumed 'hba->active_uic_cmd' could be null (see line 5400) drivers/ufs/core/ufshcd.c:2350 ufshcd_hba_capabilities() warn: missing error code? 'err'
vim +/ret +8473 drivers/ufs/core/ufshcd.c
57b1c0ef89ac9d drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8457 static int ufshcd_alloc_mcq(struct ufs_hba *hba)
57b1c0ef89ac9d drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8458 {
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8459 int ret;
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8460 int old_nutrs = hba->nutrs;
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8461
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8462 ret = ufshcd_mcq_decide_queue_depth(hba);
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8463 if (ret < 0)
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8464 return ret;
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8465
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8466 hba->nutrs = ret;
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8467 ret = ufshcd_mcq_init(hba);
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8468 if (ret)
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8469 goto err;
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8470
2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 8471 if (hba->nutrs * hba->nr_hw_queues > SZ_64K - 1) {
2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 8472 dev_info(hba->dev, "there can be at most 64K inflight requests\n");
2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 @8473 goto err;ret = -EINVAL;
2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 8474 }
2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 8475
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8476 /*
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8477 * Previously allocated memory for nutrs may not be enough in MCQ mode.
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8478 * Number of supported tags in MCQ mode may be larger than SDB mode.
6ccf44fe4cd7c4 drivers/scsi/ufs/ufshcd.c Seungwon Jeon 2013-06-26 8479 */
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8480 if (hba->nutrs != old_nutrs) {
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8481 ufshcd_release_sdb_queue(hba, old_nutrs);
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8482 ret = ufshcd_memory_alloc(hba);
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8483 if (ret)
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8484 goto err;
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8485 ufshcd_host_memory_configure(hba);
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8486 }
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8487
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8488 ret = ufshcd_mcq_memory_alloc(hba);
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8489 if (ret)
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8490 goto err;
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8491
7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8492 return 0;
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8493 err:
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8494 hba->nutrs = old_nutrs;
4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8495 return ret;
57b1c0ef89ac9d drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8496 }Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Avri Altman
reviewerQuoted 56 lines
Hi Avri,
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Avri-Altman/scsi-ufs-
mcq-Limit-the-amount-of-inflight-requests/20230331-155149base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next patch link: https://lore.kernel.org/r/20230331074650.75-1-avri.altman%40wdc.com
patch subject: [PATCH v2] scsi: ufs: mcq: Limit the amount of inflight requests
config: parisc-randconfig-m031-20230329 (https://download.01.org/0day-
ci/archive/20230401/[email protected]/config)
compiler: hppa-linux-gcc (GCC) 12.1.0If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Link: https://lore.kernel.org/r/[email protected]/New smatch warnings:
drivers/ufs/core/ufshcd.c:8473ufshcd_alloc_mcq()warn: missing error code 'ret'Old smatch warnings:
drivers/ufs/core/ufshcd.c:5412ufshcd_uic_cmd_compl()error: we previously assumed 'hba->active_uic_cmd' could be null (see line 5400)drivers/ufs/core/ufshcd.c:2350ufshcd_hba_capabilities()warn: missing error code? 'err'vim +/ret +8473
drivers/ufs/core/ufshcd.c
57b1c0ef89ac9ddrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8457
static intufshcd_alloc_mcq(struct ufs_hba *hba)57b1c0ef89ac9d drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8458 { 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8459 int ret; 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8460 int old_nutrs = hba->nutrs; 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8461 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8462ret =
ufshcd_mcq_decide_queue_depth(hba);7224c806876e46drivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8463
if (ret < 0)7224c806876e46drivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8464
return ret;7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8465 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8466
hba->nutrs= ret;7224c806876e46drivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8467
ret =ufshcd_mcq_init(hba);4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8468
if (ret)4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8469
goto err;4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8470 2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 8471
Quoted 7 lines
if (
hba->nutrs*hba->nr_hw_queues>SZ_64K- 1) {2580a95e61d461drivers/ufs/core/ufshcd.cAvri Altman 2023-03-31 8472dev_info(hba->dev, "there can be at most 64K inflight requests\n");2580a95e61d461drivers/ufs/core/ufshcd.cAvri Altman 2023-03-31 @8473
goto err;ret =
-EINVAL;
Thanks.
Avri
Quoted 47 lines
2580a95e61d461drivers/ufs/core/ufshcd.cAvri Altman 2023-03-31 8474
}2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 8475 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8476/*
4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8477
* Previously allocated memory for nutrs may not be enough in MCQ mode.4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8478
* Number of supported tags in MCQ mode may be larger than SDB mode.6ccf44fe4cd7c4drivers/scsi/ufs/ufshcd.cSeungwon Jeon 2013-06-26 8479 */4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8480
if (hba->nutrs!=old_nutrs) {4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8481ufshcd_release_sdb_queue(hba, old_nutrs);4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8482
ret =ufshcd_memory_alloc(hba);4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8483
if (ret)4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8484
goto err;4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8485ufshcd_host_memory_configure(hba);7224c806876e46drivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8486
}7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8487 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8488ret =
ufshcd_mcq_memory_alloc(hba);4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8489
if (ret)4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8490
goto err;4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8491 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8492return 0;
4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8493
err:4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8494hba->nutrs=old_nutrs;4682abfae2eb3adrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8495
return ret;57b1c0ef89ac9ddrivers/ufs/core/ufshcd.cAsutosh Das 2023-01-13 8496 }--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Quoted 20 lines · 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_IIDand IID fields. Together with the task tag (single byte), they limit the driver's hw queues capacity.---
v1 -> v2:
Attend Johannes's and Bart's commentsSigned-off-by Avri Altman <[email protected]>--- drivers/ufs/core/ufshcd.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/ufs/core/ufshcd.c +0
-0
drivers/ufs/core/ufshcd.c static int ufshcd_alloc_mcq(struct ufs_hba *hba) · line 8471
Quoted 4 lines
drivers/ufs/core/ufshcd.c +1
-0@@ -8468,6 +8468,11 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba)if (ret) goto err; +if (hba->nutrs * hba->nr_hw_queues >SZ_64K -1 ) {
If shost->host_tagset is set - which it seems to be for this driver - then the number of HW queues would not influence how many IOs the host may be sent. Rather this is just limited by just the HW queue depth.
Thanks,
John
Quoted 7 lines
drivers/ufs/core/ufshcd.c +4
-0+dev_info (hba->dev,"there can be at most 64K 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.
Avri Altman
reviewerQuoted 25 lines · Avri Altman
Quoted 23 lines
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_IIDand IID fields. Together with the task tag (single byte), they limit the driver's hw queues capacity.---
v1 -> v2:
Attend Johannes's and Bart's commentsSigned-off-by Avri Altman <[email protected]>--- drivers/ufs/core/ufshcd.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/ufs/core/ufshcd.c +0
-0@@ -8468,6 +8468,11 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba)if (ret) goto err;
Quoted 5 lines
drivers/ufs/core/ufshcd.c static int ufshcd_alloc_mcq(struct ufs_hba *hba) · line 8471
Quoted 1 line
drivers/ufs/core/ufshcd.c +1
-0+if (hba->nutrs * hba->nr_hw_queues >SZ_64K -1 ) {If
shost->host_tagsetis set - which it seems to be for this driver - then the number of HW queues would not influence how many IOs the host may be sent. Rather this is just limited by just the HW queue depth.
Thanks.
The purpose of this patch is merely to document the ufs spec restrictions. practically, it impose no functional change.
I will elaborate the commit log accordingly.
Thanks,
Avri
Quoted 13 lines
Thanks,
Johndrivers/ufs/core/ufshcd.c static int ufshcd_alloc_mcq(struct ufs_hba *hba)
Quoted 6 lines
drivers/ufs/core/ufshcd.c +4
-0+dev_info (hba->dev,"there can be at most 64K inflight requests\n" ); + goto err; + } +/* * Previously allocated memory for nutrs may not be enough in MCQ mode.
drivers/ufs/core/ufshcd.c static int ufshcd_alloc_mcq(struct ufs_hba *hba) · line 8478
Quoted 1 line
drivers/ufs/core/ufshcd.c +0
-0* Number of supported tags in MCQ mode may be larger than SDB mode.