* [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec
@ 2025-07-14 7:53 Nitin Rawat
2025-07-14 7:53 ` [PATCH V5 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6 Nitin Rawat
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Nitin Rawat @ 2025-07-14 7:53 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 v4:
1. Addressed konrad comment to remove Reported-by: kernel test
robot tag.
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] 7+ messages in thread
* [PATCH V5 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6
2025-07-14 7:53 [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Nitin Rawat
@ 2025-07-14 7:53 ` Nitin Rawat
2025-07-14 7:53 ` [PATCH V5 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes Nitin Rawat
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Nitin Rawat @ 2025-07-14 7:53 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 related [flat|nested] 7+ messages in thread
* [PATCH V5 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes
2025-07-14 7:53 [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Nitin Rawat
2025-07-14 7:53 ` [PATCH V5 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6 Nitin Rawat
@ 2025-07-14 7:53 ` Nitin Rawat
2025-07-14 16:03 ` Bart Van Assche
2025-07-14 7:53 ` [PATCH V5 3/3] ufs: ufs-qcom: Enable QUnipro Internal Clock Gating Nitin Rawat
` (2 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Nitin Rawat @ 2025-07-14 7:53 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
Introduce `ufshcd_dme_rmw` API to read, modify, and write DME
attributes in UFS host controllers using a mask and value.
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 related [flat|nested] 7+ messages in thread
* [PATCH V5 3/3] ufs: ufs-qcom: Enable QUnipro Internal Clock Gating
2025-07-14 7:53 [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Nitin Rawat
2025-07-14 7:53 ` [PATCH V5 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6 Nitin Rawat
2025-07-14 7:53 ` [PATCH V5 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes Nitin Rawat
@ 2025-07-14 7:53 ` Nitin Rawat
2025-07-15 1:05 ` [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Martin K. Petersen
2025-07-22 3:47 ` Martin K. Petersen
4 siblings, 0 replies; 7+ messages in thread
From: Nitin Rawat @ 2025-07-14 7:53 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 Qualcomm UFS host controller 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 related [flat|nested] 7+ messages in thread
* Re: [PATCH V5 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes
2025-07-14 7:53 ` [PATCH V5 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes Nitin Rawat
@ 2025-07-14 16:03 ` Bart Van Assche
0 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2025-07-14 16:03 UTC (permalink / raw)
To: Nitin Rawat, mani, James.Bottomley, martin.petersen, avri.altman,
ebiggers, neil.armstrong, konrad.dybcio
Cc: linux-arm-msm, linux-kernel, linux-scsi
On 7/14/25 12:53 AM, Nitin Rawat wrote:
> + * @mask: mask to apply on read value
The description of 'mask' could have been more clear, e.g. "indicates
which bits to clear from the value that has been read". Anyway:
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec
2025-07-14 7:53 [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Nitin Rawat
` (2 preceding siblings ...)
2025-07-14 7:53 ` [PATCH V5 3/3] ufs: ufs-qcom: Enable QUnipro Internal Clock Gating Nitin Rawat
@ 2025-07-15 1:05 ` Martin K. Petersen
2025-07-22 3:47 ` Martin K. Petersen
4 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2025-07-15 1:05 UTC (permalink / raw)
To: Nitin Rawat
Cc: mani, James.Bottomley, martin.petersen, bvanassche, avri.altman,
ebiggers, neil.armstrong, konrad.dybcio, linux-arm-msm,
linux-kernel, linux-scsi
Nitin,
> This patch series adds programming support for Qualcomm UFS to align
> with Hardware Specification.
Applied to 6.17/scsi-staging, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec
2025-07-14 7:53 [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Nitin Rawat
` (3 preceding siblings ...)
2025-07-15 1:05 ` [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Martin K. Petersen
@ 2025-07-22 3:47 ` Martin K. Petersen
4 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2025-07-22 3:47 UTC (permalink / raw)
To: mani, James.Bottomley, bvanassche, avri.altman, ebiggers,
neil.armstrong, konrad.dybcio, Nitin Rawat
Cc: Martin K . Petersen, linux-arm-msm, linux-kernel, linux-scsi
On Mon, 14 Jul 2025 13:23:33 +0530, Nitin Rawat wrote:
> 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
>
> [...]
Applied to 6.17/scsi-queue, thanks!
[1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6
https://git.kernel.org/mkp/scsi/c/7a9d5195a7f5
[2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes
https://git.kernel.org/mkp/scsi/c/c49601642f95
[3/3] ufs: ufs-qcom: Enable QUnipro Internal Clock Gating
https://git.kernel.org/mkp/scsi/c/5a6f304f39c2
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-07-22 3:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 7:53 [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Nitin Rawat
2025-07-14 7:53 ` [PATCH V5 1/3] ufs: ufs-qcom: Update esi_vec_mask for HW major version >= 6 Nitin Rawat
2025-07-14 7:53 ` [PATCH V5 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes Nitin Rawat
2025-07-14 16:03 ` Bart Van Assche
2025-07-14 7:53 ` [PATCH V5 3/3] ufs: ufs-qcom: Enable QUnipro Internal Clock Gating Nitin Rawat
2025-07-15 1:05 ` [PATCH V5 0/3] ufs: ufs-qcom: Align programming sequence as per HW spec Martin K. Petersen
2025-07-22 3:47 ` 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).