]> git.hungrycats.org Git - linux/commitdiff
cpufreq/amd-pstate: Reorder notifier unregistration and floor perf reset
authorK Prateek Nayak <kprateek.nayak@amd.com>
Fri, 8 May 2026 05:17:46 +0000 (05:17 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Sep 2026 11:36:16 +0000 (13:36 +0200)
[ Upstream commit f3acf7ff113007557538b278ccb0e4ab7ae513ea ]

An active power supply notifier can race with amd_pstate_epp_cpu_exit()
trying to reset the floor perf and can overwrite the floor perf set in
MSR_AMD_CPPC_REQ.

Unregister the notifier before setting the floor perf to prevent the
rare race.

Fixes: e30ca6dd5345 ("cpufreq/amd-pstate: Add dynamic energy performance preference")
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://lore.kernel.org/r/20260508051748.10484-5-kprateek.nayak@amd.com
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/cpufreq/amd-pstate.c

index 627d578c7e13ab2f8ccfea2db4a0fd2cb381d6a8..1e14e974641c38df492dd8b330db9c02368512f1 100644 (file)
@@ -1841,11 +1841,12 @@ static void amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy)
        if (cpudata) {
                union perf_cached perf = READ_ONCE(cpudata->perf);
 
+               if (cpudata->dynamic_epp)
+                       amd_pstate_clear_dynamic_epp(policy);
+
                /* Reset CPPC_REQ MSR to the BIOS value */
                amd_pstate_update_perf(policy, perf.bios_min_perf, 0U, 0U, 0U, false);
 
-               if (cpudata->dynamic_epp)
-                       amd_pstate_clear_dynamic_epp(policy);
                kfree(cpudata);
                policy->driver_data = NULL;
        }