]> git.hungrycats.org Git - linux/commit
cpufreq/amd-pstate: Grab "amd_pstate_driver_lock" when toggling dynamic_epp
authorK Prateek Nayak <kprateek.nayak@amd.com>
Fri, 8 May 2026 05:17:43 +0000 (05:17 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Sep 2026 11:36:16 +0000 (13:36 +0200)
commitc6584e98b60ee64bc3e8b2739b2ef101ea5f4bc1
tree36589b0a95e71475f0100bb5dfe74c122f93da08
parenteee67e91751e093ed51da6ec5e737151c777af91
cpufreq/amd-pstate: Grab "amd_pstate_driver_lock" when toggling dynamic_epp

[ Upstream commit 9228169d2ae055ed09a163887fc59a710a5eb73b ]

Concurrently changing driver mode and dynamic_epp with:

    echo passive > /sys/devices/system/cpu/amd_pstate/status&
    echo disable > /sys/devices/system/cpu/amd_pstate/dynamic_epp&

hits the WARN_ON_ONCE() in static_key_disable_cpuslocked() and hangs the
system since both sysfs writes are trying to do
amd_pstate_change_driver_mode() without any synchronization.

Grab the "amd_pstate_driver_lock" mutex when modifying "dynamic_epp" to
prevent the two paths from racing with each other. Add a lockdep
assertion for "amd_pstate_driver_lock" in
amd_pstate_change_driver_mode() to formalize the dependency.

Since "cppc_mode" is stable under "amd_pstate_driver_lock", only reload
the driver when in "AMD_PSTATE_ACTIVE" mode and reject all writes when
in passive or guided mode, or if the driver is not loaded, since only
active mode operates on EPP.

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-2-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