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>
11 DECLARE_EVENT_CLASS(cpu,
13 TP_PROTO(unsigned int state, unsigned int cpu_id),
15 TP_ARGS(state, cpu_id),
19 __field( u32, cpu_id )
23 __entry->state = state;
24 __entry->cpu_id = cpu_id;
27 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
28 (unsigned long)__entry->cpu_id)
31 DEFINE_EVENT(cpu, cpu_idle,
33 TP_PROTO(unsigned int state, unsigned int cpu_id),
35 TP_ARGS(state, cpu_id)
38 TRACE_EVENT(pstate_sample,
40 TP_PROTO(u32 core_busy,
57 __field(u32, core_busy)
58 __field(u32, scaled_busy)
67 __entry->core_busy = core_busy;
68 __entry->scaled_busy = scaled_busy;
69 __entry->state = state;
70 __entry->mperf = mperf;
71 __entry->aperf = aperf;
75 TP_printk("core_busy=%lu scaled=%lu state=%lu mperf=%llu aperf=%llu freq=%lu ",
76 (unsigned long)__entry->core_busy,
77 (unsigned long)__entry->scaled_busy,
78 (unsigned long)__entry->state,
79 (unsigned long long)__entry->mperf,
80 (unsigned long long)__entry->aperf,
81 (unsigned long)__entry->freq
86 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
87 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
88 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
90 #define PWR_EVENT_EXIT -1
93 DEFINE_EVENT(cpu, cpu_frequency,
95 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
97 TP_ARGS(frequency, cpu_id)
100 TRACE_EVENT(machine_suspend,
102 TP_PROTO(unsigned int state),
107 __field( u32, state )
111 __entry->state = state;
114 TP_printk("state=%lu", (unsigned long)__entry->state)
117 TRACE_EVENT(device_pm_report_time,
119 TP_PROTO(struct device *dev, const char *pm_ops, s64 ops_time,
120 char *pm_event_str, int error),
122 TP_ARGS(dev, pm_ops, ops_time, pm_event_str, error),
125 __string(device, dev_name(dev))
126 __string(driver, dev_driver_string(dev))
127 __string(parent, dev->parent ? dev_name(dev->parent) : "none")
128 __string(pm_ops, pm_ops ? pm_ops : "none ")
129 __string(pm_event_str, pm_event_str)
130 __field(s64, ops_time)
135 const char *tmp = dev->parent ? dev_name(dev->parent) : "none";
136 const char *tmp_i = pm_ops ? pm_ops : "none ";
138 __assign_str(device, dev_name(dev));
139 __assign_str(driver, dev_driver_string(dev));
140 __assign_str(parent, tmp);
141 __assign_str(pm_ops, tmp_i);
142 __assign_str(pm_event_str, pm_event_str);
143 __entry->ops_time = ops_time;
144 __entry->error = error;
147 /* ops_str has an extra space at the end */
148 TP_printk("%s %s parent=%s state=%s ops=%snsecs=%lld err=%d",
149 __get_str(driver), __get_str(device), __get_str(parent),
150 __get_str(pm_event_str), __get_str(pm_ops),
151 __entry->ops_time, __entry->error)
154 DECLARE_EVENT_CLASS(wakeup_source,
156 TP_PROTO(const char *name, unsigned int state),
158 TP_ARGS(name, state),
161 __string( name, name )
162 __field( u64, state )
166 __assign_str(name, name);
167 __entry->state = state;
170 TP_printk("%s state=0x%lx", __get_str(name),
171 (unsigned long)__entry->state)
174 DEFINE_EVENT(wakeup_source, wakeup_source_activate,
176 TP_PROTO(const char *name, unsigned int state),
181 DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
183 TP_PROTO(const char *name, unsigned int state),
189 * The clock events are used for clock enable/disable and for
192 DECLARE_EVENT_CLASS(clock,
194 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
196 TP_ARGS(name, state, cpu_id),
199 __string( name, name )
200 __field( u64, state )
201 __field( u64, cpu_id )
205 __assign_str(name, name);
206 __entry->state = state;
207 __entry->cpu_id = cpu_id;
210 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
211 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
214 DEFINE_EVENT(clock, clock_enable,
216 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
218 TP_ARGS(name, state, cpu_id)
221 DEFINE_EVENT(clock, clock_disable,
223 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
225 TP_ARGS(name, state, cpu_id)
228 DEFINE_EVENT(clock, clock_set_rate,
230 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
232 TP_ARGS(name, state, cpu_id)
236 * The power domain events are used for power domains transitions
238 DECLARE_EVENT_CLASS(power_domain,
240 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
242 TP_ARGS(name, state, cpu_id),
245 __string( name, name )
246 __field( u64, state )
247 __field( u64, cpu_id )
251 __assign_str(name, name);
252 __entry->state = state;
253 __entry->cpu_id = cpu_id;
256 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
257 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
260 DEFINE_EVENT(power_domain, power_domain_target,
262 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
264 TP_ARGS(name, state, cpu_id)
268 * The pm qos events are used for pm qos update
270 DECLARE_EVENT_CLASS(pm_qos_request,
272 TP_PROTO(int pm_qos_class, s32 value),
274 TP_ARGS(pm_qos_class, value),
277 __field( int, pm_qos_class )
278 __field( s32, value )
282 __entry->pm_qos_class = pm_qos_class;
283 __entry->value = value;
286 TP_printk("pm_qos_class=%s value=%d",
287 __print_symbolic(__entry->pm_qos_class,
288 { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
289 { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
290 { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
294 DEFINE_EVENT(pm_qos_request, pm_qos_add_request,
296 TP_PROTO(int pm_qos_class, s32 value),
298 TP_ARGS(pm_qos_class, value)
301 DEFINE_EVENT(pm_qos_request, pm_qos_update_request,
303 TP_PROTO(int pm_qos_class, s32 value),
305 TP_ARGS(pm_qos_class, value)
308 DEFINE_EVENT(pm_qos_request, pm_qos_remove_request,
310 TP_PROTO(int pm_qos_class, s32 value),
312 TP_ARGS(pm_qos_class, value)
315 TRACE_EVENT(pm_qos_update_request_timeout,
317 TP_PROTO(int pm_qos_class, s32 value, unsigned long timeout_us),
319 TP_ARGS(pm_qos_class, value, timeout_us),
322 __field( int, pm_qos_class )
323 __field( s32, value )
324 __field( unsigned long, timeout_us )
328 __entry->pm_qos_class = pm_qos_class;
329 __entry->value = value;
330 __entry->timeout_us = timeout_us;
333 TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld",
334 __print_symbolic(__entry->pm_qos_class,
335 { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
336 { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
337 { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
338 __entry->value, __entry->timeout_us)
341 DECLARE_EVENT_CLASS(pm_qos_update,
343 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
345 TP_ARGS(action, prev_value, curr_value),
348 __field( enum pm_qos_req_action, action )
349 __field( int, prev_value )
350 __field( int, curr_value )
354 __entry->action = action;
355 __entry->prev_value = prev_value;
356 __entry->curr_value = curr_value;
359 TP_printk("action=%s prev_value=%d curr_value=%d",
360 __print_symbolic(__entry->action,
361 { PM_QOS_ADD_REQ, "ADD_REQ" },
362 { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
363 { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
364 __entry->prev_value, __entry->curr_value)
367 DEFINE_EVENT(pm_qos_update, pm_qos_update_target,
369 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
371 TP_ARGS(action, prev_value, curr_value)
374 DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
376 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
378 TP_ARGS(action, prev_value, curr_value),
380 TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
381 __print_symbolic(__entry->action,
382 { PM_QOS_ADD_REQ, "ADD_REQ" },
383 { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
384 { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
385 __entry->prev_value, __entry->curr_value)
388 DECLARE_EVENT_CLASS(dev_pm_qos_request,
390 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
393 TP_ARGS(name, type, new_value),
396 __string( name, name )
397 __field( enum dev_pm_qos_req_type, type )
398 __field( s32, new_value )
402 __assign_str(name, name);
403 __entry->type = type;
404 __entry->new_value = new_value;
407 TP_printk("device=%s type=%s new_value=%d",
409 __print_symbolic(__entry->type,
410 { DEV_PM_QOS_LATENCY, "DEV_PM_QOS_LATENCY" },
411 { DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS" }),
415 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_add_request,
417 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
420 TP_ARGS(name, type, new_value)
423 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_update_request,
425 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
428 TP_ARGS(name, type, new_value)
431 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,
433 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
436 TP_ARGS(name, type, new_value)
438 #endif /* _TRACE_POWER_H */
440 /* This part must be outside protection */
441 #include <trace/define_trace.h>