From: sashiko-bot@kernel.org
To: "Nitin Rawat" <nitin.rawat@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH V1 1/2] scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling
Date: Sat, 29 Aug 2026 07:55:14 +0000 [thread overview]
Message-ID: <20260829075515.2674E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260829074355.946543-2-nitin.rawat@oss.qualcomm.com>
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 <ziqi.chen@oss.qualcomm.com>
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.
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 291c434487648..399269c3f0597 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
[ ... ]
> @@ -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' */
> + 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)?
> + gear = UFS_HS_DONT_CHANGE;
> unipro_freq = ufs_qcom_opp_freq_to_clk_freq(hba, freq, "core_clk_unipro");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260829074355.946543-1-nitin.rawat@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-08-29 7:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-29 7:43 [PATCH V1 0/2] scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling Nitin Rawat
2026-08-29 7:43 ` [PATCH V1 1/2] " Nitin Rawat
2026-08-29 7:55 ` sashiko-bot [this message]
2026-09-02 16:02 ` Manivannan Sadhasivam
2026-08-29 7:43 ` [PATCH V1 2/2] arm64: dts: qcom: Set specified gear configuration for Hamoa Nitin Rawat
2026-08-29 7:53 ` sashiko-bot
2026-09-02 16:03 ` Manivannan Sadhasivam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260829075515.2674E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=nitin.rawat@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox