Add support for parsing 'limit-hs-gear' and 'limit-rate' device tree
properties to restrict high-speed gear and rate during initialization.
This is useful in cases where the customer board may have signal
integrity, clock configuration or layout issues that prevent reliable
operation at higher gears. Such limitations are especially critical in
those platforms, where stability is prioritized over peak performance.
Co-developed-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Signed-off-by: Ram Kumar Dwivedi <quic_rdwivedi@quicinc.com>
---
drivers/ufs/host/ufshcd-pltfrm.c | 36 ++++++++++++++++++++++++++++++++
drivers/ufs/host/ufshcd-pltfrm.h | 1 +
2 files changed, 37 insertions(+)
diff --git a/drivers/ufs/host/ufshcd-pltfrm.c b/drivers/ufs/host/ufshcd-pltfrm.c
index ffe5d1d2b215..a3cfb1935bbc 100644
--- a/drivers/ufs/host/ufshcd-pltfrm.c
+++ b/drivers/ufs/host/ufshcd-pltfrm.c
@@ -430,6 +430,42 @@ int ufshcd_negotiate_pwr_params(const struct ufs_host_params *host_params,
}
EXPORT_SYMBOL_GPL(ufshcd_negotiate_pwr_params);
+/**
+ * ufshcd_parse_limits - Parse DT-based gear and rate limits for UFS
+ * @hba: Pointer to UFS host bus adapter instance
+ * @host_params: Pointer to UFS host parameters structure to be updated
+ *
+ * This function reads optional device tree properties to apply
+ * platform-specific constraints.
+ *
+ * "limit-hs-gear": Specifies the max HS gear.
+ * "limit-rate": Specifies the max High-Speed rate.
+ */
+void ufshcd_parse_limits(struct ufs_hba *hba, struct ufs_host_params *host_params)
+{
+ struct device_node *np = hba->dev->of_node;
+ u32 hs_gear;
+ const char *hs_rate;
+
+ if (!np)
+ return;
+
+ if (!of_property_read_u32(np, "limit-hs-gear", &hs_gear)) {
+ host_params->hs_tx_gear = hs_gear;
+ host_params->hs_rx_gear = hs_gear;
+ }
+
+ if (!of_property_read_string(np, "limit-rate", &hs_rate)) {
+ if (!strcmp(hs_rate, "Rate-A"))
+ host_params->hs_rate = PA_HS_MODE_A;
+ else if (!strcmp(hs_rate, "Rate-B"))
+ host_params->hs_rate = PA_HS_MODE_B;
+ else
+ dev_warn(hba->dev, "Invalid limit-rate value\n", hs_rate);
+ }
+}
+EXPORT_SYMBOL_GPL(ufshcd_parse_limits);
+
void ufshcd_init_host_params(struct ufs_host_params *host_params)
{
*host_params = (struct ufs_host_params){
diff --git a/drivers/ufs/host/ufshcd-pltfrm.h b/drivers/ufs/host/ufshcd-pltfrm.h
index 3017f8e8f93c..1617f2541273 100644
--- a/drivers/ufs/host/ufshcd-pltfrm.h
+++ b/drivers/ufs/host/ufshcd-pltfrm.h
@@ -29,6 +29,7 @@ int ufshcd_negotiate_pwr_params(const struct ufs_host_params *host_params,
const struct ufs_pa_layer_attr *dev_max,
struct ufs_pa_layer_attr *agreed_pwr);
void ufshcd_init_host_params(struct ufs_host_params *host_params);
+void ufshcd_parse_limits(struct ufs_hba *hba, struct ufs_host_params *host_params);
int ufshcd_pltfrm_init(struct platform_device *pdev,
const struct ufs_hba_variant_ops *vops);
void ufshcd_pltfrm_remove(struct platform_device *pdev);
--
2.50.1
Hi Ram,
kernel test robot noticed the following build warnings:
[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on jejb-scsi/for-next robh/for-next linus/master v6.17-rc4 next-20250901]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ram-Kumar-Dwivedi/ufs-dt-bindings-Document-gear-and-rate-limit-properties/20250902-000038
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
patch link: https://lore.kernel.org/r/20250901155801.26988-4-quic_rdwivedi%40quicinc.com
patch subject: [PATCH V4 3/4] ufs: pltfrm: Allow limiting HS gear and rate via DT
config: arc-randconfig-002-20250902 (https://download.01.org/0day-ci/archive/20250902/202509021257.jIDXzoS6-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 9.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250902/202509021257.jIDXzoS6-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509021257.jIDXzoS6-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/device.h:15,
from include/linux/platform_device.h:13,
from drivers/ufs/host/ufshcd-pltfrm.c:13:
drivers/ufs/host/ufshcd-pltfrm.c: In function 'ufshcd_parse_limits':
>> drivers/ufs/host/ufshcd-pltfrm.c:464:23: warning: too many arguments for format [-Wformat-extra-args]
464 | dev_warn(hba->dev, "Invalid limit-rate value\n", hs_rate);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:110:16: note: in definition of macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:156:54: note: in expansion of macro 'dev_fmt'
156 | dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/ufs/host/ufshcd-pltfrm.c:464:4: note: in expansion of macro 'dev_warn'
464 | dev_warn(hba->dev, "Invalid limit-rate value\n", hs_rate);
| ^~~~~~~~
vim +464 drivers/ufs/host/ufshcd-pltfrm.c
432
433 /**
434 * ufshcd_parse_limits - Parse DT-based gear and rate limits for UFS
435 * @hba: Pointer to UFS host bus adapter instance
436 * @host_params: Pointer to UFS host parameters structure to be updated
437 *
438 * This function reads optional device tree properties to apply
439 * platform-specific constraints.
440 *
441 * "limit-hs-gear": Specifies the max HS gear.
442 * "limit-rate": Specifies the max High-Speed rate.
443 */
444 void ufshcd_parse_limits(struct ufs_hba *hba, struct ufs_host_params *host_params)
445 {
446 struct device_node *np = hba->dev->of_node;
447 u32 hs_gear;
448 const char *hs_rate;
449
450 if (!np)
451 return;
452
453 if (!of_property_read_u32(np, "limit-hs-gear", &hs_gear)) {
454 host_params->hs_tx_gear = hs_gear;
455 host_params->hs_rx_gear = hs_gear;
456 }
457
458 if (!of_property_read_string(np, "limit-rate", &hs_rate)) {
459 if (!strcmp(hs_rate, "Rate-A"))
460 host_params->hs_rate = PA_HS_MODE_A;
461 else if (!strcmp(hs_rate, "Rate-B"))
462 host_params->hs_rate = PA_HS_MODE_B;
463 else
> 464 dev_warn(hba->dev, "Invalid limit-rate value\n", hs_rate);
465 }
466 }
467 EXPORT_SYMBOL_GPL(ufshcd_parse_limits);
468
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.