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=1796380347; b=rIEtcvziKzciWeNVvjm6JQXHXcF3IDTVGP5JjM0Xx95vaXEIre1rUATY4lWdHobSy3IS po51bpMfs9/hBYe3tFZwW0Gi9hSnsoYD3JoRekvBzpK1FHN/QfOfLqRXV0QcYTHFusRRs Uxy4JevXQAAtdTnj+IqjgK1GuKMP7Y69oETbJ4Pps+YV0gvzeen8gJLv9FcvbuLWRRGxP 10M+FnU45hVXlqxsnEyHLBCPRbOLhvexN49sO5ntmOi55jrdx4vNNgVLStZGWQlN3qrrE xbtdN7hz4DNtzLvyYA0xPetnwMZTBxgKeiDQ8EjnRjUekxEkCnqAx2agcAy5JgkRGXA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380347; 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=CHYRV/mHrpGVpcGqjXOcfUt1fUhreliIgRUgITEdZpU=; b=yJAfr8Iz2WGOtRRjfe7X5JHvx5eK5YXPg22hwJVB37MhIBDsDAqQJLNHUwpAWj391B04 /mfx+MfWnlRYOepFgrPAleBntIE0bh29skB7xNCR1Ak3xsImiD9aNP/xm1FpJYy3gbjdu T0d/mBxXUdw5LMnA+Wq5ChBGIH/PDfnMNap1qEGVJh/k3buxacjtXOXifEFQq1k+lpbFF vbRn7pV+RbV18N0VC0/vpzfTxjxER4Q3WcpArI2+V9FdgC9QZDtvsNCBc949lTdZxrWVl dZxDjgCyyJfHrAg5gLk4YhRjs16JxozrO0wHvw64O9/fXr6RFcxz3EN09embXcFTHbQ== 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=lyu4roWl; 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 E92EC606A337; Fri, 4 Dec 2026 10:32:26 +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=lyu4roWl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E8DC1F00A17; Fri, 4 Dec 2026 10:32:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380346; bh=CHYRV/mHrpGVpcGqjXOcfUt1fUhreliIgRUgITEdZpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lyu4roWlHyXVS3uDEoTViNQ/+3706K7z/PnVYBn7VtBsnjzPce0FBDSQpD0SBFdv5 17Gd23/+djU2OpS1wlBxsKjICyC/cCecpvypNDiXnqOh2c2wnl38rFpx5k3x+0x2BU gUpLaFLnKDMeuBNRRHx+JUGvnP22NWxD2+FM++f0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Borah, Chaitanya Kumar" , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 7.3 235/742] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state() Date: Fri, 4 Dec 2026 19:01:39 +0900 Message-ID: <20261204100641.311553455@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rafael J. Wysocki [ Upstream commit 569e1eb36b033f42a9c363ffe4bfbf50bdadae51 ] 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: Sasha Levin --- drivers/cpufreq/intel_pstate.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index d3650a6e37b54..05c0ba06e1e31 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1351,13 +1351,14 @@ static void intel_pstate_hwp_offline(struct cpudata *cpu) /* 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 input) 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 cpufreq_policy *policy) 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); -- 2.53.0