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

thermal: debug: add debug statement for core and step_wise

To ease debugging thermal problem, add these dynamic debug statements
so that user do not need rebuild kernel to see these info.

Based on a patch from Zhang Rui for debugging on bugzilla:
https://bugzilla.kernel.org/attachment.cgi?id=98671

A sample output after we turn on dynamic debug with the following cmd:
# echo 'module thermal_sys +fp' > /sys/kernel/debug/dynamic_debug/control
is like:

[ 355.147627] update_temperature: thermal thermal_zone0: last_temperature=52000, current_temperature=55000
[ 355.147636] thermal_zone_trip_update: thermal thermal_zone0: Trip1[type=1,temp=79000]:trend=2,throttle=0
[ 355.147644] get_target_state: thermal cooling_device8: cur_state=0
[ 355.147647] thermal_zone_trip_update: thermal cooling_device8: old_target=-1, target=-1
[ 355.147652] get_target_state: thermal cooling_device7: cur_state=0
[ 355.147655] thermal_zone_trip_update: thermal cooling_device7: old_target=-1, target=-1
[ 355.147660] get_target_state: thermal cooling_device6: cur_state=0
[ 355.147663] thermal_zone_trip_update: thermal cooling_device6: old_target=-1, target=-1
[ 355.147668] get_target_state: thermal cooling_device5: cur_state=0
[ 355.147671] thermal_zone_trip_update: thermal cooling_device5: old_target=-1, target=-1
[ 355.147678] thermal_zone_trip_update: thermal thermal_zone0: Trip2[type=0,temp=90000]:trend=1,throttle=0
[ 355.147776] get_target_state: thermal cooling_device0: cur_state=0
[ 355.147783] thermal_zone_trip_update: thermal cooling_device0: old_target=-1, target=-1
[ 355.147792] thermal_zone_trip_update: thermal thermal_zone0: Trip3[type=0,temp=80000]:trend=1,throttle=0
[ 355.147845] get_target_state: thermal cooling_device1: cur_state=0
[ 355.147849] thermal_zone_trip_update: thermal cooling_device1: old_target=-1, target=-1
[ 355.147856] thermal_zone_trip_update: thermal thermal_zone0: Trip4[type=0,temp=70000]:trend=1,throttle=0
[ 355.147904] get_target_state: thermal cooling_device2: cur_state=0
[ 355.147908] thermal_zone_trip_update: thermal cooling_device2: old_target=-1, target=-1
[ 355.147915] thermal_zone_trip_update: thermal thermal_zone0: Trip5[type=0,temp=60000]:trend=1,throttle=0
[ 355.147963] get_target_state: thermal cooling_device3: cur_state=0
[ 355.147967] thermal_zone_trip_update: thermal cooling_device3: old_target=-1, target=-1
[ 355.147973] thermal_zone_trip_update: thermal thermal_zone0: Trip6[type=0,temp=55000]:trend=1,throttle=1
[ 355.148022] get_target_state: thermal cooling_device4: cur_state=0
[ 355.148025] thermal_zone_trip_update: thermal cooling_device4: old_target=-1, target=1
[ 355.148036] thermal_cdev_update: thermal cooling_device4: zone0->target=1
[ 355.169279] thermal_cdev_update: thermal cooling_device4: set to state 1

Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>

authored by

Aaron Lu and committed by
Zhang Rui
06475b55 dea4f48a

+12
+6
drivers/thermal/step_wise.c
··· 60 60 */ 61 61 cdev->ops->get_cur_state(cdev, &cur_state); 62 62 next_target = instance->target; 63 + dev_dbg(&cdev->device, "cur_state=%ld\n", cur_state); 63 64 64 65 switch (trend) { 65 66 case THERMAL_TREND_RAISING: ··· 132 131 if (tz->temperature >= trip_temp) 133 132 throttle = true; 134 133 134 + dev_dbg(&tz->device, "Trip%d[type=%d,temp=%ld]:trend=%d,throttle=%d\n", 135 + trip, trip_type, trip_temp, trend, throttle); 136 + 135 137 mutex_lock(&tz->lock); 136 138 137 139 list_for_each_entry(instance, &tz->thermal_instances, tz_node) { ··· 143 139 144 140 old_target = instance->target; 145 141 instance->target = get_target_state(instance, trend, throttle); 142 + dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n", 143 + old_target, (int)instance->target); 146 144 147 145 if (old_target == instance->target) 148 146 continue;
+6
drivers/thermal/thermal_core.c
··· 450 450 tz->last_temperature = tz->temperature; 451 451 tz->temperature = temp; 452 452 mutex_unlock(&tz->lock); 453 + 454 + dev_dbg(&tz->device, "last_temperature=%d, current_temperature=%d\n", 455 + tz->last_temperature, tz->temperature); 453 456 } 454 457 455 458 void thermal_zone_device_update(struct thermal_zone_device *tz) ··· 1210 1207 mutex_lock(&cdev->lock); 1211 1208 /* Make sure cdev enters the deepest cooling state */ 1212 1209 list_for_each_entry(instance, &cdev->thermal_instances, cdev_node) { 1210 + dev_dbg(&cdev->device, "zone%d->target=%lu\n", 1211 + instance->tz->id, instance->target); 1213 1212 if (instance->target == THERMAL_NO_TARGET) 1214 1213 continue; 1215 1214 if (instance->target > target) ··· 1220 1215 mutex_unlock(&cdev->lock); 1221 1216 cdev->ops->set_cur_state(cdev, target); 1222 1217 cdev->updated = true; 1218 + dev_dbg(&cdev->device, "set to state %lu\n", target); 1223 1219 } 1224 1220 EXPORT_SYMBOL(thermal_cdev_update); 1225 1221