* [PATCH] cpufreq/amd-pstate: Fix a regression leading to EPP 0 after resume
@ 2025-08-26 5:27 Mario Limonciello (AMD)
2025-08-27 22:33 ` Willian Wang
2025-09-03 15:05 ` Gautham R. Shenoy
0 siblings, 2 replies; 3+ messages in thread
From: Mario Limonciello (AMD) @ 2025-08-26 5:27 UTC (permalink / raw)
To: Gautham R . Shenoy
Cc: Perry Yuan, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:CPU FREQUENCY SCALING FRAMEWORK,
Mario Limonciello (AMD)
During the suspend sequence the cached CPPC request is destroyed
with the expectation that it's restored during resume. This assumption
broke when the separate cache EPP variable was removed, and then it was
broken again by commit 608a76b65288 ("cpufreq/amd-pstate: Add support
for the "Requested CPU Min frequency" BIOS option") which explicitly
set it to zero during suspend.
Remove the invalidation and set the value during the suspend call to
update limits so that the cached variable can be used to restore on
resume.
Fixes: 608a76b65288 ("cpufreq/amd-pstate: Add support for the "Requested CPU Min frequency" BIOS option")
Fixes: b7a41156588a ("cpufreq/amd-pstate: Invalidate cppc_req_cached during suspend")
Closes: https://community.frame.work/t/increased-power-usage-after-resuming-from-suspend-on-ryzen-7040-kernel-6-15-regression/
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
drivers/cpufreq/amd-pstate.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index bbc27ef9edf7b..8eca4707226b8 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -1626,13 +1626,14 @@ static int amd_pstate_suspend(struct cpufreq_policy *policy)
* min_perf value across kexec reboots. If this CPU is just resumed back without kexec,
* the limits, epp and desired perf will get reset to the cached values in cpudata struct
*/
- ret = amd_pstate_update_perf(policy, perf.bios_min_perf, 0U, 0U, 0U, false);
+ ret = amd_pstate_update_perf(policy, perf.bios_min_perf,
+ FIELD_GET(AMD_CPPC_DES_PERF_MASK, cpudata->cppc_req_cached),
+ FIELD_GET(AMD_CPPC_MAX_PERF_MASK, cpudata->cppc_req_cached),
+ FIELD_GET(AMD_CPPC_EPP_PERF_MASK, cpudata->cppc_req_cached),
+ false);
if (ret)
return ret;
- /* invalidate to ensure it's rewritten during resume */
- cpudata->cppc_req_cached = 0;
-
/* set this flag to avoid setting core offline*/
cpudata->suspended = true;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq/amd-pstate: Fix a regression leading to EPP 0 after resume
2025-08-26 5:27 [PATCH] cpufreq/amd-pstate: Fix a regression leading to EPP 0 after resume Mario Limonciello (AMD)
@ 2025-08-27 22:33 ` Willian Wang
2025-09-03 15:05 ` Gautham R. Shenoy
1 sibling, 0 replies; 3+ messages in thread
From: Willian Wang @ 2025-08-27 22:33 UTC (permalink / raw)
To: superm1; +Cc: gautham.shenoy, linux-kernel, linux-pm, perry.yuan
Hi, I can confim that this patch works as intended. I only checked the value of "energy performance preference" field on `cpupower frequency-info` before and after suspend/resume cycle. If there are any other tests you want me to do, please let me know.
I'm using Fedora KDE 42, AMD 7840U, Tuned-2.25.1.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cpufreq/amd-pstate: Fix a regression leading to EPP 0 after resume
2025-08-26 5:27 [PATCH] cpufreq/amd-pstate: Fix a regression leading to EPP 0 after resume Mario Limonciello (AMD)
2025-08-27 22:33 ` Willian Wang
@ 2025-09-03 15:05 ` Gautham R. Shenoy
1 sibling, 0 replies; 3+ messages in thread
From: Gautham R. Shenoy @ 2025-09-03 15:05 UTC (permalink / raw)
To: Mario Limonciello (AMD)
Cc: Perry Yuan, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:CPU FREQUENCY SCALING FRAMEWORK
Hello Mario,
On Tue, Aug 26, 2025 at 12:27:47AM -0500, Mario Limonciello (AMD) wrote:
> During the suspend sequence the cached CPPC request is destroyed
> with the expectation that it's restored during resume. This assumption
> broke when the separate cache EPP variable was removed, and then it was
> broken again by commit 608a76b65288 ("cpufreq/amd-pstate: Add support
> for the "Requested CPU Min frequency" BIOS option") which explicitly
> set it to zero during suspend.
>
> Remove the invalidation and set the value during the suspend call to
> update limits so that the cached variable can be used to restore on
> resume.
>
> Fixes: 608a76b65288 ("cpufreq/amd-pstate: Add support for the "Requested CPU Min frequency" BIOS option")
> Fixes: b7a41156588a ("cpufreq/amd-pstate: Invalidate cppc_req_cached during suspend")
> Closes: https://community.frame.work/t/increased-power-usage-after-resuming-from-suspend-on-ryzen-7040-kernel-6-15-regression/
> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> ---
> drivers/cpufreq/amd-pstate.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index bbc27ef9edf7b..8eca4707226b8 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -1626,13 +1626,14 @@ static int amd_pstate_suspend(struct cpufreq_policy *policy)
> * min_perf value across kexec reboots. If this CPU is just resumed back without kexec,
> * the limits, epp and desired perf will get reset to the cached values in cpudata struct
> */
> - ret = amd_pstate_update_perf(policy, perf.bios_min_perf, 0U, 0U, 0U, false);
> + ret = amd_pstate_update_perf(policy, perf.bios_min_perf,
> + FIELD_GET(AMD_CPPC_DES_PERF_MASK, cpudata->cppc_req_cached),
> + FIELD_GET(AMD_CPPC_MAX_PERF_MASK, cpudata->cppc_req_cached),
> + FIELD_GET(AMD_CPPC_EPP_PERF_MASK, cpudata->cppc_req_cached),
> + false);
> if (ret)
> return ret;
>
> - /* invalidate to ensure it's rewritten during resume */
> - cpudata->cppc_req_cached = 0;
> -
Ah, so cppc_req_cached is required to extract the EPP value in
amd_pstate_epp_update_limit() which is called by
amd_pstate_epp_resume().
Looks good to me.
Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
--
Thanks and Regards
gautham.
> /* set this flag to avoid setting core offline*/
> cpudata->suspended = true;
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-03 15:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-26 5:27 [PATCH] cpufreq/amd-pstate: Fix a regression leading to EPP 0 after resume Mario Limonciello (AMD)
2025-08-27 22:33 ` Willian Wang
2025-09-03 15:05 ` Gautham R. Shenoy
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).