xref: /linux/drivers/thermal/thermal_trace.h (revision bf36793fa260cb68cc817f311f1f683788261796)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM thermal
4 
5 #if !defined(_TRACE_THERMAL_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_THERMAL_H
7 
8 #include <linux/devfreq.h>
9 #include <linux/thermal.h>
10 #include <linux/tracepoint.h>
11 
12 #include "thermal_core.h"
13 
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);
18 
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"})
25 
26 TRACE_EVENT(thermal_temperature,
27 
28 	TP_PROTO(struct thermal_zone_device *tz),
29 
30 	TP_ARGS(tz),
31 
32 	TP_STRUCT__entry(
33 		__string(thermal_zone, tz->type)
34 		__field(int, id)
35 		__field(int, temp_prev)
36 		__field(int, temp)
37 	),
38 
39 	TP_fast_assign(
40 		__assign_str(thermal_zone);
41 		__entry->id = tz->id;
42 		__entry->temp_prev = tz->last_temperature;
43 		__entry->temp = tz->temperature;
44 	),
45 
46 	TP_printk("thermal_zone=%s id=%d temp_prev=%d temp=%d",
47 		__get_str(thermal_zone), __entry->id, __entry->temp_prev,
48 		__entry->temp)
49 );
50 
51 TRACE_EVENT(cdev_update,
52 
53 	TP_PROTO(struct thermal_cooling_device *cdev, unsigned long target),
54 
55 	TP_ARGS(cdev, target),
56 
57 	TP_STRUCT__entry(
58 		__string(type, cdev->type)
59 		__field(unsigned long, target)
60 	),
61 
62 	TP_fast_assign(
63 		__assign_str(type);
64 		__entry->target = target;
65 	),
66 
67 	TP_printk("type=%s target=%lu", __get_str(type), __entry->target)
68 );
69 
70 TRACE_EVENT(thermal_zone_trip,
71 
72 	TP_PROTO(struct thermal_zone_device *tz, int trip,
73 		enum thermal_trip_type trip_type),
74 
75 	TP_ARGS(tz, trip, trip_type),
76 
77 	TP_STRUCT__entry(
78 		__string(thermal_zone, tz->type)
79 		__field(int, id)
80 		__field(int, trip)
81 		__field(enum thermal_trip_type, trip_type)
82 	),
83 
84 	TP_fast_assign(
85 		__assign_str(thermal_zone);
86 		__entry->id = tz->id;
87 		__entry->trip = trip;
88 		__entry->trip_type = trip_type;
89 	),
90 
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))
94 );
95 
96 #ifdef CONFIG_CPU_THERMAL
97 TRACE_EVENT(thermal_power_cpu_get_power_simple,
98 	TP_PROTO(int cpu, u32 power),
99 
100 	TP_ARGS(cpu, power),
101 
102 	TP_STRUCT__entry(
103 		__field(int, cpu)
104 		__field(u32, power)
105 	),
106 
107 	TP_fast_assign(
108 		__entry->cpu = cpu;
109 		__entry->power = power;
110 	),
111 
112 	TP_printk("cpu=%d power=%u", __entry->cpu, __entry->power)
113 );
114 
115 TRACE_EVENT(thermal_power_cpu_limit,
116 	TP_PROTO(const struct cpumask *cpus, unsigned int freq,
117 		unsigned long cdev_state, u32 power),
118 
119 	TP_ARGS(cpus, freq, cdev_state, power),
120 
121 	TP_STRUCT__entry(
122 		__bitmask(cpumask, num_possible_cpus())
123 		__field(unsigned int,  freq      )
124 		__field(unsigned long, cdev_state)
125 		__field(u32,           power     )
126 	),
127 
128 	TP_fast_assign(
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;
134 	),
135 
136 	TP_printk("cpus=%s freq=%u cdev_state=%lu power=%u",
137 		__get_bitmask(cpumask), __entry->freq, __entry->cdev_state,
138 		__entry->power)
139 );
140 #endif /* CONFIG_CPU_THERMAL */
141 
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,
146 		u32 power),
147 
148 	TP_ARGS(cdev, status,  freq, power),
149 
150 	TP_STRUCT__entry(
151 		__string(type,         cdev->type    )
152 		__field(unsigned long, freq          )
153 		__field(u32,           busy_time)
154 		__field(u32,           total_time)
155 		__field(u32,           power)
156 	),
157 
158 	TP_fast_assign(
159 		__assign_str(type);
160 		__entry->freq = freq;
161 		__entry->busy_time = status->busy_time;
162 		__entry->total_time = status->total_time;
163 		__entry->power = power;
164 	),
165 
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,
170 		__entry->power)
171 );
172 
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),
176 
177 	TP_ARGS(cdev, freq, cdev_state, power),
178 
179 	TP_STRUCT__entry(
180 		__string(type,         cdev->type)
181 		__field(unsigned int,  freq      )
182 		__field(unsigned long, cdev_state)
183 		__field(u32,           power     )
184 	),
185 
186 	TP_fast_assign(
187 		__assign_str(type);
188 		__entry->freq = freq;
189 		__entry->cdev_state = cdev_state;
190 		__entry->power = power;
191 	),
192 
193 	TP_printk("type=%s freq=%u cdev_state=%lu power=%u",
194 		__get_str(type), __entry->freq, __entry->cdev_state,
195 		__entry->power)
196 );
197 #endif /* CONFIG_DEVFREQ_THERMAL */
198 #endif /* _TRACE_THERMAL_H */
199 
200 #undef TRACE_INCLUDE_PATH
201 #define TRACE_INCLUDE_PATH .
202 
203 #undef TRACE_INCLUDE_FILE
204 #define TRACE_INCLUDE_FILE thermal_trace
205 
206 /* This part must be outside protection */
207 #include <trace/define_trace.h>
208