2 #define TRACE_SYSTEM power
4 #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/ktime.h>
8 #include <linux/pm_qos.h>
9 #include <linux/tracepoint.h>
10 #include <linux/ftrace_event.h>
12 #define TPS(x) tracepoint_string(x)
14 DECLARE_EVENT_CLASS(cpu
,
16 TP_PROTO(unsigned int state
, unsigned int cpu_id
),
18 TP_ARGS(state
, cpu_id
),
22 __field( u32
, cpu_id
)
26 __entry
->state
= state
;
27 __entry
->cpu_id
= cpu_id
;
30 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry
->state
,
31 (unsigned long)__entry
->cpu_id
)
34 DEFINE_EVENT(cpu
, cpu_idle
,
36 TP_PROTO(unsigned int state
, unsigned int cpu_id
),
38 TP_ARGS(state
, cpu_id
)
41 TRACE_EVENT(pstate_sample
,
43 TP_PROTO(u32 core_busy
,
60 __field(u32
, core_busy
)
61 __field(u32
, scaled_busy
)
70 __entry
->core_busy
= core_busy
;
71 __entry
->scaled_busy
= scaled_busy
;
72 __entry
->state
= state
;
73 __entry
->mperf
= mperf
;
74 __entry
->aperf
= aperf
;
78 TP_printk("core_busy=%lu scaled=%lu state=%lu mperf=%llu aperf=%llu freq=%lu ",
79 (unsigned long)__entry
->core_busy
,
80 (unsigned long)__entry
->scaled_busy
,
81 (unsigned long)__entry
->state
,
82 (unsigned long long)__entry
->mperf
,
83 (unsigned long long)__entry
->aperf
,
84 (unsigned long)__entry
->freq
89 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
90 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
91 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
93 #define PWR_EVENT_EXIT -1
96 #define pm_verb_symbolic(event) \
97 __print_symbolic(event, \
98 { PM_EVENT_SUSPEND, "suspend" }, \
99 { PM_EVENT_RESUME, "resume" }, \
100 { PM_EVENT_FREEZE, "freeze" }, \
101 { PM_EVENT_QUIESCE, "quiesce" }, \
102 { PM_EVENT_HIBERNATE, "hibernate" }, \
103 { PM_EVENT_THAW, "thaw" }, \
104 { PM_EVENT_RESTORE, "restore" }, \
105 { PM_EVENT_RECOVER, "recover" })
107 DEFINE_EVENT(cpu
, cpu_frequency
,
109 TP_PROTO(unsigned int frequency
, unsigned int cpu_id
),
111 TP_ARGS(frequency
, cpu_id
)
114 TRACE_EVENT(device_pm_callback_start
,
116 TP_PROTO(struct device
*dev
, const char *pm_ops
, int event
),
118 TP_ARGS(dev
, pm_ops
, event
),
121 __string(device
, dev_name(dev
))
122 __string(driver
, dev_driver_string(dev
))
123 __string(parent
, dev
->parent
? dev_name(dev
->parent
) : "none")
124 __string(pm_ops
, pm_ops
? pm_ops
: "none ")
129 __assign_str(device
, dev_name(dev
));
130 __assign_str(driver
, dev_driver_string(dev
));
132 dev
->parent
? dev_name(dev
->parent
) : "none");
133 __assign_str(pm_ops
, pm_ops
? pm_ops
: "none ");
134 __entry
->event
= event
;
137 TP_printk("%s %s, parent: %s, %s[%s]", __get_str(driver
),
138 __get_str(device
), __get_str(parent
), __get_str(pm_ops
),
139 pm_verb_symbolic(__entry
->event
))
142 TRACE_EVENT(device_pm_callback_end
,
144 TP_PROTO(struct device
*dev
, int error
),
149 __string(device
, dev_name(dev
))
150 __string(driver
, dev_driver_string(dev
))
155 __assign_str(device
, dev_name(dev
));
156 __assign_str(driver
, dev_driver_string(dev
));
157 __entry
->error
= error
;
160 TP_printk("%s %s, err=%d",
161 __get_str(driver
), __get_str(device
), __entry
->error
)
164 TRACE_EVENT(suspend_resume
,
166 TP_PROTO(const char *action
, int val
, bool start
),
168 TP_ARGS(action
, val
, start
),
171 __field(const char *, action
)
177 __entry
->action
= action
;
179 __entry
->start
= start
;
182 TP_printk("%s[%u] %s", __entry
->action
, (unsigned int)__entry
->val
,
183 (__entry
->start
)?"begin":"end")
186 DECLARE_EVENT_CLASS(wakeup_source
,
188 TP_PROTO(const char *name
, unsigned int state
),
190 TP_ARGS(name
, state
),
193 __string( name
, name
)
194 __field( u64
, state
)
198 __assign_str(name
, name
);
199 __entry
->state
= state
;
202 TP_printk("%s state=0x%lx", __get_str(name
),
203 (unsigned long)__entry
->state
)
206 DEFINE_EVENT(wakeup_source
, wakeup_source_activate
,
208 TP_PROTO(const char *name
, unsigned int state
),
213 DEFINE_EVENT(wakeup_source
, wakeup_source_deactivate
,
215 TP_PROTO(const char *name
, unsigned int state
),
221 * The clock events are used for clock enable/disable and for
224 DECLARE_EVENT_CLASS(clock
,
226 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
228 TP_ARGS(name
, state
, cpu_id
),
231 __string( name
, name
)
232 __field( u64
, state
)
233 __field( u64
, cpu_id
)
237 __assign_str(name
, name
);
238 __entry
->state
= state
;
239 __entry
->cpu_id
= cpu_id
;
242 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name
),
243 (unsigned long)__entry
->state
, (unsigned long)__entry
->cpu_id
)
246 DEFINE_EVENT(clock
, clock_enable
,
248 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
250 TP_ARGS(name
, state
, cpu_id
)
253 DEFINE_EVENT(clock
, clock_disable
,
255 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
257 TP_ARGS(name
, state
, cpu_id
)
260 DEFINE_EVENT(clock
, clock_set_rate
,
262 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
264 TP_ARGS(name
, state
, cpu_id
)
268 * The power domain events are used for power domains transitions
270 DECLARE_EVENT_CLASS(power_domain
,
272 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
274 TP_ARGS(name
, state
, cpu_id
),
277 __string( name
, name
)
278 __field( u64
, state
)
279 __field( u64
, cpu_id
)
283 __assign_str(name
, name
);
284 __entry
->state
= state
;
285 __entry
->cpu_id
= cpu_id
;
288 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name
),
289 (unsigned long)__entry
->state
, (unsigned long)__entry
->cpu_id
)
292 DEFINE_EVENT(power_domain
, power_domain_target
,
294 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
296 TP_ARGS(name
, state
, cpu_id
)
300 * The pm qos events are used for pm qos update
302 DECLARE_EVENT_CLASS(pm_qos_request
,
304 TP_PROTO(int pm_qos_class
, s32 value
),
306 TP_ARGS(pm_qos_class
, value
),
309 __field( int, pm_qos_class
)
310 __field( s32
, value
)
314 __entry
->pm_qos_class
= pm_qos_class
;
315 __entry
->value
= value
;
318 TP_printk("pm_qos_class=%s value=%d",
319 __print_symbolic(__entry
->pm_qos_class
,
320 { PM_QOS_CPU_DMA_LATENCY
, "CPU_DMA_LATENCY" },
321 { PM_QOS_NETWORK_LATENCY
, "NETWORK_LATENCY" },
322 { PM_QOS_NETWORK_THROUGHPUT
, "NETWORK_THROUGHPUT" }),
326 DEFINE_EVENT(pm_qos_request
, pm_qos_add_request
,
328 TP_PROTO(int pm_qos_class
, s32 value
),
330 TP_ARGS(pm_qos_class
, value
)
333 DEFINE_EVENT(pm_qos_request
, pm_qos_update_request
,
335 TP_PROTO(int pm_qos_class
, s32 value
),
337 TP_ARGS(pm_qos_class
, value
)
340 DEFINE_EVENT(pm_qos_request
, pm_qos_remove_request
,
342 TP_PROTO(int pm_qos_class
, s32 value
),
344 TP_ARGS(pm_qos_class
, value
)
347 TRACE_EVENT(pm_qos_update_request_timeout
,
349 TP_PROTO(int pm_qos_class
, s32 value
, unsigned long timeout_us
),
351 TP_ARGS(pm_qos_class
, value
, timeout_us
),
354 __field( int, pm_qos_class
)
355 __field( s32
, value
)
356 __field( unsigned long, timeout_us
)
360 __entry
->pm_qos_class
= pm_qos_class
;
361 __entry
->value
= value
;
362 __entry
->timeout_us
= timeout_us
;
365 TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld",
366 __print_symbolic(__entry
->pm_qos_class
,
367 { PM_QOS_CPU_DMA_LATENCY
, "CPU_DMA_LATENCY" },
368 { PM_QOS_NETWORK_LATENCY
, "NETWORK_LATENCY" },
369 { PM_QOS_NETWORK_THROUGHPUT
, "NETWORK_THROUGHPUT" }),
370 __entry
->value
, __entry
->timeout_us
)
373 DECLARE_EVENT_CLASS(pm_qos_update
,
375 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
377 TP_ARGS(action
, prev_value
, curr_value
),
380 __field( enum pm_qos_req_action
, action
)
381 __field( int, prev_value
)
382 __field( int, curr_value
)
386 __entry
->action
= action
;
387 __entry
->prev_value
= prev_value
;
388 __entry
->curr_value
= curr_value
;
391 TP_printk("action=%s prev_value=%d curr_value=%d",
392 __print_symbolic(__entry
->action
,
393 { PM_QOS_ADD_REQ
, "ADD_REQ" },
394 { PM_QOS_UPDATE_REQ
, "UPDATE_REQ" },
395 { PM_QOS_REMOVE_REQ
, "REMOVE_REQ" }),
396 __entry
->prev_value
, __entry
->curr_value
)
399 DEFINE_EVENT(pm_qos_update
, pm_qos_update_target
,
401 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
403 TP_ARGS(action
, prev_value
, curr_value
)
406 DEFINE_EVENT_PRINT(pm_qos_update
, pm_qos_update_flags
,
408 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
410 TP_ARGS(action
, prev_value
, curr_value
),
412 TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
413 __print_symbolic(__entry
->action
,
414 { PM_QOS_ADD_REQ
, "ADD_REQ" },
415 { PM_QOS_UPDATE_REQ
, "UPDATE_REQ" },
416 { PM_QOS_REMOVE_REQ
, "REMOVE_REQ" }),
417 __entry
->prev_value
, __entry
->curr_value
)
420 DECLARE_EVENT_CLASS(dev_pm_qos_request
,
422 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
425 TP_ARGS(name
, type
, new_value
),
428 __string( name
, name
)
429 __field( enum dev_pm_qos_req_type
, type
)
430 __field( s32
, new_value
)
434 __assign_str(name
, name
);
435 __entry
->type
= type
;
436 __entry
->new_value
= new_value
;
439 TP_printk("device=%s type=%s new_value=%d",
441 __print_symbolic(__entry
->type
,
442 { DEV_PM_QOS_RESUME_LATENCY
, "DEV_PM_QOS_RESUME_LATENCY" },
443 { DEV_PM_QOS_FLAGS
, "DEV_PM_QOS_FLAGS" }),
447 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_add_request
,
449 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
452 TP_ARGS(name
, type
, new_value
)
455 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_update_request
,
457 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
460 TP_ARGS(name
, type
, new_value
)
463 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_remove_request
,
465 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
468 TP_ARGS(name
, type
, new_value
)
470 #endif /* _TRACE_POWER_H */
472 /* This part must be outside protection */
473 #include <trace/define_trace.h>