[PATCH v2 0/2] cpufreq/amd-pstate: Fix EPP initialization and add capability check

Marco Scardovi posted 2 patches 4 days, 18 hours ago
drivers/cpufreq/amd-pstate.c | 52 +++++++++++++++++++++++++++++++++++-
drivers/cpufreq/amd-pstate.h |  2 ++
2 files changed, 53 insertions(+), 1 deletion(-)
[PATCH v2 0/2] cpufreq/amd-pstate: Fix EPP initialization and add capability check
Posted by Marco Scardovi 4 days, 18 hours ago
Hi Prateek and all,

before trying merging in @Mario's git il post the new patches with the
changes you suggested. If something doesn't feel right let me know.

This series addresses a boot-time performance regression on shared memory
systems where the CPU gets stuck at the lowest non-linear frequency
(1.7GHz), and adds proper EPP capability checks to prevent active mode from
being incorrectly enabled on systems without EPP support.

Patch 1 fixes the boot-time initialization regression by introducing an
`epp_hw_programmed` flag in struct amd_cpudata to track whether EPP has
been configured on the hardware. This bypasses a false cache hit on boot
due to zero-initialized caching registers, ensuring that EPP and auto_sel
are always written during CPU initialization, while still preserving the
cache guard optimization for all subsequent runtime transitions.

Patch 2 implements an EPP capability check at boot time using a new
amd_pstate_epp_supported() helper, which queries the EPP performance
capability on the first online CPU. If EPP is unsupported, the driver falls
back to passive mode at boot, and rejects any subsequent runtime
transitions to active mode.

Changes in v2:
- Patch 1: Rename `epp_initialized` to `epp_hw_programmed`, explicitly
  document the flag semantics, and add a comment documenting the EPP cache
  guard optimization behavior.
- Patch 2: Add comments explaining the uniform CPU capability check on x86,
  handle EPP capability check errors robustly using a tri-state model (only
  treat -EOPNOTSUPP as unsupported, warn and assume supported for other
  errors to avoid false negatives), and reject runtime active mode transitions
  at sysfs store time (preventing the driver from being left in an
  unregistered state).

Changes in v1:
- Fix the boot-time CPPC EPP/auto_sel initialization regression in
  shmem_set_epp() using a state tracking flag while preserving runtime
  cache optimization.
- Add an EPP capability check helper during initialization.
- Fall back to passive mode at boot if EPP is not supported, and reject
  transitions to active mode at runtime if EPP is not supported.

Marco Scardovi (2):
  cpufreq/amd-pstate: Fix EPP initialization for shared memory systems
  cpufreq/amd-pstate: Prevent active mode on systems without EPP support

 drivers/cpufreq/amd-pstate.c | 52 +++++++++++++++++++++++++++++++++++-
 drivers/cpufreq/amd-pstate.h |  2 ++
 2 files changed, 53 insertions(+), 1 deletion(-)

-- 
2.54.0
Re: [PATCH v2 0/2] cpufreq/amd-pstate: Fix EPP initialization and add capability check
Posted by Mario Limonciello 4 days, 12 hours ago

On 6/3/26 06:56, Marco Scardovi wrote:
> Hi Prateek and all,
> 
> before trying merging in @Mario's git il post the new patches with the
> changes you suggested. If something doesn't feel right let me know.
> 
> This series addresses a boot-time performance regression on shared memory
> systems where the CPU gets stuck at the lowest non-linear frequency
> (1.7GHz), and adds proper EPP capability checks to prevent active mode from
> being incorrectly enabled on systems without EPP support.
> 
> Patch 1 fixes the boot-time initialization regression by introducing an
> `epp_hw_programmed` flag in struct amd_cpudata to track whether EPP has
> been configured on the hardware. This bypasses a false cache hit on boot
> due to zero-initialized caching registers, ensuring that EPP and auto_sel
> are always written during CPU initialization, while still preserving the
> cache guard optimization for all subsequent runtime transitions.
> 
> Patch 2 implements an EPP capability check at boot time using a new
> amd_pstate_epp_supported() helper, which queries the EPP performance
> capability on the first online CPU. If EPP is unsupported, the driver falls
> back to passive mode at boot, and rejects any subsequent runtime
> transitions to active mode.
> 
> Changes in v2:
> - Patch 1: Rename `epp_initialized` to `epp_hw_programmed`, explicitly
>    document the flag semantics, and add a comment documenting the EPP cache
>    guard optimization behavior.
> - Patch 2: Add comments explaining the uniform CPU capability check on x86,
>    handle EPP capability check errors robustly using a tri-state model (only
>    treat -EOPNOTSUPP as unsupported, warn and assume supported for other
>    errors to avoid false negatives), and reject runtime active mode transitions
>    at sysfs store time (preventing the driver from being left in an
>    unregistered state).
> 
> Changes in v1:
> - Fix the boot-time CPPC EPP/auto_sel initialization regression in
>    shmem_set_epp() using a state tracking flag while preserving runtime
>    cache optimization.
> - Add an EPP capability check helper during initialization.
> - Fall back to passive mode at boot if EPP is not supported, and reject
>    transitions to active mode at runtime if EPP is not supported.
> 
> Marco Scardovi (2):
>    cpufreq/amd-pstate: Fix EPP initialization for shared memory systems
>    cpufreq/amd-pstate: Prevent active mode on systems without EPP support
> 
>   drivers/cpufreq/amd-pstate.c | 52 +++++++++++++++++++++++++++++++++++-
>   drivers/cpufreq/amd-pstate.h |  2 ++
>   2 files changed, 53 insertions(+), 1 deletion(-)
> 

Did you see Prateek's suggestion?  Can you check if that helps before we 
go down this path?

Thanks,