2 #define TRACE_SYSTEM power
4 #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/ktime.h>
8 #include <linux/tracepoint.h>
9 #include <linux/version.h>
11 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12 DECLARE_EVENT_CLASS(power_cpu,
14 TP_PROTO(unsigned int state, unsigned int cpu_id),
16 TP_ARGS(state, cpu_id),
20 __field( u32, cpu_id )
24 tp_assign(state, state)
25 tp_assign(cpu_id, cpu_id)
28 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
29 (unsigned long)__entry->cpu_id)
32 DEFINE_EVENT_MAP(power_cpu, cpu_idle,
36 TP_PROTO(unsigned int state, unsigned int cpu_id),
38 TP_ARGS(state, cpu_id)
41 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
42 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
43 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
45 #define PWR_EVENT_EXIT -1
48 DEFINE_EVENT_MAP(power_cpu, cpu_frequency,
52 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
54 TP_ARGS(frequency, cpu_id)
57 TRACE_EVENT_MAP(machine_suspend,
59 power_machine_suspend,
61 TP_PROTO(unsigned int state),
70 tp_assign(state, state)
73 TP_printk("state=%lu", (unsigned long)__entry->state)
77 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
78 DECLARE_EVENT_CLASS(power_wakeup_source,
80 TP_PROTO(const char *name, unsigned int state),
85 __string( name, name )
91 tp_assign(state, state)
94 TP_printk("%s state=0x%lx", __get_str(name),
95 (unsigned long)__entry->state)
98 DEFINE_EVENT_MAP(power_wakeup_source, wakeup_source_activate,
100 power_wakeup_source_activate,
102 TP_PROTO(const char *name, unsigned int state),
107 DEFINE_EVENT_MAP(power_wakeup_source, wakeup_source_deactivate,
109 power_wakeup_source_deactivate,
111 TP_PROTO(const char *name, unsigned int state),
117 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
118 #undef CONFIG_EVENT_POWER_TRACING_DEPRECATED
119 #define CONFIG_EVENT_POWER_TRACING_DEPRECATED
120 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
123 #ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
126 * The power events are used for cpuidle & suspend (power_start, power_end)
127 * and for cpufreq (power_frequency)
129 DECLARE_EVENT_CLASS(power,
131 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
132 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
134 TP_ARGS(type, state, cpu_id),
136 TP_PROTO(unsigned int type, unsigned int state),
138 TP_ARGS(type, state),
143 __field( u64, state )
144 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
145 __field( u64, cpu_id )
150 tp_assign(type, type)
151 tp_assign(state, state)
152 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
153 tp_assign(cpu_id, cpu_id)
157 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
158 TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type,
159 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
161 TP_printk("type=%lu state=%lu", (unsigned long)__entry->type,
162 (unsigned long)__entry->state)
166 DEFINE_EVENT(power, power_start,
168 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
169 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
171 TP_ARGS(type, state, cpu_id)
173 TP_PROTO(unsigned int type, unsigned int state),
179 DEFINE_EVENT(power, power_frequency,
181 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
182 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
184 TP_ARGS(type, state, cpu_id)
186 TP_PROTO(unsigned int type, unsigned int state),
192 TRACE_EVENT(power_end,
194 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
195 TP_PROTO(unsigned int cpu_id),
205 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
206 __field( u64, cpu_id )
208 __field( u64, dummy )
213 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
214 tp_assign(cpu_id, cpu_id)
216 tp_assign(dummy, 0xffff)
220 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
221 TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
223 TP_printk("dummy=%lu", (unsigned long)__entry->dummy)
227 /* Deprecated dummy functions must be protected against multi-declartion */
228 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
229 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
236 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
238 #else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
240 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
241 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
248 /* These dummy declaration have to be ripped out when the deprecated
249 events get removed */
250 static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
251 static inline void trace_power_end(u64 cpuid) {};
252 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
253 static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
254 static inline void trace_power_end_rcuidle(u64 cpuid) {};
256 static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
257 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
259 #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
261 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
263 * The clock events are used for clock enable/disable and for
266 DECLARE_EVENT_CLASS(power_clock,
268 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
270 TP_ARGS(name, state, cpu_id),
273 __string( name, name )
274 __field( u64, state )
275 __field( u64, cpu_id )
279 tp_strcpy(name, name)
280 tp_assign(state, state)
281 tp_assign(cpu_id, cpu_id)
284 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
285 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
288 DEFINE_EVENT_MAP(power_clock, clock_enable,
292 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
294 TP_ARGS(name, state, cpu_id)
297 DEFINE_EVENT_MAP(power_clock, clock_disable,
301 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
303 TP_ARGS(name, state, cpu_id)
306 DEFINE_EVENT_MAP(power_clock, clock_set_rate,
308 power_clock_set_rate,
310 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
312 TP_ARGS(name, state, cpu_id)
316 * The power domain events are used for power domains transitions
318 DECLARE_EVENT_CLASS(power_domain,
320 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
322 TP_ARGS(name, state, cpu_id),
325 __string( name, name )
326 __field( u64, state )
327 __field( u64, cpu_id )
331 tp_strcpy(name, name)
332 tp_assign(state, state)
333 tp_assign(cpu_id, cpu_id)
336 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
337 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
340 DEFINE_EVENT(power_domain, power_domain_target,
342 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
344 TP_ARGS(name, state, cpu_id)
348 #endif /* _TRACE_POWER_H */
350 /* This part must be outside protection */
351 #include "../../../probes/define_trace.h"