drivers/thermal/thermal_debugfs.c
Source file repositories/reference/linux-study-clean/drivers/thermal/thermal_debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/thermal_debugfs.c- Extension
.c- Size
- 25614 bytes
- Lines
- 969
- Domain
- Driver Families
- Bucket
- drivers/thermal
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/ktime.hlinux/list.hlinux/minmax.hlinux/mutex.hlinux/thermal.hthermal_core.h
Detected Declarations
struct cdev_debugfsstruct cdev_recordstruct trip_statsstruct tz_episodestruct tz_debugfsstruct thermal_debugfsfunction thermal_debug_initfunction thermal_debugfs_remove_idfunction thermal_debugfs_cdev_record_allocfunction thermal_debugfs_cdev_record_findfunction thermal_debugfs_cdev_record_getfunction thermal_debugfs_cdev_clearfunction list_for_each_entry_safefunction list_for_each_entry_safefunction cdev_seq_stopfunction cdev_tt_seq_showfunction list_for_each_entryfunction cdev_dt_seq_showfunction list_for_each_entryfunction cdev_clear_setfunction thermal_debug_cdev_state_updatefunction thermal_debug_cdev_addfunction thermal_debug_cdev_removefunction thermal_debug_tz_trip_upfunction tz_episode_close_tripfunction thermal_debug_tz_trip_downfunction thermal_debug_update_trip_statsfunction tze_seq_stopfunction tze_seq_showfunction for_each_trip_descfunction thermal_debug_tz_addfunction thermal_debug_tz_removefunction list_for_each_entry_safefunction thermal_debug_tz_resume
Annotated Snippet
struct cdev_debugfs {
u32 total;
int current_state;
ktime_t timestamp;
struct list_head transitions[CDEVSTATS_HASH_SIZE];
struct list_head durations[CDEVSTATS_HASH_SIZE];
};
/**
* struct cdev_record - Common structure for cooling device entry
*
* The following common structure allows to store the information
* related to the transitions and to the state residencies. They are
* identified with a id which is associated to a value. It is used as
* nodes for the "transitions" and "durations" above.
*
* @node: node to insert the structure in a list
* @id: identifier of the value which can be a state or a transition
* @residency: a ktime_t representing a state residency duration
* @count: a number of occurrences
*/
struct cdev_record {
struct list_head node;
int id;
union {
ktime_t residency;
u64 count;
};
};
/**
* struct trip_stats - Thermal trip statistics
*
* The trip_stats structure has the relevant information to show the
* statistics related to temperature going above a trip point.
*
* @timestamp: the trip crossing timestamp
* @duration: total time when the zone temperature was above the trip point
* @trip_temp: trip temperature at mitigation start
* @trip_hyst: trip hysteresis at mitigation start
* @count: the number of times the zone temperature was above the trip point
* @min: minimum recorded temperature above the trip point
* @avg: average temperature above the trip point
*/
struct trip_stats {
ktime_t timestamp;
ktime_t duration;
int trip_temp;
int trip_hyst;
int count;
int min;
int avg;
};
/**
* struct tz_episode - A mitigation episode information
*
* The tz_episode structure describes a mitigation episode. A
* mitigation episode begins the trip point with the lower temperature
* is crossed the way up and ends when it is crossed the way
* down. During this episode we can have multiple trip points crossed
* the way up and down if there are multiple trip described in the
* firmware after the lowest temperature trip point.
*
* @timestamp: first trip point crossed the way up
* @duration: total duration of the mitigation episode
* @node: a list element to be added to the list of tz events
* @max_temp: maximum zone temperature during this episode
* @trip_stats: per trip point statistics, flexible array
*/
struct tz_episode {
ktime_t timestamp;
ktime_t duration;
struct list_head node;
int max_temp;
struct trip_stats trip_stats[];
};
/**
* struct tz_debugfs - Store all mitigation episodes for a thermal zone
*
* The tz_debugfs structure contains the list of the mitigation
* episodes and has to track which trip point has been crossed in
* order to handle correctly nested trip point mitigation episodes.
*
* We keep the history of the trip point crossed in an array and as we
* can go back and forth inside this history, eg. trip 0,1,2,1,2,1,0,
* we keep track of the current position in the history array.
*
* @tz_episodes: a list of thermal mitigation episodes
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/ktime.h`, `linux/list.h`, `linux/minmax.h`, `linux/mutex.h`, `linux/thermal.h`, `thermal_core.h`.
- Detected declarations: `struct cdev_debugfs`, `struct cdev_record`, `struct trip_stats`, `struct tz_episode`, `struct tz_debugfs`, `struct thermal_debugfs`, `function thermal_debug_init`, `function thermal_debugfs_remove_id`, `function thermal_debugfs_cdev_record_alloc`, `function thermal_debugfs_cdev_record_find`.
- Atlas domain: Driver Families / drivers/thermal.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.