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