From: sashiko-bot@kernel.org
To: "Bean Huo" <beanhuo@iokpp.de>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 1/4] PM / devfreq: Fall back to previous_freq when get_cur_freq() fails
Date: Mon, 07 Sep 2026 19:33:42 +0000 [thread overview]
Message-ID: <20260907193342.841D91F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260907192140.2701755-2-beanhuo@iokpp.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Medium] devfreq->resume_freq is incorrectly overwritten with devfreq->suspend_freq during system suspend, causing devices to resume to their suspend frequency rather than their active frequency.
--
commit 252cf4045ad4d642d45961b4d6845aa317e8ee57
Author: Bean Huo <beanhuo@micron.com>
PM / devfreq: Fall back to previous_freq when get_cur_freq() fails
This commit updates devfreq_set_target() to fall back to the previous
frequency when get_cur_freq() returns an error. This prevents uninitialized
stack values from being passed to notifiers during frequency changes.
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index f08fc6966eaee..f20d9a6607791 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -348,9 +348,8 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
> unsigned long cur_freq;
> int err = 0;
>
> - if (devfreq->profile->get_cur_freq)
> - devfreq->profile->get_cur_freq(devfreq->dev.parent, &cur_freq);
> - else
> + if (!devfreq->profile->get_cur_freq ||
> + devfreq->profile->get_cur_freq(devfreq->dev.parent, &cur_freq))
> cur_freq = devfreq->previous_freq;
>
> freqs.old = cur_freq;
[Severity: Medium]
This is a pre-existing issue, but since we are modifying devfreq_set_target(),
I noticed a potential issue with how resume frequencies are stored.
Further down in devfreq_set_target(), there is this unconditional assignment:
drivers/devfreq/devfreq.c:devfreq_set_target() {
...
if (devfreq->suspend_freq)
devfreq->resume_freq = new_freq;
return err;
}
When a device defines a suspend_freq, system suspend invokes
devfreq_suspend_device(), which places the device in the low-power state
by calling:
drivers/devfreq/devfreq.c:devfreq_suspend_device() {
...
ret = devfreq_set_target(devfreq, devfreq->suspend_freq, 0);
...
}
Does this cause devfreq_set_target() to unintentionally overwrite the saved
active frequency with the suspend frequency?
It appears that during every system suspend cycle, resume_freq gets updated to
the suspend_freq target. Will this cause devices to resume to their lowest
suspend frequency instead of their pre-suspend active frequency, degrading
performance until the governor recalculates a new target?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260907192140.2701755-1-beanhuo@iokpp.de?part=1
next prev parent reply other threads:[~2026-09-07 19:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 19:21 [PATCH v2 0/4] devfreq: check the get_cur_freq() return value and use it in ufshcd Bean Huo
2026-09-07 19:21 ` [PATCH v2 1/4] PM / devfreq: Fall back to previous_freq when get_cur_freq() fails Bean Huo
2026-09-07 19:33 ` sashiko-bot [this message]
2026-09-07 20:29 ` Bean Huo
2026-09-07 19:21 ` [PATCH v2 2/4] PM / devfreq: Add more details to the get_cur_freq() comment Bean Huo
2026-09-07 19:21 ` [PATCH v2 3/4] scsi: ufs: core: Record the frequency the controller starts at Bean Huo
2026-09-07 19:41 ` sashiko-bot
2026-09-07 20:50 ` Bean Huo
2026-09-07 19:21 ` [PATCH v2 4/4] scsi: ufs: core: Report the current clock frequency to devfreq Bean Huo
2026-09-07 19:35 ` sashiko-bot
2026-09-07 20:23 ` Bean Huo
2026-09-08 1:34 ` [PATCH v2 0/4] devfreq: check the get_cur_freq() return value and use it in ufshcd Stanley Jhu
2026-09-10 2:28 ` Martin K. Petersen (Oracle)
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=20260907193342.841D91F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=beanhuo@iokpp.de \
--cc=linux-scsi@vger.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;
as well as URLs for NNTP newsgroup(s).