From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384235; b=Hk9KWivi53rwp5PqxD0mnToy0Acx7tEEFnmscSCaw/VQQAA1ZNyT94TGOzm1kKoe1f4F znJyGeIErKeCoXtnNw2qlutOmvzFoGnGg7Z+vYkuBbgtPiMldpjU79WXjk5D7Q8v38HBc HxXl4K9BWKh52ZLY0ywacxRusAyBpVmLFxoWitm5xtFIbX9dbiR5YUR99Nn59AV2jeHL2 fiE9ZddVnzG4v6XIIE1xqNm9E6BiPEUwPuvv87M8ukePbv4Od4mH/eqjUvDhoV+GUDpAl QUEEICmR7wKWh0DVNphSFiZ+7Gr8dYIVV9ye6qKd4uw+pggtnPtOAmwvsgXL/BpVcZQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384235; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=1I9eeDpAlv0d8ULzknhdodmUl4BLoBTuA3cXCwuhlaA=; b=admoBUx2jkkw7/AU3M8NHJS/bAP9+kbQCnysWFtJoXQ3xkaMM++77Im3kQEFoAHZql+S zp3mZy6f7FrGEp+2Yhz44U5MnHb4HJ+svC7obDKWUP/zH0NttiTeaASnQEknsA4ccRXts ssr52bVX5aBORaqLLgIUpmBYC+PuFUDhw6wbGQIqPwv7fvRInViJ0rOA4L+0WgJpf1mYk mmgK+YrmLvb3x7LuVc/gRz3hNk1khtlAV4YQWG9mRMm2Yj8ARl4byP7FtcLRbioo7awWY 5W37FyDV3W0auqgoKc2WR2ImDq2+oRKb9S06r2l49Z2qt84opIBxFvjbLaHTVAdwzOQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=qKaKVAHG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3670606A32C; Fri, 4 Dec 2026 11:37:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=qKaKVAHG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A31C1F000C2; Fri, 4 Dec 2026 11:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384235; bh=1I9eeDpAlv0d8ULzknhdodmUl4BLoBTuA3cXCwuhlaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qKaKVAHGj0A575RLi0uWfRvhsL3UOyioTexv9QinNhycvXd3iVnxvpgCJx4wCKz+V ojL0wZMKF8cAbKJGpAKe31omi+lHCOdMfTHfVXuUNdDN6lJx3+xp0LjZ/b1FrxPoag ydvHmaH4k1T/8Nf0K95m/uIFMYQP5Z8+Qze4RNok= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Borah, Chaitanya Kumar" , "Rafael J. Wysocki" Subject: [PATCH 6.12 555/555] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state() Date: Fri, 4 Dec 2026 19:09:58 +0900 Message-ID: <20261204100629.647494110@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rafael J. Wysocki commit 569e1eb36b033f42a9c363ffe4bfbf50bdadae51 upstream. 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" Closes: https://lore.kernel.org/linux-pm/efcb1647-46fd-442a-bbda-283560d9df53@intel.com/ Signed-off-by: Rafael J. Wysocki Link: https://patch.msgid.link/2862244.mvXUDI8C0e@rafael.j.wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/intel_pstate.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1276,13 +1276,15 @@ static void intel_pstate_hwp_offline(str #define POWER_CTL_EE_ENABLE 1 #define POWER_CTL_EE_DISABLE 2 +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; - mutex_lock(&intel_pstate_driver_lock); + lockdep_assert_held(&power_ctl_update_lock); + rdmsrl(MSR_IA32_POWER_CTL, power_ctl); if (input) { power_ctl &= ~BIT(MSR_IA32_POWER_CTL_BIT_EE); @@ -1292,7 +1294,13 @@ static void set_power_ctl_ee_state(bool power_ctl_ee_state = POWER_CTL_EE_DISABLE; } wrmsrl(MSR_IA32_POWER_CTL, power_ctl); - mutex_unlock(&intel_pstate_driver_lock); +} + +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); @@ -1323,11 +1331,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);