Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq/amd-pstate: Push adjust_perf vfunc init into cpu_init

As the driver can be changed in and out of different modes it's possible
that adjust_perf is assigned when it shouldn't be.

This could happen if an MSR design is started up in passive mode and then
switches to active mode.

To solve this explicitly clear `adjust_perf` in amd_pstate_epp_cpu_init().

Tested-by: Klara Modin <klarasmodin@gmail.com>
Tested-by: Dhananjay Ugwekar <dhananjay.ugwekar@amd.com>
Link: https://lore.kernel.org/r/20241028145542.1739160-1-superm1@kernel.org
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

+2 -2
+2 -2
drivers/cpufreq/amd-pstate.c
··· 1504 1504 WRITE_ONCE(cpudata->cppc_cap1_cached, value); 1505 1505 } 1506 1506 1507 + current_pstate_driver->adjust_perf = NULL; 1508 + 1507 1509 return 0; 1508 1510 1509 1511 free_cpudata1: ··· 1868 1866 /* capability check */ 1869 1867 if (cpu_feature_enabled(X86_FEATURE_CPPC)) { 1870 1868 pr_debug("AMD CPPC MSR based functionality is supported\n"); 1871 - if (cppc_state != AMD_PSTATE_ACTIVE) 1872 - current_pstate_driver->adjust_perf = amd_pstate_adjust_perf; 1873 1869 } else { 1874 1870 pr_debug("AMD CPPC shared memory based functionality is supported\n"); 1875 1871 static_call_update(amd_pstate_cppc_enable, shmem_cppc_enable);