Skip to content

Commit 755113d

Browse files
dlezcanorafaeljw
authored andcommitted
thermal/debugfs: Add thermal cooling device debugfs information
The thermal framework does not have any debug information except a sysfs stat which is a bit controversial. This one allocates big chunks of memory for every cooling devices with a high number of states and could represent on some systems in production several megabytes of memory for just a portion of it. As the sysfs is limited to a page size, the output is not exploitable with large data array and gets truncated. The patch provides the same information than sysfs except the transitions are dynamically allocated, thus they won't show more events than the ones which actually occurred. There is no longer a size limitation and it opens the field for more debugging information where the debugfs is designed for, not sysfs. The thermal debugfs directory structure tries to stay consistent with the sysfs one but in a very simplified way: thermal/ -- cooling_devices |-- 0 | |-- clear | |-- time_in_state_ms | |-- total_trans | `-- trans_table |-- 1 | |-- clear | |-- time_in_state_ms | |-- total_trans | `-- trans_table |-- 2 | |-- clear | |-- time_in_state_ms | |-- total_trans | `-- trans_table |-- 3 | |-- clear | |-- time_in_state_ms | |-- total_trans | `-- trans_table `-- 4 |-- clear |-- time_in_state_ms |-- total_trans `-- trans_table The content of the files in the cooling devices directory is the same as the sysfs one except for the trans_table which has the following format: Transition Hits 1->0 246 0->1 246 2->1 632 1->2 632 3->2 98 2->3 98 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> [ rjw: White space fixups, rebase ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 2f52189 commit 755113d

8 files changed

Lines changed: 497 additions & 6 deletions

File tree

drivers/thermal/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ config THERMAL_STATISTICS
3333

3434
If in doubt, say N.
3535

36+
config THERMAL_DEBUGFS
37+
bool "Thermal subsystem debug support"
38+
depends on DEBUG_FS
39+
help
40+
Say Y to allow the thermal subsystem to collect diagnostic
41+
information that can be accessed via debugfs.
42+
3643
config THERMAL_EMERGENCY_POWEROFF_DELAY_MS
3744
int "Emergency poweroff delay in milli-seconds"
3845
default 0

drivers/thermal/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ thermal_sys-y += thermal_trip.o thermal_helpers.o
1010
# netlink interface to manage the thermal framework
1111
thermal_sys-$(CONFIG_THERMAL_NETLINK) += thermal_netlink.o
1212

13+
thermal_sys-$(CONFIG_THERMAL_DEBUGFS) += thermal_debugfs.o
14+
1315
# interface to/from other layers providing sensors
1416
thermal_sys-$(CONFIG_THERMAL_HWMON) += thermal_hwmon.o
1517
thermal_sys-$(CONFIG_THERMAL_OF) += thermal_of.o

drivers/thermal/thermal_core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,8 @@ __thermal_cooling_device_register(struct device_node *np,
960960

961961
mutex_unlock(&thermal_list_lock);
962962

963+
thermal_debug_cdev_add(cdev);
964+
963965
return cdev;
964966

965967
out_cooling_dev:
@@ -1166,6 +1168,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
11661168
if (!cdev)
11671169
return;
11681170

1171+
thermal_debug_cdev_remove(cdev);
1172+
11691173
mutex_lock(&thermal_list_lock);
11701174

11711175
if (!thermal_cooling_device_present(cdev)) {
@@ -1629,6 +1633,8 @@ static int __init thermal_init(void)
16291633
{
16301634
int result;
16311635

1636+
thermal_debug_init();
1637+
16321638
result = thermal_netlink_init();
16331639
if (result)
16341640
goto error;

drivers/thermal/thermal_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/thermal.h>
1414

1515
#include "thermal_netlink.h"
16+
#include "thermal_debugfs.h"
1617

1718
/* Default Thermal Governor */
1819
#if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE)

0 commit comments

Comments
 (0)