blob: 908977d69783b8e4ba1c1f775a5c51bc9f0befd7 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Arjan van de Ven61613522009-09-17 16:11:28 +02002#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
8#include <linux/ktime.h>
Sahara247e9ee2013-06-21 11:12:28 +09009#include <linux/pm_qos.h>
Arjan van de Ven61613522009-09-17 16:11:28 +020010#include <linux/tracepoint.h>
Steven Rostedt (Red Hat)af658dc2015-04-29 14:36:05 -040011#include <linux/trace_events.h>
Todd E Brandtbb3632c2014-06-06 05:40:17 -070012
13#define TPS(x) tracepoint_string(x)
Arjan van de Ven61613522009-09-17 16:11:28 +020014
Thomas Renninger25e41932011-01-03 17:50:44 +010015DECLARE_EVENT_CLASS(cpu,
16
17 TP_PROTO(unsigned int state, unsigned int cpu_id),
18
19 TP_ARGS(state, cpu_id),
20
21 TP_STRUCT__entry(
22 __field( u32, state )
23 __field( u32, cpu_id )
24 ),
25
26 TP_fast_assign(
27 __entry->state = state;
28 __entry->cpu_id = cpu_id;
29 ),
30
31 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
32 (unsigned long)__entry->cpu_id)
33);
34
35DEFINE_EVENT(cpu, cpu_idle,
36
37 TP_PROTO(unsigned int state, unsigned int cpu_id),
38
39 TP_ARGS(state, cpu_id)
40);
41
Shilpasri G Bhat0306e482016-02-03 01:11:40 +053042TRACE_EVENT(powernv_throttle,
43
44 TP_PROTO(int chip_id, const char *reason, int pmax),
45
46 TP_ARGS(chip_id, reason, pmax),
47
48 TP_STRUCT__entry(
49 __field(int, chip_id)
50 __string(reason, reason)
51 __field(int, pmax)
52 ),
53
54 TP_fast_assign(
55 __entry->chip_id = chip_id;
56 __assign_str(reason, reason);
57 __entry->pmax = pmax;
58 ),
59
60 TP_printk("Chip %d Pmax %d %s", __entry->chip_id,
61 __entry->pmax, __get_str(reason))
62);
63
Dirk Brandewieb69880f2014-01-16 10:32:25 -080064TRACE_EVENT(pstate_sample,
65
66 TP_PROTO(u32 core_busy,
67 u32 scaled_busy,
Doug Smythies4055fad2015-04-11 21:10:26 -070068 u32 from,
69 u32 to,
Dirk Brandewieb69880f2014-01-16 10:32:25 -080070 u64 mperf,
71 u64 aperf,
Doug Smythies4055fad2015-04-11 21:10:26 -070072 u64 tsc,
Srinivas Pandruvada3ba7bca2016-09-13 17:41:33 -070073 u32 freq,
74 u32 io_boost
Dirk Brandewieb69880f2014-01-16 10:32:25 -080075 ),
76
77 TP_ARGS(core_busy,
78 scaled_busy,
Doug Smythies4055fad2015-04-11 21:10:26 -070079 from,
80 to,
Dirk Brandewieb69880f2014-01-16 10:32:25 -080081 mperf,
82 aperf,
Doug Smythies4055fad2015-04-11 21:10:26 -070083 tsc,
Srinivas Pandruvada3ba7bca2016-09-13 17:41:33 -070084 freq,
85 io_boost
Dirk Brandewieb69880f2014-01-16 10:32:25 -080086 ),
87
88 TP_STRUCT__entry(
89 __field(u32, core_busy)
90 __field(u32, scaled_busy)
Doug Smythies4055fad2015-04-11 21:10:26 -070091 __field(u32, from)
92 __field(u32, to)
Dirk Brandewieb69880f2014-01-16 10:32:25 -080093 __field(u64, mperf)
94 __field(u64, aperf)
Doug Smythies4055fad2015-04-11 21:10:26 -070095 __field(u64, tsc)
Dirk Brandewieb69880f2014-01-16 10:32:25 -080096 __field(u32, freq)
Srinivas Pandruvada3ba7bca2016-09-13 17:41:33 -070097 __field(u32, io_boost)
Doug Smythies4055fad2015-04-11 21:10:26 -070098 ),
Dirk Brandewieb69880f2014-01-16 10:32:25 -080099
100 TP_fast_assign(
101 __entry->core_busy = core_busy;
102 __entry->scaled_busy = scaled_busy;
Doug Smythies4055fad2015-04-11 21:10:26 -0700103 __entry->from = from;
104 __entry->to = to;
Dirk Brandewieb69880f2014-01-16 10:32:25 -0800105 __entry->mperf = mperf;
106 __entry->aperf = aperf;
Doug Smythies4055fad2015-04-11 21:10:26 -0700107 __entry->tsc = tsc;
Dirk Brandewieb69880f2014-01-16 10:32:25 -0800108 __entry->freq = freq;
Srinivas Pandruvada3ba7bca2016-09-13 17:41:33 -0700109 __entry->io_boost = io_boost;
Dirk Brandewieb69880f2014-01-16 10:32:25 -0800110 ),
111
Srinivas Pandruvada3ba7bca2016-09-13 17:41:33 -0700112 TP_printk("core_busy=%lu scaled=%lu from=%lu to=%lu mperf=%llu aperf=%llu tsc=%llu freq=%lu io_boost=%lu",
Dirk Brandewieb69880f2014-01-16 10:32:25 -0800113 (unsigned long)__entry->core_busy,
114 (unsigned long)__entry->scaled_busy,
Doug Smythies4055fad2015-04-11 21:10:26 -0700115 (unsigned long)__entry->from,
116 (unsigned long)__entry->to,
Dirk Brandewieb69880f2014-01-16 10:32:25 -0800117 (unsigned long long)__entry->mperf,
118 (unsigned long long)__entry->aperf,
Doug Smythies4055fad2015-04-11 21:10:26 -0700119 (unsigned long long)__entry->tsc,
Srinivas Pandruvada3ba7bca2016-09-13 17:41:33 -0700120 (unsigned long)__entry->freq,
121 (unsigned long)__entry->io_boost
Dirk Brandewieb69880f2014-01-16 10:32:25 -0800122 )
123
124);
125
Thomas Renninger25e41932011-01-03 17:50:44 +0100126/* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
127#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
128#define _PWR_EVENT_AVOID_DOUBLE_DEFINING
129
130#define PWR_EVENT_EXIT -1
Arjan van de Ven61613522009-09-17 16:11:28 +0200131#endif
132
Todd E Brandte8bca472014-06-10 07:31:22 -0700133#define pm_verb_symbolic(event) \
134 __print_symbolic(event, \
135 { PM_EVENT_SUSPEND, "suspend" }, \
136 { PM_EVENT_RESUME, "resume" }, \
137 { PM_EVENT_FREEZE, "freeze" }, \
138 { PM_EVENT_QUIESCE, "quiesce" }, \
139 { PM_EVENT_HIBERNATE, "hibernate" }, \
140 { PM_EVENT_THAW, "thaw" }, \
141 { PM_EVENT_RESTORE, "restore" }, \
142 { PM_EVENT_RECOVER, "recover" })
143
Thomas Renninger25e41932011-01-03 17:50:44 +0100144DEFINE_EVENT(cpu, cpu_frequency,
145
146 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
147
148 TP_ARGS(frequency, cpu_id)
149);
150
Todd E Brandte8bca472014-06-10 07:31:22 -0700151TRACE_EVENT(device_pm_callback_start,
Shuah Khan53644672013-07-26 13:30:20 -0600152
Todd E Brandte8bca472014-06-10 07:31:22 -0700153 TP_PROTO(struct device *dev, const char *pm_ops, int event),
Shuah Khan53644672013-07-26 13:30:20 -0600154
Todd E Brandte8bca472014-06-10 07:31:22 -0700155 TP_ARGS(dev, pm_ops, event),
Shuah Khan53644672013-07-26 13:30:20 -0600156
157 TP_STRUCT__entry(
158 __string(device, dev_name(dev))
159 __string(driver, dev_driver_string(dev))
160 __string(parent, dev->parent ? dev_name(dev->parent) : "none")
161 __string(pm_ops, pm_ops ? pm_ops : "none ")
Todd E Brandte8bca472014-06-10 07:31:22 -0700162 __field(int, event)
163 ),
164
165 TP_fast_assign(
166 __assign_str(device, dev_name(dev));
167 __assign_str(driver, dev_driver_string(dev));
168 __assign_str(parent,
169 dev->parent ? dev_name(dev->parent) : "none");
170 __assign_str(pm_ops, pm_ops ? pm_ops : "none ");
171 __entry->event = event;
172 ),
173
174 TP_printk("%s %s, parent: %s, %s[%s]", __get_str(driver),
175 __get_str(device), __get_str(parent), __get_str(pm_ops),
176 pm_verb_symbolic(__entry->event))
177);
178
179TRACE_EVENT(device_pm_callback_end,
180
181 TP_PROTO(struct device *dev, int error),
182
183 TP_ARGS(dev, error),
184
185 TP_STRUCT__entry(
186 __string(device, dev_name(dev))
187 __string(driver, dev_driver_string(dev))
Shuah Khan53644672013-07-26 13:30:20 -0600188 __field(int, error)
189 ),
190
191 TP_fast_assign(
Shuah Khan53644672013-07-26 13:30:20 -0600192 __assign_str(device, dev_name(dev));
193 __assign_str(driver, dev_driver_string(dev));
Shuah Khan53644672013-07-26 13:30:20 -0600194 __entry->error = error;
195 ),
196
Todd E Brandte8bca472014-06-10 07:31:22 -0700197 TP_printk("%s %s, err=%d",
198 __get_str(driver), __get_str(device), __entry->error)
Shuah Khan53644672013-07-26 13:30:20 -0600199);
200
Todd E Brandtbb3632c2014-06-06 05:40:17 -0700201TRACE_EVENT(suspend_resume,
202
203 TP_PROTO(const char *action, int val, bool start),
204
205 TP_ARGS(action, val, start),
206
207 TP_STRUCT__entry(
208 __field(const char *, action)
209 __field(int, val)
210 __field(bool, start)
211 ),
212
213 TP_fast_assign(
214 __entry->action = action;
215 __entry->val = val;
216 __entry->start = start;
217 ),
218
219 TP_printk("%s[%u] %s", __entry->action, (unsigned int)__entry->val,
220 (__entry->start)?"begin":"end")
221);
222
Arve Hjønnevåg6791e362012-04-29 22:53:02 +0200223DECLARE_EVENT_CLASS(wakeup_source,
224
225 TP_PROTO(const char *name, unsigned int state),
226
227 TP_ARGS(name, state),
228
229 TP_STRUCT__entry(
230 __string( name, name )
231 __field( u64, state )
232 ),
233
234 TP_fast_assign(
235 __assign_str(name, name);
236 __entry->state = state;
237 ),
238
239 TP_printk("%s state=0x%lx", __get_str(name),
240 (unsigned long)__entry->state)
241);
242
243DEFINE_EVENT(wakeup_source, wakeup_source_activate,
244
245 TP_PROTO(const char *name, unsigned int state),
246
247 TP_ARGS(name, state)
248);
249
250DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
251
252 TP_PROTO(const char *name, unsigned int state),
253
254 TP_ARGS(name, state)
255);
256
Jean Pihet74704ac2010-09-07 09:21:32 +0200257/*
258 * The clock events are used for clock enable/disable and for
259 * clock rate change
260 */
261DECLARE_EVENT_CLASS(clock,
262
263 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
264
265 TP_ARGS(name, state, cpu_id),
266
267 TP_STRUCT__entry(
268 __string( name, name )
269 __field( u64, state )
270 __field( u64, cpu_id )
271 ),
272
273 TP_fast_assign(
274 __assign_str(name, name);
275 __entry->state = state;
276 __entry->cpu_id = cpu_id;
277 ),
278
279 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
280 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
281);
282
283DEFINE_EVENT(clock, clock_enable,
284
285 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
286
287 TP_ARGS(name, state, cpu_id)
288);
289
290DEFINE_EVENT(clock, clock_disable,
291
292 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
293
294 TP_ARGS(name, state, cpu_id)
295);
296
297DEFINE_EVENT(clock, clock_set_rate,
298
299 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
300
301 TP_ARGS(name, state, cpu_id)
302);
303
304/*
305 * The power domain events are used for power domains transitions
306 */
307DECLARE_EVENT_CLASS(power_domain,
308
309 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
310
311 TP_ARGS(name, state, cpu_id),
312
313 TP_STRUCT__entry(
314 __string( name, name )
315 __field( u64, state )
316 __field( u64, cpu_id )
317 ),
318
319 TP_fast_assign(
320 __assign_str(name, name);
321 __entry->state = state;
322 __entry->cpu_id = cpu_id;
323),
324
325 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
326 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
327);
328
329DEFINE_EVENT(power_domain, power_domain_target,
330
331 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
332
333 TP_ARGS(name, state, cpu_id)
334);
Sahara247e9ee2013-06-21 11:12:28 +0900335
336/*
337 * The pm qos events are used for pm qos update
338 */
Saharaae8822b2013-06-21 11:12:29 +0900339DECLARE_EVENT_CLASS(pm_qos_request,
340
341 TP_PROTO(int pm_qos_class, s32 value),
342
343 TP_ARGS(pm_qos_class, value),
344
345 TP_STRUCT__entry(
346 __field( int, pm_qos_class )
347 __field( s32, value )
348 ),
349
350 TP_fast_assign(
351 __entry->pm_qos_class = pm_qos_class;
352 __entry->value = value;
353 ),
354
355 TP_printk("pm_qos_class=%s value=%d",
356 __print_symbolic(__entry->pm_qos_class,
357 { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
358 { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
359 { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
360 __entry->value)
361);
362
363DEFINE_EVENT(pm_qos_request, pm_qos_add_request,
364
365 TP_PROTO(int pm_qos_class, s32 value),
366
367 TP_ARGS(pm_qos_class, value)
368);
369
370DEFINE_EVENT(pm_qos_request, pm_qos_update_request,
371
372 TP_PROTO(int pm_qos_class, s32 value),
373
374 TP_ARGS(pm_qos_class, value)
375);
376
377DEFINE_EVENT(pm_qos_request, pm_qos_remove_request,
378
379 TP_PROTO(int pm_qos_class, s32 value),
380
381 TP_ARGS(pm_qos_class, value)
382);
383
384TRACE_EVENT(pm_qos_update_request_timeout,
385
386 TP_PROTO(int pm_qos_class, s32 value, unsigned long timeout_us),
387
388 TP_ARGS(pm_qos_class, value, timeout_us),
389
390 TP_STRUCT__entry(
391 __field( int, pm_qos_class )
392 __field( s32, value )
393 __field( unsigned long, timeout_us )
394 ),
395
396 TP_fast_assign(
397 __entry->pm_qos_class = pm_qos_class;
398 __entry->value = value;
399 __entry->timeout_us = timeout_us;
400 ),
401
402 TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld",
403 __print_symbolic(__entry->pm_qos_class,
404 { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
405 { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
406 { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
407 __entry->value, __entry->timeout_us)
408);
409
Sahara247e9ee2013-06-21 11:12:28 +0900410DECLARE_EVENT_CLASS(pm_qos_update,
411
412 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
413
414 TP_ARGS(action, prev_value, curr_value),
415
416 TP_STRUCT__entry(
417 __field( enum pm_qos_req_action, action )
418 __field( int, prev_value )
419 __field( int, curr_value )
420 ),
421
422 TP_fast_assign(
423 __entry->action = action;
424 __entry->prev_value = prev_value;
425 __entry->curr_value = curr_value;
426 ),
427
428 TP_printk("action=%s prev_value=%d curr_value=%d",
429 __print_symbolic(__entry->action,
430 { PM_QOS_ADD_REQ, "ADD_REQ" },
431 { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
432 { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
433 __entry->prev_value, __entry->curr_value)
434);
435
436DEFINE_EVENT(pm_qos_update, pm_qos_update_target,
437
438 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
439
440 TP_ARGS(action, prev_value, curr_value)
441);
442
443DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
444
445 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
446
447 TP_ARGS(action, prev_value, curr_value),
448
449 TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
450 __print_symbolic(__entry->action,
451 { PM_QOS_ADD_REQ, "ADD_REQ" },
452 { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
453 { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
454 __entry->prev_value, __entry->curr_value)
455);
Sahara96d9d0b2013-06-21 11:12:30 +0900456
457DECLARE_EVENT_CLASS(dev_pm_qos_request,
458
459 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
460 s32 new_value),
461
462 TP_ARGS(name, type, new_value),
463
464 TP_STRUCT__entry(
465 __string( name, name )
466 __field( enum dev_pm_qos_req_type, type )
467 __field( s32, new_value )
468 ),
469
470 TP_fast_assign(
471 __assign_str(name, name);
472 __entry->type = type;
473 __entry->new_value = new_value;
474 ),
475
476 TP_printk("device=%s type=%s new_value=%d",
477 __get_str(name),
478 __print_symbolic(__entry->type,
Rafael J. Wysockib02f6692014-02-11 00:35:23 +0100479 { DEV_PM_QOS_RESUME_LATENCY, "DEV_PM_QOS_RESUME_LATENCY" },
480 { DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS" }),
Sahara96d9d0b2013-06-21 11:12:30 +0900481 __entry->new_value)
482);
483
484DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_add_request,
485
486 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
487 s32 new_value),
488
489 TP_ARGS(name, type, new_value)
490);
491
492DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_update_request,
493
494 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
495 s32 new_value),
496
497 TP_ARGS(name, type, new_value)
498);
499
500DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,
501
502 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
503 s32 new_value),
504
505 TP_ARGS(name, type, new_value)
506);
Arjan van de Ven61613522009-09-17 16:11:28 +0200507#endif /* _TRACE_POWER_H */
508
509/* This part must be outside protection */
510#include <trace/define_trace.h>