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/trace_events.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
,
64 __field(u32
, core_busy
)
65 __field(u32
, scaled_busy
)
75 __entry
->core_busy
= core_busy
;
76 __entry
->scaled_busy
= scaled_busy
;
79 __entry
->mperf
= mperf
;
80 __entry
->aperf
= aperf
;
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
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
102 #define PWR_EVENT_EXIT -1
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" })
116 DEFINE_EVENT(cpu
, cpu_frequency
,
118 TP_PROTO(unsigned int frequency
, unsigned int cpu_id
),
120 TP_ARGS(frequency
, cpu_id
)
123 TRACE_EVENT(device_pm_callback_start
,
125 TP_PROTO(struct device
*dev
, const char *pm_ops
, int event
),
127 TP_ARGS(dev
, pm_ops
, event
),
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 ")
138 __assign_str(device
, dev_name(dev
));
139 __assign_str(driver
, dev_driver_string(dev
));
141 dev
->parent
? dev_name(dev
->parent
) : "none");
142 __assign_str(pm_ops
, pm_ops
? pm_ops
: "none ");
143 __entry
->event
= event
;
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
))
151 TRACE_EVENT(device_pm_callback_end
,
153 TP_PROTO(struct device
*dev
, int error
),
158 __string(device
, dev_name(dev
))
159 __string(driver
, dev_driver_string(dev
))
164 __assign_str(device
, dev_name(dev
));
165 __assign_str(driver
, dev_driver_string(dev
));
166 __entry
->error
= error
;
169 TP_printk("%s %s, err=%d",
170 __get_str(driver
), __get_str(device
), __entry
->error
)
173 TRACE_EVENT(suspend_resume
,
175 TP_PROTO(const char *action
, int val
, bool start
),
177 TP_ARGS(action
, val
, start
),
180 __field(const char *, action
)
186 __entry
->action
= action
;
188 __entry
->start
= start
;
191 TP_printk("%s[%u] %s", __entry
->action
, (unsigned int)__entry
->val
,
192 (__entry
->start
)?"begin":"end")
195 DECLARE_EVENT_CLASS(wakeup_source
,
197 TP_PROTO(const char *name
, unsigned int state
),
199 TP_ARGS(name
, state
),
202 __string( name
, name
)
203 __field( u64
, state
)
207 __assign_str(name
, name
);
208 __entry
->state
= state
;
211 TP_printk("%s state=0x%lx", __get_str(name
),
212 (unsigned long)__entry
->state
)
215 DEFINE_EVENT(wakeup_source
, wakeup_source_activate
,
217 TP_PROTO(const char *name
, unsigned int state
),
222 DEFINE_EVENT(wakeup_source
, wakeup_source_deactivate
,
224 TP_PROTO(const char *name
, unsigned int state
),
230 * The clock events are used for clock enable/disable and for
233 DECLARE_EVENT_CLASS(clock
,
235 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
237 TP_ARGS(name
, state
, cpu_id
),
240 __string( name
, name
)
241 __field( u64
, state
)
242 __field( u64
, cpu_id
)
246 __assign_str(name
, name
);
247 __entry
->state
= state
;
248 __entry
->cpu_id
= cpu_id
;
251 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name
),
252 (unsigned long)__entry
->state
, (unsigned long)__entry
->cpu_id
)
255 DEFINE_EVENT(clock
, clock_enable
,
257 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
259 TP_ARGS(name
, state
, cpu_id
)
262 DEFINE_EVENT(clock
, clock_disable
,
264 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
266 TP_ARGS(name
, state
, cpu_id
)
269 DEFINE_EVENT(clock
, clock_set_rate
,
271 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
273 TP_ARGS(name
, state
, cpu_id
)
277 * The power domain events are used for power domains transitions
279 DECLARE_EVENT_CLASS(power_domain
,
281 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
283 TP_ARGS(name
, state
, cpu_id
),
286 __string( name
, name
)
287 __field( u64
, state
)
288 __field( u64
, cpu_id
)
292 __assign_str(name
, name
);
293 __entry
->state
= state
;
294 __entry
->cpu_id
= cpu_id
;
297 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name
),
298 (unsigned long)__entry
->state
, (unsigned long)__entry
->cpu_id
)
301 DEFINE_EVENT(power_domain
, power_domain_target
,
303 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
305 TP_ARGS(name
, state
, cpu_id
)
309 * The pm qos events are used for pm qos update
311 DECLARE_EVENT_CLASS(pm_qos_request
,
313 TP_PROTO(int pm_qos_class
, s32 value
),
315 TP_ARGS(pm_qos_class
, value
),
318 __field( int, pm_qos_class
)
319 __field( s32
, value
)
323 __entry
->pm_qos_class
= pm_qos_class
;
324 __entry
->value
= value
;
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" }),
335 DEFINE_EVENT(pm_qos_request
, pm_qos_add_request
,
337 TP_PROTO(int pm_qos_class
, s32 value
),
339 TP_ARGS(pm_qos_class
, value
)
342 DEFINE_EVENT(pm_qos_request
, pm_qos_update_request
,
344 TP_PROTO(int pm_qos_class
, s32 value
),
346 TP_ARGS(pm_qos_class
, value
)
349 DEFINE_EVENT(pm_qos_request
, pm_qos_remove_request
,
351 TP_PROTO(int pm_qos_class
, s32 value
),
353 TP_ARGS(pm_qos_class
, value
)
356 TRACE_EVENT(pm_qos_update_request_timeout
,
358 TP_PROTO(int pm_qos_class
, s32 value
, unsigned long timeout_us
),
360 TP_ARGS(pm_qos_class
, value
, timeout_us
),
363 __field( int, pm_qos_class
)
364 __field( s32
, value
)
365 __field( unsigned long, timeout_us
)
369 __entry
->pm_qos_class
= pm_qos_class
;
370 __entry
->value
= value
;
371 __entry
->timeout_us
= timeout_us
;
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
)
382 DECLARE_EVENT_CLASS(pm_qos_update
,
384 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
386 TP_ARGS(action
, prev_value
, curr_value
),
389 __field( enum pm_qos_req_action
, action
)
390 __field( int, prev_value
)
391 __field( int, curr_value
)
395 __entry
->action
= action
;
396 __entry
->prev_value
= prev_value
;
397 __entry
->curr_value
= curr_value
;
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
)
408 DEFINE_EVENT(pm_qos_update
, pm_qos_update_target
,
410 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
412 TP_ARGS(action
, prev_value
, curr_value
)
415 DEFINE_EVENT_PRINT(pm_qos_update
, pm_qos_update_flags
,
417 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
419 TP_ARGS(action
, prev_value
, curr_value
),
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
)
429 DECLARE_EVENT_CLASS(dev_pm_qos_request
,
431 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
434 TP_ARGS(name
, type
, new_value
),
437 __string( name
, name
)
438 __field( enum dev_pm_qos_req_type
, type
)
439 __field( s32
, new_value
)
443 __assign_str(name
, name
);
444 __entry
->type
= type
;
445 __entry
->new_value
= new_value
;
448 TP_printk("device=%s type=%s new_value=%d",
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" }),
456 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_add_request
,
458 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
461 TP_ARGS(name
, type
, new_value
)
464 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_update_request
,
466 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
469 TP_ARGS(name
, type
, new_value
)
472 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_remove_request
,
474 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
477 TP_ARGS(name
, type
, new_value
)
479 #endif /* _TRACE_POWER_H */
481 /* This part must be outside protection */
482 #include <trace/define_trace.h>