[PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes

Nitin Rawat posted 3 patches 2 months, 4 weeks ago
There is a newer version of this series
[PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes
Posted by Nitin Rawat 2 months, 4 weeks ago
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
Re: [PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes
Posted by Konrad Dybcio 2 months, 4 weeks ago
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
Re: [PATCH V4 2/3] scsi: ufs: core: Add ufshcd_dme_rmw to modify DME attributes
Posted by Nitin Rawat 2 months, 4 weeks ago

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