* [PATCH 1/2] cpufreq/amd-pstate: Keep minimum requests within policy limits
2026-10-29 12:19 [PATCH 0/2] cpufreq/amd-pstate register write fixes Christian Loehle
@ 2026-10-29 12:19 ` Christian Loehle
2026-10-29 12:19 ` [PATCH 2/2] cpufreq/amd-pstate: Clamp desired perf on resume Christian Loehle
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Christian Loehle @ 2026-10-29 12:19 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar, K Prateek Nayak, Mario Limonciello
Cc: Gautham R . Shenoy, Perry Yuan, Huang Rui, Dhananjay Ugwekar,
linux-pm, linux-kernel, Christian Loehle
The minimum performance hint can exceed the policy maximum, e.g.
for schedutil when an RT task requests full CPU capacity. After
converting that hint, amd_pstate_adjust_perf() raises max_perf to
min_perf. This replaces the policy cap with the scheduler's minimum
request, and the subsequent Desired clamp uses the expanded interval.
Clamp min_perf to max_limit_perf instead of raising max_perf, to
enforce the policy's upper-bound again.
Fixes: 3f7b835fa4d0 ("cpufreq/amd-pstate: Move limit updating code")
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
drivers/cpufreq/amd-pstate.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 4bedfbfc18b6..28df8507d93f 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -866,8 +866,7 @@ static void amd_pstate_adjust_perf(struct cpufreq_policy *policy,
min_perf = perf.min_limit_perf;
max_perf = perf.max_limit_perf;
- if (max_perf < min_perf)
- max_perf = min_perf;
+ min_perf = min(min_perf, max_perf);
amd_pstate_update(policy, min_perf, des_perf, max_perf, true,
policy->governor->flags);
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/2] cpufreq/amd-pstate: Clamp desired perf on resume
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
2026-10-29 19:35 ` [PATCH 0/2] cpufreq/amd-pstate register write fixes Mario Limonciello
2026-10-30 3:11 ` K Prateek Nayak
3 siblings, 0 replies; 5+ messages in thread
From: Christian Loehle @ 2026-10-29 12:19 UTC (permalink / raw)
To: Rafael J . Wysocki, Viresh Kumar, K Prateek Nayak, Mario Limonciello
Cc: Gautham R . Shenoy, Perry Yuan, Huang Rui, Dhananjay Ugwekar,
linux-pm, linux-kernel, Christian Loehle
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 0/2] cpufreq/amd-pstate register write fixes
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 ` [PATCH 2/2] cpufreq/amd-pstate: Clamp desired perf on resume Christian Loehle
@ 2026-10-29 19:35 ` Mario Limonciello
2026-10-30 3:11 ` K Prateek Nayak
3 siblings, 0 replies; 5+ messages in thread
From: Mario Limonciello @ 2026-10-29 19:35 UTC (permalink / raw)
To: Christian Loehle, Rafael J . Wysocki, Viresh Kumar, K Prateek Nayak
Cc: Gautham R . Shenoy, Perry Yuan, Huang Rui, Dhananjay Ugwekar,
linux-pm, linux-kernel
On 10/29/26 07:19, Christian Loehle wrote:
> Two issues that popped up when trying to integrate an AMD machine into
> my testing for acpi-cppc, in particular for this (otherwise
> unrelated) patch:
> https://lore.kernel.org/lkml/20261020121846.691218-2-sumitg@nvidia.com/
>
> The first is rather straightforward, I think the case was just not
> considered during the refactor of the Fixes commit.
> The second is part of the resume handling and was introduced when
> that restored the register values (DESIRED derived from policy->cur).
> My platform seems to handle it well, but it's still strange
> behaviour, so why not fix it.
> (Also of course the resume value will generally be overwritten and
> therefore 'fixed' anyway.)
>
> Christian Loehle (2):
> cpufreq/amd-pstate: Keep minimum requests within policy limits
> cpufreq/amd-pstate: Clamp desired perf on resume
>
> drivers/cpufreq/amd-pstate.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>
> base-commit: c339f4010dea8b0d754f84ace70cd1b089878ef8
Thanks for the fixes. I'll pick them up for 7.4-rc2.
Acked-by: Mario Limociello (AMD) <superm1@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] cpufreq/amd-pstate register write fixes
2026-10-29 12:19 [PATCH 0/2] cpufreq/amd-pstate register write fixes Christian Loehle
` (2 preceding siblings ...)
2026-10-29 19:35 ` [PATCH 0/2] cpufreq/amd-pstate register write fixes Mario Limonciello
@ 2026-10-30 3:11 ` K Prateek Nayak
3 siblings, 0 replies; 5+ messages in thread
From: K Prateek Nayak @ 2026-10-30 3:11 UTC (permalink / raw)
To: Christian Loehle, Rafael J . Wysocki, Viresh Kumar, Mario Limonciello
Cc: Gautham R . Shenoy, Perry Yuan, Huang Rui, Dhananjay Ugwekar,
linux-pm, linux-kernel
Hello Chris,
On 10/29/2026 5:49 PM, Christian Loehle wrote:
> Two issues that popped up when trying to integrate an AMD machine into
> my testing for acpi-cppc, in particular for this (otherwise
> unrelated) patch:
> https://lore.kernel.org/lkml/20261020121846.691218-2-sumitg@nvidia.com/
>
> The first is rather straightforward, I think the case was just not
> considered during the refactor of the Fixes commit.
> The second is part of the resume handling and was introduced when
> that restored the register values (DESIRED derived from policy->cur).
> My platform seems to handle it well, but it's still strange
> behaviour, so why not fix it.
> (Also of course the resume value will generally be overwritten and
> therefore 'fixed' anyway.)
Thank you for catching them. For the whole series, feel free to include:
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
--
Thanks and Regards,
Prateek
^ permalink raw reply [flat|nested] 5+ messages in thread