diff mbox series

[V2] scsi: ufs: core: Check LSDBS cap when !mcq

Message ID 20240705083050epcms2p85f6e53e075a0d8f6d7980cdad7e62b80@epcms2p8 (mailing list archive)
State Superseded
Headers show
Series [V2] scsi: ufs: core: Check LSDBS cap when !mcq | expand

Commit Message

Kyoungrul Kim July 5, 2024, 8:30 a.m. UTC
if the user set use_mcq_mode to 0, the host will activate the lsdb mode
unconditionally even when the lsdbs of device hci cap is 0. so it makes
timeout cmds and fail to device probing.

To prevent that problem. check the lsdbs cap when mcq is not supported
case.

Signed-off-by: k831.kim <k831.kim@samsung.com>

---
Changes to v1: Fix wrong bit of lsdb support.
---
 drivers/ufs/core/ufshcd.c | 16 ++++++++++++++++
 include/ufs/ufshcd.h      |  1 +
 include/ufs/ufshci.h      |  1 +
 3 files changed, 18 insertions(+)

Comments

Ed Tsai (蔡宗軒) July 8, 2024, 2:53 a.m. UTC | #1
On Fri, 2024-07-05 at 17:30 +0900, Kyoungrul Kim wrote:
> if the user set use_mcq_mode to 0, the host will activate the lsdb
> mode
> unconditionally even when the lsdbs of device hci cap is 0. so it
> makes

lsdbs = 1 indicates unsupported, not 0.

or simply say host controller doesn't support LSDB mode ?

> timeout cmds and fail to device probing.
> 
> To prevent that problem. check the lsdbs cap when mcq is not
> supported
> case.
> 
> Signed-off-by: k831.kim <k831.kim@samsung.com>
> 
> ---
> Changes to v1: Fix wrong bit of lsdb support.
> ---
>  drivers/ufs/core/ufshcd.c | 16 ++++++++++++++++
>  include/ufs/ufshcd.h      |  1 +
>  include/ufs/ufshci.h      |  1 +
>  3 files changed, 18 insertions(+)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 1b65e6ae4137..b5a05f8492c4 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -2412,7 +2412,17 @@ static inline int
> ufshcd_hba_capabilities(struct ufs_hba *hba)
>  return err;
>  }
>  
> +/*
> + *  UFS 3.0 has no MCQ_SUPPORT and LSDB_SUPPORT, but [31:29] as
> reserved
> + *  bits with reset value 0s, which means we can simply read values
> + *  regardless to version
> + */
>  hba->mcq_sup = FIELD_GET(MASK_MCQ_SUPPORT, hba->capabilities);
> +/*
> + *  0h: legacy single doorbell support is available
> + *  1h: indicate that legacy single doorbell support have been
> remove

s/remove/removed/

also, seems like there is an extra space at the beginning of each
comment message ?

> + */
> +hba->lsdb_sup = !FIELD_GET(MASK_LSDB_SUPPORT, hba->capabilities);
>  if (!hba->mcq_sup)
>  return 0;
>  
> @@ -10449,6 +10459,12 @@ int ufshcd_init(struct ufs_hba *hba, void
> __iomem *mmio_base, unsigned int irq)
>  }
>  
>  if (!is_mcq_supported(hba)) {
> +if (!hba->lsdb_sup) {
> +dev_err(hba->dev, "%s: failed to initialize (legacy doorbell mode
> not supported\n",
> +__func__);
> +err = -EINVAL;
> +goto out_disable;
> +}
>  err = scsi_add_host(host, hba->dev);
>  if (err) {
>  dev_err(hba->dev, "scsi_add_host failed\n");
> diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
> index bad88bd91995..fd391f6eee73 100644
> --- a/include/ufs/ufshcd.h
> +++ b/include/ufs/ufshcd.h
> @@ -1074,6 +1074,7 @@ struct ufs_hba {
>  bool ext_iid_sup;
>  bool scsi_host_added;
>  bool mcq_sup;
> +bool lsdb_sup;
>  bool mcq_enabled;
>  struct ufshcd_res_info res[RES_MAX];
>  void __iomem *mcq_base;
> diff --git a/include/ufs/ufshci.h b/include/ufs/ufshci.h
> index 385e1c6b8d60..22ba85e81d8c 100644
> --- a/include/ufs/ufshci.h
> +++ b/include/ufs/ufshci.h
> @@ -75,6 +75,7 @@ enum {
>  MASK_OUT_OF_ORDER_DATA_DELIVERY_SUPPORT= 0x02000000,
>  MASK_UIC_DME_TEST_MODE_SUPPORT= 0x04000000,
>  MASK_CRYPTO_SUPPORT= 0x10000000,
> +MASK_LSDB_SUPPORT= 0x20000000,
>  MASK_MCQ_SUPPORT= 0x40000000,
>  };
>  
> -- 
> 2.34.1
>
Kyoungrul Kim July 8, 2024, 5:09 a.m. UTC | #2
I made a mistake.
I will revise comment and commit message.
thanks.
 
 
--------- Original Message ---------
Sender : Ed Tsai (蔡宗軒) <Ed.Tsai@mediatek.com>
Date : 2024-07-08 11:53 (GMT+9)
Title : Re: [PATCH V2] scsi: ufs: core: Check LSDBS cap when !mcq
 
On Fri, 2024-07-05 at 17:30 +0900, Kyoungrul Kim wrote:
> if the user set use_mcq_mode to 0, the host will activate the lsdb
> mode
> unconditionally even when the lsdbs of device hci cap is 0. so it
> makes

lsdbs = 1 indicates unsupported, not 0.

or simply say host controller doesn't support LSDB mode ?

> timeout cmds and fail to device probing.
>
> To prevent that problem. check the lsdbs cap when mcq is not
> supported
> case.
>
> Signed-off-by: k831.kim <k831.kim@samsung.com>
>
> ---
> Changes to v1: Fix wrong bit of lsdb support.
> ---
>  drivers/ufs/core/ufshcd.c 16 ++++++++++++++++
>  include/ufs/ufshcd.h        1 +
>  include/ufs/ufshci.h        1 +
>  3 files changed, 18 insertions(+)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 1b65e6ae4137..b5a05f8492c4 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -2412,7 +2412,17 @@ static inline int
> ufshcd_hba_capabilities(struct ufs_hba *hba)
>  return err;
>  }

> +/*
> + *  UFS 3.0 has no MCQ_SUPPORT and LSDB_SUPPORT, but [31:29] as
> reserved
> + *  bits with reset value 0s, which means we can simply read values
> + *  regardless to version
> + */
>  hba->mcq_sup = FIELD_GET(MASK_MCQ_SUPPORT, hba->capabilities);
> +/*
> + *  0h: legacy single doorbell support is available
> + *  1h: indicate that legacy single doorbell support have been
> remove

s/remove/removed/

also, seems like there is an extra space at the beginning of each
comment message ?

> + */
> +hba->lsdb_sup = !FIELD_GET(MASK_LSDB_SUPPORT, hba->capabilities);
>  if (!hba->mcq_sup)
>  return 0;

> @@ -10449,6 +10459,12 @@ int ufshcd_init(struct ufs_hba *hba, void
> __iomem *mmio_base, unsigned int irq)
>  }

>  if (!is_mcq_supported(hba)) {
> +if (!hba->lsdb_sup) {
> +dev_err(hba->dev, "%s: failed to initialize (legacy doorbell mode
> not supported\n",
> +__func__);
> +err = -EINVAL;
> +goto out_disable;
> +}
>  err = scsi_add_host(host, hba->dev);
>  if (err) {
>  dev_err(hba->dev, "scsi_add_host failed\n");
> diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
> index bad88bd91995..fd391f6eee73 100644
> --- a/include/ufs/ufshcd.h
> +++ b/include/ufs/ufshcd.h
> @@ -1074,6 +1074,7 @@ struct ufs_hba {
>  bool ext_iid_sup;
>  bool scsi_host_added;
>  bool mcq_sup;
> +bool lsdb_sup;
>  bool mcq_enabled;
>  struct ufshcd_res_info res[RES_MAX];
>  void __iomem *mcq_base;
> diff --git a/include/ufs/ufshci.h b/include/ufs/ufshci.h
> index 385e1c6b8d60..22ba85e81d8c 100644
> --- a/include/ufs/ufshci.h
> +++ b/include/ufs/ufshci.h
> @@ -75,6 +75,7 @@ enum {
>  MASK_OUT_OF_ORDER_DATA_DELIVERY_SUPPORT= 0x02000000,
>  MASK_UIC_DME_TEST_MODE_SUPPORT= 0x04000000,
>  MASK_CRYPTO_SUPPORT= 0x10000000,
> +MASK_LSDB_SUPPORT= 0x20000000,
>  MASK_MCQ_SUPPORT= 0x40000000,
>  };

> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 1b65e6ae4137..b5a05f8492c4 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2412,7 +2412,17 @@  static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
 		return err;
 	}
 
+	/*
+	 *  UFS 3.0 has no MCQ_SUPPORT and LSDB_SUPPORT, but [31:29] as reserved
+	 *  bits with reset value 0s, which means we can simply read values
+	 *  regardless to version
+	 */
 	hba->mcq_sup = FIELD_GET(MASK_MCQ_SUPPORT, hba->capabilities);
+	/*
+	 *  0h: legacy single doorbell support is available
+	 *  1h: indicate that legacy single doorbell support have been remove
+	 */
+	hba->lsdb_sup = !FIELD_GET(MASK_LSDB_SUPPORT, hba->capabilities);
 	if (!hba->mcq_sup)
 		return 0;
 
@@ -10449,6 +10459,12 @@  int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 	}
 
 	if (!is_mcq_supported(hba)) {
+		if (!hba->lsdb_sup) {
+			dev_err(hba->dev, "%s: failed to initialize (legacy doorbell mode not supported\n",
+				__func__);
+			err = -EINVAL;
+			goto out_disable;
+		}
 		err = scsi_add_host(host, hba->dev);
 		if (err) {
 			dev_err(hba->dev, "scsi_add_host failed\n");
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index bad88bd91995..fd391f6eee73 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -1074,6 +1074,7 @@  struct ufs_hba {
 	bool ext_iid_sup;
 	bool scsi_host_added;
 	bool mcq_sup;
+	bool lsdb_sup;
 	bool mcq_enabled;
 	struct ufshcd_res_info res[RES_MAX];
 	void __iomem *mcq_base;
diff --git a/include/ufs/ufshci.h b/include/ufs/ufshci.h
index 385e1c6b8d60..22ba85e81d8c 100644
--- a/include/ufs/ufshci.h
+++ b/include/ufs/ufshci.h
@@ -75,6 +75,7 @@  enum {
 	MASK_OUT_OF_ORDER_DATA_DELIVERY_SUPPORT	= 0x02000000,
 	MASK_UIC_DME_TEST_MODE_SUPPORT		= 0x04000000,
 	MASK_CRYPTO_SUPPORT			= 0x10000000,
+	MASK_LSDB_SUPPORT			= 0x20000000,
 	MASK_MCQ_SUPPORT			= 0x40000000,
 };