From: Bean Huo <beanhuo@iokpp.de>
To: Stanley Jhu <stanleyjhu@google.com>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
"Martin K . Petersen" <mkp@kernel.org>,
"James E . J . Bottomley" <James.Bottomley@hansenpartnership.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@sandisk.com>,
Bart Van Assche <bvanassche@acm.org>,
Jie Zhan <zhanjie9@hisilicon.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
linux-pm@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, Bean Huo <beanhuo@micron.com>
Subject: Re: [PATCH 3/3] scsi: ufs: core: Report the current clock frequency to devfreq
Date: Thu, 03 Sep 2026 23:33:43 +0200 [thread overview]
Message-ID: <f1e59607ab2f5554993dacf21947024e41278058.camel@iokpp.de> (raw)
In-Reply-To: <CAE14pddCf1VhLVC_H-Nv30C4BzK_UO4Eknd27g72d1nAjdBdpA@mail.gmail.com>
On Tue, 2026-09-01 at 09:33 +0800, Stanley Jhu wrote:
> On Mon, 31 Aug 2026 15:01:29 +0200, Bean Huo wrote:
> > + /*
> > + * target_freq stays 0 until something scales the controller for the
> > + * first time. Report nothing rather than 0 so devfreq falls back to
> > + * the frequency it last set.
> > + */
> > + if (!cur_freq)
> > + return -EINVAL;
>
> If ufshcd_devfreq_get_cur_freq() returns -EINVAL here, devfreq falls back
> to devfreq->previous_freq. However, because UFS does not set
> devfreq_profile.initial_freq, previous_freq is also 0 at boot. On platforms
> with use_pm_opp=true, the initial sysfs read or the first transition before
> scaling still ends up seeing 0 Hz.
>
> Would it be cleaner to initialize hba->clk_scaling.target_freq and
> devfreq_profile.initial_freq to the max frequency in ufshcd_devfreq_init()?
> That way, cur_freq is valid from the start and we wouldn't need to handle
> the !cur_freq case here.
>
> Thanks,
> Stanley Jhu
yes, thanks, that is better. I will do it in v2.
digging deeper, the problem is a bit wider than the sysfs read. with use_pm_opp,
ufshcd_init_clocks() already puts the controller at the highest OPP, but nothing
records that, so target_freq stays 0. Then ufshcd_devfreq_get_dev_status()
reports 0 Hz, the ondemand governor asks for the maximum frequency, and
ufshcd_devfreq_target() sees 0 != max and runs a full ufshcd_devfreq_scale().
That holds up the queue for up to a second only to set the same OPP and the same
gear again. This happens today, without my patch.
Patches 1 and 2 are not affected.
Kind regards,
Bean
next prev parent reply other threads:[~2026-09-03 21:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 13:01 [PATCH 0/3] devfreq: check the get_cur_freq() return value and use it in ufshcd Bean Huo
2026-08-31 13:01 ` [PATCH 1/3] PM / devfreq: Fall back to previous_freq when get_cur_freq() fails Bean Huo
2026-08-31 13:01 ` [PATCH 2/3] PM / devfreq: Add more details to the get_cur_freq() comment Bean Huo
2026-08-31 13:01 ` [PATCH 3/3] scsi: ufs: core: Report the current clock frequency to devfreq Bean Huo
2026-09-01 1:33 ` Stanley Jhu
2026-09-03 21:33 ` Bean Huo [this message]
2026-09-04 1:29 ` Stanley Jhu
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=f1e59607ab2f5554993dacf21947024e41278058.camel@iokpp.de \
--to=beanhuo@iokpp.de \
--cc=James.Bottomley@hansenpartnership.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@sandisk.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=cw00.choi@samsung.com \
--cc=krzk@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=stanleyjhu@google.com \
--cc=zhanjie9@hisilicon.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