From: Kapileshwar Singh Date: Mon, 16 Mar 2015 12:00:51 +0000 (+0000) Subject: thermal: cpu_cooling: Fix power calculation when CPUs are offline X-Git-Tag: MMI-PSA29.97-13-9~9872^2^2^2~6 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dd658e02357ec879edd0c62ee1f3a19c92b0b027;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git 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 Signed-off-by: Kapileshwar Singh Signed-off-by: Eduardo Valentin --- 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, 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);