mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Loehle <christian.loehle@arm.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	Mario Limonciello <mario.limonciello@amd.com>
Cc: "Gautham R . Shenoy" <gautham.shenoy@amd.com>,
	Perry Yuan <perry.yuan@amd.com>, Huang Rui <ray.huang@amd.com>,
	Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Christian Loehle <christian.loehle@arm.com>
Subject: [PATCH 2/2] cpufreq/amd-pstate: Clamp desired perf on resume
Date: Thu, 29 Oct 2026 12:19:45 +0000	[thread overview]
Message-ID: <20261029121945.854675-3-christian.loehle@arm.com> (raw)
In-Reply-To: <20261029121945.854675-1-christian.loehle@arm.com>

amd_pstate_resume() converts policy->cur to a performance level and
writes it directly alongside the cached policy limits. Both
frequency/performance conversions round up, so the converted value
can exceed max_limit_perf even when the request before suspend was
within the policy limits.

On a Ryzen 5 7430U with a fixed 1.2 GHz policy, a request with
Desired=46 becomes policy->cur=1216621 kHz and converts back to
Desired=47. Resume then writes MIN=46, Desired=47, MAX=46.

Clamp the converted Desired to the cached minimum and maximum before
restoring the request.

Fixes: 608a76b65288 ("cpufreq/amd-pstate: Add support for the "Requested CPU Min frequency" BIOS option")
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
 drivers/cpufreq/amd-pstate.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 28df8507d93f..0b1b0e263577 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -2211,6 +2211,7 @@ static int amd_pstate_resume(struct cpufreq_policy *policy)
 	int ret;
 
 	/* Set CPPC_REQ to last sane value until the governor updates it */
+	cur_perf = clamp(cur_perf, perf.min_limit_perf, perf.max_limit_perf);
 	ret = amd_pstate_update_perf(policy, perf.min_limit_perf, cur_perf, perf.max_limit_perf,
 				     0U, false);
 	if (ret)
-- 
2.34.1


  parent reply	other threads:[~2026-10-29 12:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 12:19 [PATCH 0/2] cpufreq/amd-pstate register write fixes Christian Loehle
2026-10-29 12:19 ` [PATCH 1/2] cpufreq/amd-pstate: Keep minimum requests within policy limits Christian Loehle
2026-10-29 12:19 ` Christian Loehle [this message]
2026-10-29 19:35 ` [PATCH 0/2] cpufreq/amd-pstate register write fixes Mario Limonciello
2026-10-30  3:11 ` K Prateek Nayak

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=20261029121945.854675-3-christian.loehle@arm.com \
    --to=christian.loehle@arm.com \
    --cc=Dhananjay.Ugwekar@amd.com \
    --cc=gautham.shenoy@amd.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=perry.yuan@amd.com \
    --cc=rafael@kernel.org \
    --cc=ray.huang@amd.com \
    --cc=viresh.kumar@linaro.org \
    /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

all inboxes | Powered by JetHome®