scsi: ufs: cleanup ufs initialization
v4 cover scsi: ufs: cleanup ufs initialization
From: Bean Huo <[email protected]>
Cleanup UFS descriptor length initialization, and delete unnecessary code.
Changelog:
v2 - v3:
1. Fix typo in the commit message (Avri Altman & Bart van Assche)
2. Delete ufshcd_init_desc_sizes() in patch 3/4 (Stanley Chu)
3. Remove max_t() and buff_len in patch 1/4 (Bart van Assche)
4. Add patch 4/4
v1 - v2:
1. Split patch
2. Fix one compiling WARNING (Reported-by: kbuild test robot <[email protected]>)
Bean Huo (4):
scsi: ufs: remove max_t in ufs_get_device_desc
scsi: ufs: delete ufshcd_read_desc()
scsi: ufs: cleanup ufs initialization path
scsi: ufs: add compatibility with 3.1 UFS unit descriptor length
drivers/scsi/ufs/ufs.h | 11 +- drivers/scsi/ufs/ufs_bsg.c | 5 +- drivers/scsi/ufs/ufshcd.c | 200 ++++++++----------------------------- drivers/scsi/ufs/ufshcd.h | 16 +-- 4 files changed, 50 insertions(+), 182 deletions(-)
Signature · 1 line
2.17.1
PATCH v4 1/4 scsi: ufs: remove max_t in ufs_get_device_desc
From: Bean Huo <[email protected]>
For the UFS device, the maximum descriptor size is 255, max_t called in ufs_get_device_desc() is useless.
--- drivers/scsi/ufs/ufshcd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/scsi/ufs/ufshcd.c +1 -4
@@ -6876,14 +6876,11 @@ static void ufs_fixup_device_setup(struct ufs_hba *hba)static int ufs_get_device_desc (struct ufs_hba *hba) {int err; -size_t buff_len;u8 model_index;u8 *desc_buf;struct ufs_dev_info *dev_info = &hba->dev_info; - buff_len =max_t (size_t, hba->desc_size.dev_desc, -QUERY_DESC_MAX_SIZE +1 ); - desc_buf =kmalloc (buff_len,GFP_KERNEL ); + desc_buf =kmalloc (QUERY_DESC_MAX_SIZE ,GFP_KERNEL );if (!desc_buf) { err = -ENOMEM ; goto out;
Signature · 1 line
2.17.1
Re: [PATCH v4 1/4] scsi: ufs: remove max_t in ufs_get_device_desc
Quoted 8 lines · Bean Huo
From: Bean Huo <[email protected]>
For the UFS device, the maximum descriptor size is 255,
max_tcalled inufs_get_device_desc()is useless.Signed-off-by Bart van Assche <[email protected]>Signed-off-by Bean Huo <[email protected]>Acked-by Avri Altman <[email protected]>
PATCH v4 2/4 scsi: ufs: delete ufshcd_read_desc()
In reply to Bean HuoFrom: Bean Huo <[email protected]>
Delete ufshcd_read_desc(). Instead, let caller directly call ufshcd_read_desc_param().
--- drivers/scsi/ufs/ufshcd.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-)
drivers/scsi/ufs/ufshcd.c +8 -19
@@ -3221,16 +3221,6 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,return ret; } -static inline int ufshcd_read_desc (struct ufs_hba *hba, -enum desc_idn desc_id, -int desc_index, -void *buf, -u32 size) -{ -return ufshcd_read_desc_param (hba, desc_id, desc_index,0 , buf, size); -} - -/** * struct uc_string_id - unicode string *
@@ -3278,9 +3268,8 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,if (!uc_str)return -ENOMEM ; - ret =ufshcd_read_desc (hba,QUERY_DESC_IDN_STRING , - desc_index, uc_str, -QUERY_DESC_MAX_SIZE ); + ret =ufshcd_read_desc_param (hba,QUERY_DESC_IDN_STRING , desc_index,0 , + (u8 *)uc_str,QUERY_DESC_MAX_SIZE );if (ret <0 ) {dev_err (hba->dev,"Reading String Desc failed after %d retries. err = %d\n" ,QUERY_REQ_RETRIES , ret);
@@ -6684,8 +6673,8 @@ static void ufshcd_set_active_icc_lvl(struct ufs_hba *hba)if (!desc_buf)return ; - ret =ufshcd_read_desc (hba,QUERY_DESC_IDN_POWER ,0 , - desc_buf, buff_len); + ret =ufshcd_read_desc_param (hba,QUERY_DESC_IDN_POWER ,0 ,0 , + desc_buf, buff_len);if (ret) { dev_err(hba->dev, "%s: Failed reading power descriptor.len = %d ret = %d",
@@ -6886,8 +6875,8 @@ static int ufs_get_device_desc(struct ufs_hba *hba) goto out; } - err =ufshcd_read_desc (hba,QUERY_DESC_IDN_DEVICE ,0 , desc_buf, - hba->desc_size.dev_desc); + err =ufshcd_read_desc_param (hba,QUERY_DESC_IDN_DEVICE ,0 ,0 , desc_buf, + hba->desc_size.dev_desc);if (err) {dev_err (hba->dev,"%s: Failed reading Device Desc. err = %d\n" , __func__, err);
@@ -7168,8 +7157,8 @@ static int ufshcd_device_geo_params_init(struct ufs_hba *hba) goto out; } - err =ufshcd_read_desc (hba,QUERY_DESC_IDN_GEOMETRY ,0 , - desc_buf, buff_len); + err =ufshcd_read_desc_param (hba,QUERY_DESC_IDN_GEOMETRY ,0 ,0 , + desc_buf, buff_len);if (err) {dev_err (hba->dev,"%s: Failed reading Geometry Desc. err = %d\n" , __func__, err);
Signature · 1 line
2.17.1
PATCH v4 3/4 scsi: ufs: cleanup ufs initialization path
In reply to Bean HuoFrom: Bean Huo <[email protected]>
At UFS initialization stage, to get the length of the descriptor, ufshcd_read_desc_length() being called 6 times. Instead, we will capture the descriptor size the first time we'll read it.
Delete unnecessary redundant code, remove ufshcd_read_desc_length(), ufshcd_init_desc_sizes(), and boost UFS initialization.
--- drivers/scsi/ufs/ufs.h | 10 --- drivers/scsi/ufs/ufs_bsg.c | 5 +- drivers/scsi/ufs/ufshcd.c | 165 +++++++------------------------------ drivers/scsi/ufs/ufshcd.h | 16 +--- 4 files changed, 36 insertions(+), 160 deletions(-)
drivers/scsi/ufs/ufs.h +0 -10
@@ -200,16 +200,6 @@ enum desc_header_offset { QUERY_DESC_DESC_TYPE_OFFSET = 0x01, }; -enum ufs_desc_def_size { -QUERY_DESC_DEVICE_DEF_SIZE =0x59 , -QUERY_DESC_CONFIGURATION_DEF_SIZE =0x90 , -QUERY_DESC_UNIT_DEF_SIZE =0x2D , -QUERY_DESC_INTERCONNECT_DEF_SIZE =0x06 , -QUERY_DESC_GEOMETRY_DEF_SIZE =0x48 , -QUERY_DESC_POWER_DEF_SIZE =0x62 , -QUERY_DESC_HEALTH_DEF_SIZE =0x25 , -}; -/* Unit descriptor parameters offsets in bytes*/ enum unit_desc_param {UNIT_DESC_PARAM_LEN =0x0 ,
drivers/scsi/ufs/ufs_bsg.c +2 -3
@@ -11,13 +11,12 @@ static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len, {int desc_size =be16_to_cpu (qr->length);int desc_id = qr->idn; -int ret;if (desc_size <=0 )return -EINVAL ; - ret =ufshcd_map_desc_id_to_length (hba, desc_id, desc_len); -if (ret || !*desc_len) +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);
drivers/scsi/ufs/ufshcd.c +31 -134
235 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.h +3 -13
@@ -236,16 +236,6 @@ struct ufs_dev_cmd {struct ufs_query query; }; -struct ufs_desc_size { -int dev_desc; -int pwr_desc; -int geom_desc; -int interc_desc; -int unit_desc; -int conf_desc; -int hlth_desc; -}; -/** * struct ufs_clk_info - UFS clock related info * @list: list headed by hba->clk_list_head
@@ -738,7 +728,7 @@ struct ufs_hba {bool is_urgent_bkops_lvl_checked;struct rw_semaphore clk_scaling_lock; -struct ufs_desc_size desc_size; +unsigned char desc_size[QUERY_DESC_IDN_MAX ];atomic_t scsi_block_reqs_cnt;struct device bsg_dev;
@@ -975,8 +965,8 @@ 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); -int ufshcd_map_desc_id_to_length (struct ufs_hba *hba,enum desc_idn desc_id, -int *desc_length); +void ufshcd_map_desc_id_to_length (struct ufs_hba *hba,enum desc_idn desc_id, +int *desc_length);u32 ufshcd_get_local_unipro_ver (struct ufs_hba *hba);
Signature · 1 line
2.17.1
RE: [PATCH v4 3/4] scsi: ufs: cleanup ufs initialization path
drivers/scsi/ufs/ufshcd.c int ufshcd_query_descriptor_retry(struct ufs_hba *hba, · line 3133
Quoted 2 lines
drivers/scsi/ufs/ufshcd.c +0
-2-case QUERY_DESC_IDN_RFU_0 : -case QUERY_DESC_IDN_RFU_1 :
You forgot to check that desc_id < QUERY_DESC_IDN_MAX
Quoted 48 lines
+ if (
desc_id==QUERY_DESC_IDN_RFU_0||desc_id==QUERY_DESC_IDN_RFU_1)*desc_len = 0;drivers/scsi/ufs/ufshcd.c +16
-16-break ; -default : - *desc_len =0 ; -return -EINVAL ; - } -return 0 ; +else + *desc_len = hba->desc_size[desc_id]; }EXPORT_SYMBOL (ufshcd_map_desc_id_to_length); +static void ufshcd_update_desc_length (struct ufs_hba *hba, +enum desc_idn desc_id, +unsigned char desc_len) +{ +if (hba->desc_size[desc_id] ==QUERY_DESC_MAX_SIZE && + desc_id !=QUERY_DESC_IDN_STRING ) + hba->desc_size[desc_id] = desc_len; +} +/** * ufshcd_read_desc_param - read the specified descriptor parameter * @hba: Pointer to adapter instance @@ -3168,16 +3105,11 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, if (desc_id >= QUERY_DESC_IDN_MAX || !param_size) return -EINVAL; -/* Get the max length of descriptor from structure filled up at probe -* time. -*/ - ret =ufshcd_map_desc_id_to_length (hba, desc_id, &buff_len); - -/* Sanity checks */ -if (ret || !buff_len) { -dev_err (hba->dev,"%s: Failed to get full descriptor length" , - __func__); -return ret; +/* Get the length of descriptor */ +ufshcd_map_desc_id_to_length (hba, desc_id, &buff_len); +if (!buff_len) { +dev_err (hba->dev,"%s: Failed to get desc length" , __func__); +return -EINVAL ; }
Quoted 1 line
/* Check whether we need temp memory */
The first time we are reading the descriptor, we no longer can rely on its true size. So for this check, buff_len is 256 and kmalloc will always happen.
Do you think that this check is still relevant?
/* Check whether we need temp memory */
if (param_offset != 0 || param_size < buff_len) {
desc_buf = kmalloc(buff_len, GFP_KERNEL);
if (!desc_buf)
return -ENOMEM;
} else {
desc_buf = param_read_buf;
is_kmalloc = false;
}drivers/scsi/ufs/ufshcd.c int ufshcd_read_desc_param(struct ufs_hba *hba, · line 3149
Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +3
-0@@ -3209,6 +3141,9 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, goto out; } +ufshcd_update_desc_length (hba, desc_id, + desc_buf[QUERY_DESC_LENGTH_OFFSET ]); +/* Check wherher we will not copy more data, than available */ if (is_kmalloc && param_size > buff_len) param_size = buff_len;
And here, we might want to update buff_len to hold the true descriptor size, Before checking the copy-back buffer.
Thanks,
Avri
Re: [PATCH v4 3/4] scsi: ufs: cleanup ufs initialization path
Hi Avri
thanks your review.
Quoted 4 lines · Avri Altman
drivers/scsi/ufs/ufshcd.c int ufshcd_query_descriptor_retry(struct ufs_hba *hba, · line 3133
Quoted 2 lines
drivers/scsi/ufs/ufshcd.c +0
-2-case QUERY_DESC_IDN_RFU_0 : -case QUERY_DESC_IDN_RFU_1 :You forgot to check that
desc_id<QUERY_DESC_IDN_MAX
I deleted it since I saw the caller has checked this. I will add back.
Quoted 55 lines
Quoted 55 lines
+ if (
desc_id==QUERY_DESC_IDN_RFU_0||desc_id==QUERY_DESC_IDN_RFU_1)*desc_len = 0;drivers/scsi/ufs/ufshcd.c +11
-6-break ; -default : - *desc_len =0 ; -return -EINVAL ; - } -return 0 ; +else + *desc_len = hba->desc_size[desc_id]; }EXPORT_SYMBOL (ufshcd_map_desc_id_to_length); +static void ufshcd_update_desc_length (struct ufs_hba *hba, +enum desc_idn desc_id, +unsigned char desc_len) +{ +if (hba->desc_size[desc_id] ==QUERY_DESC_MAX_SIZE && + desc_id !=QUERY_DESC_IDN_STRING ) + hba->desc_size[desc_id] = desc_len; +} +/** * ufshcd_read_desc_param - read the specified descriptor parameter
* @hba: Pointer to adapter instancedrivers/scsi/ufs/ufshcd.c +0
-1@@ -3168,16 +3105,11 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, if (desc_id >= QUERY_DESC_IDN_MAX || !param_size) return -EINVAL; -/* Get the max length of descriptor from structure filled up at probe
drivers/scsi/ufs/ufshcd.c +0
-3-* time. -*/ - ret = ufshcd_map_desc_id_to_length(hba, desc_id,
&buff_len);drivers/scsi/ufs/ufshcd.c +0
-4- -/* Sanity checks */ -if (ret || !buff_len) { - dev_err(hba->dev, "%s: Failed to get fulldescriptor length",
drivers/scsi/ufs/ufshcd.c +4
-2- __func__); -return ret; +/* Get the length of descriptor */ +ufshcd_map_desc_id_to_length (hba, desc_id, &buff_len); +if (!buff_len) { + dev_err(hba->dev, "%s: Failed to get desc length",
__func__);+ return -EINVAL; }
Quoted 6 lines
Quoted 1 line
/* Check whether we need temp memory */The first time we are reading the descriptor, we no longer can rely on its true size.
So for this check,buff_lenis 256 and kmalloc will always happen. Do you think that this check is still relevant?
you are right, I will delete this redundat code.
Quoted 17 lines
/* Check whether we need temp memory */
if (param_offset != 0 || param_size < buff_len) { desc_buf = kmalloc(buff_len, GFP_KERNEL); if (!desc_buf) return -ENOMEM; } else { desc_buf = param_read_buf; is_kmalloc = false; }Quoted 5 lines
drivers/scsi/ufs/ufshcd.c +0
-0@@ -3209,6 +3141,9 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, goto out; }
Quoted 13 lines
Quoted 8 lines
(quoted diff) +3
-0+ ufshcd_update_desc_length(hba, desc_id, + desc_buf[QUERY_DESC_LENGTH_OFFSET ]); + /* Check wherher we will not copy more data, than available*/
if (is_kmalloc && param_size > buff_len) param_size = buff_len;And here, we might want to update
buff_lento hold the true descriptor size,
Before checking the copy-back buffer.
yes, buff_len should be updated here. will change it.
thanks
Bean
Re: [PATCH v4 3/4] scsi: ufs: cleanup ufs initialization path
In reply to Avri AltmanQuoted 16 lines · Avri Altman
Quoted 9 lines
drivers/scsi/ufs/ufshcd.c +4
-0+/* Get the length of descriptor */ +ufshcd_map_desc_id_to_length (hba, desc_id, &buff_len); +if (!buff_len) { + dev_err(hba->dev, "%s: Failed to get desc length",
__func__);+ return -EINVAL; } /* Check whether we need temp memory */The first time we are reading the descriptor, we no longer can rely on its true size.
So for this check,buff_lenis 256 and kmalloc will always happen. Do you think that this check is still relevant?/* Check whether we need temp memory */
Quoted 8 lines
if (param_offset != 0 || param_size < buff_len) {
desc_buf = kmalloc(buff_len, GFP_KERNEL);
if (!desc_buf)
return -ENOMEM;
} else {
desc_buf = param_read_buf;
is_kmalloc = false;
}Avri
I found this checkup is still needed since LU descriptor read will multiple enter this function. so I didn't delete it in the new version patch.
thanks,
Bean
PATCH v4 4/4 scsi: ufs: add compatibility with 3.1 UFS unit descriptor length
In reply to Bean HuoFrom: Bean Huo <[email protected]>
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.
--- drivers/scsi/ufs/ufs.h | 1 + drivers/scsi/ufs/ufshcd.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/scsi/ufs/ufs.h +1 -0
@@ -63,6 +63,7 @@#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
drivers/scsi/ufs/ufshcd.c +8 -3
@@ -3070,11 +3070,16 @@ void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,EXPORT_SYMBOL (ufshcd_map_desc_id_to_length);static void ufshcd_update_desc_length (struct ufs_hba *hba, -enum desc_idn desc_id, +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_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; }
@@ -3141,7 +3146,7 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, goto out; } -ufshcd_update_desc_length (hba, desc_id, +ufshcd_update_desc_length (hba, desc_id, desc_index, desc_buf[QUERY_DESC_LENGTH_OFFSET ]);/* Check wherher we will not copy more data, than available */
Signature · 1 line
2.17.1
RE: [PATCH v4 4/4] scsi: ufs: add compatibility with 3.1 UFS unit descriptor length
Quoted 8 lines
From: Bean Huo <[email protected]>
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 bydesc_index.
This is not what your code is doing.
For RPMB - desc size will not be 0x2d but remain 256.
Your strategy is still correct IMO - if you assign the larger size, The device will not reply with error, but with the proper buffer.
You can also rely that reading the rpmb unit descriptor will not happen before Reading regular luns, because this is happening in the first slave_alloc.
Hence, I think you can drop the extra if, and just add the comment.
Thanks,
Avri
Quoted 56 lines
Signed-off-by Bean Huo <[email protected]>--- drivers/scsi/ufs/ufs.h | 1 + drivers/scsi/ufs/ufshcd.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-)drivers/scsi/ufs/ufs.h +1
-0@@ -63,6 +63,7 @@#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_ID8drivers/scsi/ufs/ufshcd.c +7
-2@@ -3070,11 +3070,16 @@ void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,EXPORT_SYMBOL (ufshcd_map_desc_id_to_length );static void ufshcd_update_desc_length (struct ufs_hba *hba, -enum desc_idn desc_id, +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_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;}
drivers/scsi/ufs/ufshcd.c +1
-2@@ -3141,7 +3146,7 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, goto out; } -ufshcd_update_desc_length (hba, desc_id, +ufshcd_update_desc_length (hba, desc_id, desc_index, desc_buf[QUERY_DESC_LENGTH_OFFSET ]);/* Check wherher we will not copy more data, than available */ --2.17.1
Re: [PATCH v4 4/4] scsi: ufs: add compatibility with 3.1 UFS unit descriptor length
Avri,
Quoted 11 lines · Avri Altman
Quoted 8 lines
From: Bean Huo <[email protected]>
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 bydesc_index.This is not what your code is doing.
For RPMB - desc size will not be0x2dbut remain 256.
sorry, I'm afraid I didn't quite get your point here. would you go over it again in detail please?
Quoted 9 lines
Your strategy is still correct IMO - if you assign the larger size, The device will not reply with error, but with the proper buffer.
You can also rely that reading the rpmb unit descriptor will not happen before
Reading regular luns, because this is happening in the firstslave_alloc.
On my side, I saw the Well-know LU descriptor is read before regulaer/normal LU descritptor. see ufshcd_add_lus();
I did further debug to verify my patch, and the unit descriptor read sequence:
1. read RPMB descriptor: desc_id 2, desc_index 0xc4
2. read LU 0 descriptor: desc_id 2, desc_index 0
3. read LU 0 descriptor: desc_id 2, desc_index 1
4. read LU 0 descriptor: desc_id 2, desc_index 2
5. read LU 0 descriptor: desc_id 2, desc_index 4
....
Quoted 2 lines
Hence, I think you can drop the extra if, and just add the comment.
so, this 'if' is still needed. otherwise, LU descriptor length will be initialized as 0x23(RPMB descriptor length).
if I am wrong, please correct me.
thanks,
Bean
Avri Altman
Reviewed-byRE: [PATCH v4 4/4] scsi: ufs: add compatibility with 3.1 UFS unit descriptor length
Quoted 44 lines
Avri,
Quoted 11 lines · Avri Altman
Quoted 8 lines
From: Bean Huo <[email protected]>
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 bydesc_index.This is not what your code is doing.
For RPMB - desc size will not be0x2dbut remain 256.sorry, I'm afraid I didn't quite get your point here. would you go over it again in detail please?
Quoted 9 lines
Your strategy is still correct IMO - if you assign the larger size, The device will not reply with error, but with the proper buffer.
You can also rely that reading the rpmb unit descriptor will not happen before
Reading regular luns, because this is happening in the firstslave_alloc.On my side, I saw the Well-know LU descriptor is read before regulaer/normal LU descritptor. see
ufshcd_add_lus();I did further debug to verify my patch, and the unit descriptor read sequence:
1. read RPMB descriptor:
desc_id2,desc_index0xc4
2. read LU 0 descriptor:desc_id2,desc_index0
3. read LU 0 descriptor:desc_id2,desc_index1
4. read LU 0 descriptor:desc_id2,desc_index2
5. read LU 0 descriptor:desc_id2,desc_index4
....
Quoted 6 lines
Quoted 2 lines
Hence, I think you can drop the extra if, and just add the comment.
so, this 'if' is still needed. otherwise, LU descriptor length will be initialized as 0x23(RPMB descriptor length).
Ahha, ok. I see your point now,
Fair enough.