Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Nitin Rawat <nitin.rawat@oss.qualcomm.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: krzk+dt@kernel.org, robh@kernel.org, conor+dt@kernel.org,
	andersson@kernel.org, konradybcio@kernel.org,
	James.Bottomley@hansenpartnership.com, mkp@kernel.org,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-scsi@vger.kernel.org,
	Ziqi Chen <ziqi.chen@oss.qualcomm.com>
Subject: Re: [PATCH V1 1/2] scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling
Date: Wed, 9 Sep 2026 10:34:58 +0530	[thread overview]
Message-ID: <50e348ef-2d9a-4197-84ca-99d3902cbc37@oss.qualcomm.com> (raw)
In-Reply-To: <stik7u2o6ydje6ws7cyrltmdw4wz6iyximnxeyegw2f562b2bv@4m2sueuuzisb>



On 9/2/2026 9:32 PM, Manivannan Sadhasivam wrote:
> On Sat, Aug 29, 2026 at 01:13:54PM +0530, Nitin Rawat wrote:
>> From: Ziqi Chen <ziqi.chen@oss.qualcomm.com>
>>
>> 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>
>> ---
>>   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...
Sure, will take in next patchset


> 
>>   		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.
Sure, will take in next patchset

> 
>>
>>   	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.
Sure, will take in next patchset

> 
>> +		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.

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:


 > +	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






> 
> - Mani
> 


  reply	other threads:[~2026-09-09  5:05 UTC|newest]

Thread overview: 9+ 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
2026-09-02 16:02   ` Manivannan Sadhasivam
2026-09-09  5:04     ` Nitin Rawat [this message]
2026-09-09  7: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=50e348ef-2d9a-4197-84ca-99d3902cbc37@oss.qualcomm.com \
    --to=nitin.rawat@oss.qualcomm.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=mkp@kernel.org \
    --cc=robh@kernel.org \
    --cc=ziqi.chen@oss.qualcomm.com \
    /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