linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] two changes for UFS/HPB
@ 2021-08-04 18:21 Bean Huo
  2021-08-04 18:21 ` [PATCH v1 1/2] scsi: ufs: Add L2P entry swap quirk for Micron UFS in HPB READ command Bean Huo
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Bean Huo @ 2021-08-04 18:21 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, cang, daejun7.park
  Cc: linux-scsi, linux-kernel

From: Bean Huo <beanhuo@micron.com>

These patches are based on the Martin's git Repo 5.15/scsi-staging branch

Bean Huo (2):
  scsi: ufs: Add L2P entry swap quirk for Micron UFS in HPB READ command
  scsi: ufs: Add lu_enable sysfs node

 drivers/scsi/ufs/ufs-sysfs.c  |  3 ++-
 drivers/scsi/ufs/ufs_quirks.h |  6 ++++++
 drivers/scsi/ufs/ufshcd.c     |  3 ++-
 drivers/scsi/ufs/ufshpb.c     | 15 ++++++++++-----
 4 files changed, 20 insertions(+), 7 deletions(-)

-- 
2.25.1


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

* [PATCH v1 1/2] scsi: ufs: Add L2P entry swap quirk for Micron UFS in HPB READ command
  2021-08-04 18:21 [PATCH v1 0/2] two changes for UFS/HPB Bean Huo
@ 2021-08-04 18:21 ` Bean Huo
  2021-08-05  6:34   ` Avri Altman
  2021-08-04 18:21 ` [PATCH v1 2/2] scsi: ufs: Add lu_enable sysfs node Bean Huo
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Bean Huo @ 2021-08-04 18:21 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, cang, daejun7.park
  Cc: linux-scsi, linux-kernel

From: Bean Huo <beanhuo@micron.com>

For the Micron UFS, L2P entry need to be swapped in HPB READ command
before sending HPB READ command to the UFS device. Add this quirk
UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ to fix this inconsistency.

Fixes: 2fff76f87542 ("scsi: ufs: ufshpb: Prepare HPB read for cached sub-region")
Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/scsi/ufs/ufs_quirks.h |  6 ++++++
 drivers/scsi/ufs/ufshcd.c     |  3 ++-
 drivers/scsi/ufs/ufshpb.c     | 15 ++++++++++-----
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h
index 07f559ac5883..35ec9ea79869 100644
--- a/drivers/scsi/ufs/ufs_quirks.h
+++ b/drivers/scsi/ufs/ufs_quirks.h
@@ -116,4 +116,10 @@ struct ufs_dev_fix {
  */
 #define UFS_DEVICE_QUIRK_DELAY_AFTER_LPM        (1 << 11)
 
+/*
+ * Some UFS devices require L2P entry should be swapped before being sent to the
+ * UFS device for HPB READ command.
+ */
+#define UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ (1 << 12)
+
 #endif /* UFS_QUIRKS_H_ */
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 47a5085f16a9..c3a14d3b0030 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -199,7 +199,8 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state,
 static struct ufs_dev_fix ufs_fixups[] = {
 	/* UFS cards deviations table */
 	UFS_FIX(UFS_VENDOR_MICRON, UFS_ANY_MODEL,
-		UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM),
+		UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
+		UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ),
 	UFS_FIX(UFS_VENDOR_SAMSUNG, UFS_ANY_MODEL,
 		UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
 		UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE |
diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c
index 54e8e019bdbe..d0eb14be47a3 100644
--- a/drivers/scsi/ufs/ufshpb.c
+++ b/drivers/scsi/ufs/ufshpb.c
@@ -323,15 +323,19 @@ ufshpb_get_pos_from_lpn(struct ufshpb_lu *hpb, unsigned long lpn, int *rgn_idx,
 }
 
 static void
-ufshpb_set_hpb_read_to_upiu(struct ufshpb_lu *hpb, struct ufshcd_lrb *lrbp,
-			    u32 lpn, __be64 ppn, u8 transfer_len, int read_id)
+ufshpb_set_hpb_read_to_upiu(struct ufs_hba *hba, struct ufshpb_lu *hpb,
+			    struct ufshcd_lrb *lrbp, u32 lpn, __be64 ppn,
+			    u8 transfer_len, int read_id)
 {
 	unsigned char *cdb = lrbp->cmd->cmnd;
-
+	__be64 ppn_tmp = ppn;
 	cdb[0] = UFSHPB_READ;
 
+	if (hba->dev_quirks & UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ)
+		ppn_tmp = swab64(ppn);
+
 	/* ppn value is stored as big-endian in the host memory */
-	memcpy(&cdb[6], &ppn, sizeof(__be64));
+	memcpy(&cdb[6], &ppn_tmp, sizeof(__be64));
 	cdb[14] = transfer_len;
 	cdb[15] = read_id;
 
@@ -689,7 +693,8 @@ int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 		}
 	}
 
-	ufshpb_set_hpb_read_to_upiu(hpb, lrbp, lpn, ppn, transfer_len, read_id);
+	ufshpb_set_hpb_read_to_upiu(hba, hpb, lrbp, lpn, ppn, transfer_len,
+				    read_id);
 
 	hpb->stats.hit_cnt++;
 	return 0;
-- 
2.25.1


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

* [PATCH v1 2/2] scsi: ufs: Add lu_enable sysfs node
  2021-08-04 18:21 [PATCH v1 0/2] two changes for UFS/HPB Bean Huo
  2021-08-04 18:21 ` [PATCH v1 1/2] scsi: ufs: Add L2P entry swap quirk for Micron UFS in HPB READ command Bean Huo
@ 2021-08-04 18:21 ` Bean Huo
  2021-08-05  6:35   ` Avri Altman
  2021-08-06  3:21 ` [PATCH v1 0/2] two changes for UFS/HPB Martin K. Petersen
  2021-08-10  5:20 ` Martin K. Petersen
  3 siblings, 1 reply; 7+ messages in thread
From: Bean Huo @ 2021-08-04 18:21 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, cang, daejun7.park
  Cc: linux-scsi, linux-kernel

From: Bean Huo <beanhuo@micron.com>

We need to check HPB being enabled on which LU from the userspace tool,
so, add lu_enable sysfs node.

Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/scsi/ufs/ufs-sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index 08fe037069bc..5c405ff7b6ea 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -1163,6 +1163,7 @@ static DEVICE_ATTR_RO(_pname)
 #define UFS_UNIT_DESC_PARAM(_name, _uname, _size)			\
 	UFS_LUN_DESC_PARAM(_name, _uname, UNIT, _size)
 
+UFS_UNIT_DESC_PARAM(lu_enable, _LU_ENABLE, 1);
 UFS_UNIT_DESC_PARAM(boot_lun_id, _BOOT_LUN_ID, 1);
 UFS_UNIT_DESC_PARAM(lun_write_protect, _LU_WR_PROTECT, 1);
 UFS_UNIT_DESC_PARAM(lun_queue_depth, _LU_Q_DEPTH, 1);
@@ -1181,8 +1182,8 @@ UFS_UNIT_DESC_PARAM(hpb_pinned_region_start_offset, _HPB_PIN_RGN_START_OFF, 2);
 UFS_UNIT_DESC_PARAM(hpb_number_pinned_regions, _HPB_NUM_PIN_RGNS, 2);
 UFS_UNIT_DESC_PARAM(wb_buf_alloc_units, _WB_BUF_ALLOC_UNITS, 4);
 
-
 static struct attribute *ufs_sysfs_unit_descriptor[] = {
+	&dev_attr_lu_enable.attr,
 	&dev_attr_boot_lun_id.attr,
 	&dev_attr_lun_write_protect.attr,
 	&dev_attr_lun_queue_depth.attr,
-- 
2.25.1


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

* RE: [PATCH v1 1/2] scsi: ufs: Add L2P entry swap quirk for Micron UFS in HPB READ command
  2021-08-04 18:21 ` [PATCH v1 1/2] scsi: ufs: Add L2P entry swap quirk for Micron UFS in HPB READ command Bean Huo
@ 2021-08-05  6:34   ` Avri Altman
  0 siblings, 0 replies; 7+ messages in thread
From: Avri Altman @ 2021-08-05  6:34 UTC (permalink / raw)
  To: Bean Huo, alim.akhtar, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, cang, daejun7.park
  Cc: linux-scsi, linux-kernel

> From: Bean Huo <beanhuo@micron.com>
> 
> For the Micron UFS, L2P entry need to be swapped in HPB READ command
> before sending HPB READ command to the UFS device. Add this quirk
> UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ to fix this
> inconsistency.
> 
> Fixes: 2fff76f87542 ("scsi: ufs: ufshpb: Prepare HPB read for cached sub-
> region")
Not really needed - the patch is fine.

> Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

> ---
>  drivers/scsi/ufs/ufs_quirks.h |  6 ++++++
>  drivers/scsi/ufs/ufshcd.c     |  3 ++-
>  drivers/scsi/ufs/ufshpb.c     | 15 ++++++++++-----
>  3 files changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h
> index 07f559ac5883..35ec9ea79869 100644
> --- a/drivers/scsi/ufs/ufs_quirks.h
> +++ b/drivers/scsi/ufs/ufs_quirks.h
> @@ -116,4 +116,10 @@ struct ufs_dev_fix {
>   */
>  #define UFS_DEVICE_QUIRK_DELAY_AFTER_LPM        (1 << 11)
> 
> +/*
> + * Some UFS devices require L2P entry should be swapped before being sent to
> the
> + * UFS device for HPB READ command.
> + */
> +#define UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ (1 << 12)
> +
>  #endif /* UFS_QUIRKS_H_ */
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 47a5085f16a9..c3a14d3b0030 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -199,7 +199,8 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum
> ufs_dev_pwr_mode dev_state,
>  static struct ufs_dev_fix ufs_fixups[] = {
>         /* UFS cards deviations table */
>         UFS_FIX(UFS_VENDOR_MICRON, UFS_ANY_MODEL,
> -               UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM),
> +               UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
> +               UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ),
>         UFS_FIX(UFS_VENDOR_SAMSUNG, UFS_ANY_MODEL,
>                 UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
>                 UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE |
> diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c
> index 54e8e019bdbe..d0eb14be47a3 100644
> --- a/drivers/scsi/ufs/ufshpb.c
> +++ b/drivers/scsi/ufs/ufshpb.c
> @@ -323,15 +323,19 @@ ufshpb_get_pos_from_lpn(struct ufshpb_lu *hpb,
> unsigned long lpn, int *rgn_idx,
>  }
> 
>  static void
> -ufshpb_set_hpb_read_to_upiu(struct ufshpb_lu *hpb, struct ufshcd_lrb *lrbp,
> -                           u32 lpn, __be64 ppn, u8 transfer_len, int read_id)
> +ufshpb_set_hpb_read_to_upiu(struct ufs_hba *hba, struct ufshpb_lu *hpb,
> +                           struct ufshcd_lrb *lrbp, u32 lpn, __be64 ppn,
> +                           u8 transfer_len, int read_id)
>  {
>         unsigned char *cdb = lrbp->cmd->cmnd;
> -
> +       __be64 ppn_tmp = ppn;
>         cdb[0] = UFSHPB_READ;
> 
> +       if (hba->dev_quirks &
> UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ)
> +               ppn_tmp = swab64(ppn);
> +
>         /* ppn value is stored as big-endian in the host memory */
> -       memcpy(&cdb[6], &ppn, sizeof(__be64));
> +       memcpy(&cdb[6], &ppn_tmp, sizeof(__be64));
>         cdb[14] = transfer_len;
>         cdb[15] = read_id;
> 
> @@ -689,7 +693,8 @@ int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb
> *lrbp)
>                 }
>         }
> 
> -       ufshpb_set_hpb_read_to_upiu(hpb, lrbp, lpn, ppn, transfer_len, read_id);
> +       ufshpb_set_hpb_read_to_upiu(hba, hpb, lrbp, lpn, ppn, transfer_len,
> +                                   read_id);
> 
>         hpb->stats.hit_cnt++;
>         return 0;
> --
> 2.25.1


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

* RE: [PATCH v1 2/2] scsi: ufs: Add lu_enable sysfs node
  2021-08-04 18:21 ` [PATCH v1 2/2] scsi: ufs: Add lu_enable sysfs node Bean Huo
@ 2021-08-05  6:35   ` Avri Altman
  0 siblings, 0 replies; 7+ messages in thread
From: Avri Altman @ 2021-08-05  6:35 UTC (permalink / raw)
  To: Bean Huo, alim.akhtar, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, cang, daejun7.park
  Cc: linux-scsi, linux-kernel

> From: Bean Huo <beanhuo@micron.com>
> 
> We need to check HPB being enabled on which LU from the userspace tool,
> so, add lu_enable sysfs node.
> 
> Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Tested-by: Avri Altman <avri.altman@wdc.com>

> ---
>  drivers/scsi/ufs/ufs-sysfs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
> index 08fe037069bc..5c405ff7b6ea 100644
> --- a/drivers/scsi/ufs/ufs-sysfs.c
> +++ b/drivers/scsi/ufs/ufs-sysfs.c
> @@ -1163,6 +1163,7 @@ static DEVICE_ATTR_RO(_pname)
>  #define UFS_UNIT_DESC_PARAM(_name, _uname, _size)                      \
>         UFS_LUN_DESC_PARAM(_name, _uname, UNIT, _size)
> 
> +UFS_UNIT_DESC_PARAM(lu_enable, _LU_ENABLE, 1);
>  UFS_UNIT_DESC_PARAM(boot_lun_id, _BOOT_LUN_ID, 1);
>  UFS_UNIT_DESC_PARAM(lun_write_protect, _LU_WR_PROTECT, 1);
>  UFS_UNIT_DESC_PARAM(lun_queue_depth, _LU_Q_DEPTH, 1);
> @@ -1181,8 +1182,8 @@
> UFS_UNIT_DESC_PARAM(hpb_pinned_region_start_offset,
> _HPB_PIN_RGN_START_OFF, 2);
>  UFS_UNIT_DESC_PARAM(hpb_number_pinned_regions,
> _HPB_NUM_PIN_RGNS, 2);
>  UFS_UNIT_DESC_PARAM(wb_buf_alloc_units, _WB_BUF_ALLOC_UNITS, 4);
> 
> -
>  static struct attribute *ufs_sysfs_unit_descriptor[] = {
> +       &dev_attr_lu_enable.attr,
>         &dev_attr_boot_lun_id.attr,
>         &dev_attr_lun_write_protect.attr,
>         &dev_attr_lun_queue_depth.attr,
> --
> 2.25.1


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

* Re: [PATCH v1 0/2] two changes for UFS/HPB
  2021-08-04 18:21 [PATCH v1 0/2] two changes for UFS/HPB Bean Huo
  2021-08-04 18:21 ` [PATCH v1 1/2] scsi: ufs: Add L2P entry swap quirk for Micron UFS in HPB READ command Bean Huo
  2021-08-04 18:21 ` [PATCH v1 2/2] scsi: ufs: Add lu_enable sysfs node Bean Huo
@ 2021-08-06  3:21 ` Martin K. Petersen
  2021-08-10  5:20 ` Martin K. Petersen
  3 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2021-08-06  3:21 UTC (permalink / raw)
  To: Bean Huo
  Cc: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, cang, daejun7.park, linux-scsi,
	linux-kernel


Bean,

> These patches are based on the Martin's git Repo 5.15/scsi-staging
> branch

Applied to 5.15/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH v1 0/2] two changes for UFS/HPB
  2021-08-04 18:21 [PATCH v1 0/2] two changes for UFS/HPB Bean Huo
                   ` (2 preceding siblings ...)
  2021-08-06  3:21 ` [PATCH v1 0/2] two changes for UFS/HPB Martin K. Petersen
@ 2021-08-10  5:20 ` Martin K. Petersen
  3 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2021-08-10  5:20 UTC (permalink / raw)
  To: asutoshd, alim.akhtar, cang, daejun7.park, avri.altman, jejb,
	stanley.chu, beanhuo, Bean Huo, bvanassche
  Cc: Martin K . Petersen, linux-kernel, linux-scsi

On Wed, 4 Aug 2021 20:21:26 +0200, Bean Huo wrote:

> From: Bean Huo <beanhuo@micron.com>
> 
> These patches are based on the Martin's git Repo 5.15/scsi-staging branch
> 
> Bean Huo (2):
>   scsi: ufs: Add L2P entry swap quirk for Micron UFS in HPB READ command
>   scsi: ufs: Add lu_enable sysfs node
> 
> [...]

Applied to 5.15/scsi-queue, thanks!

[1/2] scsi: ufs: Add L2P entry swap quirk for Micron UFS in HPB READ command
      https://git.kernel.org/mkp/scsi/c/63522bf3aced
[2/2] scsi: ufs: Add lu_enable sysfs node
      https://git.kernel.org/mkp/scsi/c/f5efd4fe78de

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2021-08-10  5:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04 18:21 [PATCH v1 0/2] two changes for UFS/HPB Bean Huo
2021-08-04 18:21 ` [PATCH v1 1/2] scsi: ufs: Add L2P entry swap quirk for Micron UFS in HPB READ command Bean Huo
2021-08-05  6:34   ` Avri Altman
2021-08-04 18:21 ` [PATCH v1 2/2] scsi: ufs: Add lu_enable sysfs node Bean Huo
2021-08-05  6:35   ` Avri Altman
2021-08-06  3:21 ` [PATCH v1 0/2] two changes for UFS/HPB Martin K. Petersen
2021-08-10  5:20 ` 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).