* [PATCH v6 0/2] cpufreq: Keep global boost enabled after partial enable
@ 2026-12-01 2:29 Jiangtian Feng
2026-12-01 2:30 ` [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies Jiangtian Feng
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Jiangtian Feng @ 2026-12-01 2:29 UTC (permalink / raw)
To: rafael, viresh.kumar
Cc: linux-pm, linux-kernel, zhongqiu.han, christian.loehle,
ananthu.cv, pierre.gondois, zhangpengjie2, zhenglifeng1, zhanjie9
This series treats global boost as a persistent permission that userspace
can configure even when no active policy currently supports boost.
The first patch initializes ret to 0 so the no-active-capable-policy case
records the requested setting and returns success. The active-policy loop
is unchanged: active, boost-capable policies are still updated through
policy_set_boost(), and real callback failures are preserved. This
intentionally removes the no-policy -EOPNOTSUPP result introduced by
77cf053b041f, which userspace sees as an -EINVAL write failure.
This also handles the CPPC default-enabled case: userspace can disable
boost before a capable policy becomes available instead of having a failed
write leave the global permission enabled.
The second patch is the existing partial-enable change. If enabling at
least one policy succeeds before a later failure, global boost remains
enabled so that the valid mixed per-policy state remains locally
repairable. Disable and no-success failure paths retain their previous
behavior.
Base: Linux v7.4-rc5
fe6ff8d5d675c01793b9f051d16055dd4aa75244
Changes in v6:
- Simplify patch 1 to ret = 0, restore for_each_active_policy(), and drop
the v5 any_boost_supported tracking.
- Explicitly document the intentional no-policy ABI change from
77cf053b041f and the CPPC default-enabled motivation.
- Keep patch 2 code unchanged and add Pengjie's Reviewed-by.
Previous version:
https://lore.kernel.org/all/20261130111348.363810-1-jiangtianfeng@linux.alibaba.com/
Pengjie's default-enabled review:
https://lore.kernel.org/all/467b9ef5-1fc3-4771-9895-363e815670c7@huawei.com/
CPPC default boost change:
https://lore.kernel.org/all/20261118013558.3075038-1-zhangpengjie2@huawei.com/
Validation:
- ARM64 W=1 build of drivers/cpufreq/cpufreq.o with Buildroot GCC 13.3.0
and binutils 2.43.1.
- Complete ARM64 Image build; size 43,010,560 bytes, SHA-256
d8bd08acc9584356805575d8b7fcbf758b85d2173787df23c11c71faf4525953.
- Static state-matrix and policy-list locking/lifetime review covering
no-policy, no-support, inactive-capable, active success/failure,
partial-enable and subsequent online behavior.
- Independent review found no High/Medium/Low functional code issue in the
two-patch candidate; the commit-description findings were corrected.
- Final signed patches: checkpatch 0 errors and 0 warnings for both patches.
NOT_RUN:
- CPU hotplug, suspend/resume, driver unregister/global-write concurrency,
lockdep and KCSAN testing.
- CPPC, ACPI, AMD and ARM hardware frequency/QoS testing.
- Runtime fault injection for policy_set_boost() failures.
- The existing policy-online callback-failure handling is unchanged and is
not claimed to be fixed by this series.
Qoder, an AI coding assistant, helped analyze the review history, design
and draft the preparatory change, and review the state matrix and failure
paths. The submitter reviewed the resulting changes and is responsible for
the final validation and submission.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies
2026-12-01 2:29 [PATCH v6 0/2] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
@ 2026-12-01 2:30 ` Jiangtian Feng
2026-12-02 16:34 ` Christian Loehle
` (3 more replies)
2026-12-01 2:30 ` [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
2026-12-03 10:13 ` [PATCH v6 0/2] " Zhongqiu Han
2 siblings, 4 replies; 10+ messages in thread
From: Jiangtian Feng @ 2026-12-01 2:30 UTC (permalink / raw)
To: rafael, viresh.kumar
Cc: linux-pm, linux-kernel, zhongqiu.han, christian.loehle,
ananthu.cv, pierre.gondois, zhangpengjie2, zhenglifeng1, zhanjie9,
Jiangtian Feng
Global boost grants permission to use boost; it does not require boost to
be active on every policy. Saving that permission should not depend on at
least one boost-capable policy being active when the global knob is
written.
Since commit 77cf053b041f ("cpufreq: Return -EOPNOTSUPP if no policy
supports boost"), cpufreq_boost_trigger_state() returns -EOPNOTSUPP when
the active-policy loop has no boost-capable policy, and store_boost() maps
that error to -EINVAL for the global sysfs write. Besides rejecting an
otherwise valid preconfiguration, this prevents users from disabling boost
before a capable policy becomes active when a driver starts with boost
enabled by default.
Initialize ret to 0 so the no-active-capable-policy case saves the
requested global state and returns success. Continue to call
policy_set_boost() for every active, boost-capable policy and preserve
all real callback failures. This intentionally changes the no-policy
result introduced by 77cf053b041f.
Link: https://lore.kernel.org/all/467b9ef5-1fc3-4771-9895-363e815670c7@huawei.com/
Qoder, an AI coding assistant, helped analyze the default-enabled case,
review the active-policy/error semantics and draft this change and
description. Runtime hardware and hotplug behavior remain subject to
final review and validation.
Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
---
drivers/cpufreq/cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 4332cb114070..e97838e40a54 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2887,7 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
struct cpufreq_policy *policy;
unsigned long flags;
bool boost_enabled;
- int ret = -EOPNOTSUPP;
+ int ret = 0;
guard(mutex)(&cpufreq_boost_mutex);
--
2.47.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable
2026-12-01 2:29 [PATCH v6 0/2] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
2026-12-01 2:30 ` [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies Jiangtian Feng
@ 2026-12-01 2:30 ` Jiangtian Feng
2026-12-02 16:35 ` Christian Loehle
2026-12-03 10:53 ` Viresh Kumar
2026-12-03 10:13 ` [PATCH v6 0/2] " Zhongqiu Han
2 siblings, 2 replies; 10+ messages in thread
From: Jiangtian Feng @ 2026-12-01 2:30 UTC (permalink / raw)
To: rafael, viresh.kumar
Cc: linux-pm, linux-kernel, zhongqiu.han, christian.loehle,
ananthu.cv, pierre.gondois, zhangpengjie2, zhenglifeng1, zhanjie9,
Jiangtian Feng
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>
Reviewed-by: Pengjie Zhang <zhangpengjie2@huawei.com>
Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
---
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 e97838e40a54..d998ea0ed43c 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 = 0;
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies
2026-12-01 2:30 ` [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies Jiangtian Feng
@ 2026-12-02 16:34 ` Christian Loehle
2026-12-03 10:13 ` Zhongqiu Han
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Christian Loehle @ 2026-12-02 16:34 UTC (permalink / raw)
To: Jiangtian Feng, rafael, viresh.kumar
Cc: linux-pm, linux-kernel, zhongqiu.han, ananthu.cv, pierre.gondois,
zhangpengjie2, zhenglifeng1, zhanjie9
On 12/1/26 02:30, Jiangtian Feng wrote:
> Global boost grants permission to use boost; it does not require boost to
> be active on every policy. Saving that permission should not depend on at
> least one boost-capable policy being active when the global knob is
> written.
>
> Since commit 77cf053b041f ("cpufreq: Return -EOPNOTSUPP if no policy
> supports boost"), cpufreq_boost_trigger_state() returns -EOPNOTSUPP when
> the active-policy loop has no boost-capable policy, and store_boost() maps
> that error to -EINVAL for the global sysfs write. Besides rejecting an
> otherwise valid preconfiguration, this prevents users from disabling boost
> before a capable policy becomes active when a driver starts with boost
> enabled by default.
>
> Initialize ret to 0 so the no-active-capable-policy case saves the
> requested global state and returns success. Continue to call
> policy_set_boost() for every active, boost-capable policy and preserve
> all real callback failures. This intentionally changes the no-policy
> result introduced by 77cf053b041f.
>
> Link: https://lore.kernel.org/all/467b9ef5-1fc3-4771-9895-363e815670c7@huawei.com/
>
> Qoder, an AI coding assistant, helped analyze the default-enabled case,
> review the active-policy/error semantics and draft this change and
> description. Runtime hardware and hotplug behavior remain subject to
> final review and validation.
>
> Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
> ---
> drivers/cpufreq/cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 4332cb114070..e97838e40a54 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2887,7 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
> struct cpufreq_policy *policy;
> unsigned long flags;
> bool boost_enabled;
> - int ret = -EOPNOTSUPP;
> + int ret = 0;
>
> guard(mutex)(&cpufreq_boost_mutex);
>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable
2026-12-01 2:30 ` [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
@ 2026-12-02 16:35 ` Christian Loehle
2026-12-03 10:53 ` Viresh Kumar
1 sibling, 0 replies; 10+ messages in thread
From: Christian Loehle @ 2026-12-02 16:35 UTC (permalink / raw)
To: Jiangtian Feng, rafael, viresh.kumar
Cc: linux-pm, linux-kernel, zhongqiu.han, ananthu.cv, pierre.gondois,
zhangpengjie2, zhenglifeng1, zhanjie9
On 12/1/26 02:30, 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@oss.qualcomm.com>
> Reviewed-by: Pengjie Zhang <zhangpengjie2@huawei.com>
> Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
> ---
> 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 e97838e40a54..d998ea0ed43c 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 = 0;
>
> 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));
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6 0/2] cpufreq: Keep global boost enabled after partial enable
2026-12-01 2:29 [PATCH v6 0/2] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
2026-12-01 2:30 ` [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies Jiangtian Feng
2026-12-01 2:30 ` [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
@ 2026-12-03 10:13 ` Zhongqiu Han
2 siblings, 0 replies; 10+ messages in thread
From: Zhongqiu Han @ 2026-12-03 10:13 UTC (permalink / raw)
To: Jiangtian Feng, rafael, viresh.kumar
Cc: linux-pm, linux-kernel, christian.loehle, ananthu.cv,
pierre.gondois, zhangpengjie2, zhenglifeng1, zhanjie9,
Zhongqiu Han
On 12/1/2026 10:29 AM, Jiangtian Feng wrote:
> This series treats global boost as a persistent permission that userspace
> can configure even when no active policy currently supports boost.
>
> The first patch initializes ret to 0 so the no-active-capable-policy case
> records the requested setting and returns success. The active-policy loop
> is unchanged: active, boost-capable policies are still updated through
> policy_set_boost(), and real callback failures are preserved. This
> intentionally removes the no-policy -EOPNOTSUPP result introduced by
> 77cf053b041f, which userspace sees as an -EINVAL write failure.
>
> This also handles the CPPC default-enabled case: userspace can disable
> boost before a capable policy becomes available instead of having a failed
> write leave the global permission enabled.
>
> The second patch is the existing partial-enable change. If enabling at
> least one policy succeeds before a later failure, global boost remains
> enabled so that the valid mixed per-policy state remains locally
> repairable. Disable and no-success failure paths retain their previous
> behavior.
Behavior change of this series relative to the current code, based on
code reading and QEMU testing (with a fake cpufreq driver that injects
->set_boost() failures):
The result of a global boost write depends on whether, at the time of
the write, there is any policy that is active (at least one CPU online)
and supports boost.
1. None: no policy supports boost, or all boost-capable policies are
offline.
- Currently: writing 0 and writing 1 both return -EINVAL (even if
the value is unchanged), and global boost is restored to its previous
value. Userspace cannot change it; e.g. if it defaults to 1, it cannot
be turned off.
- With patch 1: the write succeeds and reads back the written value,
but it is only a permission. No policy is changed at write time; boost
capable policies are handled by cpufreq_online() (unchanged by this
series) when they come online. Writing 0 applies to every policy that
comes online afterwards. Writing 1 applies only to newly created
policies; a re-onlined policy keeps the value it had before going
offline. If no policy supports boost, the write only changes the value
read back.
2. Some: at least one policy is active and supports boost.
- Currently: policies are set one by one in order (a policy already
at the value counts as success). Offline policies are skipped and are
likewise handled by cpufreq_online() when they come online. The loop
stops at the first failure and returns -EINVAL. Policies already updated
are not rolled back, and global boost is restored to its previous value.
If writing 1 fails after some policy was already set to 1, global boost
is left at 0 while those policies remain boosted. Their own boost files
cannot change them; options include writing global 0 (which
disables all) or writing 1 again after the fault is cleared.
- With patch 2: only a failed write of 1 changes. If some policy was
set to 1 successfully before the failure (including one that was
already 1), global boost stays 1, but -EINVAL is still returned;
otherwise the previous value is restored. Writing 0 behaves as before.
Patch 1 only changes case 1, patch 2 only changes case 2, and the two
are functionally independent.
>
> Base: Linux v7.4-rc5
> fe6ff8d5d675c01793b9f051d16055dd4aa75244
>
> Changes in v6:
> - Simplify patch 1 to ret = 0, restore for_each_active_policy(), and drop
> the v5 any_boost_supported tracking.
> - Explicitly document the intentional no-policy ABI change from
> 77cf053b041f and the CPPC default-enabled motivation.
> - Keep patch 2 code unchanged and add Pengjie's Reviewed-by.
>
> Previous version:
> https://lore.kernel.org/all/20261130111348.363810-1-jiangtianfeng@linux.alibaba.com/
>
> Pengjie's default-enabled review:
> https://lore.kernel.org/all/467b9ef5-1fc3-4771-9895-363e815670c7@huawei.com/
>
> CPPC default boost change:
> https://lore.kernel.org/all/20261118013558.3075038-1-zhangpengjie2@huawei.com/
Just for review reference, here is how I understand the revision history:
v6
- P1: initialize ret to 0, so that a global write of 0/1 succeeds when
there is no active boost-capable policy, instead of returning the
-EOPNOTSUPP introduced by 77cf053b041f; when CPPC enables boost by
default [1], userspace can write 0 to disable it (Pengjie)
- Drop the for_each_policy() walk and any_boost_supported that v5 used
to decide whether to return -EOPNOTSUPP; the loop goes back to
for_each_active_policy(); relative to mainline, P1 only changes
ret = 0
- P2: no code change, add Pengjie's Reviewed-by
-
https://lore.kernel.org/all/20261201023001.1131130-1-jiangtianfeng@linux.alibaba.com/
v5
- New P1: allow the global write when all boost-capable policies are
inactive; still return the -EOPNOTSUPP from 77cf053b041f when no
policy supports boost at all (Pengjie)
- P2: no logic change
-
https://lore.kernel.org/all/20261130111348.363810-1-jiangtianfeng@linux.alibaba.com/
v4
- Drop RFC, add Zhongqiu's Reviewed-by, no code change
-
https://lore.kernel.org/all/20261127090513.910723-1-jiangtianfeng@linux.alibaba.com/
RFC v3
- Reword the changelog (drop the "same-state resynchronization" wording
left over from v1) and the code comment (left over from v1's goto
branch) to match the code (Zhongqiu)
- Add version change notes and links to the previous versions (Zhongqiu)
- No logic change
-
https://lore.kernel.org/all/20261127060407.732709-1-jiangtianfeng@linux.alibaba.com/
RFC v2
- Drop the goto since the function uses guard(); simplify the restore
condition to !state || !policy_success (Zhongqiu)
-
https://lore.kernel.org/all/20261127014937.413500-1-jiangtianfeng@linux.alibaba.com/
RFC v1
-
https://lore.kernel.org/all/20261126110903.3747240-1-jiangtianfeng@linux.alibaba.com/
[1] CPPC default boost change:
https://lore.kernel.org/all/20261118013558.3075038-1-zhangpengjie2@huawei.com/
>
> Validation:
> - ARM64 W=1 build of drivers/cpufreq/cpufreq.o with Buildroot GCC 13.3.0
> and binutils 2.43.1.
> - Complete ARM64 Image build; size 43,010,560 bytes, SHA-256
> d8bd08acc9584356805575d8b7fcbf758b85d2173787df23c11c71faf4525953.
> - Static state-matrix and policy-list locking/lifetime review covering
> no-policy, no-support, inactive-capable, active success/failure,
> partial-enable and subsequent online behavior.
> - Independent review found no High/Medium/Low functional code issue in the
> two-patch candidate; the commit-description findings were corrected.
> - Final signed patches: checkpatch 0 errors and 0 warnings for both patches.
>
> NOT_RUN:
> - CPU hotplug, suspend/resume, driver unregister/global-write concurrency,
> lockdep and KCSAN testing.
> - CPPC, ACPI, AMD and ARM hardware frequency/QoS testing.
> - Runtime fault injection for policy_set_boost() failures.
> - The existing policy-online callback-failure handling is unchanged and is
> not claimed to be fixed by this series.
>
> Qoder, an AI coding assistant, helped analyze the review history, design
> and draft the preparatory change, and review the state matrix and failure
> paths. The submitter reviewed the resulting changes and is responsible for
> the final validation and submission.
--
Thx and BRs,
Zhongqiu Han
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies
2026-12-01 2:30 ` [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies Jiangtian Feng
2026-12-02 16:34 ` Christian Loehle
@ 2026-12-03 10:13 ` Zhongqiu Han
2026-12-03 10:40 ` Viresh Kumar
2026-12-03 10:57 ` Pengjie Zhang
3 siblings, 0 replies; 10+ messages in thread
From: Zhongqiu Han @ 2026-12-03 10:13 UTC (permalink / raw)
To: Jiangtian Feng, rafael, viresh.kumar
Cc: linux-pm, linux-kernel, christian.loehle, ananthu.cv,
pierre.gondois, zhangpengjie2, zhenglifeng1, zhanjie9,
Zhongqiu Han
On 12/1/2026 10:30 AM, Jiangtian Feng wrote:
> Global boost grants permission to use boost; it does not require boost to
> be active on every policy. Saving that permission should not depend on at
> least one boost-capable policy being active when the global knob is
> written.
>
> Since commit 77cf053b041f ("cpufreq: Return -EOPNOTSUPP if no policy
> supports boost"), cpufreq_boost_trigger_state() returns -EOPNOTSUPP when
> the active-policy loop has no boost-capable policy, and store_boost() maps
> that error to -EINVAL for the global sysfs write. Besides rejecting an
> otherwise valid preconfiguration, this prevents users from disabling boost
> before a capable policy becomes active when a driver starts with boost
> enabled by default.
>
> Initialize ret to 0 so the no-active-capable-policy case saves the
> requested global state and returns success. Continue to call
> policy_set_boost() for every active, boost-capable policy and preserve
> all real callback failures. This intentionally changes the no-policy
> result introduced by 77cf053b041f.
>
> Link: https://lore.kernel.org/all/467b9ef5-1fc3-4771-9895-363e815670c7@huawei.com/
>
> Qoder, an AI coding assistant, helped analyze the default-enabled case,
> review the active-policy/error semantics and draft this change and
> description. Runtime hardware and hotplug behavior remain subject to
> final review and validation.
>
> Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
> ---
> drivers/cpufreq/cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 4332cb114070..e97838e40a54 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2887,7 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
> struct cpufreq_policy *policy;
> unsigned long flags;
> bool boost_enabled;
> - int ret = -EOPNOTSUPP;
> + int ret = 0;
>
> guard(mutex)(&cpufreq_boost_mutex);
>
--
Thx and BRs,
Zhongqiu Han
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies
2026-12-01 2:30 ` [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies Jiangtian Feng
2026-12-02 16:34 ` Christian Loehle
2026-12-03 10:13 ` Zhongqiu Han
@ 2026-12-03 10:40 ` Viresh Kumar
2026-12-03 10:57 ` Pengjie Zhang
3 siblings, 0 replies; 10+ messages in thread
From: Viresh Kumar @ 2026-12-03 10:40 UTC (permalink / raw)
To: Jiangtian Feng
Cc: rafael, linux-pm, linux-kernel, zhongqiu.han, christian.loehle,
ananthu.cv, pierre.gondois, zhangpengjie2, zhenglifeng1, zhanjie9
On 01-12-26, 10:30, Jiangtian Feng wrote:
> Global boost grants permission to use boost; it does not require boost to
> be active on every policy. Saving that permission should not depend on at
> least one boost-capable policy being active when the global knob is
> written.
>
> Since commit 77cf053b041f ("cpufreq: Return -EOPNOTSUPP if no policy
> supports boost"), cpufreq_boost_trigger_state() returns -EOPNOTSUPP when
> the active-policy loop has no boost-capable policy, and store_boost() maps
> that error to -EINVAL for the global sysfs write. Besides rejecting an
> otherwise valid preconfiguration, this prevents users from disabling boost
> before a capable policy becomes active when a driver starts with boost
> enabled by default.
>
> Initialize ret to 0 so the no-active-capable-policy case saves the
> requested global state and returns success. Continue to call
> policy_set_boost() for every active, boost-capable policy and preserve
> all real callback failures. This intentionally changes the no-policy
> result introduced by 77cf053b041f.
>
> Link: https://lore.kernel.org/all/467b9ef5-1fc3-4771-9895-363e815670c7@huawei.com/
>
> Qoder, an AI coding assistant, helped analyze the default-enabled case,
> review the active-policy/error semantics and draft this change and
> description. Runtime hardware and hotplug behavior remain subject to
> final review and validation.
>
> Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
> ---
> drivers/cpufreq/cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable
2026-12-01 2:30 ` [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
2026-12-02 16:35 ` Christian Loehle
@ 2026-12-03 10:53 ` Viresh Kumar
1 sibling, 0 replies; 10+ messages in thread
From: Viresh Kumar @ 2026-12-03 10:53 UTC (permalink / raw)
To: Jiangtian Feng
Cc: rafael, linux-pm, linux-kernel, zhongqiu.han, christian.loehle,
ananthu.cv, pierre.gondois, zhangpengjie2, zhenglifeng1, zhanjie9
On 01-12-26, 10:30, Jiangtian Feng wrote:
> +++ 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;
I would rather name this differently.
bool restore = !state;
> int ret = 0;
>
> 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;
restore = false;
> }
>
> 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) {
if (restore) {
> + 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));
--
viresh
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies
2026-12-01 2:30 ` [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies Jiangtian Feng
` (2 preceding siblings ...)
2026-12-03 10:40 ` Viresh Kumar
@ 2026-12-03 10:57 ` Pengjie Zhang
3 siblings, 0 replies; 10+ messages in thread
From: Pengjie Zhang @ 2026-12-03 10:57 UTC (permalink / raw)
To: Jiangtian Feng, rafael, viresh.kumar
Cc: linux-pm, linux-kernel, zhongqiu.han, christian.loehle,
ananthu.cv, pierre.gondois, zhenglifeng1, zhanjie9
On 12/1/2026 10:30 AM, Jiangtian Feng wrote:
> Global boost grants permission to use boost; it does not require boost to
> be active on every policy. Saving that permission should not depend on at
> least one boost-capable policy being active when the global knob is
> written.
>
> Since commit 77cf053b041f ("cpufreq: Return -EOPNOTSUPP if no policy
> supports boost"), cpufreq_boost_trigger_state() returns -EOPNOTSUPP when
> the active-policy loop has no boost-capable policy, and store_boost() maps
> that error to -EINVAL for the global sysfs write. Besides rejecting an
> otherwise valid preconfiguration, this prevents users from disabling boost
> before a capable policy becomes active when a driver starts with boost
> enabled by default.
>
> Initialize ret to 0 so the no-active-capable-policy case saves the
> requested global state and returns success. Continue to call
> policy_set_boost() for every active, boost-capable policy and preserve
> all real callback failures. This intentionally changes the no-policy
> result introduced by 77cf053b041f.
>
> Link: https://lore.kernel.org/all/467b9ef5-1fc3-4771-9895-363e815670c7@huawei.com/
>
> Qoder, an AI coding assistant, helped analyze the default-enabled case,
> review the active-policy/error semantics and draft this change and
> description. Runtime hardware and hotplug behavior remain subject to
> final review and validation.
>
> Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
> ---
> drivers/cpufreq/cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 4332cb114070..e97838e40a54 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2887,7 +2887,7 @@ static int cpufreq_boost_trigger_state(int state)
> struct cpufreq_policy *policy;
> unsigned long flags;
> bool boost_enabled;
> - int ret = -EOPNOTSUPP;
> + int ret = 0;
>
> guard(mutex)(&cpufreq_boost_mutex);
>
Reviewed-by: Pengjie Zhang<zhangpengjie2@huawei.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-12-03 10:57 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 2:29 [PATCH v6 0/2] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
2026-12-01 2:30 ` [PATCH 1/2] cpufreq: Allow global boost updates without active capable policies Jiangtian Feng
2026-12-02 16:34 ` Christian Loehle
2026-12-03 10:13 ` Zhongqiu Han
2026-12-03 10:40 ` Viresh Kumar
2026-12-03 10:57 ` Pengjie Zhang
2026-12-01 2:30 ` [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
2026-12-02 16:35 ` Christian Loehle
2026-12-03 10:53 ` Viresh Kumar
2026-12-03 10:13 ` [PATCH v6 0/2] " Zhongqiu Han
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox