Skip to content

Commit c91e585

Browse files
beanhuomartinkpetersen
authored andcommitted
scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not support EHS length in UTRD
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. Remove the limitation that advanced RPMB only works when EHS length is supported in UTRD. Fixes: 6ff265f ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg") Co-developed-by: "jonghwi.rha" <[email protected]> Signed-off-by: "jonghwi.rha" <[email protected]> Signed-off-by: Bean Huo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 0854065 commit c91e585

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

drivers/ufs/core/ufs_bsg.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ static int ufs_bsg_exec_advanced_rpmb_req(struct ufs_hba *hba, struct bsg_job *j
7676
int ret;
7777
int data_len;
7878

79-
if (hba->ufs_version < ufshci_version(4, 0) || !hba->dev_info.b_advanced_rpmb_en ||
80-
!(hba->capabilities & MASK_EHSLUTRD_SUPPORTED))
79+
if (hba->ufs_version < ufshci_version(4, 0) || !hba->dev_info.b_advanced_rpmb_en)
8180
return -EINVAL;
8281

8382
if (rpmb_request->ehs_req.length != 2 || rpmb_request->ehs_req.ehs_type != 1)

drivers/ufs/core/ufshcd.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -7240,7 +7240,15 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
72407240
/* Advanced RPMB starts from UFS 4.0, so its command type is UTP_CMD_TYPE_UFS_STORAGE */
72417241
lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
72427242

7243-
ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, dir, 2);
7243+
/*
7244+
* According to UFSHCI 4.0 specification page 24, if EHSLUTRDS is 0, host controller takes
7245+
* EHS length from CMD UPIU, and SW driver use EHS Length field in CMD UPIU. if it is 1,
7246+
* HW controller takes EHS length from UTRD.
7247+
*/
7248+
if (hba->capabilities & MASK_EHSLUTRD_SUPPORTED)
7249+
ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, dir, 2);
7250+
else
7251+
ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, dir, 0);
72447252

72457253
/* update the task tag and LUN in the request upiu */
72467254
req_upiu->header.flags = upiu_flags;

0 commit comments

Comments
 (0)