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=1796326231; b=CXIJv6WJpdV4Yady5/H6TR2x99LEnW1lgHI5BpZ9FpnTeL6uN90vJzsu5NXoo4WvFbH/ WniHNN6s2qTPX7yQQycIzs/1fspOVPEXRri8l+Ia/jt4JsT6QG57ppiSIzrSQEzVOnR/a 5kBCTNnsSCK2hS3eDLW96rXyfo00BK8C6dyLfZgIH3ln/qnTbubHUYHuJTM/WMMQ/FYrJ tLdvGR3XXKlqbHl2ralOo3HUNyieDtKr3pZ9cmgm4SRm59cFVtaxKHkcrefAsZQ1DGd0Y edr4YTqiEe0+psJGlpuultkhBkHXL6AzRq/HuoY7L3QlHIc9rTypzwQcGggZhgifScQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796326231; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=qtIgUfnJV/qSsBKpGB/ZJ/G5I4SugfLEPD/qC4Us9E0=; b=wIjdtkI1dVGp7SzywtiJVfcjgqHp/V6tTvvZQVnVQWVDXgwHDBXFaERKHzfk/7OY51Am REjMcej/zKp/FseNpvD1J+Yn7egr0yxjsTqdyMlXRkARCpYWUs/RERlBHiavs4mdL22tH q/nV7/R/74PhOp0P7Xtcekrurkl52a7Tb0YCokOI72RvZdpWeNjsBTeHi3ItOJ7iY1Fw0 araN9IciPSebjDTNF16JdG0SK8x/pj+9UbkXC+OHvglkiVCCwSn8c0k7gUkieFV5QHJXj +o3Oqyt1RLsdayY5zUTj460huaWdQVcdlodXMQVMRZmWcuLRzSy8bxIEiNac9D5JqEg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EYxLsykw; 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 4223A606A687 for ; Thu, 3 Dec 2026 19:30:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EYxLsykw Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50E071F000C2; Thu, 3 Dec 2026 19:30:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796326231; bh=qtIgUfnJV/qSsBKpGB/ZJ/G5I4SugfLEPD/qC4Us9E0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EYxLsykwmw97DKbLyJ0rBbg+nLYNWXL6USN9Hgy6D07bErc1qcSz4HilxSzL3AD9e WQaEvtjuAjbWg6wBnWKgH1iTW6SCFIQ4ckqDIYP4CaEAU4FtFxBUDz09xrhxtbdqyE 4ODb7Y8QVZ8AVbigMyG7aiS9WdR4G8qDnV2hMhMb5o+5e3DBYNmLoULivAk5eMp9dg ndOgvoV5t143BDnFkVYUgkUsTTqkQc7Vx1L3cVdLpjka1e489NGuGzWRcdx9sfLfy3 8BBslJ1EP3eOiBgeOty8TVbzxtCmBz0PJ7O4F8d+DLh4o7YRcuS2LeI3o6EwF7jm05 BK4MqysoN7Hrw== From: Sasha Levin To: stable@vger.kernel.org Cc: "Rafael J. Wysocki" , Viresh Kumar , Mario Limonciello , Sudeep Holla , Sasha Levin Subject: [PATCH 6.6.y 3/4] cpufreq: Add and use cpufreq policy locking guards Date: Thu, 3 Dec 2026 14:30:25 -0500 Message-ID: <20261203193010.628401-3-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261203193010.628401-1-sashal@kernel.org> References: <2026120247-residency-drab-33a4@gregkh> <20261203193010.628401-1-sashal@kernel.org> 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 From: "Rafael J. Wysocki" [ Upstream commit 6fec833b9d70c54ceacbf7d07665215fbd0cddef ] Introduce "read" and "write" locking guards for cpufreq policies and use them where applicable in the cpufreq core. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Viresh Kumar Reviewed-by: Mario Limonciello Acked-by: Sudeep Holla Tested-by: Sudeep Holla Link: https://patch.msgid.link/8518682.T7Z3S40VBb@rjwysocki.net Stable-dep-of: c5bdb8757372 ("cpufreq: Skip inactive policies in cpufreq_driver_target()") Signed-off-by: Sasha Levin --- drivers/cpufreq/cpufreq.c | 10 ++-------- include/linux/cpufreq.h | 6 ++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index fd30060927f32..18666cdf64d29 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2452,15 +2452,9 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { - int ret; - - down_write(&policy->rwsem); - - ret = __cpufreq_driver_target(policy, target_freq, relation); + guard(cpufreq_policy_write)(policy); - up_write(&policy->rwsem); - - return ret; + return __cpufreq_driver_target(policy, target_freq, relation); } EXPORT_SYMBOL_GPL(cpufreq_driver_target); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 03ea59ad0b2dc..eed53fec5f0ee 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -179,6 +179,12 @@ struct cpufreq_policy { struct notifier_block nb_max; }; +DEFINE_GUARD(cpufreq_policy_write, struct cpufreq_policy *, + down_write(&_T->rwsem), up_write(&_T->rwsem)) + +DEFINE_GUARD(cpufreq_policy_read, struct cpufreq_policy *, + down_read(&_T->rwsem), up_read(&_T->rwsem)) + /* * Used for passing new cpufreq policy data to the cpufreq driver's ->verify() * callback for sanitization. That callback is only expected to modify the min -- 2.53.0