From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
"Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [PATCH v1] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state()
Date: Thu, 19 Nov 2026 20:56:34 +0100 [thread overview]
Message-ID: <2862244.mvXUDI8C0e@rafael.j.wysocki> (raw)
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);
reply other threads:[~2026-11-19 19:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2862244.mvXUDI8C0e@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=chaitanya.kumar.borah@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®