| From bd4858dc64b8a88cf0b3b76998182ce93438d33e Mon Sep 17 00:00:00 2001 | |
| From: Sasha Levin <sashal@kernel.org> | |
| Date: Thu, 5 Nov 2026 21:52:22 +0000 | |
| Subject: cpufreq: Preserve global boost state on failed updates | |
| From: Christian Loehle <christian.loehle@arm.com> | |
| [ Upstream commit a0cde2b601bc32b76d61e50141c619790e5e2e41 ] | |
| cpufreq_boost_trigger_state() restores the opposite of the requested | |
| state when updating policy boost state fails. For example, a failed | |
| write of 0 when global boost is already disabled enables the global | |
| flag without enabling any policies. | |
| Save the original global boost state and restore it on failure. | |
| Fixes: 121baab7b88e ("cpufreq: Force sync policy boost with global boost on sysfs update") | |
| Signed-off-by: Christian Loehle <christian.loehle@arm.com> | |
| Reviewed-by: Pengjie Zhang <zhangpengjie2@huawei.com> | |
| Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com> | |
| Reviewed-by: Sumit Gupta <sumitg@nvidia.com> | |
| Link: https://patch.msgid.link/20261105215223.1263415-2-christian.loehle@arm.com | |
| Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | |
| Signed-off-by: Sasha Levin <sashal@kernel.org> | |
| --- | |
| drivers/cpufreq/cpufreq.c | 4 +++- | |
| 1 file changed, 3 insertions(+), 1 deletion(-) | |
| diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c | |
| index 015962e6c1fe4..4bf7738a81b0f 100644 | |
| --- a/drivers/cpufreq/cpufreq.c | |
| +++ b/drivers/cpufreq/cpufreq.c | |
| @@ -2818,6 +2818,7 @@ static int cpufreq_boost_trigger_state(int state) | |
| { | |
| struct cpufreq_policy *policy; | |
| unsigned long flags; | |
| + bool boost_enabled; | |
| int ret = -EOPNOTSUPP; | |
| /* | |
| @@ -2826,6 +2827,7 @@ static int cpufreq_boost_trigger_state(int state) | |
| */ | |
| write_lock_irqsave(&cpufreq_driver_lock, flags); | |
| + boost_enabled = cpufreq_driver->boost_enabled; | |
| cpufreq_driver->boost_enabled = state; | |
| write_unlock_irqrestore(&cpufreq_driver_lock, flags); | |
| @@ -2847,7 +2849,7 @@ static int cpufreq_boost_trigger_state(int state) | |
| return 0; | |
| write_lock_irqsave(&cpufreq_driver_lock, flags); | |
| - cpufreq_driver->boost_enabled = !state; | |
| + cpufreq_driver->boost_enabled = boost_enabled; | |
| write_unlock_irqrestore(&cpufreq_driver_lock, flags); | |
| pr_err("%s: Cannot %s BOOST\n", | |
| -- | |
| 2.53.0 | |