1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM thermal
5 #if !defined(_TRACE_THERMAL_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_THERMAL_H
8 #include <linux/devfreq.h>
9 #include <linux/thermal.h>
10 #include <linux/tracepoint.h>
12 TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL);
13 TRACE_DEFINE_ENUM(THERMAL_TRIP_HOT);
14 TRACE_DEFINE_ENUM(THERMAL_TRIP_PASSIVE);
15 TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
17 #define show_tzt_type(type) \
18 __print_symbolic(type, \
19 { THERMAL_TRIP_CRITICAL, "CRITICAL"}, \
20 { THERMAL_TRIP_HOT, "HOT"}, \
21 { THERMAL_TRIP_PASSIVE, "PASSIVE"}, \
22 { THERMAL_TRIP_ACTIVE, "ACTIVE"})
24 TRACE_EVENT(thermal_temperature,
26 TP_PROTO(struct thermal_zone_device *tz),
31 __string(thermal_zone, tz->type)
33 __field(int, temp_prev)
38 __assign_str(thermal_zone, tz->type);
40 __entry->temp_prev = tz->last_temperature;
41 __entry->temp = tz->temperature;
44 TP_printk("thermal_zone=%s id=%d temp_prev=%d temp=%d",
45 __get_str(thermal_zone), __entry->id, __entry->temp_prev,
49 TRACE_EVENT(cdev_update,
51 TP_PROTO(struct thermal_cooling_device *cdev, unsigned long target),
53 TP_ARGS(cdev, target),
56 __string(type, cdev->type)
57 __field(unsigned long, target)
61 __assign_str(type, cdev->type);
62 __entry->target = target;
65 TP_printk("type=%s target=%lu", __get_str(type), __entry->target)
68 TRACE_EVENT(thermal_zone_trip,
70 TP_PROTO(struct thermal_zone_device *tz, int trip,
71 enum thermal_trip_type trip_type),
73 TP_ARGS(tz, trip, trip_type),
76 __string(thermal_zone, tz->type)
79 __field(enum thermal_trip_type, trip_type)
83 __assign_str(thermal_zone, tz->type);
86 __entry->trip_type = trip_type;
89 TP_printk("thermal_zone=%s id=%d trip=%d trip_type=%s",
90 __get_str(thermal_zone), __entry->id, __entry->trip,
91 show_tzt_type(__entry->trip_type))
94 #ifdef CONFIG_CPU_THERMAL
95 TRACE_EVENT(thermal_power_cpu_get_power_simple,
96 TP_PROTO(int cpu, u32 power),
107 __entry->power = power;
110 TP_printk("cpu=%d power=%u", __entry->cpu, __entry->power)
113 TRACE_EVENT(thermal_power_cpu_limit,
114 TP_PROTO(const struct cpumask *cpus, unsigned int freq,
115 unsigned long cdev_state, u32 power),
117 TP_ARGS(cpus, freq, cdev_state, power),
120 __bitmask(cpumask, num_possible_cpus())
121 __field(unsigned int, freq )
122 __field(unsigned long, cdev_state)
127 __assign_bitmask(cpumask, cpumask_bits(cpus),
128 num_possible_cpus());
129 __entry->freq = freq;
130 __entry->cdev_state = cdev_state;
131 __entry->power = power;
134 TP_printk("cpus=%s freq=%u cdev_state=%lu power=%u",
135 __get_bitmask(cpumask), __entry->freq, __entry->cdev_state,
138 #endif /* CONFIG_CPU_THERMAL */
140 #ifdef CONFIG_DEVFREQ_THERMAL
141 TRACE_EVENT(thermal_power_devfreq_get_power,
142 TP_PROTO(struct thermal_cooling_device *cdev,
143 struct devfreq_dev_status *status, unsigned long freq,
146 TP_ARGS(cdev, status, freq, power),
149 __string(type, cdev->type )
150 __field(unsigned long, freq )
151 __field(u32, busy_time)
152 __field(u32, total_time)
157 __assign_str(type, cdev->type);
158 __entry->freq = freq;
159 __entry->busy_time = status->busy_time;
160 __entry->total_time = status->total_time;
161 __entry->power = power;
164 TP_printk("type=%s freq=%lu load=%u power=%u",
165 __get_str(type), __entry->freq,
166 __entry->total_time == 0 ? 0 :
167 (100 * __entry->busy_time) / __entry->total_time,
171 TRACE_EVENT(thermal_power_devfreq_limit,
172 TP_PROTO(struct thermal_cooling_device *cdev, unsigned long freq,
173 unsigned long cdev_state, u32 power),
175 TP_ARGS(cdev, freq, cdev_state, power),
178 __string(type, cdev->type)
179 __field(unsigned int, freq )
180 __field(unsigned long, cdev_state)
185 __assign_str(type, cdev->type);
186 __entry->freq = freq;
187 __entry->cdev_state = cdev_state;
188 __entry->power = power;
191 TP_printk("type=%s freq=%u cdev_state=%lu power=%u",
192 __get_str(type), __entry->freq, __entry->cdev_state,
195 #endif /* CONFIG_DEVFREQ_THERMAL */
196 #endif /* _TRACE_THERMAL_H */
198 #undef TRACE_INCLUDE_PATH
199 #define TRACE_INCLUDE_PATH .
201 #undef TRACE_INCLUDE_FILE
202 #define TRACE_INCLUDE_FILE thermal_trace
204 /* This part must be outside protection */
205 #include <trace/define_trace.h>