Skip to content

Commit ced255c

Browse files
committed
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
Pull thermal management fixes from Zhang Rui: - Power allocator governor changes to allow binding on thermal zones with missing power estimates information. From Javi Merino. - Add compile test flags on thermal drivers that allow it without producing compilation errors. From Eduardo Valentin. - Fixes around memory allocation on cpu_cooling. From Javi Merino. - Fix on db8500 cpufreq code to allow autoload. From Luis de Bethencourt. - Maintainer entries for cpu cooling device * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: thermal: power_allocator: exit early if there are no cooling devices thermal: power_allocator: don't require tzp to be present for the thermal zone thermal: power_allocator: relax the requirement of two passive trip points thermal: power_allocator: relax the requirement of a sustainable_power in tzp thermal: Add a function to get the minimum power thermal: cpu_cooling: free power table on error or when unregistering thermal: cpu_cooling: don't call kcalloc() under rcu_read_lock thermal: db8500_cpufreq_cooling: Fix module autoload for OF platform driver thermal: cpu_cooling: Add MAINTAINERS entry thermal: ti-soc: Kconfig fix to avoid menu showing wrongly thermal: ti-soc: allow compile test thermal: qcom_spmi: allow compile test thermal: exynos: allow compile test thermal: armada: allow compile test thermal: dove: allow compile test thermal: kirkwood: allow compile test thermal: rockchip: allow compile test thermal: spear: allow compile test thermal: hisi: allow compile test thermal: Fix thermal_zone_of_sensor_register to match documentation
2 parents 4401555 + 97584d1 commit ced255c

9 files changed

Lines changed: 269 additions & 100 deletions

File tree

‎Documentation/thermal/power_allocator.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Power allocator governor tunables
44
Trip points
55
-----------
66

7-
The governor requires the following two passive trip points:
7+
The governor works optimally with the following two passive trip points:
88

99
1. "switch on" trip point: temperature above which the governor
1010
control loop starts operating. This is the first passive trip

‎MAINTAINERS‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10338,6 +10338,16 @@ F: include/uapi/linux/thermal.h
1033810338
F: include/linux/cpu_cooling.h
1033910339
F: Documentation/devicetree/bindings/thermal/
1034010340

10341+
THERMAL/CPU_COOLING
10342+
M: Amit Daniel Kachhap <amit.kachhap@gmail.com>
10343+
M: Viresh Kumar <viresh.kumar@linaro.org>
10344+
M: Javi Merino <javi.merino@arm.com>
10345+
L: linux-pm@vger.kernel.org
10346+
S: Supported
10347+
F: Documentation/thermal/cpu-cooling-api.txt
10348+
F: drivers/thermal/cpu_cooling.c
10349+
F: include/linux/cpu_cooling.h
10350+
1034110351
THINGM BLINK(1) USB RGB LED DRIVER
1034210352
M: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
1034310353
S: Maintained

‎drivers/thermal/Kconfig‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ config THERMAL_EMULATION
163163

164164
config HISI_THERMAL
165165
tristate "Hisilicon thermal driver"
166-
depends on ARCH_HISI && CPU_THERMAL && OF
166+
depends on (ARCH_HISI && CPU_THERMAL && OF) || COMPILE_TEST
167167
help
168168
Enable this to plug hisilicon's thermal sensor driver into the Linux
169169
thermal framework. cpufreq is used as the cooling device to throttle
@@ -182,15 +182,15 @@ config IMX_THERMAL
182182

183183
config SPEAR_THERMAL
184184
bool "SPEAr thermal sensor driver"
185-
depends on PLAT_SPEAR
185+
depends on PLAT_SPEAR || COMPILE_TEST
186186
depends on OF
187187
help
188188
Enable this to plug the SPEAr thermal sensor driver into the Linux
189189
thermal framework.
190190

191191
config ROCKCHIP_THERMAL
192192
tristate "Rockchip thermal driver"
193-
depends on ARCH_ROCKCHIP
193+
depends on ARCH_ROCKCHIP || COMPILE_TEST
194194
depends on RESET_CONTROLLER
195195
help
196196
Rockchip thermal driver provides support for Temperature sensor
@@ -208,15 +208,15 @@ config RCAR_THERMAL
208208

209209
config KIRKWOOD_THERMAL
210210
tristate "Temperature sensor on Marvell Kirkwood SoCs"
211-
depends on MACH_KIRKWOOD
211+
depends on MACH_KIRKWOOD || COMPILE_TEST
212212
depends on OF
213213
help
214214
Support for the Kirkwood thermal sensor driver into the Linux thermal
215215
framework. Only kirkwood 88F6282 and 88F6283 have this sensor.
216216

217217
config DOVE_THERMAL
218218
tristate "Temperature sensor on Marvell Dove SoCs"
219-
depends on ARCH_DOVE || MACH_DOVE
219+
depends on ARCH_DOVE || MACH_DOVE || COMPILE_TEST
220220
depends on OF
221221
help
222222
Support for the Dove thermal sensor driver in the Linux thermal
@@ -234,7 +234,7 @@ config DB8500_THERMAL
234234

235235
config ARMADA_THERMAL
236236
tristate "Armada 370/XP thermal management"
237-
depends on ARCH_MVEBU
237+
depends on ARCH_MVEBU || COMPILE_TEST
238238
depends on OF
239239
help
240240
Enable this option if you want to have support for thermal management
@@ -349,11 +349,12 @@ config INTEL_PCH_THERMAL
349349
programmable trip points and other information.
350350

351351
menu "Texas Instruments thermal drivers"
352+
depends on ARCH_HAS_BANDGAP || COMPILE_TEST
352353
source "drivers/thermal/ti-soc-thermal/Kconfig"
353354
endmenu
354355

355356
menu "Samsung thermal drivers"
356-
depends on ARCH_EXYNOS
357+
depends on ARCH_EXYNOS || COMPILE_TEST
357358
source "drivers/thermal/samsung/Kconfig"
358359
endmenu
359360

@@ -364,7 +365,7 @@ endmenu
364365

365366
config QCOM_SPMI_TEMP_ALARM
366367
tristate "Qualcomm SPMI PMIC Temperature Alarm"
367-
depends on OF && SPMI && IIO
368+
depends on OF && (SPMI || COMPILE_TEST) && IIO
368369
select REGMAP_SPMI
369370
help
370371
This enables a thermal sysfs driver for Qualcomm plug-and-play (QPNP)

‎drivers/thermal/cpu_cooling.c‎

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb,
262262
* efficiently. Power is stored in mW, frequency in KHz. The
263263
* resulting table is in ascending order.
264264
*
265-
* Return: 0 on success, -E* on error.
265+
* Return: 0 on success, -EINVAL if there are no OPPs for any CPUs,
266+
* -ENOMEM if we run out of memory or -EAGAIN if an OPP was
267+
* added/enabled while the function was executing.
266268
*/
267269
static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device,
268270
u32 capacitance)
@@ -273,8 +275,6 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device,
273275
int num_opps = 0, cpu, i, ret = 0;
274276
unsigned long freq;
275277

276-
rcu_read_lock();
277-
278278
for_each_cpu(cpu, &cpufreq_device->allowed_cpus) {
279279
dev = get_cpu_device(cpu);
280280
if (!dev) {
@@ -284,31 +284,33 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device,
284284
}
285285

286286
num_opps = dev_pm_opp_get_opp_count(dev);
287-
if (num_opps > 0) {
287+
if (num_opps > 0)
288288
break;
289-
} else if (num_opps < 0) {
290-
ret = num_opps;
291-
goto unlock;
292-
}
289+
else if (num_opps < 0)
290+
return num_opps;
293291
}
294292

295-
if (num_opps == 0) {
296-
ret = -EINVAL;
297-
goto unlock;
298-
}
293+
if (num_opps == 0)
294+
return -EINVAL;
299295

300296
power_table = kcalloc(num_opps, sizeof(*power_table), GFP_KERNEL);
301-
if (!power_table) {
302-
ret = -ENOMEM;
303-
goto unlock;
304-
}
297+
if (!power_table)
298+
return -ENOMEM;
299+
300+
rcu_read_lock();
305301

306302
for (freq = 0, i = 0;
307303
opp = dev_pm_opp_find_freq_ceil(dev, &freq), !IS_ERR(opp);
308304
freq++, i++) {
309305
u32 freq_mhz, voltage_mv;
310306
u64 power;
311307

308+
if (i >= num_opps) {
309+
rcu_read_unlock();
310+
ret = -EAGAIN;
311+
goto free_power_table;
312+
}
313+
312314
freq_mhz = freq / 1000000;
313315
voltage_mv = dev_pm_opp_get_voltage(opp) / 1000;
314316

@@ -326,17 +328,22 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device,
326328
power_table[i].power = power;
327329
}
328330

329-
if (i == 0) {
331+
rcu_read_unlock();
332+
333+
if (i != num_opps) {
330334
ret = PTR_ERR(opp);
331-
goto unlock;
335+
goto free_power_table;
332336
}
333337

334338
cpufreq_device->cpu_dev = dev;
335339
cpufreq_device->dyn_power_table = power_table;
336340
cpufreq_device->dyn_power_table_entries = i;
337341

338-
unlock:
339-
rcu_read_unlock();
342+
return 0;
343+
344+
free_power_table:
345+
kfree(power_table);
346+
340347
return ret;
341348
}
342349

@@ -847,7 +854,7 @@ __cpufreq_cooling_register(struct device_node *np,
847854
ret = get_idr(&cpufreq_idr, &cpufreq_dev->id);
848855
if (ret) {
849856
cool_dev = ERR_PTR(ret);
850-
goto free_table;
857+
goto free_power_table;
851858
}
852859

853860
snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
@@ -889,6 +896,8 @@ __cpufreq_cooling_register(struct device_node *np,
889896

890897
remove_idr:
891898
release_idr(&cpufreq_idr, cpufreq_dev->id);
899+
free_power_table:
900+
kfree(cpufreq_dev->dyn_power_table);
892901
free_table:
893902
kfree(cpufreq_dev->freq_table);
894903
free_time_in_idle_timestamp:
@@ -1039,6 +1048,7 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
10391048

10401049
thermal_cooling_device_unregister(cpufreq_dev->cool_dev);
10411050
release_idr(&cpufreq_idr, cpufreq_dev->id);
1051+
kfree(cpufreq_dev->dyn_power_table);
10421052
kfree(cpufreq_dev->time_in_idle_timestamp);
10431053
kfree(cpufreq_dev->time_in_idle);
10441054
kfree(cpufreq_dev->freq_table);

‎drivers/thermal/db8500_cpufreq_cooling.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static const struct of_device_id db8500_cpufreq_cooling_match[] = {
7272
{ .compatible = "stericsson,db8500-cpufreq-cooling" },
7373
{},
7474
};
75+
MODULE_DEVICE_TABLE(of, db8500_cpufreq_cooling_match);
7576
#endif
7677

7778
static struct platform_driver db8500_cpufreq_cooling_driver = {

0 commit comments

Comments
 (0)