From: Viresh Kumar viresh.kumar@linaro.org
[ Upstream commit 121baab7b88ed865532dadb7ef1aee6e2bea86f5 ]
If the global boost flag is enabled and policy boost flag is disabled, a call to `cpufreq_boost_trigger_state(true)` must enable the policy's boost state.
The current code misses that because of an optimization. Fix it.
Suggested-by: Lifeng Zheng zhenglifeng1@huawei.com Reviewed-by: Lifeng Zheng zhenglifeng1@huawei.com Signed-off-by: Viresh Kumar viresh.kumar@linaro.org Link: https://patch.msgid.link/852ff11c589e6300730d207baac195b2d9d8b95f.1745511526... Signed-off-by: Rafael J. Wysocki rafael.j.wysocki@intel.com Signed-off-by: Sasha Levin sashal@kernel.org ---
**YES** This commit should be backported to stable kernel trees. ## Analysis ### Code Change Analysis The commit makes a very small, targeted fix to the `cpufreq_boost_trigger_state()` function in `/drivers/cpufreq/cpufreq.c`. The change removes a single optimization check: **Before:** ```c if (cpufreq_driver->boost_enabled == state) return 0; ``` **After:** ```c /bin /bin.usr-is-merged /boot /dev /etc /home /init /lib /lib.usr-is-merged /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /sbin.usr-is-merged /snap /srv /sys /tmp /usr /var linux linux-kernel Don't compare 'cpufreq_driver->boost_enabled' with 'state' here to linux linux-kernel make sure all policies are in sync with global boost flag. linux-kernel/ linux/ ``` ### Bug Being Fixed The commit fixes a synchronization bug between global boost settings and per-policy boost settings. The problem occurs when: 1. Global boost is enabled (`cpufreq_driver->boost_enabled = true`) 2. Some policies have boost disabled (`policy->boost_enabled = false`) 3. A call to `cpufreq_boost_trigger_state(true)` should enable boost on all policies The old code would return early due to the optimization check, failing to sync the policy-level boost flags with the global setting. This means individual policies could remain out of sync with the global boost state. ### Backport Suitability Assessment **✅ Fixes Important Bug:** Yes - this addresses a functional bug where boost settings can become inconsistent between global and per-policy levels. **✅ Small and Contained:** Yes - the change is minimal (removes 2 lines, adds comment), affecting only one function. **✅ Low Risk:** Yes - the change simply removes an optimization, ensuring the existing sync logic always runs. This cannot introduce new bugs. **✅ No Architectural Changes:** Yes - this doesn't change any APIs or data structures. **✅ Critical Subsystem:** While cpufreq is important, this specific bug affects only boost functionality, which is not a core feature. **✅ Clear Side Effects:** The only side effect is that `cpufreq_boost_trigger_state()` will now always iterate through all policies even when the global state appears unchanged, ensuring proper synchronization. ### Comparison with Similar Commits Looking at the provided similar commits: - **Similar Commit #3 (YES):** Also fixes per-policy boost behavior with targeted changes - **Similar Commit #4 (YES):** Introduces boost_supported flag with minimal risk changes - **Similar Commits #1, #2, #5 (NO):** These add new features or make broader architectural changes This commit follows the pattern of commits #3 and #4 - it's a small, targeted fix to existing boost functionality without introducing new features. ### Stable Tree Criteria Compliance This commit meets all stable tree criteria: - Fixes a real bug affecting users who rely on per-policy boost controls - The fix is obvious and minimal - No risk of regression since it only removes an optimization - Doesn't change user-visible behavior except to fix the broken synchronization - The bug could affect power management and performance on systems using cpufreq boost The commit represents exactly the type of small, safe bugfix that stable trees are designed to include.
drivers/cpufreq/cpufreq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 6682f422cadd9..11264692ac686 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2793,8 +2793,10 @@ int cpufreq_boost_trigger_state(int state) unsigned long flags; int ret = 0;
- if (cpufreq_driver->boost_enabled == state) - return 0; + /* + * Don't compare 'cpufreq_driver->boost_enabled' with 'state' here to + * make sure all policies are in sync with global boost flag. + */
write_lock_irqsave(&cpufreq_driver_lock, flags); cpufreq_driver->boost_enabled = state;