Skip to content

Commit af59f2c

Browse files
committed
cpufreq: amd-pstate: cpufreq: amd-pstate: reset MSR_AMD_PERF_CTL register at init
Bugzilla: https://bugzilla.redhat.com/2150425 commit 919f455 Author: Wyes Karny <wyes.karny@amd.com> Date: Thu Nov 17 15:35:37 2022 +0800 cpufreq: amd-pstate: cpufreq: amd-pstate: reset MSR_AMD_PERF_CTL register at init MSR_AMD_PERF_CTL is guaranteed to be 0 on a cold boot. However, on a kexec boot, for instance, it may have a non-zero value (if the cpu was in a non-P0 Pstate). In such cases, the cores with non-P0 Pstates at boot will never be pushed to P0, let alone boost frequencies. Kexec is a common workflow for reboot on Linux and this creates a regression in performance. Fix it by explicitly setting the MSR_AMD_PERF_CTL to 0 during amd_pstate driver init. Cc: All applicable <stable@vger.kernel.org> Acked-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Tested-by: Wyes Karny <wyes.karny@amd.com> Signed-off-by: Wyes Karny <wyes.karny@amd.com> Signed-off-by: Perry Yuan <Perry.Yuan@amd.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent 8112d54 commit af59f2c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,22 @@ static void amd_pstate_boost_init(struct amd_cpudata *cpudata)
424424
amd_pstate_driver.boost_enabled = true;
425425
}
426426

427+
static void amd_perf_ctl_reset(unsigned int cpu)
428+
{
429+
wrmsrl_on_cpu(cpu, MSR_AMD_PERF_CTL, 0);
430+
}
431+
427432
static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
428433
{
429434
int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret;
430435
struct device *dev;
431436
struct amd_cpudata *cpudata;
432437

438+
/*
439+
* Resetting PERF_CTL_MSR will put the CPU in P0 frequency,
440+
* which is ideal for initialization process.
441+
*/
442+
amd_perf_ctl_reset(policy->cpu);
433443
dev = get_cpu_device(policy->cpu);
434444
if (!dev)
435445
return -ENODEV;

0 commit comments

Comments
 (0)