scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling
Subsystems (5)
cover scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling
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.
Nitin Rawat (1):
arm64: dts: qcom: Set specified gear configuration for Hamoa
Ziqi Chen (1):
scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling
arch/arm64/boot/dts/qcom/hamoa.dtsi | 3 +++ drivers/ufs/host/ufs-qcom.c | 30 +++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-)
--
2.34.1
PATCH 1/2 scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling
From: Ziqi Chen <[email protected]>
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.
--- drivers/ufs/host/ufs-qcom.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
drivers/ufs/host/ufs-qcom.c +26 -4
@@ -2460,8 +2460,9 @@ 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)) { -dev_err (hba->dev,"Failed to find OPP for exact frequency %lu\n" , freq); +if (IS_ERR_OR_NULL (opp)) { +dev_err (hba->dev,"%s: Failed to find OPP for exact frequency %lu\n" , + __func__, freq);return 0 ; }
@@ -2489,12 +2490,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 ; +struct dev_pm_opp *opp;unsigned long unipro_freq; +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,"%s: Failed to find OPP for exact frequency %lu\n" , + __func__, freq); +return gear; + } + +/* Get HS gear speed from 'opp-level' */ + gear =dev_pm_opp_get_level (opp); +dev_pm_opp_put (opp); + +/* +* Greater than max gear means that there is no specified gear configured in DT +* or the specified gear is invalid. +*/ +if (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 :
@@ -2515,7 +2536,8 @@ static u32 ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq) gear =UFS_HS_G1 ;break ;default : -dev_err (hba->dev,"%s: Unsupported clock freq : %lu\n" , __func__, freq); +dev_err (hba->dev,"%s: Unsupported clock freq [sys_clk: %lu, unipro_clk: %lu]\n" , + __func__, freq, unipro_freq);return UFS_HS_DONT_CHANGE ; }
--
2.34.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Valid `opp-level` DT gear configurations are improperly ignored and downgraded if they exceed the…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Valid opp-level DT gear configurations are improperly ignored and downgraded if they exceed the attached device's maximum supported gear, breaking forward compatibility. --
commit d0c65635e24a4008e442b75486fc367af65e28be
Author: Ziqi Chen <[email protected]>
scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling
This commit introduces a device tree based configuration interface that allows specifying the HS gear speed for supported operating frequencies using the "opp-level" property. If this property is not configured, the driver falls back to a default frequency-to-gear mapping table.
Quoted 4 lines
drivers/ufs/host/ufs-qcom.c +0
-0
[ ... ]
Quoted 20 lines
drivers/ufs/host/ufs-qcom.c +10
-1@@ -2490,12 +2491,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 ; +struct dev_pm_opp *opp;unsigned long unipro_freq; +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,"%s: Failed to find OPP for exact frequency %lu\n" , + __func__, freq); +return gear; + } + +/* Get HS gear speed from 'opp-level' */
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2518
Quoted 10 lines
drivers/ufs/host/ufs-qcom.c +10
-0+ gear =dev_pm_opp_get_level (opp); +dev_pm_opp_put (opp); + +/* +* Greater than max gear means that there is no specified gear configured in DT +* or the specified gear is invalid. +*/ +if (gear <= hba->max_pwr_info.info.gear_rx) +return gear; +
[Severity: High]
Does this condition inadvertently downgrade valid DT gear configurations if they exceed the attached device's maximum supported gear?
If a platform specifies a valid opp-level (e.g., 5) but the connected UFS device supports a lower maximum gear (e.g., gear_rx = 4), this check evaluates to false. The driver will then incorrectly fall back to the legacy hardcoded mapping table instead of using the capped value.
If the frequency is not present in the fallback table, it returns UFS_HS_DONT_CHANGE, which can cause a mismatch between the configured clock and active gear speed. This mismatch could potentially lead to UFS link drops and system panics during frequency scaling.
It appears this logic conflates a missing DT property (where gear might evaluate to OPP_LEVEL_UNSET or U32_MAX) with a valid property that simply exceeds the device capability.
Could this be addressed by explicitly checking if the property was provided, and if so, safely capping it to the device's maximum supported gear using min_t(u32, gear, hba->max_pwr_info.info.gear_rx)?
Quoted 2 lines
drivers/ufs/host/ufs-qcom.c +1
-0+ gear =UFS_HS_DONT_CHANGE ; unipro_freq =ufs_qcom_opp_freq_to_clk_freq (hba, freq,"core_clk_unipro" );
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Manivannan Sadhasivam
maintainerQuoted 20 lines · Nitin Rawat
From: Ziqi Chen <[email protected]>
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 <[email protected]>Signed-off-by Nitin Rawat <[email protected]>--- drivers/ufs/host/ufs-qcom.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)drivers/ufs/host/ufs-qcom.c +0
-0
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2465
Quoted 8 lines
drivers/ufs/host/ufs-qcom.c +3
-2@@ -2460,8 +2460,9 @@ 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)) { -dev_err (hba->dev,"Failed to find OPP for exact frequency %lu\n" , freq); +if (IS_ERR_OR_NULL (opp)) { +dev_err (hba->dev,"%s: Failed to find OPP for exact frequency %lu\n" , + __func__, freq);
Don't bring back the '__func__' marking please...
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2495
Quoted 11 lines
drivers/ufs/host/ufs-qcom.c +2
-1return 0 ; }@@ -2489,12 +2490,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 ; +struct dev_pm_opp *opp;unsigned long unipro_freq; +u32 gear =UFS_HS_DONT_CHANGE ;
Nit: Preserve reverse Xmas order.
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2503
Quoted 8 lines
drivers/ufs/host/ufs-qcom.c +4
-0if (!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,"%s: Failed to find OPP for exact frequency %lu\n" , + __func__, freq);
Drop '__func__' here and below.
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2516
Quoted 13 lines
drivers/ufs/host/ufs-qcom.c +13
-0+return gear; + } + +/* Get HS gear speed from 'opp-level' */ + gear =dev_pm_opp_get_level (opp); +dev_pm_opp_put (opp); + +/* +* Greater than max gear means that there is no specified gear configured in DT +* or the specified gear is invalid. +*/ +if (gear <= hba->max_pwr_info.info.gear_rx) +return gear;
Sashiko pointed out a valid concern with this check, please take a look.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 23 lines · Manivannan Sadhasivam
Quoted 22 lines · Nitin Rawat
From: Ziqi Chen <[email protected]>
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 <[email protected]>Signed-off-by Nitin Rawat <[email protected]>--- drivers/ufs/host/ufs-qcom.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)drivers/ufs/host/ufs-qcom.c +0
-0@@ -2460,8 +2460,9 @@ static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba,bool found = false;
Quoted 8 lines
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2465
Quoted 6 lines
drivers/ufs/host/ufs-qcom.c +3
-2opp =dev_pm_opp_find_freq_exact_indexed (hba->dev, freq,0 , true); -if (IS_ERR (opp)) { -dev_err (hba->dev,"Failed to find OPP for exact frequency %lu\n" , freq); +if (IS_ERR_OR_NULL (opp)) { +dev_err (hba->dev,"%s: Failed to find OPP for exact frequency %lu\n" , + __func__, freq);Don't bring back the '
__func__' marking please...
Sure, will take in next patchset
Quoted 6 lines
Quoted 6 lines
drivers/ufs/host/ufs-qcom.c +0
-0return 0 ; }@@ -2489,12 +2490,32 @@ static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba,
Quoted 8 lines
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2495
Quoted 6 lines
drivers/ufs/host/ufs-qcom.c +2
-1static u32 ufs_qcom_freq_to_gear_speed (struct ufs_hba *hba,unsigned long freq) { -u32 gear =UFS_HS_DONT_CHANGE ; +struct dev_pm_opp *opp;unsigned long unipro_freq; +u32 gear =UFS_HS_DONT_CHANGE ;Nit: Preserve reverse Xmas order.
Sure, will take in next patchset
Quoted 11 lines
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2503
Quoted 9 lines
drivers/ufs/host/ufs-qcom.c +4
-0if (!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,"%s: Failed to find OPP for exact frequency %lu\n" , + __func__, freq);Drop '
__func__' here and below.
Sure, will take in next patchset
Quoted 16 lines
Quoted 4 lines
drivers/ufs/host/ufs-qcom.c +3
-0+return gear; + } +drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2516
Quoted 10 lines
drivers/ufs/host/ufs-qcom.c +10
-0+/* Get HS gear speed from 'opp-level' */ + gear =dev_pm_opp_get_level (opp); +dev_pm_opp_put (opp); + +/* +* Greater than max gear means that there is no specified gear configured in DT +* or the specified gear is invalid. +*/ +if (gear <= hba->max_pwr_info.info.gear_rx) +return gear;Sashiko pointed out a valid concern with this check, please take a look.
I reviewed the bot's comment. The concern raised applies to the case where the gear value provided through the device tree is higher (for example, 5) than what a UFS 3.x device can support. After link startup and negotiation, hba->max_pwr_info.info.gear_rx would be 4. In this scenario, the condition below evaluates to false:
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2516
Quoted 2 lines
drivers/ufs/host/ufs-qcom.c +2
-0+if (gear <= hba->max_pwr_info.info.gear_rx) +return gear;
Execution then falls back to the switch-case logic. If the current frequency does not match any of the predefined entries, the function returns UFS_HS_DONT_CHANGE, which effectively maps to the minimum gear. Shahiko's suggestion is to instead return the device's maximum negotiated gear using:
A couple of points to note:
1. If the current frequency does not match any of the expected frequency entries, that is already an existing issue. In such a case, simply returning the maximum negotiated gear may not be correct because we do not know the actual gear corresponding to the currently programmed frequency.
2. The patch under review does not change this existing behavior. It only addresses the handling of gear values that are within the negotiated device capabilities and does not alter the fallback path when the frequency lookup fails.
Considering the above points, I believe no changes are required for this patch at this time. We can revisit this behavior separately and evaluate potential optimizations in a future patch if needed.
Please let me know your opinion.
Thanks,
Nitin
Quoted 3 lines
- Mani
Manivannan Sadhasivam
maintainerQuoted 111 lines · Nitin Rawat
Quoted 23 lines · Manivannan Sadhasivam
Quoted 22 lines · Nitin Rawat
From: Ziqi Chen <[email protected]>
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 <[email protected]>Signed-off-by Nitin Rawat <[email protected]>--- drivers/ufs/host/ufs-qcom.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)drivers/ufs/host/ufs-qcom.c +0
-0@@ -2460,8 +2460,9 @@ static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba,bool found = false;Quoted 8 lines
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2465
Quoted 6 lines
drivers/ufs/host/ufs-qcom.c +3
-2opp =dev_pm_opp_find_freq_exact_indexed (hba->dev, freq,0 , true); -if (IS_ERR (opp)) { -dev_err (hba->dev,"Failed to find OPP for exact frequency %lu\n" , freq); +if (IS_ERR_OR_NULL (opp)) { +dev_err (hba->dev,"%s: Failed to find OPP for exact frequency %lu\n" , + __func__, freq);Don't bring back the '
__func__' marking please...Sure, will take in next patchset
Quoted 6 lines
Quoted 6 lines
drivers/ufs/host/ufs-qcom.c +0
-0return 0 ; }@@ -2489,12 +2490,32 @@ static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba,Quoted 8 lines
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2495
Quoted 6 lines
drivers/ufs/host/ufs-qcom.c +2
-1static u32 ufs_qcom_freq_to_gear_speed (struct ufs_hba *hba,unsigned long freq) { -u32 gear =UFS_HS_DONT_CHANGE ; +struct dev_pm_opp *opp;unsigned long unipro_freq; +u32 gear =UFS_HS_DONT_CHANGE ;Nit: Preserve reverse Xmas order.
Sure, will take in next patchset
Quoted 11 lines
drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2503
Quoted 9 lines
drivers/ufs/host/ufs-qcom.c +4
-0if (!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,"%s: Failed to find OPP for exact frequency %lu\n" , + __func__, freq);Drop '
__func__' here and below.Sure, will take in next patchset
Quoted 16 lines
Quoted 4 lines
drivers/ufs/host/ufs-qcom.c +3
-0+return gear; + } +drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2516
Quoted 10 lines
drivers/ufs/host/ufs-qcom.c +10
-0+/* Get HS gear speed from 'opp-level' */ + gear =dev_pm_opp_get_level (opp); +dev_pm_opp_put (opp); + +/* +* Greater than max gear means that there is no specified gear configured in DT +* or the specified gear is invalid. +*/ +if (gear <= hba->max_pwr_info.info.gear_rx) +return gear;Sashiko pointed out a valid concern with this check, please take a look.
I reviewed the bot's comment. The concern raised applies to the case where the gear value provided through the device tree is higher (for example, 5) than what a UFS 3.x device can support. After link startup and negotiation,
hba->max_pwr_info.info.gear_rxwould be 4. In this scenario, the condition below evaluates to false:drivers/ufs/host/ufs-qcom.c static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, · line 2516
Quoted 2 lines
drivers/ufs/host/ufs-qcom.c +2
-0+if (gear <= hba->max_pwr_info.info.gear_rx) +return gear;Execution then falls back to the switch-case logic. If the current frequency does not match any of the predefined entries, the function returns
UFS_HS_DONT_CHANGE, which effectively maps to the minimum gear. Shahiko's suggestion is to instead return the device's maximum negotiated gear using:A couple of points to note:
1. If the current frequency does not match any of the expected frequency entries, that is already an existing issue. In such a case, simply returning the maximum negotiated gear may not be correct because we do not know the actual gear corresponding to the currently programmed frequency.
2. The patch under review does not change this existing behavior. It only addresses the handling of gear values that are within the negotiated device capabilities and does not alter the fallback path when the frequency lookup fails.
Quoted 5 lines
Considering the above points, I believe no changes are required for this patch at this time.
We can revisit this behavior separately and evaluate potential optimizations in a future patch if needed.
Fair enough.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
PATCH 2/2 arm64: dts: qcom: Set specified gear configuration for Hamoa
In reply to Nitin RawatAssign 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).
--- arch/arm64/boot/dts/qcom/hamoa.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/boot/dts/qcom/hamoa.dtsi +3 -0
@@ -3918,6 +3918,7 @@ opp-75000000 { /bits/ 64 <0>, /bits/ 64 <0>, /bits/ 64 <0>; + opp-level = <1>; /* HS-G1 */ required-opps = <&rpmhpd_opp_low_svs>; };
@@ -3930,6 +3931,7 @@ opp-150000000 { /bits/ 64 <0>, /bits/ 64 <0>, /bits/ 64 <0>; + opp-level = <3>; /* HS-G3 */ required-opps = <&rpmhpd_opp_svs>; };
@@ -3942,6 +3944,7 @@ opp-300000000 { /bits/ 64 <0>, /bits/ 64 <0>, /bits/ 64 <0>; + opp-level = <5>; /* HS-G5 */ required-opps = <&rpmhpd_opp_nom>; }; };
--
2.34.1
[email protected]
AI reviewRe: [PATCH V1 2/2] arm64: dts: qcom: Set specified gear configuration for Hamoa
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Incorrect fallback logic when DT-specified `opp-level` exceeds the negotiated maximum gear. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Incorrect fallback logic when DT-specified opp-level exceeds the negotiated maximum gear. --
commit 1074dd135232851ffc9d0417dea7de1323a012a4
Author: Nitin Rawat <[email protected]>
arm64: dts: qcom: Set specified gear configuration for Hamoa
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).
Quoted 4 lines
arch/arm64/boot/dts/qcom/hamoa.dtsi +0
-0
[ ... ]
arch/arm64/boot/dts/qcom/hamoa.dtsi opp-300000000 { · line 3997
Quoted 5 lines
arch/arm64/boot/dts/qcom/hamoa.dtsi +1
-0@@ -3992,6 +3994,7 @@ opp-300000000 { /bits/ 64 <0>, /bits/ 64 <0>, /bits/ 64 <0>; + opp-level = <5>; /* HS-G5 */
[Severity: High]
Will adding this HS-G5 opp-level break devfreq gear scaling if the host is paired with a slower UFS memory device, such as one with a maximum of G4?
Looking at ufs_qcom_freq_to_gear_speed() in drivers/ufs/host/ufs-qcom.c, the retrieved opp-level is checked against the negotiated maximum gear:
gear = dev_pm_opp_get_level(dev, freq);
/* ... */
/*
* Greater than max gear means that there is no specified gear configured
* in DT or the specified gear is invalid.
*/
if (gear <= hba->max_pwr_info.info.gear_rx)
return gear;
gear = UFS_HS_DONT_CHANGE;If this DT configures a gear level of 5 (HS-G5), but the attached UFS device only supports gear 4 (HS-G4), the check 5 <= 4 evaluates to false.
Because dev_pm_opp_get_level() returns OPP_LEVEL_UNSET (U32_MAX) when the property is missing, the code seems to conflate a missing property with a gear that simply exceeds the attached device's maximum capability.
When the check fails, instead of capping the gear to the device's maximum, the code falls through to the legacy hardcoded switch block. If the new frequency is missing from that legacy block, it hits the default case, logs an "Unsupported clock freq" error, and fails to scale entirely.
Does ufs_qcom_freq_to_gear_speed() need to explicitly check against OPP_LEVEL_UNSET and cap the DT gear to the negotiated maximum instead of falling back to the legacy behavior?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH V1 2/2] arm64: dts: qcom: Set specified gear configuration for Hamoa
In reply to Nitin RawatQuoted 5 lines · Nitin Rawat
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).
Signed-off-by Nitin Rawat <[email protected]>
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்