]> git.ipfire.org Git - thirdparty/kernel/linux.git/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)
committerMario Limonciello (AMD) <superm1@kernel.org>
Fri, 8 May 2026 05:30:50 +0000 (00:30 -0500)
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>
drivers/cpufreq/amd-pstate.c

index 462ddad7bc79e5d5ee4e5bb0040c1c78ffe76c24..175925762a93cfffd6ce00c1da160916416eadf4 100644 (file)
@@ -1982,12 +1982,13 @@ 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);
                amd_pstate_set_floor_perf(policy, cpudata->bios_floor_perf);
 
-               if (cpudata->dynamic_epp)
-                       amd_pstate_clear_dynamic_epp(policy);
                kfree(cpudata);
                policy->driver_data = NULL;
        }