Re: [PATCH v2 1/2] cpufreq/amd-pstate: Fix EPP initialization for shared memory systems
From: K Prateek Nayak
Date: Thu Jun 04 2026 - 23:47:06 EST
Hello Mario,
On 6/5/2026 12:13 AM, Mario Limonciello wrote:
> So at least for patch 1 if you run dynamic epp, and are plugged into a wall
> you start out on EPP 0, but I'm pretty sure that's usually the firmware
> default anyway. But this gives me a (better?) idea. How about we just
> read the EPP from the firmware initially at startup?
I'm looking at the ACPI tables across various generations and, from Zen4
onward, we stopped including the optional AUTO_SEL_ENABLE register as
the platforms introduced MSR based interfaces.
The Energy Performance Preference Register definition reads:
If supported, contains a resource descriptor with a single
Register() descriptor that describes a register to which OSPM writes
a value to control the Energy vs. Performance preference of the
platform’s energy efficiency and performance optimization policies
when *Autonomous Selection is enabled*.
I think, the shmem platforms should call cppc_set_auto_sel(cpu, 1) just
as a safety during epp_cpu_init just to ensure we are not missing out
on enabling it if there is some dependency there.
>
> Something like this:
>
> ╰─❯ git diff
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 3f06e33f47120..0e32f7f92651b 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -1939,6 +1939,8 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
>
> policy->boost_supported = READ_ONCE(cpudata->boost_supported);
>
> + WRITE_ONCE(cpudata->cppc_req_cached, FIELD_PREP(AMD_CPPC_EPP_PERF_MASK, amd_pstate_get_epp(cpudata)));
> +
> /*
> * Set the policy to provide a valid fallback value in case
> * the default cpufreq governor is neither powersave nor performance.
>
Building on top of your suggestion:
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 72df461e7b39..27ed0db02bcb 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -1882,6 +1882,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
struct amd_cpudata *cpudata;
union perf_cached perf;
struct device *dev;
+ s16 default_epp;
int ret;
/*
@@ -1928,9 +1929,22 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
/* It will be updated by governor */
policy->cur = policy->cpuinfo.min_freq;
-
policy->boost_supported = READ_ONCE(cpudata->boost_supported);
+ /* Cache the firmware programmed EPP */
+ default_epp = amd_pstate_get_epp(cpudata);
+ FIELD_MODIFY(AMD_CPPC_EPP_PERF_MASK, &cpudata->cppc_req_cached, default_epp);
+
+ /*
+ * Shared memory based systems may require the AUTO_SEL_ENABLE register
+ * to be toggled on to function correctly. Since the first call to
+ * amd_pstate_set_epp() may bail out early if the desired EPP is
+ * same as the one configured by the firmware, attempt to toggle the
+ * AUTO_SEL_ENABLE here, independent of EPP programming.
+ */
+ if (!cpu_feature_enabled(X86_FEATURE_CPPC))
+ cppc_set_auto_sel(policy->cpu, 1);
+
/*
* Set the policy to provide a valid fallback value in case
* the default cpufreq governor is neither powersave nor performance.
@@ -1938,7 +1952,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
if (amd_pstate_acpi_pm_profile_server() ||
amd_pstate_acpi_pm_profile_undefined()) {
policy->policy = CPUFREQ_POLICY_PERFORMANCE;
- cpudata->epp_default_ac = cpudata->epp_default_dc = amd_pstate_get_epp(cpudata);
+ cpudata->epp_default_ac = cpudata->epp_default_dc = default_epp;
cpudata->current_profile = PLATFORM_PROFILE_PERFORMANCE;
} else {
policy->policy = CPUFREQ_POLICY_POWERSAVE;
---
I'm not sure whether guided mode needs this but I'll get my hands on a
Zen2 part to test this out.
--
Thanks and Regards,
Prateek