[PATCH 0/6] cpufreq/amd-pstate: Dynamic EPP fixes

K Prateek Nayak posted 6 patches 1 month ago
drivers/cpufreq/amd-pstate-ut.c | 36 ++++++++++++++++++++++++++-------
drivers/cpufreq/amd-pstate.c    | 23 ++++++++++++++++-----
2 files changed, 47 insertions(+), 12 deletions(-)
[PATCH 0/6] cpufreq/amd-pstate: Dynamic EPP fixes
Posted by K Prateek Nayak 1 month ago
Few rare race conditions were found when testing the Dynamic EPP feature
on EPYC platforms:

o Toggling dynamic EPP is essentially a driver switch into the same mode
  and can race with an admin-initiated driver switch which can cause the
  system to hang.

o If a profile change / power supply status change races with the driver
  unloading, it can overwrite the Floor Perf restored in the CPPC_REQ
  register that was meant to be left untouched until the next driver
  load.

o When dynamic mode is disabled, the default EPP hint is set based on
  the power supply mode at the time of driver load which can cause the
  battery to drain faster when starting off from AC supply and then
  switching to battery.

When fixing and testing the above, a couple of incorrect error codes
were noted which is also fixed in the series along with the unit test.

Series is based on mainline at v7.1-rc2 release tag. Thanks to Mario for
initial review. Feedback is greatly appreciated.
---
K Prateek Nayak (6):
  cpufreq/amd-pstate: Grab "amd_pstate_driver_lock" when toggling
    dynamic_epp
  cpufreq/amd-pstate: Return -ENOMEM on failure to allocate profile_name
  cpufreq/amd-pstate: Allow writes to dynamic_epp when state isn't
    modified
  cpufreq/amd-pstate: Reorder notifier unregistration and floor perf
    reset
  cpufreq/amd-pstate: Use "epp_default_dc" as default when dynamic_epp
    is disabled
  cpufreq/amd-pstate-ut: Drop policy reference before driver switch

 drivers/cpufreq/amd-pstate-ut.c | 36 ++++++++++++++++++++++++++-------
 drivers/cpufreq/amd-pstate.c    | 23 ++++++++++++++++-----
 2 files changed, 47 insertions(+), 12 deletions(-)


base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32
-- 
2.34.1
Re: [PATCH 0/6] cpufreq/amd-pstate: Dynamic EPP fixes
Posted by Mario Limonciello 1 month ago

On 5/8/26 00:17, K Prateek Nayak wrote:
> Few rare race conditions were found when testing the Dynamic EPP feature
> on EPYC platforms:
> 
> o Toggling dynamic EPP is essentially a driver switch into the same mode
>    and can race with an admin-initiated driver switch which can cause the
>    system to hang.
> 
> o If a profile change / power supply status change races with the driver
>    unloading, it can overwrite the Floor Perf restored in the CPPC_REQ
>    register that was meant to be left untouched until the next driver
>    load.
> 
> o When dynamic mode is disabled, the default EPP hint is set based on
>    the power supply mode at the time of driver load which can cause the
>    battery to drain faster when starting off from AC supply and then
>    switching to battery.
> 
> When fixing and testing the above, a couple of incorrect error codes
> were noted which is also fixed in the series along with the unit test.
> 
> Series is based on mainline at v7.1-rc2 release tag. Thanks to Mario for
> initial review. Feedback is greatly appreciated.
> ---
> K Prateek Nayak (6):
>    cpufreq/amd-pstate: Grab "amd_pstate_driver_lock" when toggling
>      dynamic_epp
>    cpufreq/amd-pstate: Return -ENOMEM on failure to allocate profile_name
>    cpufreq/amd-pstate: Allow writes to dynamic_epp when state isn't
>      modified
>    cpufreq/amd-pstate: Reorder notifier unregistration and floor perf
>      reset
>    cpufreq/amd-pstate: Use "epp_default_dc" as default when dynamic_epp
>      is disabled
>    cpufreq/amd-pstate-ut: Drop policy reference before driver switch
> 
>   drivers/cpufreq/amd-pstate-ut.c | 36 ++++++++++++++++++++++++++-------
>   drivers/cpufreq/amd-pstate.c    | 23 ++++++++++++++++-----
>   2 files changed, 47 insertions(+), 12 deletions(-)
> 
> 
> base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32

Much appreciated.  I've staged these in amd-pstate-fixes and will send 
out the PR next week after more testing.