Re: [PATCH V1 1/2] scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling
From: Manivannan Sadhasivam
Date: Wed Sep 02 2026 - 12:16:14 EST
On Sat, Aug 29, 2026 at 01:13:54PM +0530, Nitin Rawat wrote:
> From: Ziqi Chen <ziqi.chen@xxxxxxxxxxxxxxxx>
>
> 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@xxxxxxxxxxxxxxxx>
> Signed-off-by: Nitin Rawat <nitin.rawat@xxxxxxxxxxxxxxxx>
> ---
> drivers/ufs/host/ufs-qcom.c | 30 ++++++++++++++++++++++++++----
> 1 file changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 0f2e083b04fd..aa2ac2cd2b69 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -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...
> 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;
Nit: Preserve reverse Xmas order.
>
> 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);
Drop '__func__' here and below.
> + 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
--
மணிவண்ணன் சதாசிவம்