Devicetree
 help / color / mirror / Atom feed
* [PATCH v2 0/3] ufs-qcom: Add specified gear support for multi gear scaling
@ 2026-12-02  8:14 Giri Prasad Goriparthi
  2026-12-02  8:14 ` [PATCH v2 1/3] scsi: ufs: " Giri Prasad Goriparthi
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Giri Prasad Goriparthi @ 2026-12-02  8:14 UTC (permalink / raw)
  To: Manivannan Sadhasivam, James E.J. Bottomley, Martin K. Petersen,
	Bjorn Andersson, Konrad Dybcio, Abel Vesa, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Nitin Rawat, linux-arm-msm, linux-scsi, linux-kernel, devicetree,
	Giri Prasad Goriparthi, Ziqi Chen, Manivannan Sadhasivam

This patch series adds support for configuring UFS gear speeds on a
per-OPP frequency basis for Qualcomm UFS host controllers, enabling
more flexible multi-gear scaling.

On certain Qualcomm platforms, the UFS clock frequency and gear speed
do not have a strict one-to-one mapping. To handle this, the first patch
introduces a device tree based configuration mechanism using the
"opp-level" property within the OPP table. This allows each supported
operating frequency to be explicitly associated with a specific HS gear
speed. When this property is absent, the driver gracefully falls back to
the existing default frequency-to-gear lookup table.

The second patch applies this configuration to the Hamoa platform,
assigning the appropriate HS gear levels (G1, G3, G5) to the
corresponding OPP frequency entries in the device tree.

The third patch applies this configuration to the Talos platform,
assigning the appropriate HS gear levels (G1, G1, G3) to the
corresponding OPP frequency entries in the device tree.

Changes in V2:
- Retained Reviewed-by tag from Mani on hamoa.dtsi
- Drop __func__ from dev_err() [Mani]
- Fix variable declaration order to preserve Xmas order [Mani]
- Fix opp-level validation to check OPP_LEVEL_UNSET 
  explicitly [sashiko-bot]
- Add Talos DT opp-level entries

Signed-off-by: Giri Prasad Goriparthi <giri.goriparthi@oss.qualcomm.com>
---
Giri Prasad Goriparthi (3):
      scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling
      arm64: dts: qcom: hamoa: Add opp-level for UFS gear speed
      arm64: dts: qcom: talos: Add opp-level for UFS gear speed

 arch/arm64/boot/dts/qcom/hamoa.dtsi |  3 +++
 arch/arm64/boot/dts/qcom/talos.dtsi |  3 +++
 drivers/ufs/host/ufs-qcom.c         | 24 ++++++++++++++++++++++--
 3 files changed, 28 insertions(+), 2 deletions(-)
---
base-commit: d138596e9f822033490b2e577ec2ea64f2aa246c
change-id: 20261201-b4-ufs-qcom-multi-gear-scaling-30e082d0aeb6

Best regards,
--  
Giri Prasad Goriparthi <giri.goriparthi@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/3] scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling
  2026-12-02  8:14 [PATCH v2 0/3] ufs-qcom: Add specified gear support for multi gear scaling Giri Prasad Goriparthi
@ 2026-12-02  8:14 ` Giri Prasad Goriparthi
  2026-12-02  8:32   ` sashiko-bot
  2026-12-02  8:14 ` [PATCH v2 2/3] arm64: dts: qcom: hamoa: Add opp-level for UFS gear speed Giri Prasad Goriparthi
  2026-12-02  8:15 ` [PATCH v2 3/3] arm64: dts: qcom: talos: " Giri Prasad Goriparthi
  2 siblings, 1 reply; 7+ messages in thread
From: Giri Prasad Goriparthi @ 2026-12-02  8:14 UTC (permalink / raw)
  To: Manivannan Sadhasivam, James E.J. Bottomley, Martin K. Petersen,
	Bjorn Andersson, Konrad Dybcio, Abel Vesa, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Nitin Rawat, linux-arm-msm, linux-scsi, linux-kernel, devicetree,
	Giri Prasad Goriparthi, Ziqi Chen

The UFS clock frequency and gear speed do not necessarily have a strict
one-to-one correspondence on all platforms. Introduce a device tree
based configuration interface that allows specifying the HS gear
speed for each supported operating frequency via the "opp-level"
property in the OPP table. When this property is not configured, the
driver falls back to the default frequency-to-gear mapping table.

Signed-off-by: Ziqi Chen <ziqi.chen@oss.qualcomm.com>
Signed-off-by: Nitin Rawat <nitin.rawat@oss.qualcomm.com>
Signed-off-by: Giri Prasad Goriparthi <giri.goriparthi@oss.qualcomm.com>
---
 drivers/ufs/host/ufs-qcom.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 6afb8498b8c2..cc6380ebb145 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -2506,7 +2506,7 @@ static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba,
 	bool found = false;
 
 	opp = dev_pm_opp_find_freq_exact_indexed(hba->dev, freq, 0, true);
-	if (IS_ERR(opp)) {
+	if (IS_ERR_OR_NULL(opp)) {
 		dev_err(hba->dev, "Failed to find OPP for exact frequency %lu\n", freq);
 		return 0;
 	}
@@ -2535,12 +2535,32 @@ static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba,
 
 static u32 ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq)
 {
-	u32 gear = UFS_HS_DONT_CHANGE;
 	unsigned long unipro_freq;
+	struct dev_pm_opp *opp;
+	u32 gear = UFS_HS_DONT_CHANGE;
 
 	if (!hba->use_pm_opp)
 		return gear;
 
+	opp = dev_pm_opp_find_freq_exact_indexed(hba->dev, freq, 0, true);
+	if (IS_ERR_OR_NULL(opp)) {
+		dev_err(hba->dev, "Failed to find OPP for exact frequency %lu\n", freq);
+		return gear;
+	}
+
+	/* Get HS gear speed from 'opp-level' */
+	gear = dev_pm_opp_get_level(opp);
+	dev_pm_opp_put(opp);
+
+	/*
+	 * If opp-level is not configured in DT or the specified gear exceeds
+	 * the max supported gear, fall back to the frequency-to-gear table.
+	 */
+	if (gear != OPP_LEVEL_UNSET && gear <= hba->max_pwr_info.info.gear_rx)
+		return gear;
+
+	gear = UFS_HS_DONT_CHANGE;
+
 	unipro_freq = ufs_qcom_opp_freq_to_clk_freq(hba, freq, "core_clk_unipro");
 	switch (unipro_freq) {
 	case 403000000:

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] arm64: dts: qcom: hamoa: Add opp-level for UFS gear speed
  2026-12-02  8:14 [PATCH v2 0/3] ufs-qcom: Add specified gear support for multi gear scaling Giri Prasad Goriparthi
  2026-12-02  8:14 ` [PATCH v2 1/3] scsi: ufs: " Giri Prasad Goriparthi
@ 2026-12-02  8:14 ` Giri Prasad Goriparthi
  2026-12-02  8:28   ` sashiko-bot
  2026-12-02  8:15 ` [PATCH v2 3/3] arm64: dts: qcom: talos: " Giri Prasad Goriparthi
  2 siblings, 1 reply; 7+ messages in thread
From: Giri Prasad Goriparthi @ 2026-12-02  8:14 UTC (permalink / raw)
  To: Manivannan Sadhasivam, James E.J. Bottomley, Martin K. Petersen,
	Bjorn Andersson, Konrad Dybcio, Abel Vesa, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Nitin Rawat, linux-arm-msm, linux-scsi, linux-kernel, devicetree,
	Giri Prasad Goriparthi, Manivannan Sadhasivam

Assign the appropriate UFS HS gear speed levels to each OPP frequency
entry in the device tree, enabling proper per-frequency gear
scaling (G1 at 75MHz, G3 at 150MHz, G5 at 300MHz).

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Signed-off-by: Nitin Rawat <nitin.rawat@oss.qualcomm.com>
Signed-off-by: Giri Prasad Goriparthi <giri.goriparthi@oss.qualcomm.com>
---
 arch/arm64/boot/dts/qcom/hamoa.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/hamoa.dtsi b/arch/arm64/boot/dts/qcom/hamoa.dtsi
index 443c1a5c212d..71c8a428de51 100644
--- a/arch/arm64/boot/dts/qcom/hamoa.dtsi
+++ b/arch/arm64/boot/dts/qcom/hamoa.dtsi
@@ -3946,6 +3946,7 @@ opp-75000000 {
 						 /bits/ 64 <0>,
 						 /bits/ 64 <0>,
 						 /bits/ 64 <0>;
+					opp-level = <1>; /* HS-G1 */
 					required-opps = <&rpmhpd_opp_low_svs>;
 				};
 
@@ -3958,6 +3959,7 @@ opp-150000000 {
 						 /bits/ 64 <0>,
 						 /bits/ 64 <0>,
 						 /bits/ 64 <0>;
+					opp-level = <3>; /* HS-G3 */
 					required-opps = <&rpmhpd_opp_svs>;
 				};
 
@@ -3970,6 +3972,7 @@ opp-300000000 {
 						 /bits/ 64 <0>,
 						 /bits/ 64 <0>,
 						 /bits/ 64 <0>;
+					opp-level = <5>; /* HS-G5 */
 					required-opps = <&rpmhpd_opp_nom>;
 				};
 			};

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] arm64: dts: qcom: talos: Add opp-level for UFS gear speed
  2026-12-02  8:14 [PATCH v2 0/3] ufs-qcom: Add specified gear support for multi gear scaling Giri Prasad Goriparthi
  2026-12-02  8:14 ` [PATCH v2 1/3] scsi: ufs: " Giri Prasad Goriparthi
  2026-12-02  8:14 ` [PATCH v2 2/3] arm64: dts: qcom: hamoa: Add opp-level for UFS gear speed Giri Prasad Goriparthi
@ 2026-12-02  8:15 ` Giri Prasad Goriparthi
  2026-12-02  8:30   ` sashiko-bot
  2 siblings, 1 reply; 7+ messages in thread
From: Giri Prasad Goriparthi @ 2026-12-02  8:15 UTC (permalink / raw)
  To: Manivannan Sadhasivam, James E.J. Bottomley, Martin K. Petersen,
	Bjorn Andersson, Konrad Dybcio, Abel Vesa, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Nitin Rawat, linux-arm-msm, linux-scsi, linux-kernel, devicetree,
	Giri Prasad Goriparthi

Assign the appropriate UFS HS gear speed levels to each OPP frequency
entry in the device tree, enabling proper per-frequency gear
scaling (G1 at 50MHz, G1 at 100MHz, G3 at 200MHz).

Signed-off-by: Giri Prasad Goriparthi <giri.goriparthi@oss.qualcomm.com>
---
 arch/arm64/boot/dts/qcom/talos.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/talos.dtsi b/arch/arm64/boot/dts/qcom/talos.dtsi
index 1d74e459f892..b9e21108637d 100644
--- a/arch/arm64/boot/dts/qcom/talos.dtsi
+++ b/arch/arm64/boot/dts/qcom/talos.dtsi
@@ -1498,6 +1498,7 @@ opp-50000000 {
 						 /bits/ 64 <0>,
 						 /bits/ 64 <0>,
 						 /bits/ 64 <75000000>;
+					opp-level = <1>;
 					required-opps = <&rpmhpd_opp_low_svs>;
 				};
 
@@ -1510,6 +1511,7 @@ opp-100000000 {
 						 /bits/ 64 <0>,
 						 /bits/ 64 <0>,
 						 /bits/ 64 <150000000>;
+					opp-level = <1>;
 					required-opps = <&rpmhpd_opp_svs>;
 				};
 
@@ -1522,6 +1524,7 @@ opp-200000000 {
 						 /bits/ 64 <0>,
 						 /bits/ 64 <0>,
 						 /bits/ 64 <300000000>;
+					opp-level = <3>;
 					required-opps = <&rpmhpd_opp_nom>;
 				};
 			};

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/3] arm64: dts: qcom: hamoa: Add opp-level for UFS gear speed
  2026-12-02  8:14 ` [PATCH v2 2/3] arm64: dts: qcom: hamoa: Add opp-level for UFS gear speed Giri Prasad Goriparthi
@ 2026-12-02  8:28   ` sashiko-bot
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-12-02  8:28 UTC (permalink / raw)
  To: Giri Prasad Goriparthi; +Cc: linux-scsi, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] arm64: dts: qcom: hamoa: opp-level in ufs_opp_table clobbers
  RPMHPD vote
--

commit 870d72d00b1227c3e627343e9d1008e0d9e3c077
Author: Giri Prasad Goriparthi <giri.goriparthi@oss.qualcomm.com>

arm64: dts: qcom: hamoa: Add opp-level for UFS gear speed

This commit adds opp-level properties (1, 3, and 5) to the UFS OPP table
entries in hamoa.dtsi to specify HS gear levels for per-frequency gear
scaling.

> diff --git a/arch/arm64/boot/dts/qcom/hamoa.dtsi b/arch/arm64/boot/dts/qcom/hamoa.dtsi
> index 443c1a5c212d9..71c8a428de51e 100644
> --- a/arch/arm64/boot/dts/qcom/hamoa.dtsi
> +++ b/arch/arm64/boot/dts/qcom/hamoa.dtsi
> @@ -3946,6 +3946,7 @@ opp-75000000 {
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <0>;
> +					opp-level = <1>; /* HS-G1 */
>  					required-opps = <&rpmhpd_opp_low_svs>;
>  				};
>  
> @@ -3958,6 +3959,7 @@ opp-150000000 {
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <0>;
> +					opp-level = <3>; /* HS-G3 */
>  					required-opps = <&rpmhpd_opp_svs>;
>  				};
>  
> @@ -3970,6 +3972,7 @@ opp-300000000 {
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <0>;
> +					opp-level = <5>; /* HS-G5 */
>  					required-opps = <&rpmhpd_opp_nom>;
>  				};
>  			};

[Severity: High]
Does adding opp-level to these entries clobber the required-opps vote on
RPMHPD_CX?

Because ufs_mem_hc attaches to a single power domain (GCC_UFS_PHY_GDSC,
whose parent is RPMHPD_CX), genpd_set_required_opp_dev() registers the UFS
device itself as opp_table->required_devs[0]. When scaling up via
ufshcd_opp_set_rate() -> dev_pm_opp_set_opp() -> _set_opp():

drivers/opp/core.c:_set_opp() {
    ...
		ret = _set_required_opps(dev, opp_table, opp, true);
		if (ret) {
			dev_err(dev, "Failed to set required opps: %d\n", ret);
			return ret;
		}

		ret = _set_opp_level(dev, opp);
    ...
}

_set_required_opps() sets the device's PM domain performance state to the
required RPMHPD corner (64, 128, or 256), and _set_opp_level() immediately
overwrites the performance state on the same device with opp->level (1, 3,
or 5). In rpmhpd_set_performance_state(), levels 1, 3, and 5 map to
RPMH_REGULATOR_LEVEL_MIN_SVS (48), undervolting RPMHPD_CX right before the
UFS clocks scale up to 150 MHz or 300 MHz. On scale-down, _set_opp_level()
runs before _set_required_opps(), causing a transient drop to MIN_SVS
before the target corner is applied.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-b4-ufs-qcom-multi-gear-scaling-v2-0-e2fe4cbce19d@oss.qualcomm.com?part=2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/3] arm64: dts: qcom: talos: Add opp-level for UFS gear speed
  2026-12-02  8:15 ` [PATCH v2 3/3] arm64: dts: qcom: talos: " Giri Prasad Goriparthi
@ 2026-12-02  8:30   ` sashiko-bot
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-12-02  8:30 UTC (permalink / raw)
  To: Giri Prasad Goriparthi; +Cc: linux-scsi, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] arm64: dts: qcom: talos: ufs opp-level overwrites RPMHPD_CX
  required-opps vote
--

commit 6e8685a87ed8d43c7930a350f78d3142645dd78c
Author: Giri Prasad Goriparthi <giri.goriparthi@oss.qualcomm.com>

arm64: dts: qcom: talos: Add opp-level for UFS gear speed

This commit adds opp-level properties to the UFS OPP table in talos.dtsi to
specify the UFS HS gear level for each frequency entry.

> diff --git a/arch/arm64/boot/dts/qcom/talos.dtsi b/arch/arm64/boot/dts/qcom/talos.dtsi
> index 1d74e459f892e..b9e21108637d2 100644
> --- a/arch/arm64/boot/dts/qcom/talos.dtsi
> +++ b/arch/arm64/boot/dts/qcom/talos.dtsi
> @@ -1498,6 +1498,7 @@ opp-50000000 {
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <75000000>;
> +					opp-level = <1>;
>  					required-opps = <&rpmhpd_opp_low_svs>;
>  				};
>  
> @@ -1510,6 +1511,7 @@ opp-100000000 {
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <150000000>;
> +					opp-level = <1>;
>  					required-opps = <&rpmhpd_opp_svs>;
>  				};
>  
> @@ -1522,6 +1524,7 @@ opp-200000000 {
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <0>,
>  						 /bits/ 64 <300000000>;
> +					opp-level = <3>;
>  					required-opps = <&rpmhpd_opp_nom>;
>  				};
>  			};

[Severity: High]
Does adding opp-level alongside required-opps here overwrite the UFS
controller's RPMHPD_CX performance state vote with the raw UFS gear number
(1 or 3)?

Because ufs_mem_hc has a single power-domains entry (<&gcc UFS_PHY_GDSC>,
which is a subdomain of RPMHPD_CX), __genpd_dev_pm_attach() attaches the
UFS device itself as opp_table->required_devs[0].

When _set_opp() scales up, _set_required_opps() votes for the required-opps
corner (64, 128, or 256) on the UFS device, and _set_opp_level() runs right
after on the same device:

drivers/opp/core.c:_set_opp() {
	...
	if (!scaling_down) {
		ret = _set_required_opps(dev, opp_table, opp, true);
		if (ret) {
			dev_err(dev, "Failed to set required opps: %d\n", ret);
			return ret;
		}

		ret = _set_opp_level(dev, opp);
		if (ret)
			return ret;
	}
	...
}

Previously opp->level was unset, so _set_opp_level() was a no-op. With
opp-level set to 1 or 3, _set_opp_level() calls
dev_pm_domain_set_performance_state(dev, opp->level) on the same UFS
device, replacing the SVS (128) or NOM (256) vote on RPMHPD_CX with 1 or 3
(dropping the UFS CX vote to enable_corner) before scaling UFS clocks up to
100 MHz or 200 MHz.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-b4-ufs-qcom-multi-gear-scaling-v2-0-e2fe4cbce19d@oss.qualcomm.com?part=3

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling
  2026-12-02  8:14 ` [PATCH v2 1/3] scsi: ufs: " Giri Prasad Goriparthi
@ 2026-12-02  8:32   ` sashiko-bot
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-12-02  8:32 UTC (permalink / raw)
  To: Giri Prasad Goriparthi; +Cc: linux-scsi, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] scsi: ufs: ufs-qcom: opp-level gear clobbers PM domain
  performance state
- [Medium] scsi: ufs: ufs-qcom: ufs_qcom_freq_to_gear_speed() fails to
  clamp opp-level
--

commit 73d84f7e8cb1062be352f4560a2e81fc675ef5ff
Author: Giri Prasad Goriparthi <giri.goriparthi@oss.qualcomm.com>

scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling

This commit reads the opp-level property from the UFS OPP table in
ufs_qcom_freq_to_gear_speed() to select the HS gear for a given operating
frequency, falling back to the hardcoded frequency-to-gear table when
opp-level is unset or exceeds the maximum Rx gear.

> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 6afb8498b8c26..cc6380ebb1458 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c

[ ... ]

> @@ -2535,12 +2535,32 @@ static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba,
>  
>  static u32 ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq)
>  {
> -	u32 gear = UFS_HS_DONT_CHANGE;
>  	unsigned long unipro_freq;
> +	struct dev_pm_opp *opp;
> +	u32 gear = UFS_HS_DONT_CHANGE;
>  
>  	if (!hba->use_pm_opp)
>  		return gear;
>  
> +	opp = dev_pm_opp_find_freq_exact_indexed(hba->dev, freq, 0, true);
> +	if (IS_ERR_OR_NULL(opp)) {
> +		dev_err(hba->dev, "Failed to find OPP for exact frequency %lu\n", freq);
> +		return gear;
> +	}
> +
> +	/* Get HS gear speed from 'opp-level' */
> +	gear = dev_pm_opp_get_level(opp);
> +	dev_pm_opp_put(opp);

[Severity: High]
Does repurposing opp-level in the UFS controller's OPP table to store UFS
HS gear values (1..6) overwrite the device's required-opps PM domain
performance state vote when scaling up clocks?

On Qualcomm SoCs, the UFS host controller has a single power-domains entry
(GCC_UFS_PHY_GDSC, a subdomain of RPMHPD_CX) and per-OPP required-opps
entries pointing to RPMHPD voltage corners (for example,
RPMH_REGULATOR_LEVEL_NOM = 256).  When a single power domain is attached,
__genpd_dev_pm_attach() -> genpd_set_required_opp_dev() registers hba->dev
itself as opp_table->required_devs[0].

During clock initialization and devfreq scaling, ufshcd_opp_set_rate()
calls dev_pm_opp_set_opp(hba->dev, opp) -> _set_opp():

drivers/opp/core.c:_set_opp() {
	...
	if (!scaling_down) {
		ret = _set_required_opps(dev, opp_table, opp, true);
		if (ret) {
			dev_err(dev, "Failed to set required opps: %d\n", ret);
			return ret;
		}

		ret = _set_opp_level(dev, opp);
		if (ret)
			return ret;
	...
}

When scaling up, _set_required_opps() first votes the required RPMHPD
corner on hba->dev via dev_pm_domain_set_performance_state().  With
opp-level populated on the UFS OPP node, _set_opp_level(hba->dev, opp)
immediately calls dev_pm_domain_set_performance_state(hba->dev, opp->level)
on the same device, replacing the required RPMHPD corner vote with the raw
UFS gear number (1..6) and dropping the CX rail vote to its floor corner
before raising the UFS clock rates.

> +
> +	/*
> +	 * If opp-level is not configured in DT or the specified gear exceeds
> +	 * the max supported gear, fall back to the frequency-to-gear table.
> +	 */
> +	if (gear != OPP_LEVEL_UNSET && gear <= hba->max_pwr_info.info.gear_rx)
> +		return gear;

[Severity: Medium]
When opp-level is configured in DT with a gear above
hba->max_pwr_info.info.gear_rx (for example, when attached to a lower-gear
UFS device or constrained by limit-hs-gear), should this clamp gear to
hba->max_pwr_info.info.gear_rx with min_t() as the bottom of
ufs_qcom_freq_to_gear_speed() does, instead of falling back to the
hardcoded unipro_freq switch table?

Falling back to the switch table defeats the platform-specific mapping
whenever the platform's UniPro clock frequency maps to a different gear in
the switch table (such as 150 MHz mapping to UFS_HS_G2 in the switch table
instead of UFS_HS_G3), or returns UFS_HS_DONT_CHANGE (0) if the frequency
is not in the switch table.  Returning 0 causes ufshcd_scale_gear() to fall
into its legacy two-gear scaling path, where a subsequent scale-up copies
an uninitialized zeroed hba->clk_scaling.saved_pwr_info into new_pwr_info.

Also, if opp-level is 0, gear != OPP_LEVEL_UNSET && gear <=
hba->max_pwr_info.info.gear_rx evaluates to true and returns
UFS_HS_DONT_CHANGE (0) directly instead of falling back.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-b4-ufs-qcom-multi-gear-scaling-v2-0-e2fe4cbce19d@oss.qualcomm.com?part=1

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-12-02  8:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  8:14 [PATCH v2 0/3] ufs-qcom: Add specified gear support for multi gear scaling Giri Prasad Goriparthi
2026-12-02  8:14 ` [PATCH v2 1/3] scsi: ufs: " Giri Prasad Goriparthi
2026-12-02  8:32   ` sashiko-bot
2026-12-02  8:14 ` [PATCH v2 2/3] arm64: dts: qcom: hamoa: Add opp-level for UFS gear speed Giri Prasad Goriparthi
2026-12-02  8:28   ` sashiko-bot
2026-12-02  8:15 ` [PATCH v2 3/3] arm64: dts: qcom: talos: " Giri Prasad Goriparthi
2026-12-02  8:30   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox