Skip to content

Commit 99907d6

Browse files
lukaszluba-armrafaeljw
authored andcommitted
PM: EM: Find first CPU active while updating OPP efficiency
The Energy Model might be updated at runtime and the energy efficiency for each OPP may change. Thus, there is a need to update also the cpufreq framework and make it aligned to the new values. In order to do that, use a first active CPU from the Performance Domain. This is needed since the first CPU in the cpumask might be offline when we run this code path. Reviewed-by: Hongyan Xia <[email protected]> Reviewed-by: Dietmar Eggemann <[email protected]> Tested-by: Dietmar Eggemann <[email protected]> Signed-off-by: Lukasz Luba <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent e7b1cc9 commit 99907d6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

kernel/power/energy_model.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,19 @@ em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *table)
243243
struct em_perf_domain *pd = dev->em_pd;
244244
struct cpufreq_policy *policy;
245245
int found = 0;
246-
int i;
246+
int i, cpu;
247247

248248
if (!_is_cpu_device(dev))
249249
return;
250250

251-
policy = cpufreq_cpu_get(cpumask_first(em_span_cpus(pd)));
251+
/* Try to get a CPU which is active and in this PD */
252+
cpu = cpumask_first_and(em_span_cpus(pd), cpu_active_mask);
253+
if (cpu >= nr_cpu_ids) {
254+
dev_warn(dev, "EM: No online CPU for CPUFreq policy\n");
255+
return;
256+
}
257+
258+
policy = cpufreq_cpu_get(cpu);
252259
if (!policy) {
253260
dev_warn(dev, "EM: Access to CPUFreq policy failed\n");
254261
return;

0 commit comments

Comments
 (0)