Skip to contentSkip to conversation

cpufreq: amd-pstate: reset MSR_AMD_PERF_CTL register while driver loading

PATCH New Perry Yuan 1 participant 1 message Nov 16, 2022 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Perry Yuan

author reviewer
#1 lore raw

PATCH v3 5/6 cpufreq: amd-pstate: reset MSR_AMD_PERF_CTL register while driver loading

From: Wyes Karny <[email protected]>

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.

---
 drivers/cpufreq/amd-pstate.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/cpufreq/amd-pstate.c +6 -0
index 1ffb97b6dbe2..0057ad5dfa97 100644
@@ -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;
Signature · 1 line
2.25.1