aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKapileshwar Singh <kapileshwar.singh@arm.com>2015-03-16 12:00:51 +0000
committerKevin Hilman <khilman@linaro.org>2015-07-07 09:20:22 -0700
commit923b2476a4d19f1bf603ce0d18d655033e109b5d (patch)
treefe365d6de55f6c5ee56deab040d17290ac95247a
parent573a0dba56067334506793098238e3945a2537c8 (diff)
downloadlinux-linaro-stable-923b2476a4d19f1bf603ce0d18d655033e109b5d.tar.gz
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> (cherry picked from commit dd658e02357ec879edd0c62ee1f3a19c92b0b027) Signed-off-by: Kevin Hilman <khilman@linaro.org>
-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 2e15133b4793..07a9629edf4b 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -555,7 +555,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);