xref: /openbmc/linux/include/trace/events/power.h (revision 12eb4683)
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM power
3 
4 #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_POWER_H
6 
7 #include <linux/ktime.h>
8 #include <linux/pm_qos.h>
9 #include <linux/tracepoint.h>
10 
11 DECLARE_EVENT_CLASS(cpu,
12 
13 	TP_PROTO(unsigned int state, unsigned int cpu_id),
14 
15 	TP_ARGS(state, cpu_id),
16 
17 	TP_STRUCT__entry(
18 		__field(	u32,		state		)
19 		__field(	u32,		cpu_id		)
20 	),
21 
22 	TP_fast_assign(
23 		__entry->state = state;
24 		__entry->cpu_id = cpu_id;
25 	),
26 
27 	TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
28 		  (unsigned long)__entry->cpu_id)
29 );
30 
31 DEFINE_EVENT(cpu, cpu_idle,
32 
33 	TP_PROTO(unsigned int state, unsigned int cpu_id),
34 
35 	TP_ARGS(state, cpu_id)
36 );
37 
38 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
39 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
40 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
41 
42 #define PWR_EVENT_EXIT -1
43 #endif
44 
45 DEFINE_EVENT(cpu, cpu_frequency,
46 
47 	TP_PROTO(unsigned int frequency, unsigned int cpu_id),
48 
49 	TP_ARGS(frequency, cpu_id)
50 );
51 
52 TRACE_EVENT(machine_suspend,
53 
54 	TP_PROTO(unsigned int state),
55 
56 	TP_ARGS(state),
57 
58 	TP_STRUCT__entry(
59 		__field(	u32,		state		)
60 	),
61 
62 	TP_fast_assign(
63 		__entry->state = state;
64 	),
65 
66 	TP_printk("state=%lu", (unsigned long)__entry->state)
67 );
68 
69 TRACE_EVENT(device_pm_report_time,
70 
71 	TP_PROTO(struct device *dev, const char *pm_ops, s64 ops_time,
72 		 char *pm_event_str, int error),
73 
74 	TP_ARGS(dev, pm_ops, ops_time, pm_event_str, error),
75 
76 	TP_STRUCT__entry(
77 		__string(device, dev_name(dev))
78 		__string(driver, dev_driver_string(dev))
79 		__string(parent, dev->parent ? dev_name(dev->parent) : "none")
80 		__string(pm_ops, pm_ops ? pm_ops : "none ")
81 		__string(pm_event_str, pm_event_str)
82 		__field(s64, ops_time)
83 		__field(int, error)
84 	),
85 
86 	TP_fast_assign(
87 		const char *tmp = dev->parent ? dev_name(dev->parent) : "none";
88 		const char *tmp_i = pm_ops ? pm_ops : "none ";
89 
90 		__assign_str(device, dev_name(dev));
91 		__assign_str(driver, dev_driver_string(dev));
92 		__assign_str(parent, tmp);
93 		__assign_str(pm_ops, tmp_i);
94 		__assign_str(pm_event_str, pm_event_str);
95 		__entry->ops_time = ops_time;
96 		__entry->error = error;
97 	),
98 
99 	/* ops_str has an extra space at the end */
100 	TP_printk("%s %s parent=%s state=%s ops=%snsecs=%lld err=%d",
101 		__get_str(driver), __get_str(device), __get_str(parent),
102 		__get_str(pm_event_str), __get_str(pm_ops),
103 		__entry->ops_time, __entry->error)
104 );
105 
106 DECLARE_EVENT_CLASS(wakeup_source,
107 
108 	TP_PROTO(const char *name, unsigned int state),
109 
110 	TP_ARGS(name, state),
111 
112 	TP_STRUCT__entry(
113 		__string(       name,           name            )
114 		__field(        u64,            state           )
115 	),
116 
117 	TP_fast_assign(
118 		__assign_str(name, name);
119 		__entry->state = state;
120 	),
121 
122 	TP_printk("%s state=0x%lx", __get_str(name),
123 		(unsigned long)__entry->state)
124 );
125 
126 DEFINE_EVENT(wakeup_source, wakeup_source_activate,
127 
128 	TP_PROTO(const char *name, unsigned int state),
129 
130 	TP_ARGS(name, state)
131 );
132 
133 DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
134 
135 	TP_PROTO(const char *name, unsigned int state),
136 
137 	TP_ARGS(name, state)
138 );
139 
140 /*
141  * The clock events are used for clock enable/disable and for
142  *  clock rate change
143  */
144 DECLARE_EVENT_CLASS(clock,
145 
146 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
147 
148 	TP_ARGS(name, state, cpu_id),
149 
150 	TP_STRUCT__entry(
151 		__string(       name,           name            )
152 		__field(        u64,            state           )
153 		__field(        u64,            cpu_id          )
154 	),
155 
156 	TP_fast_assign(
157 		__assign_str(name, name);
158 		__entry->state = state;
159 		__entry->cpu_id = cpu_id;
160 	),
161 
162 	TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
163 		(unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
164 );
165 
166 DEFINE_EVENT(clock, clock_enable,
167 
168 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
169 
170 	TP_ARGS(name, state, cpu_id)
171 );
172 
173 DEFINE_EVENT(clock, clock_disable,
174 
175 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
176 
177 	TP_ARGS(name, state, cpu_id)
178 );
179 
180 DEFINE_EVENT(clock, clock_set_rate,
181 
182 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
183 
184 	TP_ARGS(name, state, cpu_id)
185 );
186 
187 /*
188  * The power domain events are used for power domains transitions
189  */
190 DECLARE_EVENT_CLASS(power_domain,
191 
192 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
193 
194 	TP_ARGS(name, state, cpu_id),
195 
196 	TP_STRUCT__entry(
197 		__string(       name,           name            )
198 		__field(        u64,            state           )
199 		__field(        u64,            cpu_id          )
200 	),
201 
202 	TP_fast_assign(
203 		__assign_str(name, name);
204 		__entry->state = state;
205 		__entry->cpu_id = cpu_id;
206 ),
207 
208 	TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
209 		(unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
210 );
211 
212 DEFINE_EVENT(power_domain, power_domain_target,
213 
214 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
215 
216 	TP_ARGS(name, state, cpu_id)
217 );
218 
219 /*
220  * The pm qos events are used for pm qos update
221  */
222 DECLARE_EVENT_CLASS(pm_qos_request,
223 
224 	TP_PROTO(int pm_qos_class, s32 value),
225 
226 	TP_ARGS(pm_qos_class, value),
227 
228 	TP_STRUCT__entry(
229 		__field( int,                    pm_qos_class   )
230 		__field( s32,                    value          )
231 	),
232 
233 	TP_fast_assign(
234 		__entry->pm_qos_class = pm_qos_class;
235 		__entry->value = value;
236 	),
237 
238 	TP_printk("pm_qos_class=%s value=%d",
239 		  __print_symbolic(__entry->pm_qos_class,
240 			{ PM_QOS_CPU_DMA_LATENCY,	"CPU_DMA_LATENCY" },
241 			{ PM_QOS_NETWORK_LATENCY,	"NETWORK_LATENCY" },
242 			{ PM_QOS_NETWORK_THROUGHPUT,	"NETWORK_THROUGHPUT" }),
243 		  __entry->value)
244 );
245 
246 DEFINE_EVENT(pm_qos_request, pm_qos_add_request,
247 
248 	TP_PROTO(int pm_qos_class, s32 value),
249 
250 	TP_ARGS(pm_qos_class, value)
251 );
252 
253 DEFINE_EVENT(pm_qos_request, pm_qos_update_request,
254 
255 	TP_PROTO(int pm_qos_class, s32 value),
256 
257 	TP_ARGS(pm_qos_class, value)
258 );
259 
260 DEFINE_EVENT(pm_qos_request, pm_qos_remove_request,
261 
262 	TP_PROTO(int pm_qos_class, s32 value),
263 
264 	TP_ARGS(pm_qos_class, value)
265 );
266 
267 TRACE_EVENT(pm_qos_update_request_timeout,
268 
269 	TP_PROTO(int pm_qos_class, s32 value, unsigned long timeout_us),
270 
271 	TP_ARGS(pm_qos_class, value, timeout_us),
272 
273 	TP_STRUCT__entry(
274 		__field( int,                    pm_qos_class   )
275 		__field( s32,                    value          )
276 		__field( unsigned long,          timeout_us     )
277 	),
278 
279 	TP_fast_assign(
280 		__entry->pm_qos_class = pm_qos_class;
281 		__entry->value = value;
282 		__entry->timeout_us = timeout_us;
283 	),
284 
285 	TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld",
286 		  __print_symbolic(__entry->pm_qos_class,
287 			{ PM_QOS_CPU_DMA_LATENCY,	"CPU_DMA_LATENCY" },
288 			{ PM_QOS_NETWORK_LATENCY,	"NETWORK_LATENCY" },
289 			{ PM_QOS_NETWORK_THROUGHPUT,	"NETWORK_THROUGHPUT" }),
290 		  __entry->value, __entry->timeout_us)
291 );
292 
293 DECLARE_EVENT_CLASS(pm_qos_update,
294 
295 	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
296 
297 	TP_ARGS(action, prev_value, curr_value),
298 
299 	TP_STRUCT__entry(
300 		__field( enum pm_qos_req_action, action         )
301 		__field( int,                    prev_value     )
302 		__field( int,                    curr_value     )
303 	),
304 
305 	TP_fast_assign(
306 		__entry->action = action;
307 		__entry->prev_value = prev_value;
308 		__entry->curr_value = curr_value;
309 	),
310 
311 	TP_printk("action=%s prev_value=%d curr_value=%d",
312 		  __print_symbolic(__entry->action,
313 			{ PM_QOS_ADD_REQ,	"ADD_REQ" },
314 			{ PM_QOS_UPDATE_REQ,	"UPDATE_REQ" },
315 			{ PM_QOS_REMOVE_REQ,	"REMOVE_REQ" }),
316 		  __entry->prev_value, __entry->curr_value)
317 );
318 
319 DEFINE_EVENT(pm_qos_update, pm_qos_update_target,
320 
321 	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
322 
323 	TP_ARGS(action, prev_value, curr_value)
324 );
325 
326 DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
327 
328 	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
329 
330 	TP_ARGS(action, prev_value, curr_value),
331 
332 	TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
333 		  __print_symbolic(__entry->action,
334 			{ PM_QOS_ADD_REQ,	"ADD_REQ" },
335 			{ PM_QOS_UPDATE_REQ,	"UPDATE_REQ" },
336 			{ PM_QOS_REMOVE_REQ,	"REMOVE_REQ" }),
337 		  __entry->prev_value, __entry->curr_value)
338 );
339 
340 DECLARE_EVENT_CLASS(dev_pm_qos_request,
341 
342 	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
343 		 s32 new_value),
344 
345 	TP_ARGS(name, type, new_value),
346 
347 	TP_STRUCT__entry(
348 		__string( name,                    name         )
349 		__field( enum dev_pm_qos_req_type, type         )
350 		__field( s32,                      new_value    )
351 	),
352 
353 	TP_fast_assign(
354 		__assign_str(name, name);
355 		__entry->type = type;
356 		__entry->new_value = new_value;
357 	),
358 
359 	TP_printk("device=%s type=%s new_value=%d",
360 		  __get_str(name),
361 		  __print_symbolic(__entry->type,
362 			{ DEV_PM_QOS_LATENCY,	"DEV_PM_QOS_LATENCY" },
363 			{ DEV_PM_QOS_FLAGS,	"DEV_PM_QOS_FLAGS" }),
364 		  __entry->new_value)
365 );
366 
367 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_add_request,
368 
369 	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
370 		 s32 new_value),
371 
372 	TP_ARGS(name, type, new_value)
373 );
374 
375 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_update_request,
376 
377 	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
378 		 s32 new_value),
379 
380 	TP_ARGS(name, type, new_value)
381 );
382 
383 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,
384 
385 	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
386 		 s32 new_value),
387 
388 	TP_ARGS(name, type, new_value)
389 );
390 #endif /* _TRACE_POWER_H */
391 
392 /* This part must be outside protection */
393 #include <trace/define_trace.h>
394