linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Changes for UFS advanced RPMB
@ 2023-08-09 18:18 Bean Huo
  2023-08-09 18:18 ` [PATCH v1 1/2] scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not support EHS length in UTRD Bean Huo
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Bean Huo @ 2023-08-09 18:18 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, tomas.winkler, cang,
	jonghwi.rha
  Cc: linux-scsi, linux-kernel, 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(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 1/2] scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not support EHS length in UTRD
  2023-08-09 18:18 [PATCH v1 0/2] Changes for UFS advanced RPMB Bean Huo
@ 2023-08-09 18:18 ` Bean Huo
  2023-08-09 18:18 ` [PATCH v1 2/2] scsi: ufs: core: No need to update UPIU.header.flags and lun in advanced RPMB handler Bean Huo
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Bean Huo @ 2023-08-09 18:18 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, tomas.winkler, cang,
	jonghwi.rha
  Cc: linux-scsi, linux-kernel

From: Bean Huo <beanhuo@micron.com>

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.

Fixes: 6ff265fc5ef6 ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg")
Signed-off-by: jonghwi.rha <jonghwi.rha@samsung.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/ufs/core/ufs_bsg.c |  3 +--
 drivers/ufs/core/ufshcd.c  | 10 +++++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/ufs/core/ufs_bsg.c b/drivers/ufs/core/ufs_bsg.c
index 34e423924e06..374e5aae4e7e 100644
--- a/drivers/ufs/core/ufs_bsg.c
+++ b/drivers/ufs/core/ufs_bsg.c
@@ -76,8 +76,7 @@ static int ufs_bsg_exec_advanced_rpmb_req(struct ufs_hba *hba, struct bsg_job *j
 	int 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)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 8b5ee1a7d454..7f965ac18ee8 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 2/2] scsi: ufs: core: No need to update UPIU.header.flags and lun in advanced RPMB handler
  2023-08-09 18:18 [PATCH v1 0/2] Changes for UFS advanced RPMB Bean Huo
  2023-08-09 18:18 ` [PATCH v1 1/2] scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not support EHS length in UTRD Bean Huo
@ 2023-08-09 18:18 ` Bean Huo
  2023-08-27 20:00 ` [PATCH v1 0/2] Changes for UFS advanced RPMB Bean Huo
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Bean Huo @ 2023-08-09 18:18 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, tomas.winkler, cang,
	jonghwi.rha
  Cc: linux-scsi, linux-kernel

From: Bean Huo <beanhuo@micron.com>

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.

Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/ufs/core/ufshcd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 7f965ac18ee8..446f949154c3 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -7250,9 +7250,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
 	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;
-	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 */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 0/2] Changes for UFS advanced RPMB
  2023-08-09 18:18 [PATCH v1 0/2] Changes for UFS advanced RPMB Bean Huo
  2023-08-09 18:18 ` [PATCH v1 1/2] scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not support EHS length in UTRD Bean Huo
  2023-08-09 18:18 ` [PATCH v1 2/2] scsi: ufs: core: No need to update UPIU.header.flags and lun in advanced RPMB handler Bean Huo
@ 2023-08-27 20:00 ` Bean Huo
  2023-08-28 18:58   ` Bart Van Assche
  2023-08-31  1:42 ` Martin K. Petersen
  2023-09-05 10:18 ` Martin K. Petersen
  4 siblings, 1 reply; 7+ messages in thread
From: Bean Huo @ 2023-08-27 20:00 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, tomas.winkler, cang,
	jonghwi.rha
  Cc: linux-scsi, linux-kernel

On Wed, 2023-08-09 at 20:18 +0200, Bean Huo wrote:
> 
> 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(-)
> 


Hi Martin and Bart,

what's opinion of this series of patch??

Bean

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 0/2] Changes for UFS advanced RPMB
  2023-08-27 20:00 ` [PATCH v1 0/2] Changes for UFS advanced RPMB Bean Huo
@ 2023-08-28 18:58   ` Bart Van Assche
  0 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2023-08-28 18:58 UTC (permalink / raw)
  To: Bean Huo, alim.akhtar, avri.altman, asutoshd, jejb,
	martin.petersen, stanley.chu, beanhuo, tomas.winkler, cang,
	jonghwi.rha
  Cc: linux-scsi, linux-kernel

On 8/27/23 13:00, Bean Huo wrote:
> 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:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 0/2] Changes for UFS advanced RPMB
  2023-08-09 18:18 [PATCH v1 0/2] Changes for UFS advanced RPMB Bean Huo
                   ` (2 preceding siblings ...)
  2023-08-27 20:00 ` [PATCH v1 0/2] Changes for UFS advanced RPMB Bean Huo
@ 2023-08-31  1:42 ` Martin K. Petersen
  2023-09-05 10:18 ` Martin K. Petersen
  4 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2023-08-31  1:42 UTC (permalink / raw)
  To: Bean Huo
  Cc: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, tomas.winkler, cang,
	jonghwi.rha, linux-scsi, linux-kernel


Bean,

> 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!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 0/2] Changes for UFS advanced RPMB
  2023-08-09 18:18 [PATCH v1 0/2] Changes for UFS advanced RPMB Bean Huo
                   ` (3 preceding siblings ...)
  2023-08-31  1:42 ` Martin K. Petersen
@ 2023-09-05 10:18 ` Martin K. Petersen
  4 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2023-09-05 10:18 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, stanley.chu, beanhuo,
	bvanassche, tomas.winkler, cang, jonghwi.rha, Bean Huo
  Cc: Martin K . Petersen, linux-scsi, linux-kernel

On Wed, 09 Aug 2023 20:18:45 +0200, Bean Huo wrote:

> 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

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-09-05 16:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-09 18:18 [PATCH v1 0/2] Changes for UFS advanced RPMB Bean Huo
2023-08-09 18:18 ` [PATCH v1 1/2] scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not support EHS length in UTRD Bean Huo
2023-08-09 18:18 ` [PATCH v1 2/2] scsi: ufs: core: No need to update UPIU.header.flags and lun in advanced RPMB handler Bean Huo
2023-08-27 20:00 ` [PATCH v1 0/2] Changes for UFS advanced RPMB Bean Huo
2023-08-28 18:58   ` Bart Van Assche
2023-08-31  1:42 ` Martin K. Petersen
2023-09-05 10:18 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).