xref: /openbmc/linux/include/trace/events/power.h (revision 0edbfea5)
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 #include <linux/trace_events.h>
11 
12 #define TPS(x)  tracepoint_string(x)
13 
14 DECLARE_EVENT_CLASS(cpu,
15 
16 	TP_PROTO(unsigned int state, unsigned int cpu_id),
17 
18 	TP_ARGS(state, cpu_id),
19 
20 	TP_STRUCT__entry(
21 		__field(	u32,		state		)
22 		__field(	u32,		cpu_id		)
23 	),
24 
25 	TP_fast_assign(
26 		__entry->state = state;
27 		__entry->cpu_id = cpu_id;
28 	),
29 
30 	TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
31 		  (unsigned long)__entry->cpu_id)
32 );
33 
34 DEFINE_EVENT(cpu, cpu_idle,
35 
36 	TP_PROTO(unsigned int state, unsigned int cpu_id),
37 
38 	TP_ARGS(state, cpu_id)
39 );
40 
41 TRACE_EVENT(powernv_throttle,
42 
43 	TP_PROTO(int chip_id, const char *reason, int pmax),
44 
45 	TP_ARGS(chip_id, reason, pmax),
46 
47 	TP_STRUCT__entry(
48 		__field(int, chip_id)
49 		__string(reason, reason)
50 		__field(int, pmax)
51 	),
52 
53 	TP_fast_assign(
54 		__entry->chip_id = chip_id;
55 		__assign_str(reason, reason);
56 		__entry->pmax = pmax;
57 	),
58 
59 	TP_printk("Chip %d Pmax %d %s", __entry->chip_id,
60 		  __entry->pmax, __get_str(reason))
61 );
62 
63 TRACE_EVENT(pstate_sample,
64 
65 	TP_PROTO(u32 core_busy,
66 		u32 scaled_busy,
67 		u32 from,
68 		u32 to,
69 		u64 mperf,
70 		u64 aperf,
71 		u64 tsc,
72 		u32 freq
73 		),
74 
75 	TP_ARGS(core_busy,
76 		scaled_busy,
77 		from,
78 		to,
79 		mperf,
80 		aperf,
81 		tsc,
82 		freq
83 		),
84 
85 	TP_STRUCT__entry(
86 		__field(u32, core_busy)
87 		__field(u32, scaled_busy)
88 		__field(u32, from)
89 		__field(u32, to)
90 		__field(u64, mperf)
91 		__field(u64, aperf)
92 		__field(u64, tsc)
93 		__field(u32, freq)
94 		),
95 
96 	TP_fast_assign(
97 		__entry->core_busy = core_busy;
98 		__entry->scaled_busy = scaled_busy;
99 		__entry->from = from;
100 		__entry->to = to;
101 		__entry->mperf = mperf;
102 		__entry->aperf = aperf;
103 		__entry->tsc = tsc;
104 		__entry->freq = freq;
105 		),
106 
107 	TP_printk("core_busy=%lu scaled=%lu from=%lu to=%lu mperf=%llu aperf=%llu tsc=%llu freq=%lu ",
108 		(unsigned long)__entry->core_busy,
109 		(unsigned long)__entry->scaled_busy,
110 		(unsigned long)__entry->from,
111 		(unsigned long)__entry->to,
112 		(unsigned long long)__entry->mperf,
113 		(unsigned long long)__entry->aperf,
114 		(unsigned long long)__entry->tsc,
115 		(unsigned long)__entry->freq
116 		)
117 
118 );
119 
120 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
121 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
122 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
123 
124 #define PWR_EVENT_EXIT -1
125 #endif
126 
127 #define pm_verb_symbolic(event) \
128 	__print_symbolic(event, \
129 		{ PM_EVENT_SUSPEND, "suspend" }, \
130 		{ PM_EVENT_RESUME, "resume" }, \
131 		{ PM_EVENT_FREEZE, "freeze" }, \
132 		{ PM_EVENT_QUIESCE, "quiesce" }, \
133 		{ PM_EVENT_HIBERNATE, "hibernate" }, \
134 		{ PM_EVENT_THAW, "thaw" }, \
135 		{ PM_EVENT_RESTORE, "restore" }, \
136 		{ PM_EVENT_RECOVER, "recover" })
137 
138 DEFINE_EVENT(cpu, cpu_frequency,
139 
140 	TP_PROTO(unsigned int frequency, unsigned int cpu_id),
141 
142 	TP_ARGS(frequency, cpu_id)
143 );
144 
145 TRACE_EVENT(device_pm_callback_start,
146 
147 	TP_PROTO(struct device *dev, const char *pm_ops, int event),
148 
149 	TP_ARGS(dev, pm_ops, event),
150 
151 	TP_STRUCT__entry(
152 		__string(device, dev_name(dev))
153 		__string(driver, dev_driver_string(dev))
154 		__string(parent, dev->parent ? dev_name(dev->parent) : "none")
155 		__string(pm_ops, pm_ops ? pm_ops : "none ")
156 		__field(int, event)
157 	),
158 
159 	TP_fast_assign(
160 		__assign_str(device, dev_name(dev));
161 		__assign_str(driver, dev_driver_string(dev));
162 		__assign_str(parent,
163 			dev->parent ? dev_name(dev->parent) : "none");
164 		__assign_str(pm_ops, pm_ops ? pm_ops : "none ");
165 		__entry->event = event;
166 	),
167 
168 	TP_printk("%s %s, parent: %s, %s[%s]", __get_str(driver),
169 		__get_str(device), __get_str(parent), __get_str(pm_ops),
170 		pm_verb_symbolic(__entry->event))
171 );
172 
173 TRACE_EVENT(device_pm_callback_end,
174 
175 	TP_PROTO(struct device *dev, int error),
176 
177 	TP_ARGS(dev, error),
178 
179 	TP_STRUCT__entry(
180 		__string(device, dev_name(dev))
181 		__string(driver, dev_driver_string(dev))
182 		__field(int, error)
183 	),
184 
185 	TP_fast_assign(
186 		__assign_str(device, dev_name(dev));
187 		__assign_str(driver, dev_driver_string(dev));
188 		__entry->error = error;
189 	),
190 
191 	TP_printk("%s %s, err=%d",
192 		__get_str(driver), __get_str(device), __entry->error)
193 );
194 
195 TRACE_EVENT(suspend_resume,
196 
197 	TP_PROTO(const char *action, int val, bool start),
198 
199 	TP_ARGS(action, val, start),
200 
201 	TP_STRUCT__entry(
202 		__field(const char *, action)
203 		__field(int, val)
204 		__field(bool, start)
205 	),
206 
207 	TP_fast_assign(
208 		__entry->action = action;
209 		__entry->val = val;
210 		__entry->start = start;
211 	),
212 
213 	TP_printk("%s[%u] %s", __entry->action, (unsigned int)__entry->val,
214 		(__entry->start)?"begin":"end")
215 );
216 
217 DECLARE_EVENT_CLASS(wakeup_source,
218 
219 	TP_PROTO(const char *name, unsigned int state),
220 
221 	TP_ARGS(name, state),
222 
223 	TP_STRUCT__entry(
224 		__string(       name,           name            )
225 		__field(        u64,            state           )
226 	),
227 
228 	TP_fast_assign(
229 		__assign_str(name, name);
230 		__entry->state = state;
231 	),
232 
233 	TP_printk("%s state=0x%lx", __get_str(name),
234 		(unsigned long)__entry->state)
235 );
236 
237 DEFINE_EVENT(wakeup_source, wakeup_source_activate,
238 
239 	TP_PROTO(const char *name, unsigned int state),
240 
241 	TP_ARGS(name, state)
242 );
243 
244 DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
245 
246 	TP_PROTO(const char *name, unsigned int state),
247 
248 	TP_ARGS(name, state)
249 );
250 
251 /*
252  * The clock events are used for clock enable/disable and for
253  *  clock rate change
254  */
255 DECLARE_EVENT_CLASS(clock,
256 
257 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
258 
259 	TP_ARGS(name, state, cpu_id),
260 
261 	TP_STRUCT__entry(
262 		__string(       name,           name            )
263 		__field(        u64,            state           )
264 		__field(        u64,            cpu_id          )
265 	),
266 
267 	TP_fast_assign(
268 		__assign_str(name, name);
269 		__entry->state = state;
270 		__entry->cpu_id = cpu_id;
271 	),
272 
273 	TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
274 		(unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
275 );
276 
277 DEFINE_EVENT(clock, clock_enable,
278 
279 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
280 
281 	TP_ARGS(name, state, cpu_id)
282 );
283 
284 DEFINE_EVENT(clock, clock_disable,
285 
286 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
287 
288 	TP_ARGS(name, state, cpu_id)
289 );
290 
291 DEFINE_EVENT(clock, clock_set_rate,
292 
293 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
294 
295 	TP_ARGS(name, state, cpu_id)
296 );
297 
298 /*
299  * The power domain events are used for power domains transitions
300  */
301 DECLARE_EVENT_CLASS(power_domain,
302 
303 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
304 
305 	TP_ARGS(name, state, cpu_id),
306 
307 	TP_STRUCT__entry(
308 		__string(       name,           name            )
309 		__field(        u64,            state           )
310 		__field(        u64,            cpu_id          )
311 	),
312 
313 	TP_fast_assign(
314 		__assign_str(name, name);
315 		__entry->state = state;
316 		__entry->cpu_id = cpu_id;
317 ),
318 
319 	TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
320 		(unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
321 );
322 
323 DEFINE_EVENT(power_domain, power_domain_target,
324 
325 	TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
326 
327 	TP_ARGS(name, state, cpu_id)
328 );
329 
330 /*
331  * The pm qos events are used for pm qos update
332  */
333 DECLARE_EVENT_CLASS(pm_qos_request,
334 
335 	TP_PROTO(int pm_qos_class, s32 value),
336 
337 	TP_ARGS(pm_qos_class, value),
338 
339 	TP_STRUCT__entry(
340 		__field( int,                    pm_qos_class   )
341 		__field( s32,                    value          )
342 	),
343 
344 	TP_fast_assign(
345 		__entry->pm_qos_class = pm_qos_class;
346 		__entry->value = value;
347 	),
348 
349 	TP_printk("pm_qos_class=%s value=%d",
350 		  __print_symbolic(__entry->pm_qos_class,
351 			{ PM_QOS_CPU_DMA_LATENCY,	"CPU_DMA_LATENCY" },
352 			{ PM_QOS_NETWORK_LATENCY,	"NETWORK_LATENCY" },
353 			{ PM_QOS_NETWORK_THROUGHPUT,	"NETWORK_THROUGHPUT" }),
354 		  __entry->value)
355 );
356 
357 DEFINE_EVENT(pm_qos_request, pm_qos_add_request,
358 
359 	TP_PROTO(int pm_qos_class, s32 value),
360 
361 	TP_ARGS(pm_qos_class, value)
362 );
363 
364 DEFINE_EVENT(pm_qos_request, pm_qos_update_request,
365 
366 	TP_PROTO(int pm_qos_class, s32 value),
367 
368 	TP_ARGS(pm_qos_class, value)
369 );
370 
371 DEFINE_EVENT(pm_qos_request, pm_qos_remove_request,
372 
373 	TP_PROTO(int pm_qos_class, s32 value),
374 
375 	TP_ARGS(pm_qos_class, value)
376 );
377 
378 TRACE_EVENT(pm_qos_update_request_timeout,
379 
380 	TP_PROTO(int pm_qos_class, s32 value, unsigned long timeout_us),
381 
382 	TP_ARGS(pm_qos_class, value, timeout_us),
383 
384 	TP_STRUCT__entry(
385 		__field( int,                    pm_qos_class   )
386 		__field( s32,                    value          )
387 		__field( unsigned long,          timeout_us     )
388 	),
389 
390 	TP_fast_assign(
391 		__entry->pm_qos_class = pm_qos_class;
392 		__entry->value = value;
393 		__entry->timeout_us = timeout_us;
394 	),
395 
396 	TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld",
397 		  __print_symbolic(__entry->pm_qos_class,
398 			{ PM_QOS_CPU_DMA_LATENCY,	"CPU_DMA_LATENCY" },
399 			{ PM_QOS_NETWORK_LATENCY,	"NETWORK_LATENCY" },
400 			{ PM_QOS_NETWORK_THROUGHPUT,	"NETWORK_THROUGHPUT" }),
401 		  __entry->value, __entry->timeout_us)
402 );
403 
404 DECLARE_EVENT_CLASS(pm_qos_update,
405 
406 	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
407 
408 	TP_ARGS(action, prev_value, curr_value),
409 
410 	TP_STRUCT__entry(
411 		__field( enum pm_qos_req_action, action         )
412 		__field( int,                    prev_value     )
413 		__field( int,                    curr_value     )
414 	),
415 
416 	TP_fast_assign(
417 		__entry->action = action;
418 		__entry->prev_value = prev_value;
419 		__entry->curr_value = curr_value;
420 	),
421 
422 	TP_printk("action=%s prev_value=%d curr_value=%d",
423 		  __print_symbolic(__entry->action,
424 			{ PM_QOS_ADD_REQ,	"ADD_REQ" },
425 			{ PM_QOS_UPDATE_REQ,	"UPDATE_REQ" },
426 			{ PM_QOS_REMOVE_REQ,	"REMOVE_REQ" }),
427 		  __entry->prev_value, __entry->curr_value)
428 );
429 
430 DEFINE_EVENT(pm_qos_update, pm_qos_update_target,
431 
432 	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
433 
434 	TP_ARGS(action, prev_value, curr_value)
435 );
436 
437 DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
438 
439 	TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
440 
441 	TP_ARGS(action, prev_value, curr_value),
442 
443 	TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
444 		  __print_symbolic(__entry->action,
445 			{ PM_QOS_ADD_REQ,	"ADD_REQ" },
446 			{ PM_QOS_UPDATE_REQ,	"UPDATE_REQ" },
447 			{ PM_QOS_REMOVE_REQ,	"REMOVE_REQ" }),
448 		  __entry->prev_value, __entry->curr_value)
449 );
450 
451 DECLARE_EVENT_CLASS(dev_pm_qos_request,
452 
453 	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
454 		 s32 new_value),
455 
456 	TP_ARGS(name, type, new_value),
457 
458 	TP_STRUCT__entry(
459 		__string( name,                    name         )
460 		__field( enum dev_pm_qos_req_type, type         )
461 		__field( s32,                      new_value    )
462 	),
463 
464 	TP_fast_assign(
465 		__assign_str(name, name);
466 		__entry->type = type;
467 		__entry->new_value = new_value;
468 	),
469 
470 	TP_printk("device=%s type=%s new_value=%d",
471 		  __get_str(name),
472 		  __print_symbolic(__entry->type,
473 			{ DEV_PM_QOS_RESUME_LATENCY, "DEV_PM_QOS_RESUME_LATENCY" },
474 			{ DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS" }),
475 		  __entry->new_value)
476 );
477 
478 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_add_request,
479 
480 	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
481 		 s32 new_value),
482 
483 	TP_ARGS(name, type, new_value)
484 );
485 
486 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_update_request,
487 
488 	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
489 		 s32 new_value),
490 
491 	TP_ARGS(name, type, new_value)
492 );
493 
494 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,
495 
496 	TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
497 		 s32 new_value),
498 
499 	TP_ARGS(name, type, new_value)
500 );
501 #endif /* _TRACE_POWER_H */
502 
503 /* This part must be outside protection */
504 #include <trace/define_trace.h>
505