Skip to content

Commit f37a4d6

Browse files
Sibi Sankarrafaeljw
authored andcommitted
cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw()
In the existing code, per-policy flags don't have any impact i.e. if cpufreq_driver boost is enabled and boost is disabled for one or more of the policies, the cpufreq driver will behave as if boost is enabled. Fix this by incorporating per-policy boost flag in the policy->max computation used in cpufreq_frequency_table_cpuinfo and setting the default per-policy boost to mirror the cpufreq_driver boost flag. Fixes: 218a06a ("cpufreq: Support per-policy performance boost") Reported-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Dhruva Gole <d-gole@ti.com> Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com> Tested-by:Yipeng Zou <zouyipeng@huawei.com> <mailto:zouyipeng@huawei.com> Reviewed-by: Yipeng Zou <zouyipeng@huawei.com> <mailto:zouyipeng@huawei.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 07abb19 commit f37a4d6

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,14 +653,16 @@ static ssize_t store_local_boost(struct cpufreq_policy *policy,
653653
if (policy->boost_enabled == enable)
654654
return count;
655655

656+
policy->boost_enabled = enable;
657+
656658
cpus_read_lock();
657659
ret = cpufreq_driver->set_boost(policy, enable);
658660
cpus_read_unlock();
659661

660-
if (ret)
662+
if (ret) {
663+
policy->boost_enabled = !policy->boost_enabled;
661664
return ret;
662-
663-
policy->boost_enabled = enable;
665+
}
664666

665667
return count;
666668
}
@@ -1428,6 +1430,9 @@ static int cpufreq_online(unsigned int cpu)
14281430
goto out_free_policy;
14291431
}
14301432

1433+
/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
1434+
policy->boost_enabled = cpufreq_boost_enabled() && policy_has_boost_freq(policy);
1435+
14311436
/*
14321437
* The initialization has succeeded and the policy is online.
14331438
* If there is a problem with its frequency table, take it
@@ -2769,11 +2774,12 @@ int cpufreq_boost_trigger_state(int state)
27692774

27702775
cpus_read_lock();
27712776
for_each_active_policy(policy) {
2777+
policy->boost_enabled = state;
27722778
ret = cpufreq_driver->set_boost(policy, state);
2773-
if (ret)
2779+
if (ret) {
2780+
policy->boost_enabled = !policy->boost_enabled;
27742781
goto err_reset_state;
2775-
2776-
policy->boost_enabled = state;
2782+
}
27772783
}
27782784
cpus_read_unlock();
27792785

drivers/cpufreq/freq_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
4040
cpufreq_for_each_valid_entry(pos, table) {
4141
freq = pos->frequency;
4242

43-
if (!cpufreq_boost_enabled()
43+
if ((!cpufreq_boost_enabled() || !policy->boost_enabled)
4444
&& (pos->flags & CPUFREQ_BOOST_FREQ))
4545
continue;
4646

0 commit comments

Comments
 (0)