From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Mario Limonciello <mario.limonciello@amd.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6.y 3/4] cpufreq: Add and use cpufreq policy locking guards
Date: Thu, 3 Dec 2026 14:30:25 -0500 [thread overview]
Message-ID: <20261203193010.628401-3-sashal@kernel.org> (raw)
In-Reply-To: <20261203193010.628401-1-sashal@kernel.org>
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
[ 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 <rafael.j.wysocki@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Tested-by: Sudeep Holla <sudeep.holla@arm.com>
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 <sashal@kernel.org>
---
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
next prev parent reply other threads:[~2026-12-03 19:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 12:59 FAILED: patch "[PATCH] cpufreq: Skip inactive policies in cpufreq_driver_target()" failed to apply to 6.6-stable tree gregkh
2026-12-03 19:30 ` [PATCH 6.6.y 1/4] cpufreq: Consolidate some code in cpufreq_online() Sasha Levin
2026-12-03 19:30 ` [PATCH 6.6.y 2/4] cpufreq: Split cpufreq_online() Sasha Levin
2026-12-03 19:30 ` Sasha Levin [this message]
2026-12-03 19:30 ` [PATCH 6.6.y 4/4] cpufreq: Skip inactive policies in cpufreq_driver_target() Sasha Levin
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=20261203193010.628401-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=mario.limonciello@amd.com \
--cc=rafael.j.wysocki@intel.com \
--cc=stable@vger.kernel.org \
--cc=sudeep.holla@arm.com \
--cc=viresh.kumar@linaro.org \
/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