Skip to content

Commit 691b321

Browse files
committed
cpufreq: Restrict enabling boost on policies with no boost frequencies
It is possible to have a scenario where not all cpufreq policies support boost frequencies. And letting sysfs (or other parts of the kernel) enable boost feature for that policy isn't correct. Now that all drivers (that required a change) are updated to set the policy->boost_supported properly, check this flag before enabling boost feature for a policy. Signed-off-by: Viresh Kumar <[email protected]>
1 parent a3f48fb commit 691b321

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,9 @@ static ssize_t store_local_boost(struct cpufreq_policy *policy,
632632
if (!cpufreq_driver->boost_enabled)
633633
return -EINVAL;
634634

635+
if (!policy->boost_supported)
636+
return -EINVAL;
637+
635638
if (policy->boost_enabled == enable)
636639
return count;
637640

@@ -1587,7 +1590,7 @@ static int cpufreq_online(unsigned int cpu)
15871590
policy->cdev = of_cpufreq_cooling_register(policy);
15881591

15891592
/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
1590-
if (cpufreq_driver->set_boost &&
1593+
if (cpufreq_driver->set_boost && policy->boost_supported &&
15911594
policy->boost_enabled != cpufreq_boost_enabled()) {
15921595
policy->boost_enabled = cpufreq_boost_enabled();
15931596
ret = cpufreq_driver->set_boost(policy, policy->boost_enabled);
@@ -2824,6 +2827,9 @@ static int cpufreq_boost_trigger_state(int state)
28242827

28252828
cpus_read_lock();
28262829
for_each_active_policy(policy) {
2830+
if (!policy->boost_supported)
2831+
continue;
2832+
28272833
policy->boost_enabled = state;
28282834
ret = cpufreq_driver->set_boost(policy, state);
28292835
if (ret) {

0 commit comments

Comments
 (0)