From: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>
Cc: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>,
Christian Loehle <christian.loehle@arm.com>,
Ananthu C V <ananthu.cv@oss.qualcomm.com>,
Pierre Gondois <pierre.gondois@arm.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
Subject: [PATCH v4] cpufreq: Keep global boost enabled after partial enable
Date: Fri, 27 Nov 2026 17:05:08 +0800 [thread overview]
Message-ID: <20261127090513.910723-1-jiangtianfeng@linux.alibaba.com> (raw)
In-Reply-To: <20261127060407.732709-1-jiangtianfeng@linux.alibaba.com>
When global boost is enabled from the disabled state, a failure after
one or more policies have been updated successfully currently restores
the global flag to 0 without rolling back those policies. This leaves
them locally enabled, with their boost-related driver/QoS updates
retained, while the global flag rejects per-policy sysfs writes.
Keep the global flag enabled if at least one policy_set_boost() call
succeeded, while preserving the existing error return path. Global
boost = 1 grants permission to boost; it does not require every policy
to have boost enabled. The mixed per-policy state is therefore valid
and individual policies remain accessible through per-policy sysfs.
Restore the previous global state on disable and when no policy was
enabled successfully. After a partial enable, keep global boost enabled
so users can repair individual policies through sysfs. Do not roll back
earlier policy updates.
Qoder, an AI coding assistant, helped analyze the issue, develop the fix
and state matrix, and draft this description.
Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost")
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
---
A failed write of 1 can leave the global flag readable as 1 when at
least one policy was enabled successfully. The write still returns an
error, and the resulting mixed per-policy state remains valid and locally
repairable.
Changes in v4:
- Drop the RFC prefix after review and add Zhongqiu's Reviewed-by.
- Remove the human-review/DCO-process note from the posting.
- No code changes from v3.
- Link: https://lore.kernel.org/linux-pm/20261127060407.732709-1-jiangtianfeng@linux.alibaba.com/
Changes in v3:
- Correct the changelog and comment to describe restoration on disable
or when no policy was enabled successfully, and local repair after a
partial enable.
- No code-logic change from v2.
- Link: https://lore.kernel.org/linux-pm/20261127014937.413500-1-jiangtianfeng@linux.alibaba.com/
Changes in v2:
- Remove goto/out_err from the function using cleanup guards.
- Simplify the restoration condition to !state || !policy_success.
- Link: https://lore.kernel.org/linux-pm/20261126110903.3747240-1-jiangtianfeng@linux.alibaba.com/
No normal in-tree trigger for the partial-enable sequence has been
identified. Same-state global writes already provide a resynchronization
mechanism. The same-state disable/resync failure noted by Zhongqiu is
left for separate discussion instead of expanding this patch.
Validation (unchanged code from v3):
- mainline ARM64 defconfig build of the complete Image
- checkpatch.pl
- eight-case old-global/request/success state matrix
- independent static control-flow and locking review
NOT_RUN:
- runtime fault injection or reproduction with multiple policies
- global/local concurrency, hotplug, lockdep or KCSAN testing
- CPPC, SW frequency-table, ACPI or AMD hardware frequency/QoS testing
drivers/cpufreq/cpufreq.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 4332cb114070..57f1874e087a 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2887,6 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
struct cpufreq_policy *policy;
unsigned long flags;
bool boost_enabled;
+ bool policy_success = false;
int ret = -EOPNOTSUPP;
guard(mutex)(&cpufreq_boost_mutex);
@@ -2911,6 +2912,8 @@ static int cpufreq_boost_trigger_state(int state)
ret = policy_set_boost(policy, state);
if (unlikely(ret))
break;
+
+ policy_success = true;
}
cpus_read_unlock();
@@ -2918,9 +2921,12 @@ static int cpufreq_boost_trigger_state(int state)
if (likely(!ret))
return 0;
- write_lock_irqsave(&cpufreq_driver_lock, flags);
- cpufreq_driver->boost_enabled = boost_enabled;
- write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ /* On failure, restore old state unless partial enable needs local repair. */
+ if (!state || !policy_success) {
+ write_lock_irqsave(&cpufreq_driver_lock, flags);
+ cpufreq_driver->boost_enabled = boost_enabled;
+ write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ }
pr_err("%s: Cannot %s BOOST\n",
__func__, str_enable_disable(state));
--
2.47.3
prev parent reply other threads:[~2026-11-27 9:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 11:08 [RFC PATCH] " Jiangtian Feng
2026-11-26 15:07 ` Christian Loehle
2026-11-27 5:59 ` Jiangtian Feng
2026-11-26 15:09 ` Zhongqiu Han
2026-11-27 5:59 ` Jiangtian Feng
2026-11-27 1:49 ` [RFC PATCH v2] " Jiangtian Feng
2026-11-27 3:41 ` Zhongqiu Han
2026-11-27 5:59 ` Jiangtian Feng
2026-11-27 6:03 ` [RFC PATCH v3] " Jiangtian Feng
2026-11-27 6:54 ` Zhongqiu Han
2026-11-27 8:23 ` Jiangtian Feng
2026-11-27 9:05 ` Jiangtian Feng [this message]
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=20261127090513.910723-1-jiangtianfeng@linux.alibaba.com \
--to=jiangtianfeng@linux.alibaba.com \
--cc=ananthu.cv@oss.qualcomm.com \
--cc=christian.loehle@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pierre.gondois@arm.com \
--cc=rafael@kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=zhongqiu.han@oss.qualcomm.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®