From: Eunseok Choi Date: Thu, 9 Nov 2017 13:07:26 +0000 (+0900) Subject: [COMMON] thermal: cpu_cooling: calculate power by online cpus X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=17e47c54b285d3cb84baa7d4c797d8ae18b0f47a;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] thermal: cpu_cooling: calculate power by online cpus Resolved migration conflicts from kernel 4.9 to 4.14. - allowed_cpus -> policy->related_cpus Change-Id: I82b186566d40f75f654393cb655f17d4c15dbcfb Signed-off-by: Eunseok Choi --- diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 70fe51e2d980..aa49fd3f8763 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -374,11 +374,10 @@ static int lookup_static_power(struct cpufreq_cooling_device *cpufreq_cdev, int num_cpus; int max_cpus; struct cpufreq_policy *policy = cpufreq_cdev->policy; - struct cpumask *cpumask = policy->related_cpus; cpumask_t tempmask; - cpumask_and(&tempmask, cpumask, cpu_online_mask); - max_cpus = cpumask_weight(cpumask); + cpumask_and(&tempmask, policy->related_cpus, cpu_online_mask); + max_cpus = cpumask_weight(policy->related_cpus); num_cpus = cpumask_weight(&tempmask); voltage = voltage / 1000; temperature = temperature / 1000; @@ -410,7 +409,7 @@ static int lookup_static_power(struct cpufreq_cooling_device *cpufreq_cdev, temp_index = cpufreq_cdev->var_temp_size; index = (int)(volt_index * (cpufreq_cdev->var_temp_size + 1) + temp_index); - *power = (unsigned int)cpufreq_cdev->var_table[index] * num_cpus / max_cpus; + *power = (unsigned int)cpufreq_cdev->var_table[index]; return 0; } @@ -494,9 +493,11 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_cdev, struct dev_pm_opp *opp; unsigned long voltage; struct cpufreq_policy *policy = cpufreq_cdev->policy; - struct cpumask *cpumask = policy->related_cpus; unsigned long freq_hz = freq * 1000; struct device *dev; + cpumask_t tempmask; + int num_cpus, max_cpus; + u32 raw_cpu_power; *power = 0; @@ -519,7 +520,15 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_cdev, return -EINVAL; } - return lookup_static_power(cpufreq_cdev, voltage, tz->temperature, power); + lookup_static_power(cpufreq_cdev, voltage, tz->temperature, &raw_cpu_power); + + cpumask_and(&tempmask, policy->related_cpus, cpu_online_mask); + num_cpus = cpumask_weight(&tempmask); + max_cpus = cpumask_weight(policy->related_cpus); + + *power = (raw_cpu_power * (num_cpus + 1)) / (max_cpus + 1); + + return 0; } /**