blob: 9e9475c85de50ba2eb487e0903820b5845caf564 [file] [log] [blame]
Arjan van de Ven61613522009-09-17 16:11:28 +02001#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>
Sahara247e9ee2013-06-21 11:12:28 +09008#include <linux/pm_qos.h>
Arjan van de Ven61613522009-09-17 16:11:28 +02009#include <linux/tracepoint.h>
10
Thomas Renninger25e41932011-01-03 17:50:44 +010011DECLARE_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
31DEFINE_EVENT(cpu, cpu_idle,
32
33 TP_PROTO(unsigned int state, unsigned int cpu_id),
34
35 TP_ARGS(state, cpu_id)
36);
37
Dirk Brandewieb69880f2014-01-16 10:32:25 -080038TRACE_EVENT(pstate_sample,
39
40 TP_PROTO(u32 core_busy,
41 u32 scaled_busy,
42 u32 state,
43 u64 mperf,
44 u64 aperf,
45 u32 energy,
46 u32 freq
47 ),
48
49 TP_ARGS(core_busy,
50 scaled_busy,
51 state,
52 mperf,
53 aperf,
54 energy,
55 freq
56 ),
57
58 TP_STRUCT__entry(
59 __field(u32, core_busy)
60 __field(u32, scaled_busy)
61 __field(u32, state)
62 __field(u64, mperf)
63 __field(u64, aperf)
64 __field(u32, energy)
65 __field(u32, freq)
66
67 ),
68
69 TP_fast_assign(
70 __entry->core_busy = core_busy;
71 __entry->scaled_busy = scaled_busy;
72 __entry->state = state;
73 __entry->mperf = mperf;
74 __entry->aperf = aperf;
75 __entry->energy = energy;
76 __entry->freq = freq;
77 ),
78
79 TP_printk("core_busy=%lu scaled=%lu state=%lu mperf=%llu aperf=%llu energy=%lu freq=%lu ",
80 (unsigned long)__entry->core_busy,
81 (unsigned long)__entry->scaled_busy,
82 (unsigned long)__entry->state,
83 (unsigned long long)__entry->mperf,
84 (unsigned long long)__entry->aperf,
85 (unsigned long)__entry->energy,
86 (unsigned long)__entry->freq
87 )
88
89);
90
Thomas Renninger25e41932011-01-03 17:50:44 +010091/* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
92#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
93#define _PWR_EVENT_AVOID_DOUBLE_DEFINING
94
95#define PWR_EVENT_EXIT -1
Arjan van de Ven61613522009-09-17 16:11:28 +020096#endif
97
Thomas Renninger25e41932011-01-03 17:50:44 +010098DEFINE_EVENT(cpu, cpu_frequency,
99
100 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
101
102 TP_ARGS(frequency, cpu_id)
103);
104
105TRACE_EVENT(machine_suspend,
106
107 TP_PROTO(unsigned int state),
108
109 TP_ARGS(state),
110
111 TP_STRUCT__entry(
112 __field( u32, state )
113 ),
114
115 TP_fast_assign(
116 __entry->state = state;
117 ),
118
119 TP_printk("state=%lu", (unsigned long)__entry->state)
120);
121
Shuah Khan53644672013-07-26 13:30:20 -0600122TRACE_EVENT(device_pm_report_time,
123
124 TP_PROTO(struct device *dev, const char *pm_ops, s64 ops_time,
125 char *pm_event_str, int error),
126
127 TP_ARGS(dev, pm_ops, ops_time, pm_event_str, error),
128
129 TP_STRUCT__entry(
130 __string(device, dev_name(dev))
131 __string(driver, dev_driver_string(dev))
132 __string(parent, dev->parent ? dev_name(dev->parent) : "none")
133 __string(pm_ops, pm_ops ? pm_ops : "none ")
134 __string(pm_event_str, pm_event_str)
135 __field(s64, ops_time)
136 __field(int, error)
137 ),
138
139 TP_fast_assign(
140 const char *tmp = dev->parent ? dev_name(dev->parent) : "none";
141 const char *tmp_i = pm_ops ? pm_ops : "none ";
142
143 __assign_str(device, dev_name(dev));
144 __assign_str(driver, dev_driver_string(dev));
145 __assign_str(parent, tmp);
146 __assign_str(pm_ops, tmp_i);
147 __assign_str(pm_event_str, pm_event_str);
148 __entry->ops_time = ops_time;
149 __entry->error = error;
150 ),
151
152 /* ops_str has an extra space at the end */
153 TP_printk("%s %s parent=%s state=%s ops=%snsecs=%lld err=%d",
154 __get_str(driver), __get_str(device), __get_str(parent),
155 __get_str(pm_event_str), __get_str(pm_ops),
156 __entry->ops_time, __entry->error)
157);
158
Arve Hjønnevåg6791e362012-04-29 22:53:02 +0200159DECLARE_EVENT_CLASS(wakeup_source,
160
161 TP_PROTO(const char *name, unsigned int state),
162
163 TP_ARGS(name, state),
164
165 TP_STRUCT__entry(
166 __string( name, name )
167 __field( u64, state )
168 ),
169
170 TP_fast_assign(
171 __assign_str(name, name);
172 __entry->state = state;
173 ),
174
175 TP_printk("%s state=0x%lx", __get_str(name),
176 (unsigned long)__entry->state)
177);
178
179DEFINE_EVENT(wakeup_source, wakeup_source_activate,
180
181 TP_PROTO(const char *name, unsigned int state),
182
183 TP_ARGS(name, state)
184);
185
186DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
187
188 TP_PROTO(const char *name, unsigned int state),
189
190 TP_ARGS(name, state)
191);
192
Jean Pihet74704ac2010-09-07 09:21:32 +0200193/*
194 * The clock events are used for clock enable/disable and for
195 * clock rate change
196 */
197DECLARE_EVENT_CLASS(clock,
198
199 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
200
201 TP_ARGS(name, state, cpu_id),
202
203 TP_STRUCT__entry(
204 __string( name, name )
205 __field( u64, state )
206 __field( u64, cpu_id )
207 ),
208
209 TP_fast_assign(
210 __assign_str(name, name);
211 __entry->state = state;
212 __entry->cpu_id = cpu_id;
213 ),
214
215 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
216 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
217);
218
219DEFINE_EVENT(clock, clock_enable,
220
221 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
222
223 TP_ARGS(name, state, cpu_id)
224);
225
226DEFINE_EVENT(clock, clock_disable,
227
228 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
229
230 TP_ARGS(name, state, cpu_id)
231);
232
233DEFINE_EVENT(clock, clock_set_rate,
234
235 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
236
237 TP_ARGS(name, state, cpu_id)
238);
239
240/*
241 * The power domain events are used for power domains transitions
242 */
243DECLARE_EVENT_CLASS(power_domain,
244
245 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
246
247 TP_ARGS(name, state, cpu_id),
248
249 TP_STRUCT__entry(
250 __string( name, name )
251 __field( u64, state )
252 __field( u64, cpu_id )
253 ),
254
255 TP_fast_assign(
256 __assign_str(name, name);
257 __entry->state = state;
258 __entry->cpu_id = cpu_id;
259),
260
261 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
262 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
263);
264
265DEFINE_EVENT(power_domain, power_domain_target,
266
267 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
268
269 TP_ARGS(name, state, cpu_id)
270);
Sahara247e9ee2013-06-21 11:12:28 +0900271
272/*
273 * The pm qos events are used for pm qos update
274 */
Saharaae8822b2013-06-21 11:12:29 +0900275DECLARE_EVENT_CLASS(pm_qos_request,
276
277 TP_PROTO(int pm_qos_class, s32 value),
278
279 TP_ARGS(pm_qos_class, value),
280
281 TP_STRUCT__entry(
282 __field( int, pm_qos_class )
283 __field( s32, value )
284 ),
285
286 TP_fast_assign(
287 __entry->pm_qos_class = pm_qos_class;
288 __entry->value = value;
289 ),
290
291 TP_printk("pm_qos_class=%s value=%d",
292 __print_symbolic(__entry->pm_qos_class,
293 { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
294 { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
295 { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
296 __entry->value)
297);
298
299DEFINE_EVENT(pm_qos_request, pm_qos_add_request,
300
301 TP_PROTO(int pm_qos_class, s32 value),
302
303 TP_ARGS(pm_qos_class, value)
304);
305
306DEFINE_EVENT(pm_qos_request, pm_qos_update_request,
307
308 TP_PROTO(int pm_qos_class, s32 value),
309
310 TP_ARGS(pm_qos_class, value)
311);
312
313DEFINE_EVENT(pm_qos_request, pm_qos_remove_request,
314
315 TP_PROTO(int pm_qos_class, s32 value),
316
317 TP_ARGS(pm_qos_class, value)
318);
319
320TRACE_EVENT(pm_qos_update_request_timeout,
321
322 TP_PROTO(int pm_qos_class, s32 value, unsigned long timeout_us),
323
324 TP_ARGS(pm_qos_class, value, timeout_us),
325
326 TP_STRUCT__entry(
327 __field( int, pm_qos_class )
328 __field( s32, value )
329 __field( unsigned long, timeout_us )
330 ),
331
332 TP_fast_assign(
333 __entry->pm_qos_class = pm_qos_class;
334 __entry->value = value;
335 __entry->timeout_us = timeout_us;
336 ),
337
338 TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld",
339 __print_symbolic(__entry->pm_qos_class,
340 { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
341 { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
342 { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
343 __entry->value, __entry->timeout_us)
344);
345
Sahara247e9ee2013-06-21 11:12:28 +0900346DECLARE_EVENT_CLASS(pm_qos_update,
347
348 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
349
350 TP_ARGS(action, prev_value, curr_value),
351
352 TP_STRUCT__entry(
353 __field( enum pm_qos_req_action, action )
354 __field( int, prev_value )
355 __field( int, curr_value )
356 ),
357
358 TP_fast_assign(
359 __entry->action = action;
360 __entry->prev_value = prev_value;
361 __entry->curr_value = curr_value;
362 ),
363
364 TP_printk("action=%s prev_value=%d curr_value=%d",
365 __print_symbolic(__entry->action,
366 { PM_QOS_ADD_REQ, "ADD_REQ" },
367 { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
368 { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
369 __entry->prev_value, __entry->curr_value)
370);
371
372DEFINE_EVENT(pm_qos_update, pm_qos_update_target,
373
374 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
375
376 TP_ARGS(action, prev_value, curr_value)
377);
378
379DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
380
381 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
382
383 TP_ARGS(action, prev_value, curr_value),
384
385 TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
386 __print_symbolic(__entry->action,
387 { PM_QOS_ADD_REQ, "ADD_REQ" },
388 { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
389 { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
390 __entry->prev_value, __entry->curr_value)
391);
Sahara96d9d0b2013-06-21 11:12:30 +0900392
393DECLARE_EVENT_CLASS(dev_pm_qos_request,
394
395 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
396 s32 new_value),
397
398 TP_ARGS(name, type, new_value),
399
400 TP_STRUCT__entry(
401 __string( name, name )
402 __field( enum dev_pm_qos_req_type, type )
403 __field( s32, new_value )
404 ),
405
406 TP_fast_assign(
407 __assign_str(name, name);
408 __entry->type = type;
409 __entry->new_value = new_value;
410 ),
411
412 TP_printk("device=%s type=%s new_value=%d",
413 __get_str(name),
414 __print_symbolic(__entry->type,
415 { DEV_PM_QOS_LATENCY, "DEV_PM_QOS_LATENCY" },
416 { DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS" }),
417 __entry->new_value)
418);
419
420DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_add_request,
421
422 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
423 s32 new_value),
424
425 TP_ARGS(name, type, new_value)
426);
427
428DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_update_request,
429
430 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
431 s32 new_value),
432
433 TP_ARGS(name, type, new_value)
434);
435
436DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,
437
438 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
439 s32 new_value),
440
441 TP_ARGS(name, type, new_value)
442);
Arjan van de Ven61613522009-09-17 16:11:28 +0200443#endif /* _TRACE_POWER_H */
444
445/* This part must be outside protection */
446#include <trace/define_trace.h>