From: Wyes Karny wyes.karny@amd.com
MSR_AMD_PERF_CTL register should be reseted while initializing the amd_pstate driver. On a running system, if we switch the cpufreq driver from acpi_cpufreq to amd_pstate, we see the following issue: There is no frequency change on cores which were previously running at a non-zero pstate. Hence, reset the pstate to zero on all the cores during the initialization of the amd_pstate driver to avoid performance drop.
While the AMD_PERF_CTL MSR is guaranteed to be set to 0 on a cold boot, the same is not true for a kexec boot, which is a very common mode of switching kernels/reboot in MDCs and Ubuntu.
Signed-off-by: Wyes Karny wyes.karny@amd.com Signed-off-by: Perry Yuan Perry.Yuan@amd.com Cc: stable@vger.kernel.org --- drivers/cpufreq/amd-pstate.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 1ffb97b6dbe2..0057ad5dfa97 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -420,12 +420,18 @@ static void amd_pstate_boost_init(struct amd_cpudata *cpudata) amd_pstate_driver.boost_enabled = true; }
+static void amd_perf_ctl_reset(unsigned int cpu) +{ + wrmsrl_on_cpu(cpu, MSR_AMD_PERF_CTL, 0); +} + static int amd_pstate_cpu_init(struct cpufreq_policy *policy) { int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret; struct device *dev; struct amd_cpudata *cpudata;
+ amd_perf_ctl_reset(policy->cpu); dev = get_cpu_device(policy->cpu); if (!dev) return -ENODEV;