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