Changes for UFS advanced RPMB
Subsystems (2)
cover Changes for UFS advanced RPMB
Bean Huo (2):
scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not
support EHS length in UTRD
scsi: ufs: core: No need to update UPIU.header.flags and lun in
advanced RPMB handler
drivers/ufs/core/ufs_bsg.c | 3 +-- drivers/ufs/core/ufshcd.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not support EHS length in UTRD
From: Bean Huo <[email protected]>
According to UFSHCI 4.0 specification:
5.2 Host Controller Capabilities Registers
5.2.1 Offset 00h: CAP – Controller Capabilities:
" EHS Length in UTRD Supported (EHSLUTRDS): Indicates whether the host
controller supports EHS Length field in UTRD.
0 – Host controller takes EHS length from CMD UPIU, and SW driver use EHS Length field in CMD UPIU. 1 – HW controller takes EHS length from UTRD, and SW driver use EHS Length field in UTRD. NOTE Recommend Host controllers move to taking EHS length from UTRD, and in UFS-5, it will be mandatory."
So, when UFSHCI 4.0 doesn't support EHS Length field in UTRD, we could use EHS Length field in CMD UPIU. This patch aims to remove the limitation that advanced RPMB only works when EHS length is supported in UTRD.
--- drivers/ufs/core/ufs_bsg.c | 3 +-- drivers/ufs/core/ufshcd.c | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/ufs/core/ufs_bsg.c +1 -2
@@ -76,8 +76,7 @@ static int ufs_bsg_exec_advanced_rpmb_req(struct ufs_hba *hba, struct bsg_job *jint ret;int data_len; -if (hba->ufs_version <ufshci_version (4 ,0 ) || !hba->dev_info.b_advanced_rpmb_en || - !(hba->capabilities &MASK_EHSLUTRD_SUPPORTED )) +if (hba->ufs_version <ufshci_version (4 ,0 ) || !hba->dev_info.b_advanced_rpmb_en)return -EINVAL ;if (rpmb_request->ehs_req.length !=2 || rpmb_request->ehs_req.ehs_type !=1 )
drivers/ufs/core/ufshcd.c +9 -1
@@ -7240,7 +7240,15 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r/* Advanced RPMB starts from UFS 4.0, so its command type is UTP_CMD_TYPE_UFS_STORAGE */ lrbp->command_type =UTP_CMD_TYPE_UFS_STORAGE ; -ufshcd_prepare_req_desc_hdr (lrbp, &upiu_flags, dir,2 ); +/* +* According to UFSHCI 4.0 specification page 24, if EHSLUTRDS is 0, host controller takes +* EHS length from CMD UPIU, and SW driver use EHS Length field in CMD UPIU. if it is 1, +* HW controller takes EHS length from UTRD. +*/ +if (hba->capabilities &MASK_EHSLUTRD_SUPPORTED ) +ufshcd_prepare_req_desc_hdr (lrbp, &upiu_flags, dir,2 ); +else +ufshcd_prepare_req_desc_hdr (lrbp, &upiu_flags, dir,0 );/* update the task tag and LUN in the request upiu */ req_upiu->header.flags = upiu_flags;
Signature · 1 line
2.34.1
PATCH 2/2 scsi: ufs: core: No need to update UPIU.header.flags and lun in advanced RPMB handler
In reply to Bean HuoFrom: Bean Huo <[email protected]>
For advanced RPMB requests, its UPIU package should be fully initialized in its ufs-bsg-based application, except for task tag. in ufshcd.c, we just copy UPIU (with CDB) request as-is.
--- drivers/ufs/core/ufshcd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/ufs/core/ufshcd.c +1 -3
@@ -7250,9 +7250,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *relse ufshcd_prepare_req_desc_hdr (lrbp, &upiu_flags, dir,0 ); -/* update the task tag and LUN in the request upiu */ - req_upiu->header.flags = upiu_flags; - req_upiu->header.lun =UFS_UPIU_RPMB_WLUN ; +/* update the task tag */ req_upiu->header.task_tag = tag;/* copy the UPIU(contains CDB) request as it is */
Signature · 1 line
2.34.1
Quoted 8 lines · Bean Huo
Bean Huo (2):
scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not
support EHS length in UTRD
scsi: ufs: core: No need to update UPIU.header.flags and lun in advanced RPMB handler
Quoted 4 lines
drivers/ufs/core/ufs_bsg.c | 3 +--
drivers/ufs/core/ufshcd.c | 14 ++++++++++----2 files changed, 11 insertions(+), 6 deletions(-)
Hi Martin and Bart,
what's opinion of this series of patch??
Bean
Quoted 1 line · Bean Huo
what's opinion of this series of patch??
Hi Bean,
I had not yet reviewed these patches since my employer is not using advanced RPMB. Anyway, since both patches look good to me:
Martin K. Petersen
AppliedBean,
Quoted 5 lines
Bean Huo (2):
scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not
support EHS length in UTRD
scsi: ufs: core: No need to update UPIU.header.flags and lun in
advanced RPMB handler
Applied to 6.6/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 11 lines · Bean Huo
Bean Huo (2):
scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not
support EHS length in UTRD
scsi: ufs: core: No need to update UPIU.header.flags and lun in
advanced RPMB handler
drivers/ufs/core/ufs_bsg.c| 3 +--drivers/ufs/core/ufshcd.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-)[...]
Applied to 6.6/scsi-queue, thanks!
[1/2] scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not support EHS length in UTRD
https://git.kernel.org/mkp/scsi/c/c91e585cfb3d [2/2] scsi: ufs: core: No need to update UPIU.header.flags and lun in advanced RPMB handler https://git.kernel.org/mkp/scsi/c/9f6fec656613
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering