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 #include "thermal_core.h"
14 TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL
);
15 TRACE_DEFINE_ENUM(THERMAL_TRIP_HOT
);
16 TRACE_DEFINE_ENUM(THERMAL_TRIP_PASSIVE
);
17 TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE
);
19 #define show_tzt_type(type) \
20 __print_symbolic(type, \
21 { THERMAL_TRIP_CRITICAL, "CRITICAL"}, \
22 { THERMAL_TRIP_HOT, "HOT"}, \
23 { THERMAL_TRIP_PASSIVE, "PASSIVE"}, \
24 { THERMAL_TRIP_ACTIVE, "ACTIVE"})
26 TRACE_EVENT(thermal_temperature
,
28 TP_PROTO(struct thermal_zone_device
*tz
),
33 __string(thermal_zone
, tz
->type
)
35 __field(int, temp_prev
)
40 __assign_str(thermal_zone
);
42 __entry
->temp_prev
= tz
->last_temperature
;
43 __entry
->temp
= tz
->temperature
;
46 TP_printk("thermal_zone=%s id=%d temp_prev=%d temp=%d",
47 __get_str(thermal_zone
), __entry
->id
, __entry
->temp_prev
,
51 TRACE_EVENT(cdev_update
,
53 TP_PROTO(struct thermal_cooling_device
*cdev
, unsigned long target
),
55 TP_ARGS(cdev
, target
),
58 __string(type
, cdev
->type
)
59 __field(unsigned long, target
)
64 __entry
->target
= target
;
67 TP_printk("type=%s target=%lu", __get_str(type
), __entry
->target
)
70 TRACE_EVENT(thermal_zone_trip
,
72 TP_PROTO(struct thermal_zone_device
*tz
, int trip
,
73 enum thermal_trip_type trip_type
),
75 TP_ARGS(tz
, trip
, trip_type
),
78 __string(thermal_zone
, tz
->type
)
81 __field(enum thermal_trip_type
, trip_type
)
85 __assign_str(thermal_zone
);
88 __entry
->trip_type
= trip_type
;
91 TP_printk("thermal_zone=%s id=%d trip=%d trip_type=%s",
92 __get_str(thermal_zone
), __entry
->id
, __entry
->trip
,
93 show_tzt_type(__entry
->trip_type
))
96 #ifdef CONFIG_CPU_THERMAL
97 TRACE_EVENT(thermal_power_cpu_get_power_simple
,
98 TP_PROTO(int cpu
, u32 power
),
109 __entry
->power
= power
;
112 TP_printk("cpu=%d power=%u", __entry
->cpu
, __entry
->power
)
115 TRACE_EVENT(thermal_power_cpu_limit
,
116 TP_PROTO(const struct cpumask
*cpus
, unsigned int freq
,
117 unsigned long cdev_state
, u32 power
),
119 TP_ARGS(cpus
, freq
, cdev_state
, power
),
122 __bitmask(cpumask
, num_possible_cpus())
123 __field(unsigned int, freq
)
124 __field(unsigned long, cdev_state
)
129 __assign_bitmask(cpumask
, cpumask_bits(cpus
),
130 num_possible_cpus());
131 __entry
->freq
= freq
;
132 __entry
->cdev_state
= cdev_state
;
133 __entry
->power
= power
;
136 TP_printk("cpus=%s freq=%u cdev_state=%lu power=%u",
137 __get_bitmask(cpumask
), __entry
->freq
, __entry
->cdev_state
,
140 #endif /* CONFIG_CPU_THERMAL */
142 #ifdef CONFIG_DEVFREQ_THERMAL
143 TRACE_EVENT(thermal_power_devfreq_get_power
,
144 TP_PROTO(struct thermal_cooling_device
*cdev
,
145 struct devfreq_dev_status
*status
, unsigned long freq
,
148 TP_ARGS(cdev
, status
, freq
, power
),
151 __string(type
, cdev
->type
)
152 __field(unsigned long, freq
)
153 __field(u32
, busy_time
)
154 __field(u32
, total_time
)
160 __entry
->freq
= freq
;
161 __entry
->busy_time
= status
->busy_time
;
162 __entry
->total_time
= status
->total_time
;
163 __entry
->power
= power
;
166 TP_printk("type=%s freq=%lu load=%u power=%u",
167 __get_str(type
), __entry
->freq
,
168 __entry
->total_time
== 0 ? 0 :
169 (100 * __entry
->busy_time
) / __entry
->total_time
,
173 TRACE_EVENT(thermal_power_devfreq_limit
,
174 TP_PROTO(struct thermal_cooling_device
*cdev
, unsigned long freq
,
175 unsigned long cdev_state
, u32 power
),
177 TP_ARGS(cdev
, freq
, cdev_state
, power
),
180 __string(type
, cdev
->type
)
181 __field(unsigned int, freq
)
182 __field(unsigned long, cdev_state
)
188 __entry
->freq
= freq
;
189 __entry
->cdev_state
= cdev_state
;
190 __entry
->power
= power
;
193 TP_printk("type=%s freq=%u cdev_state=%lu power=%u",
194 __get_str(type
), __entry
->freq
, __entry
->cdev_state
,
197 #endif /* CONFIG_DEVFREQ_THERMAL */
198 #endif /* _TRACE_THERMAL_H */
200 #undef TRACE_INCLUDE_PATH
201 #define TRACE_INCLUDE_PATH .
203 #undef TRACE_INCLUDE_FILE
204 #define TRACE_INCLUDE_FILE thermal_trace
206 /* This part must be outside protection */
207 #include <trace/define_trace.h>