aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorKapileshwar Singh <kapileshwar.singh@arm.com>2015-03-16 08:00:51 -0400
committerEduardo Valentin <edubezval@gmail.com>2015-05-05 00:27:54 -0400
commitdd658e02357ec879edd0c62ee1f3a19c92b0b027 (patch)
tree7902429108c8910d4cff06a0887be36ccc190b29 /drivers/thermal
parent54b92aae834ce8d02d6092f8ae5eb1fe0d607f1e (diff)
thermal: cpu_cooling: Fix power calculation when CPUs are offline
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>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/cpu_cooling.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index beffa556488a..6509c61b9648 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -559,7 +559,18 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
559 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; 559 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
560 u32 *load_cpu = NULL; 560 u32 *load_cpu = NULL;
561 561
562 freq = cpufreq_quick_get(cpumask_any(&cpufreq_device->allowed_cpus)); 562 cpu = cpumask_any_and(&cpufreq_device->allowed_cpus, cpu_online_mask);
563
564 /*
565 * All the CPUs are offline, thus the requested power by
566 * the cdev is 0
567 */
568 if (cpu >= nr_cpu_ids) {
569 *power = 0;
570 return 0;
571 }
572
573 freq = cpufreq_quick_get(cpu);
563 574
564 if (trace_thermal_power_cpu_get_power_enabled()) { 575 if (trace_thermal_power_cpu_get_power_enabled()) {
565 u32 ncpus = cpumask_weight(&cpufreq_device->allowed_cpus); 576 u32 ncpus = cpumask_weight(&cpufreq_device->allowed_cpus);