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.

Dependency Surface

Detected Declarations

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

Implementation Notes