From: Hyeonseong Gil Date: Mon, 16 May 2016 11:37:01 +0000 (+0900) Subject: [COMMON] theraml: cpu_cooling: Skip util normalize power X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a75f9f94f9a83ce7126d745bb48c3d5283bb6be5;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] theraml: cpu_cooling: Skip util normalize power Resolved migration conflicts from kernel 4.9 to 4.14. - rename cpufreq_device -> cpufreq_cdev - allowed_cpus -> policy->related_cpus Change-Id: I4dcd4a7d61ec6d7d33b4032dac2e4aaf26e48cf7 Signed-off-by: Hyeonseong Gil --- diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 49ceb0394f2e..0a3880b59d6b 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -697,12 +697,19 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, struct thermal_zone_device *tz, u32 power, unsigned long *state) { - unsigned int cur_freq, target_freq; + unsigned int cpu, cur_freq, target_freq; int ret; s32 dyn_power; - u32 last_load, normalised_power, static_power; + u32 normalised_power, static_power; struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; struct cpufreq_policy *policy = cpufreq_cdev->policy; + cpumask_t tempmask; + int num_cpus; + + cpumask_and(&tempmask, policy->related_cpus, cpu_online_mask); + num_cpus = cpumask_weight(&tempmask); + + cpu = cpumask_any_and(policy->related_cpus, cpu_online_mask); cur_freq = cpufreq_quick_get(policy->cpu); ret = get_static_power(cpufreq_cdev, tz, cur_freq, &static_power); @@ -711,10 +718,17 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, dyn_power = power - static_power; dyn_power = dyn_power > 0 ? dyn_power : 0; - last_load = cpufreq_cdev->last_load ?: 1; - normalised_power = (dyn_power * 100) / last_load; + normalised_power = dyn_power / num_cpus; target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power); + *state = cpufreq_cooling_get_level(cpu, target_freq); + if (*state == THERMAL_CSTATE_INVALID) { + dev_warn_ratelimited(&cdev->device, + "Failed to convert %dKHz for cpu %d into a cdev state\n", + target_freq, cpu); + return -EINVAL; + } + *state = get_level(cpufreq_cdev, target_freq); trace_thermal_power_cpu_limit(policy->related_cpus, target_freq, *state, power);