* [PATCH v1] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state()
@ 2026-11-19 19:56 Rafael J. Wysocki
0 siblings, 0 replies; only message in thread
From: Rafael J. Wysocki @ 2026-11-19 19:56 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Borah, Chaitanya Kumar, Srinivas Pandruvada
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Commit eee2a44e4e2b ("cpufreq: Improve suspend-resume synchronization")
caused lockdep to complain about a possible circular locking dependency
because intel_pstate_resume() is now called under cpus_read_lock, and it
calls set_power_ctl_ee_state() that acquires intel_pstate_driver_lock
which can be held around CPU hotplug locking.
Fortunately, this cannot lead to a real deadlock because
intel_pstate_resume() does not run in parallel with the other holders
of intel_pstate_driver_lock, but in fact set_power_ctl_ee_state() need
not use that particular lock either. Moreover, the original purpose of
that lock is different, so using it in set_power_ctl_ee_state() is
questionable.
Accordingly, introduce a dedicated mutex for protecting MSR_IA32_POWER_CTL
updates and power_ctl_ee_state accesses and make set_power_ctl_ee_state()
use it instead of intel_pstate_driver_lock. Also take it directly in
intel_pstate_resume() around the EE state restore.
Fixes: eee2a44e4e2b ("cpufreq: Improve suspend-resume synchronization")
Reported-by: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
Closes: https://lore.kernel.org/linux-pm/efcb1647-46fd-442a-bbda-283560d9df53@intel.com/
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/cpufreq/intel_pstate.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1351,13 +1351,14 @@ static void intel_pstate_hwp_offline(str
/* Enable bit for Dynamic Efficiency Control (DEC) */
#define POWER_CTL_DEC_ENABLE 27
+static DEFINE_MUTEX(power_ctl_update_lock);
static int power_ctl_ee_state;
-static void set_power_ctl_ee_state(bool input)
+static void __set_power_ctl_ee_state(bool input)
{
u64 power_ctl;
- guard(mutex)(&intel_pstate_driver_lock);
+ lockdep_assert_held(&power_ctl_update_lock);
rdmsrq(MSR_IA32_POWER_CTL, power_ctl);
if (input) {
@@ -1370,6 +1371,13 @@ static void set_power_ctl_ee_state(bool
wrmsrq(MSR_IA32_POWER_CTL, power_ctl);
}
+static void set_power_ctl_ee_state(bool input)
+{
+ guard(mutex)(&power_ctl_update_lock);
+
+ __set_power_ctl_ee_state(input);
+}
+
static void intel_pstate_hwp_enable(struct cpudata *cpudata);
static void intel_pstate_hwp_reenable(struct cpudata *cpu)
@@ -1398,11 +1406,13 @@ static int intel_pstate_resume(struct cp
pr_debug("CPU %d resuming\n", cpu->cpu);
- /* Only restore if the system default is changed */
- if (power_ctl_ee_state == POWER_CTL_EE_ENABLE)
- set_power_ctl_ee_state(true);
- else if (power_ctl_ee_state == POWER_CTL_EE_DISABLE)
- set_power_ctl_ee_state(false);
+ scoped_guard(mutex, &power_ctl_update_lock) {
+ /* Only restore if the system default has changed */
+ if (power_ctl_ee_state == POWER_CTL_EE_ENABLE)
+ __set_power_ctl_ee_state(true);
+ else if (power_ctl_ee_state == POWER_CTL_EE_DISABLE)
+ __set_power_ctl_ee_state(false);
+ }
if (cpu->suspended && hwp_active) {
mutex_lock(&intel_pstate_limits_lock);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-19 19:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 19:56 [PATCH v1] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state() Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®