Skip to content

Commit 99d14d0

Browse files
vireshkrafaeljw
authored andcommitted
cpufreq: Process remote callbacks from any CPU if the platform permits
On many platforms, CPUs can do DVFS across cpufreq policies. i.e CPU from policy-A can change frequency of CPUs belonging to policy-B. This is quite common in case of ARM platforms where we don't configure any per-cpu register. Add a flag to identify such platforms and update cpufreq_can_do_remote_dvfs() to allow remote callbacks if this flag is set. Also enable the flag for cpufreq-dt driver which is used only on ARM platforms currently. Signed-off-by: Viresh Kumar <[email protected]> Acked-by: Saravana Kannan <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 674e754 commit 99d14d0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

drivers/cpufreq/cpufreq-dt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
274274
transition_latency = CPUFREQ_ETERNAL;
275275

276276
policy->cpuinfo.transition_latency = transition_latency;
277+
policy->dvfs_possible_from_any_cpu = true;
277278

278279
return 0;
279280

include/linux/cpufreq.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ struct cpufreq_policy {
127127
*/
128128
unsigned int transition_delay_us;
129129

130+
/*
131+
* Remote DVFS flag (Not added to the driver structure as we don't want
132+
* to access another structure from scheduler hotpath).
133+
*
134+
* Should be set if CPUs can do DVFS on behalf of other CPUs from
135+
* different cpufreq policies.
136+
*/
137+
bool dvfs_possible_from_any_cpu;
138+
130139
/* Cached frequency lookup from cpufreq_driver_resolve_freq. */
131140
unsigned int cached_target_freq;
132141
int cached_resolved_idx;
@@ -564,8 +573,13 @@ struct governor_attr {
564573

565574
static inline bool cpufreq_can_do_remote_dvfs(struct cpufreq_policy *policy)
566575
{
567-
/* Allow remote callbacks only on the CPUs sharing cpufreq policy */
568-
if (cpumask_test_cpu(smp_processor_id(), policy->cpus))
576+
/*
577+
* Allow remote callbacks if:
578+
* - dvfs_possible_from_any_cpu flag is set
579+
* - the local and remote CPUs share cpufreq policy
580+
*/
581+
if (policy->dvfs_possible_from_any_cpu ||
582+
cpumask_test_cpu(smp_processor_id(), policy->cpus))
569583
return true;
570584

571585
return false;

0 commit comments

Comments
 (0)