Skip to content

Commit

Permalink
thermal: cpu_cooling: Fix power calculation when CPUs are offline
Browse files Browse the repository at this point in the history
Ensure that the CPU for which the frequency is being requested
is online. If none of the CPUs are online the requested power is
returned as 0.

Acked-by: Javi Merino <javi.merino@arm.com>
Signed-off-by: Kapileshwar Singh <kapileshwar.singh@arm.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
  • Loading branch information
Kapileshwar Singh authored and Eduardo Valentin committed May 5, 2015
1 parent 54b92aa commit dd658e0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion drivers/thermal/cpu_cooling.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,18 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
u32 *load_cpu = NULL;

freq = cpufreq_quick_get(cpumask_any(&cpufreq_device->allowed_cpus));
cpu = cpumask_any_and(&cpufreq_device->allowed_cpus, cpu_online_mask);

/*
* All the CPUs are offline, thus the requested power by
* the cdev is 0
*/
if (cpu >= nr_cpu_ids) {
*power = 0;
return 0;
}

freq = cpufreq_quick_get(cpu);

if (trace_thermal_power_cpu_get_power_enabled()) {
u32 ncpus = cpumask_weight(&cpufreq_device->allowed_cpus);
Expand Down

0 comments on commit dd658e0

Please sign in to comment.