Re: [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable
From: Pengjie Zhang
Date: Mon Nov 30 2026 - 08:51:19 EST
On 11/30/2026 7:13 PM, Jiangtian Feng wrote:
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@xxxxxxxxxxxxxxxx>
Signed-off-by: Jiangtian Feng <jiangtianfeng@xxxxxxxxxxxxxxxxx>
---
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 f83fc6e40fbe..3d8927cc9787 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2888,6 +2888,7 @@ static int cpufreq_boost_trigger_state(int state)
unsigned long flags;
bool boost_enabled;
bool any_boost_supported = false;
+ bool policy_success = false;
int ret = 0;
guard(mutex)(&cpufreq_boost_mutex);
@@ -2915,6 +2916,8 @@ static int cpufreq_boost_trigger_state(int state)
ret = policy_set_boost(policy, state);
if (unlikely(ret))
break;
+
+ policy_success = true;
}
if (!any_boost_supported)
@@ -2925,9 +2928,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));
Reviewed-by: Pengjie Zhang<zhangpengjie2@xxxxxxxxxx>