Skip to contentSkip to conversation

ufs: core: Always read the descriptors with max length

PATCH Superseded Arthur Simchaev 4 participants 15 messages Nov 27, 2022 – Dec 8, 2022

Subsystems (2)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover ufs: core: Always read the descriptors with max length

v3--v4:
Add "Reviewed-by" to patch's commits
Use kzalloc instead of kmalloc in drivers/ufs/core/ufshcd.c - patch 2/4

v2--v3:
Based on Bean's comments:
1)Use kzalloc instead of kmalloc in ufshcd_set_active_icc_lvl - patch 2/4 2)Delete UFS_RPMB_UNIT definition - patch 2/4
3)Delete len description - patch 3/4

v1--v2:
Fix argument warning in ufshpb.c

Read any descriptor with a maximum size of QUERY_DESC_MAX_SIZE. According to the spec the device rerurns the actual size. Thus can improve code readability and save CPU cycles.
While at it, cleanup few leftovers around the descriptor size parameter.

Arthur Simchaev (4):
ufs:core: Remove redundant wb check
ufs:core: Remove redundant desc_size variable from hba
ufs: core: Remove len parameter from ufshcd_set_active_icc_lvl
ufs: core: Remove ufshcd_map_desc_id_to_length function

 drivers/ufs/core/ufs_bsg.c     |   7 +--
 drivers/ufs/core/ufshcd-priv.h |   3 --
 drivers/ufs/core/ufshcd.c      | 100 ++++++++++-------------------------------
 drivers/ufs/core/ufshpb.c      |   5 +--
 include/ufs/ufshcd.h           |   1 -
 5 files changed, 26 insertions(+), 90 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v4 1/4 ufs: core: Remove redundant wb check

We used to use the extended-feature field in the device descriptor, as an indication that the device supports ufs2.2 or later. Remove that as this check is specifically done few lines above.

---
 drivers/ufs/core/ufshcd.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/ufs/core/ufshcd.c +0 -4
index 2dbe249..2e47c69 100644
@@ -7608,10 +7608,6 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, const u8 *desc_buf)
 	     (hba->dev_quirks & UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES)))
 		goto wb_disabled;
 
-	if (hba->desc_size[QUERY_DESC_IDN_DEVICE] <
-	    DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4)
-		goto wb_disabled;
-
 	ext_ufs_feature = get_unaligned_be32(desc_buf +
 					DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP);
 
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH v4 1/4] ufs: core: Remove redundant wb check

Quoted 15 lines · Arthur Simchaev

We used to use the extended-feature field in the device descriptor, as an indication that the device supports ufs2.2 or later. Remove that as this check is specifically done few lines above.

---
  drivers/ufs/core/ufshcd.c | 4 ----
  1 file changed, 4 deletions(-)
drivers/ufs/core/ufshcd.c +0 -0
index 2dbe249..2e47c69 100644

drivers/ufs/core/ufshcd.c static void ufshcd_wb_probe(struct ufs_hba *hba, const u8 *desc_buf) · line 7612

Quoted 9 lines
drivers/ufs/core/ufshcd.c +0 -4
@@ -7608,10 +7608,6 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, const u8 *desc_buf)
  	     (hba->dev_quirks & UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES)))
  		goto wb_disabled;
 
-	if (hba->desc_size[QUERY_DESC_IDN_DEVICE] <
-	    DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4)
-		goto wb_disabled;
-
  	ext_ufs_feature = get_unaligned_be32(desc_buf +
  					DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP);

Does this code really have to be removed? I see a check of the UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES flag above the removed code but no check of the descriptor size?

Thanks,

Bart.

#3 lore raw

Re: [PATCH v4 1/4] ufs: core: Remove redundant wb check

Quoted 21 lines · Bart Van Assche
Quoted 20 lines · Arthur Simchaev

We used to use the extended-feature field in the device descriptor, as an indication that the device supports ufs2.2 or later. Remove that as this check is specifically done few lines above.

---
  drivers/ufs/core/ufshcd.c | 4 ----

  1 file changed, 4 deletions(-)
drivers/ufs/core/ufshcd.c +0 -0
index 2dbe249..2e47c69 100644
@@ -7608,10 +7608,6 @@ static void ufshcd_wb_probe(struct ufs_hba 
 *hba, const u8 *desc_buf)
            (hba->dev_quirks & UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES)))
           goto wb_disabled;

  -    if (hba->desc_size[QUERY_DESC_IDN_DEVICE] < -        DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4)

Quoted 9 lines
Quoted 4 lines

-        goto wb_disabled;
-
      ext_ufs_feature = get_unaligned_be32(desc_buf + DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP);

Does this code really have to be removed? I see a check of the UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES flag above the removed code but no check of the descriptor size?

it is not necessary to check this, but if you have concern, we could change to like this:

        if (desc_buf[DEVICE_DESC_PARAM_LEN] < DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4) goto wb_disabled;

then   hba->desc_size could be removed.

Kind regards,

Bean

#4 lore raw

Re: [PATCH v4 1/4] ufs: core: Remove redundant wb check

Quoted 32 lines · Bean Huo
Quoted 21 lines · Bart Van Assche
Quoted 20 lines · Arthur Simchaev

We used to use the extended-feature field in the device descriptor, as an indication that the device supports ufs2.2 or later. Remove that as this check is specifically done few lines above.

---
  drivers/ufs/core/ufshcd.c | 4 ----

  1 file changed, 4 deletions(-)
drivers/ufs/core/ufshcd.c +0 -0
index 2dbe249..2e47c69 100644
@@ -7608,10 +7608,6 @@ static void ufshcd_wb_probe(struct ufs_hba 
 *hba, const u8 *desc_buf)
            (hba->dev_quirks & UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES)))
           goto wb_disabled;

  -    if (hba->desc_size[QUERY_DESC_IDN_DEVICE] < -        DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4)

Quoted 9 lines
Quoted 4 lines

-        goto wb_disabled;
-
      ext_ufs_feature = get_unaligned_be32(desc_buf + DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP);

Does this code really have to be removed? I see a check of the UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES flag above the removed code but no check of the descriptor size?

Quoted 8 lines

it is not necessary to check this, but if you have concern, we could change to like this:

        if (desc_buf[DEVICE_DESC_PARAM_LEN] < DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4) goto wb_disabled;

then   hba->desc_size could be removed.

Hi Bean,

My only concern is that this patch conflicts with the pending MCQ patch series. Since that conflict is unavoidable, let's keep this patch.

Bart.

reviewer Reviewed-by on v4 1/4
#5 lore raw

Re: [PATCH v4 1/4] ufs: core: Remove redundant wb check

In reply to Arthur Simchaev
Quoted 3 lines · Arthur Simchaev

We used to use the extended-feature field in the device descriptor, as an indication that the device supports ufs2.2 or later. Remove that as this check is specifically done few lines above.

#6 lore raw

PATCH v4 2/4 ufs: core: Remove redundant desc_size variable from hba

In reply to Arthur Simchaev

Always read the descriptor with QUERY_DESC_MAX_SIZE. According to the spec, the device returns the actual size

---
 drivers/ufs/core/ufshcd.c | 53 +++++++++++++----------------------------------
 include/ufs/ufs.h         |  1 -
 include/ufs/ufshcd.h      |  1 -
 3 files changed, 14 insertions(+), 41 deletions(-)
drivers/ufs/core/ufshcd.c +14 -39
index 2e47c69..70e96b6 100644
@@ -3377,28 +3377,11 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba,
 void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
 				  int *desc_len)
 {
-	if (desc_id >= QUERY_DESC_IDN_MAX || desc_id == QUERY_DESC_IDN_RFU_0 ||
-	    desc_id == QUERY_DESC_IDN_RFU_1)
-		*desc_len = 0;
-	else
-		*desc_len = hba->desc_size[desc_id];
+	/*Always returns QUERY_DESC_MAX_SIZE*/
+	*desc_len = QUERY_DESC_MAX_SIZE;
 }
 EXPORT_SYMBOL(ufshcd_map_desc_id_to_length);
 
-static void ufshcd_update_desc_length(struct ufs_hba *hba,
-				      enum desc_idn desc_id, int desc_index,
-				      unsigned char desc_len)
-{
-	if (hba->desc_size[desc_id] == QUERY_DESC_MAX_SIZE &&
-	    desc_id != QUERY_DESC_IDN_STRING && desc_index != UFS_RPMB_UNIT)
-		/* For UFS 3.1, the normal unit descriptor is 10 bytes larger
-		 * than the RPMB unit, however, both descriptors share the same
-		 * desc_idn, to cover both unit descriptors with one length, we
-		 * choose the normal unit descriptor length by desc_index.
-		 */
-		hba->desc_size[desc_id] = desc_len;
-}
-
 /**
  * ufshcd_read_desc_param - read the specified descriptor parameter
  * @hba: Pointer to adapter instance
@@ -3470,7 +3453,6 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
 
 	/* Update descriptor length */
 	buff_len = desc_buf[QUERY_DESC_LENGTH_OFFSET];
-	ufshcd_update_desc_length(hba, desc_id, desc_index, buff_len);
 
 	if (is_kmalloc) {
 		/* Make sure we don't copy more data than available */
@@ -4909,7 +4891,7 @@ static void ufshcd_setup_links(struct ufs_hba *hba, struct scsi_device *sdev)
  */
 static void ufshcd_lu_init(struct ufs_hba *hba, struct scsi_device *sdev)
 {
-	int len = hba->desc_size[QUERY_DESC_IDN_UNIT];
+	int len = QUERY_DESC_MAX_SIZE;
 	u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun);
 	u8 lun_qdepth = hba->nutrs;
 	u8 *desc_buf;
@@ -7480,25 +7462,24 @@ static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba,
 static void ufshcd_set_active_icc_lvl(struct ufs_hba *hba)
 {
 	int ret;
-	int buff_len = hba->desc_size[QUERY_DESC_IDN_POWER];
 	u8 *desc_buf;
 	u32 icc_level;
 
-	desc_buf = kmalloc(buff_len, GFP_KERNEL);
+	desc_buf = kzalloc(QUERY_DESC_MAX_SIZE, GFP_KERNEL);
 	if (!desc_buf)
 		return;
 
 	ret = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_POWER, 0, 0,
-				     desc_buf, buff_len);
+				     desc_buf, QUERY_DESC_MAX_SIZE);
 	if (ret) {
 		dev_err(hba->dev,
-			"%s: Failed reading power descriptor.len = %d ret = %d",
-			__func__, buff_len, ret);
+			"%s: Failed reading power descriptor ret = %d",
+			__func__, ret);
 		goto out;
 	}
 
 	icc_level = ufshcd_find_max_sup_active_icc_level(hba, desc_buf,
-							 buff_len);
+							 QUERY_DESC_MAX_SIZE);
 	dev_dbg(hba->dev, "%s: setting icc_level 0x%x", __func__, icc_level);
 
 	ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
@@ -7715,14 +7696,14 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
 	u8 *desc_buf;
 	struct ufs_dev_info *dev_info = &hba->dev_info;
 
-	desc_buf = kmalloc(QUERY_DESC_MAX_SIZE, GFP_KERNEL);
+	desc_buf = kzalloc(QUERY_DESC_MAX_SIZE, GFP_KERNEL);
 	if (!desc_buf) {
 		err = -ENOMEM;
 		goto out;
 	}
 
 	err = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_DEVICE, 0, 0, desc_buf,
-				     hba->desc_size[QUERY_DESC_IDN_DEVICE]);
+				     QUERY_DESC_MAX_SIZE);
 	if (err) {
 		dev_err(hba->dev, "%s: Failed reading Device Desc. err = %d\n",
 			__func__, err);
@@ -7969,18 +7950,16 @@ static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba)
 static int ufshcd_device_geo_params_init(struct ufs_hba *hba)
 {
 	int err;
-	size_t buff_len;
 	u8 *desc_buf;
 
-	buff_len = hba->desc_size[QUERY_DESC_IDN_GEOMETRY];
-	desc_buf = kmalloc(buff_len, GFP_KERNEL);
+	desc_buf = kzalloc(QUERY_DESC_MAX_SIZE, GFP_KERNEL);
 	if (!desc_buf) {
 		err = -ENOMEM;
 		goto out;
 	}
 
 	err = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_GEOMETRY, 0, 0,
-				     desc_buf, buff_len);
+				     desc_buf, QUERY_DESC_MAX_SIZE);
 	if (err) {
 		dev_err(hba->dev, "%s: Failed reading Geometry Desc. err = %d\n",
 				__func__, err);
@@ -7992,7 +7971,7 @@ static int ufshcd_device_geo_params_init(struct ufs_hba *hba)
 	else if (desc_buf[GEOMETRY_DESC_PARAM_MAX_NUM_LUN] == 0)
 		hba->dev_info.max_lu_supported = 8;
 
-	if (hba->desc_size[QUERY_DESC_IDN_GEOMETRY] >=
+	if (desc_buf[QUERY_DESC_LENGTH_OFFSET] >=
 		GEOMETRY_DESC_PARAM_HPB_MAX_ACTIVE_REGS)
 		ufshpb_get_geo_info(hba, desc_buf);
 
@@ -8077,11 +8056,7 @@ static int ufshcd_set_dev_ref_clk(struct ufs_hba *hba)
 static int ufshcd_device_params_init(struct ufs_hba *hba)
 {
 	bool flag;
-	int ret, i;
-
-	 /* Init device descriptor sizes */
-	for (i = 0; i < QUERY_DESC_IDN_MAX; i++)
-		hba->desc_size[i] = QUERY_DESC_MAX_SIZE;
+	int ret;
 
 	/* Init UFS geometry descriptor related parameters */
 	ret = ufshcd_device_geo_params_init(hba);
include/ufs/ufs.h +0 -1
index 1bba3fe..2fc7107 100644
@@ -38,7 +38,6 @@
 #define UFS_UPIU_MAX_UNIT_NUM_ID	0x7F
 #define UFS_MAX_LUNS		(SCSI_W_LUN_BASE + UFS_UPIU_MAX_UNIT_NUM_ID)
 #define UFS_UPIU_WLUN_ID	(1 << 7)
-#define UFS_RPMB_UNIT		0xC4
 
 /* WriteBooster buffer is available only for the logical unit from 0 to 7 */
 #define UFS_UPIU_MAX_WB_LUN_ID	8
include/ufs/ufshcd.h +0 -1
index 5cf81df..7df2ce1 100644
@@ -952,7 +952,6 @@ struct ufs_hba {
 	bool is_urgent_bkops_lvl_checked;
 
 	struct rw_semaphore clk_scaling_lock;
-	unsigned char desc_size[QUERY_DESC_IDN_MAX];
 	atomic_t scsi_block_reqs_cnt;
 
 	struct device		bsg_dev;
Signature · 1 line
2.7.4
#7 lore raw

Re: [PATCH v4 2/4] ufs: core: Remove redundant desc_size variable from hba

Quoted 18 lines · Arthur Simchaev

Always read the descriptor with QUERY_DESC_MAX_SIZE. According to the spec, the device returns the actual size

---
  drivers/ufs/core/ufshcd.c | 53 +++++++++++++----------------------------------
  include/ufs/ufs.h         |  1 -
  include/ufs/ufshcd.h      |  1 -
  3 files changed, 14 insertions(+), 41 deletions(-)
drivers/ufs/core/ufshcd.c +0 -0
index 2e47c69..70e96b6 100644
@@ -3377,28 +3377,11 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba,
  void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
  				  int *desc_len)

drivers/ufs/core/ufshcd.c int ufshcd_query_descriptor_retry(struct ufs_hba *hba, · line 3383

Quoted 10 lines
drivers/ufs/core/ufshcd.c +2 -5
  {
-	if (desc_id >= QUERY_DESC_IDN_MAX || desc_id == QUERY_DESC_IDN_RFU_0 ||
-	    desc_id == QUERY_DESC_IDN_RFU_1)
-		*desc_len = 0;
-	else
-		*desc_len = hba->desc_size[desc_id];
+	/*Always returns QUERY_DESC_MAX_SIZE*/
+	*desc_len = QUERY_DESC_MAX_SIZE;
  }
  EXPORT_SYMBOL(ufshcd_map_desc_id_to_length);

Comments should explain something that is nontrivial instead of duplicating the code. Additionally, this change makes ufshcd_map_desc_id_to_length() too short too keep it as a function. Please remove this function entirely and insert the following code into the callers of this function:

desc_len = QUERY_DESC_MAX_SIZE

Thanks,

Bart.

#8 lore raw

RE: [PATCH v4 2/4] ufs: core: Remove redundant desc_size variable from hba

Quoted 8 lines

Comments should explain something that is nontrivial instead of duplicating the
code. Additionally, this change makes ufshcd_map_desc_id_to_length() too short
too keep it as a function. Please remove this function entirely and insert the following code into the callers of this function:

Quoted 5 lines

desc_len = QUERY_DESC_MAX_SIZE

Thanks,

Bart.

Done

Regards
Arthur

#9 lore raw

PATCH v4 3/4 ufs: core: Remove len parameter from ufshcd_set_active_icc_lvl

In reply to Arthur Simchaev

len argument is not used anymore in ufshcd_set_active_icc_lvl function.

---
 drivers/ufs/core/ufshcd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ufs/core/ufshcd.c +2 -4
index 70e96b6..617c4e0 100644
@@ -7415,12 +7415,11 @@ static u32 ufshcd_get_max_icc_level(int sup_curr_uA, u32 start_scan,
  * In case regulators are not initialized we'll return 0
  * @hba: per-adapter instance
  * @desc_buf: power descriptor buffer to extract ICC levels from.
- * @len: length of desc_buff
  *
  * Returns calculated ICC level
  */
 static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba,
-						const u8 *desc_buf, int len)
+						const u8 *desc_buf)
 {
 	u32 icc_level = 0;
 
@@ -7478,8 +7477,7 @@ static void ufshcd_set_active_icc_lvl(struct ufs_hba *hba)
 		goto out;
 	}
 
-	icc_level = ufshcd_find_max_sup_active_icc_level(hba, desc_buf,
-							 QUERY_DESC_MAX_SIZE);
+	icc_level = ufshcd_find_max_sup_active_icc_level(hba, desc_buf);
 	dev_dbg(hba->dev, "%s: setting icc_level 0x%x", __func__, icc_level);
 
 	ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
Signature · 1 line
2.7.4
reviewer Reviewed-by on v4 3/4
#10 lore raw

Re: [PATCH v4 3/4] ufs: core: Remove len parameter from ufshcd_set_active_icc_lvl

Quoted 1 line · Arthur Simchaev

len argument is not used anymore in ufshcd_set_active_icc_lvl function.

#11 lore raw

PATCH v4 4/4 ufs: core: Remove ufshcd_map_desc_id_to_length function

In reply to Arthur Simchaev

There shouldn't be any restriction of the descriptor size
(not the descriptor id for that matter) up to QUERY_DESC_MAX_SIZE. According to the spec, the caller can use any descriptor size,
and it is up to the device to return the actual size.
Therefore there shouldn't be any sizes hardcoded in the kernel,
nor any need to cache it, hence ufshcd_map_desc_id_to_length function is redundant. always read the descriptors with QUERY_DESC_MAX_SIZE size.

---
 drivers/ufs/core/ufs_bsg.c     |  7 +------
 drivers/ufs/core/ufshcd-priv.h |  3 ---
 drivers/ufs/core/ufshcd.c      | 46 +++++++++++-------------------------------
 drivers/ufs/core/ufshpb.c      |  4 +---
 4 files changed, 14 insertions(+), 46 deletions(-)
drivers/ufs/core/ufs_bsg.c +1 -6
index b99e3f3..dc441ac 100644
@@ -16,16 +16,11 @@ static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,
 				       struct utp_upiu_query *qr)
 {
 	int desc_size = be16_to_cpu(qr->length);
-	int desc_id = qr->idn;
 
 	if (desc_size <= 0)
 		return -EINVAL;
 
-	ufshcd_map_desc_id_to_length(hba, desc_id, desc_len);
-	if (!*desc_len)
-		return -EINVAL;
-
-	*desc_len = min_t(int, *desc_len, desc_size);
+	*desc_len = min_t(int, QUERY_DESC_MAX_SIZE, desc_size);
 
 	return 0;
 }
drivers/ufs/core/ufshcd-priv.h +0 -3
index a9e8e1f..c52e2f3 100644
@@ -70,9 +70,6 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
 int ufshcd_hold(struct ufs_hba *hba, bool async);
 void ufshcd_release(struct ufs_hba *hba);
 
-void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
-				  int *desc_length);
-
 int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd);
 
 int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
drivers/ufs/core/ufshcd.c +12 -34

82 lines not on this page · raw message

drivers/ufs/core/ufshpb.c +1 -3
index be3fb24..19c9b5d 100644
@@ -2382,12 +2382,10 @@ static int ufshpb_get_lu_info(struct ufs_hba *hba, int lun,
 {
 	u16 max_active_rgns;
 	u8 lu_enable;
-	int size;
+	int size = QUERY_DESC_MAX_SIZE;
 	int ret;
 	char desc_buf[QUERY_DESC_MAX_SIZE];
 
-	ufshcd_map_desc_id_to_length(hba, QUERY_DESC_IDN_UNIT, &size);
-
 	ufshcd_rpm_get_sync(hba);
 	ret = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC,
 					    QUERY_DESC_IDN_UNIT, lun, 0,
Signature · 1 line
2.7.4
#12 lore raw

Re: [PATCH v4 4/4] ufs: core: Remove ufshcd_map_desc_id_to_length function

Quoted 7 lines · Arthur Simchaev

There shouldn't be any restriction of the descriptor size
(not the descriptor id for that matter) up to QUERY_DESC_MAX_SIZE. According to the spec, the caller can use any descriptor size,
and it is up to the device to return the actual size.
Therefore there shouldn't be any sizes hardcoded in the kernel,
nor any need to cache it, hence ufshcd_map_desc_id_to_length function is redundant. always read the descriptors with QUERY_DESC_MAX_SIZE size.

This patch looks good to me but I expect that it will change if my comment on patch 1/4 is addressed?

Thanks,

Bart.

#13 lore raw
In reply to Arthur Simchaev

Hi Martin,

Gentle reminder

Regards
Arthur

Quoted 43 lines

-----Original Message-----
From: Arthur Simchaev <[email protected]>
Sent: Sunday, November 27, 2022 2:08 PM
To: [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; Arthur Simchaev <[email protected]>
Subject: [PATCH v4 0/4] ufs: core: Always read the descriptors with max length

v3--v4:
Add "Reviewed-by" to patch's commits
Use kzalloc instead of kmalloc in drivers/ufs/core/ufshcd.c - patch 2/4

v2--v3:
Based on Bean's comments:
1)Use kzalloc instead of kmalloc in ufshcd_set_active_icc_lvl - patch 2/4 2)Delete UFS_RPMB_UNIT definition - patch 2/4
3)Delete len description - patch 3/4

v1--v2:
Fix argument warning in ufshpb.c

Read any descriptor with a maximum size of QUERY_DESC_MAX_SIZE. According to the spec the device rerurns the actual size. Thus can improve code readability and save CPU cycles.
While at it, cleanup few leftovers around the descriptor size parameter.

Arthur Simchaev (4):
ufs:core: Remove redundant wb check
ufs:core: Remove redundant desc_size variable from hba
ufs: core: Remove len parameter from ufshcd_set_active_icc_lvl
ufs: core: Remove ufshcd_map_desc_id_to_length function

 drivers/ufs/core/ufs_bsg.c     |   7 +--
 drivers/ufs/core/ufshcd-priv.h |   3 --
 drivers/ufs/core/ufshcd.c      | 100 ++++++++++-------------------------------
 drivers/ufs/core/ufshpb.c      |   5 +--
 include/ufs/ufshcd.h           |   1 -
 5 files changed, 26 insertions(+), 90 deletions(-)

--
2.7.4

#14 lore raw

Hi Arthur!

Quoted 1 line

Gentle reminder

We're just a few days away from release, not adding new code this late in the cycle. I would also like to see an additional review given that this is a core change.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering