Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal

Pull thermal fixes from Eduardo Valentin:
"Last minute fixes on the thermal-soc tree. There is a fix of a long
lasting bug in cpu cooling device, thanks for RMK for being pushing
this"

* 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal:
thermal/cpu_cooling: update policy limits if clipped_freq < policy->max
thermal/cpu_cooling: rename max_freq as clipped_freq in notifier
thermal/cpu_cooling: rename cpufreq_val as clipped_freq
thermal/cpu_cooling: convert 'switch' block to 'if' block in notifier
thermal/cpu_cooling: quit early after updating policy
thermal/cpu_cooling: No need to initialize max_freq to 0
thermal: cpu_cooling: fix lockdep problems in cpu_cooling
thermal: power_allocator: do not use devm* interfaces

+51 -36
+47 -32
drivers/thermal/cpu_cooling.c
··· 68 68 * registered cooling device. 69 69 * @cpufreq_state: integer value representing the current state of cpufreq 70 70 * cooling devices. 71 - * @cpufreq_val: integer value representing the absolute value of the clipped 71 + * @clipped_freq: integer value representing the absolute value of the clipped 72 72 * frequency. 73 73 * @max_level: maximum cooling level. One less than total number of valid 74 74 * cpufreq frequencies. ··· 91 91 int id; 92 92 struct thermal_cooling_device *cool_dev; 93 93 unsigned int cpufreq_state; 94 - unsigned int cpufreq_val; 94 + unsigned int clipped_freq; 95 95 unsigned int max_level; 96 96 unsigned int *freq_table; /* In descending order */ 97 97 struct cpumask allowed_cpus; ··· 107 107 static DEFINE_IDR(cpufreq_idr); 108 108 static DEFINE_MUTEX(cooling_cpufreq_lock); 109 109 110 + static unsigned int cpufreq_dev_count; 111 + 112 + static DEFINE_MUTEX(cooling_list_lock); 110 113 static LIST_HEAD(cpufreq_dev_list); 111 114 112 115 /** ··· 188 185 { 189 186 struct cpufreq_cooling_device *cpufreq_dev; 190 187 191 - mutex_lock(&cooling_cpufreq_lock); 188 + mutex_lock(&cooling_list_lock); 192 189 list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) { 193 190 if (cpumask_test_cpu(cpu, &cpufreq_dev->allowed_cpus)) { 194 - mutex_unlock(&cooling_cpufreq_lock); 191 + mutex_unlock(&cooling_list_lock); 195 192 return get_level(cpufreq_dev, freq); 196 193 } 197 194 } 198 - mutex_unlock(&cooling_cpufreq_lock); 195 + mutex_unlock(&cooling_list_lock); 199 196 200 197 pr_err("%s: cpu:%d not part of any cooling device\n", __func__, cpu); 201 198 return THERMAL_CSTATE_INVALID; ··· 218 215 unsigned long event, void *data) 219 216 { 220 217 struct cpufreq_policy *policy = data; 221 - unsigned long max_freq = 0; 218 + unsigned long clipped_freq; 222 219 struct cpufreq_cooling_device *cpufreq_dev; 223 220 224 - switch (event) { 225 - 226 - case CPUFREQ_ADJUST: 227 - mutex_lock(&cooling_cpufreq_lock); 228 - list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) { 229 - if (!cpumask_test_cpu(policy->cpu, 230 - &cpufreq_dev->allowed_cpus)) 231 - continue; 232 - 233 - max_freq = cpufreq_dev->cpufreq_val; 234 - 235 - if (policy->max != max_freq) 236 - cpufreq_verify_within_limits(policy, 0, 237 - max_freq); 238 - } 239 - mutex_unlock(&cooling_cpufreq_lock); 240 - break; 241 - default: 221 + if (event != CPUFREQ_ADJUST) 242 222 return NOTIFY_DONE; 223 + 224 + mutex_lock(&cooling_list_lock); 225 + list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) { 226 + if (!cpumask_test_cpu(policy->cpu, &cpufreq_dev->allowed_cpus)) 227 + continue; 228 + 229 + /* 230 + * policy->max is the maximum allowed frequency defined by user 231 + * and clipped_freq is the maximum that thermal constraints 232 + * allow. 233 + * 234 + * If clipped_freq is lower than policy->max, then we need to 235 + * readjust policy->max. 236 + * 237 + * But, if clipped_freq is greater than policy->max, we don't 238 + * need to do anything. 239 + */ 240 + clipped_freq = cpufreq_dev->clipped_freq; 241 + 242 + if (policy->max > clipped_freq) 243 + cpufreq_verify_within_limits(policy, 0, clipped_freq); 244 + break; 243 245 } 246 + mutex_unlock(&cooling_list_lock); 244 247 245 248 return NOTIFY_OK; 246 249 } ··· 528 519 529 520 clip_freq = cpufreq_device->freq_table[state]; 530 521 cpufreq_device->cpufreq_state = state; 531 - cpufreq_device->cpufreq_val = clip_freq; 522 + cpufreq_device->clipped_freq = clip_freq; 532 523 533 524 cpufreq_update_policy(cpu); 534 525 ··· 870 861 pr_debug("%s: freq:%u KHz\n", __func__, freq); 871 862 } 872 863 873 - cpufreq_dev->cpufreq_val = cpufreq_dev->freq_table[0]; 864 + cpufreq_dev->clipped_freq = cpufreq_dev->freq_table[0]; 874 865 cpufreq_dev->cool_dev = cool_dev; 875 866 876 867 mutex_lock(&cooling_cpufreq_lock); 877 868 869 + mutex_lock(&cooling_list_lock); 870 + list_add(&cpufreq_dev->node, &cpufreq_dev_list); 871 + mutex_unlock(&cooling_list_lock); 872 + 878 873 /* Register the notifier for first cpufreq cooling device */ 879 - if (list_empty(&cpufreq_dev_list)) 874 + if (!cpufreq_dev_count++) 880 875 cpufreq_register_notifier(&thermal_cpufreq_notifier_block, 881 876 CPUFREQ_POLICY_NOTIFIER); 882 - list_add(&cpufreq_dev->node, &cpufreq_dev_list); 883 - 884 877 mutex_unlock(&cooling_cpufreq_lock); 885 878 886 879 return cool_dev; ··· 1024 1013 return; 1025 1014 1026 1015 cpufreq_dev = cdev->devdata; 1027 - mutex_lock(&cooling_cpufreq_lock); 1028 - list_del(&cpufreq_dev->node); 1029 1016 1030 1017 /* Unregister the notifier for the last cpufreq cooling device */ 1031 - if (list_empty(&cpufreq_dev_list)) 1018 + mutex_lock(&cooling_cpufreq_lock); 1019 + if (!--cpufreq_dev_count) 1032 1020 cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, 1033 1021 CPUFREQ_POLICY_NOTIFIER); 1022 + 1023 + mutex_lock(&cooling_list_lock); 1024 + list_del(&cpufreq_dev->node); 1025 + mutex_unlock(&cooling_list_lock); 1026 + 1034 1027 mutex_unlock(&cooling_cpufreq_lock); 1035 1028 1036 1029 thermal_cooling_device_unregister(cpufreq_dev->cool_dev);
+4 -4
drivers/thermal/power_allocator.c
··· 334 334 max_allocatable_power, current_temp, 335 335 (s32)control_temp - (s32)current_temp); 336 336 337 - devm_kfree(&tz->device, req_power); 337 + kfree(req_power); 338 338 unlock: 339 339 mutex_unlock(&tz->lock); 340 340 ··· 426 426 return -EINVAL; 427 427 } 428 428 429 - params = devm_kzalloc(&tz->device, sizeof(*params), GFP_KERNEL); 429 + params = kzalloc(sizeof(*params), GFP_KERNEL); 430 430 if (!params) 431 431 return -ENOMEM; 432 432 ··· 468 468 return 0; 469 469 470 470 free: 471 - devm_kfree(&tz->device, params); 471 + kfree(params); 472 472 return ret; 473 473 } 474 474 475 475 static void power_allocator_unbind(struct thermal_zone_device *tz) 476 476 { 477 477 dev_dbg(&tz->device, "Unbinding from thermal zone %d\n", tz->id); 478 - devm_kfree(&tz->device, tz->governor_data); 478 + kfree(tz->governor_data); 479 479 tz->governor_data = NULL; 480 480 } 481 481