Skip to contentSkip to conversation

scsi: ufs: mcq: Limit the amount of inflight requests

PATCH In review Avri Altman 2 participants 3 messages Apr 20, 2023

Subsystems (2)
lore
Share & tools
lore

Avri Altman

author reviewer
#0 lore raw

PATCH v3 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.

The purpose of this patch is to document the ufs spec restrictions. practically, it impose no functional change because a) the current hw supports much less (merely 64 requests), and b) since shost->host_tagset is set - then the number of inflight IOs is limited by just the HW queue depth.

---
v2 -> v3:
fix smatch warnings (Dan Carpenter)
elaborate commit log (John Garry)

v1 -> v2:
Attend Johannes's and Bart's comments

---
 drivers/ufs/core/ufshcd.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/ufs/core/ufshcd.c +6 -0
index 03c47f9a2750..9cebec6be35c 100644
@@ -8468,6 +8468,12 @@ 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");
+		ret = -EINVAL;
+		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
#1 lore raw
Quoted 6 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_IID and IID fields. Together with the task tag (single byte), they limit the driver's hw queues capacity.

Quoted 6 lines

The purpose of this patch is to document the ufs spec restrictions. practically, it impose no functional change because a) the current hw supports much less (merely 64 requests), and b) since shost->host_tagset is set - then the number of inflight IOs is limited by just the HW queue depth.

I don't know why effectively it has no change, as it seems to me to be checking and failing something valid which could happen.

If it really cannot happen, then we generally don't add what is effectively dead code just to provide practical illustrations of the spec. And it is misleading to others who may use your driver as a reference.

A code comment would be a better choice, if anything, IMHO.

Thanks,
John

Quoted 7 lines

---
v2 -> v3:
fix smatch warnings (Dan Carpenter)
elaborate commit log (John Garry)

v1 -> v2:
Attend Johannes's and Bart's comments

This is the wrong place for these

Quoted 24 lines
---
  drivers/ufs/core/ufshcd.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/ufs/core/ufshcd.c +6 -0
index 03c47f9a2750..9cebec6be35c 100644
@@ -8468,6 +8468,12 @@ 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");
+		ret = -EINVAL;
+		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.
author reviewer
#2 lore raw
Quoted 14 lines · Avri Altman
Quoted 6 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_IID and IID fields. Together with the task tag (single byte), they limit the driver's hw queues capacity.

Quoted 6 lines

The purpose of this patch is to document the ufs spec restrictions. practically, it impose no functional change because a) the current hw supports much less (merely 64 requests), and b) since shost->host_tagset is set - then the number of inflight IOs is limited by just the HW queue depth.

Quoted 6 lines

I don't know why effectively it has no change, as it seems to me to be checking and failing something valid which could happen.

If it really cannot happen, then we generally don't add what is effectively dead code just to provide practical illustrations of the spec. And it is misleading to others who may use your driver as a reference.

Better to just drop it then.

Thanks,
Avri

Quoted 42 lines

A code comment would be a better choice, if anything, IMHO.

Thanks,
John

Quoted 7 lines

---
v2 -> v3:
fix smatch warnings (Dan Carpenter)
elaborate commit log (John Garry)

v1 -> v2:
Attend Johannes's and Bart's comments

This is the wrong place for these

Quoted 13 lines
---
  drivers/ufs/core/ufshcd.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/ufs/core/ufshcd.c +0 -0
index 03c47f9a2750..9cebec6be35c 100644
@@ -8468,6 +8468,12 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba)
      if (ret)

drivers/ufs/core/ufshcd.c static int ufshcd_alloc_mcq(struct ufs_hba *hba) · line 8478

Quoted 10 lines
drivers/ufs/core/ufshcd.c +6 -0
              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");
+             ret = -EINVAL;
+             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 8479

Quoted 1 line
drivers/ufs/core/ufshcd.c +0 -0
       * Number of supported tags in MCQ mode may be larger than SDB

mode.