* [PATCH V4 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec
@ 2025-07-09 20:56 Nitin Rawat
2025-07-09 20:56 ` [PATCH V4 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6 Nitin Rawat
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Nitin Rawat @ 2025-07-09 20:56 UTC (permalink / raw)
To: mani, James.Bottomley, martin.petersen, bvanassche, avri.altman,
ebiggers, neil.armstrong, konrad.dybcio
Cc: linux-arm-msm, linux-kernel, linux-scsi, Nitin Rawat
This patch series adds programming support for Qualcomm UFS
to align with Hardware Specification.
In this patch series below changes are taken care.
1. Enable QUnipro Internal Clock Gating
2. Update esi_vec_mask for HW major version >= 6
Changes from v3:
1. Updated the kernel-doc comment for function ufshcd_dme_rmw
to include descriptions for all parameters to fix compilation
warning (W=1).
Changes from v2:
1. Addressed bart's and Mani's comment to move ufshcd_dme_rmw
to ufshcd.c
2. Addressed Mani's and bart's comment to avoid initialisation
of cfg.
3. Addressed Mani's comment to update commit text.
Changes from v1:
1. Moved ufshcd_dme_rmw to ufshcd.h as per avri's comment.
Bao D. Nguyen (1):
ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6
Nitin Rawat (2):
scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes
ufs: ufs-qcom: Enable QUnipro Internal Clock Gating
drivers/ufs/core/ufshcd.c | 24 ++++++++++++++++++++++++
drivers/ufs/host/ufs-qcom.c | 24 ++++++++++++++++++++++--
drivers/ufs/host/ufs-qcom.h | 9 +++++++++
include/ufs/ufshcd.h | 1 +
4 files changed, 56 insertions(+), 2 deletions(-)
--
2.48.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH V4 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6
2025-07-09 20:56 [PATCH V4 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Nitin Rawat
@ 2025-07-09 20:56 ` Nitin Rawat
2025-07-09 20:56 ` [PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes Nitin Rawat
2025-07-09 20:56 ` [PATCH V4 3/3] ufs: ufs-qcom: Enable QUnipro Internal Clock Gating Nitin Rawat
2 siblings, 0 replies; 6+ messages in thread
From: Nitin Rawat @ 2025-07-09 20:56 UTC (permalink / raw)
To: mani, James.Bottomley, martin.petersen, bvanassche, avri.altman,
ebiggers, neil.armstrong, konrad.dybcio
Cc: linux-arm-msm, linux-kernel, linux-scsi, Bao D. Nguyen, Nitin Rawat
From: "Bao D. Nguyen" <quic_nguyenb@quicinc.com>
The MCQ feature and ESI are supported by all Qualcomm UFS controller
versions 6 and above.
Therefore, update the ESI vector mask in the UFS_MEM_CFG3 register
for platforms with major version number of 6 or higher.
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
---
drivers/ufs/host/ufs-qcom.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 318dca7fe3d7..dfdc52333a96 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -2113,8 +2113,7 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
retain_and_null_ptr(qi);
- if (host->hw_ver.major == 6 && host->hw_ver.minor == 0 &&
- host->hw_ver.step == 0) {
+ if (host->hw_ver.major >= 6) {
ufshcd_rmwl(hba, ESI_VEC_MASK, FIELD_PREP(ESI_VEC_MASK, MAX_ESI_VEC - 1),
REG_UFS_CFG3);
}
--
2.48.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes
2025-07-09 20:56 [PATCH V4 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Nitin Rawat
2025-07-09 20:56 ` [PATCH V4 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6 Nitin Rawat
@ 2025-07-09 20:56 ` Nitin Rawat
2025-07-10 12:26 ` Konrad Dybcio
2025-07-09 20:56 ` [PATCH V4 3/3] ufs: ufs-qcom: Enable QUnipro Internal Clock Gating Nitin Rawat
2 siblings, 1 reply; 6+ messages in thread
From: Nitin Rawat @ 2025-07-09 20:56 UTC (permalink / raw)
To: mani, James.Bottomley, martin.petersen, bvanassche, avri.altman,
ebiggers, neil.armstrong, konrad.dybcio
Cc: linux-arm-msm, linux-kernel, linux-scsi, Nitin Rawat, kernel test robot
Introduce `ufshcd_dme_rmw` API to read, modify, and write DME
attributes in UFS host controllers using a mask and value.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202507091547.T2t1t8Wz-lkp@intel.com/
Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
---
drivers/ufs/core/ufshcd.c | 24 ++++++++++++++++++++++++
include/ufs/ufshcd.h | 1 +
2 files changed, 25 insertions(+)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 13f7e0469141..42b9b7b0ee7c 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -4251,6 +4251,30 @@ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
}
EXPORT_SYMBOL_GPL(ufshcd_dme_get_attr);
+/**
+ * ufshcd_dme_rmw - get modify set a DME attribute
+ * @hba: per adapter instance
+ * @mask: mask to apply on read value
+ * @val: actual value to write
+ * @attr: dme attribute
+ */
+int ufshcd_dme_rmw(struct ufs_hba *hba, u32 mask,
+ u32 val, u32 attr)
+{
+ u32 cfg = 0;
+ int err;
+
+ err = ufshcd_dme_get(hba, UIC_ARG_MIB(attr), &cfg);
+ if (err)
+ return err;
+
+ cfg &= ~mask;
+ cfg |= (val & mask);
+
+ return ufshcd_dme_set(hba, UIC_ARG_MIB(attr), cfg);
+}
+EXPORT_SYMBOL_GPL(ufshcd_dme_rmw);
+
/**
* ufshcd_uic_pwr_ctrl - executes UIC commands (which affects the link power
* state) and waits for it to take effect.
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index 9b3515cee711..1d3943777584 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -1480,6 +1480,7 @@ void ufshcd_resume_complete(struct device *dev);
bool ufshcd_is_hba_active(struct ufs_hba *hba);
void ufshcd_pm_qos_init(struct ufs_hba *hba);
void ufshcd_pm_qos_exit(struct ufs_hba *hba);
+int ufshcd_dme_rmw(struct ufs_hba *hba, u32 mask, u32 val, u32 attr);
/* Wrapper functions for safely calling variant operations */
static inline int ufshcd_vops_init(struct ufs_hba *hba)
--
2.48.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH V4 3/3] ufs: ufs-qcom: Enable QUnipro Internal Clock Gating
2025-07-09 20:56 [PATCH V4 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Nitin Rawat
2025-07-09 20:56 ` [PATCH V4 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6 Nitin Rawat
2025-07-09 20:56 ` [PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes Nitin Rawat
@ 2025-07-09 20:56 ` Nitin Rawat
2 siblings, 0 replies; 6+ messages in thread
From: Nitin Rawat @ 2025-07-09 20:56 UTC (permalink / raw)
To: mani, James.Bottomley, martin.petersen, bvanassche, avri.altman,
ebiggers, neil.armstrong, konrad.dybcio
Cc: linux-arm-msm, linux-kernel, linux-scsi, Nitin Rawat
Enable internal clock gating for QUnipro by setting the following
attributes to 1 during host controller initialization:
- DL_VS_CLK_CFG
- PA_VS_CLK_CFG_REG
- DME_VS_CORE_CLK_CTRL.DME_HW_CGC_EN
This change is necessary to support the internal clock gating mechanism
in Qualcomm UFS host controller. This is power saving feature and hence
driver can continue to function correctly despite any error in enabling
these feature.
Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
---
drivers/ufs/host/ufs-qcom.c | 21 +++++++++++++++++++++
drivers/ufs/host/ufs-qcom.h | 9 +++++++++
2 files changed, 30 insertions(+)
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index dfdc52333a96..4bbe4de1679b 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -558,11 +558,32 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
*/
static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba *hba)
{
+ int err;
+
+ /* Enable UTP internal clock gating */
ufshcd_rmwl(hba, REG_UFS_CFG2_CGC_EN_ALL, REG_UFS_CFG2_CGC_EN_ALL,
REG_UFS_CFG2);
/* Ensure that HW clock gating is enabled before next operations */
ufshcd_readl(hba, REG_UFS_CFG2);
+
+ /* Enable Unipro internal clock gating */
+ err = ufshcd_dme_rmw(hba, DL_VS_CLK_CFG_MASK,
+ DL_VS_CLK_CFG_MASK, DL_VS_CLK_CFG);
+ if (err)
+ goto out;
+
+ err = ufshcd_dme_rmw(hba, PA_VS_CLK_CFG_REG_MASK,
+ PA_VS_CLK_CFG_REG_MASK, PA_VS_CLK_CFG_REG);
+ if (err)
+ goto out;
+
+ err = ufshcd_dme_rmw(hba, DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN,
+ DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN,
+ DME_VS_CORE_CLK_CTRL);
+out:
+ if (err)
+ dev_err(hba->dev, "hw clk gating enabled failed\n");
}
static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba,
diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h
index 0a5cfc2dd4f7..e0e129af7c16 100644
--- a/drivers/ufs/host/ufs-qcom.h
+++ b/drivers/ufs/host/ufs-qcom.h
@@ -24,6 +24,15 @@
#define UFS_QCOM_LIMIT_HS_RATE PA_HS_MODE_B
+/* bit and mask definitions for PA_VS_CLK_CFG_REG attribute */
+#define PA_VS_CLK_CFG_REG 0x9004
+#define PA_VS_CLK_CFG_REG_MASK GENMASK(8, 0)
+
+/* bit and mask definitions for DL_VS_CLK_CFG attribute */
+#define DL_VS_CLK_CFG 0xA00B
+#define DL_VS_CLK_CFG_MASK GENMASK(9, 0)
+#define DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN BIT(9)
+
/* QCOM UFS host controller vendor specific registers */
enum {
REG_UFS_SYS1CLK_1US = 0xC0,
--
2.48.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes
2025-07-09 20:56 ` [PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes Nitin Rawat
@ 2025-07-10 12:26 ` Konrad Dybcio
2025-07-10 16:00 ` Nitin Rawat
0 siblings, 1 reply; 6+ messages in thread
From: Konrad Dybcio @ 2025-07-10 12:26 UTC (permalink / raw)
To: Nitin Rawat, mani, James.Bottomley, martin.petersen, bvanassche,
avri.altman, ebiggers, neil.armstrong
Cc: linux-arm-msm, linux-kernel, linux-scsi, kernel test robot
On 7/9/25 10:56 PM, Nitin Rawat wrote:
> Introduce `ufshcd_dme_rmw` API to read, modify, and write DME
> attributes in UFS host controllers using a mask and value.
>
> Reported-by: kernel test robot <lkp@intel.com>
This tag makes sense if your patch is merged into the tree
but happens to contain a build warning/error. Using it here
makes it look like the kernel test robot suggested
introducing this wrapper
Konrad
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes
2025-07-10 12:26 ` Konrad Dybcio
@ 2025-07-10 16:00 ` Nitin Rawat
0 siblings, 0 replies; 6+ messages in thread
From: Nitin Rawat @ 2025-07-10 16:00 UTC (permalink / raw)
To: Konrad Dybcio, mani, James.Bottomley, martin.petersen,
bvanassche, avri.altman, ebiggers, neil.armstrong
Cc: linux-arm-msm, linux-kernel, linux-scsi, kernel test robot
On 7/10/2025 5:56 PM, Konrad Dybcio wrote:
> On 7/9/25 10:56 PM, Nitin Rawat wrote:
>> Introduce `ufshcd_dme_rmw` API to read, modify, and write DME
>> attributes in UFS host controllers using a mask and value.
>>
>> Reported-by: kernel test robot <lkp@intel.com>
>
> This tag makes sense if your patch is merged into the tree
> but happens to contain a build warning/error. Using it here
> makes it look like the kernel test robot suggested
> introducing this wrapper
sure Konrad. Thanks. I'll update in next patchset.
>
> Konrad
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-07-10 16:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-09 20:56 [PATCH V4 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Nitin Rawat
2025-07-09 20:56 ` [PATCH V4 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6 Nitin Rawat
2025-07-09 20:56 ` [PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes Nitin Rawat
2025-07-10 12:26 ` Konrad Dybcio
2025-07-10 16:00 ` Nitin Rawat
2025-07-09 20:56 ` [PATCH V4 3/3] ufs: ufs-qcom: Enable QUnipro Internal Clock Gating Nitin Rawat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®