Commit | Line | Data |
---|---|---|
b283666f PW |
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/tracepoint.h> | |
7c68b363 | 9 | #include <linux/version.h> |
b283666f | 10 | |
7c68b363 | 11 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
9cf29d3e | 12 | DECLARE_EVENT_CLASS(power_cpu, |
b283666f PW |
13 | |
14 | TP_PROTO(unsigned int state, unsigned int cpu_id), | |
15 | ||
16 | TP_ARGS(state, cpu_id), | |
17 | ||
18 | TP_STRUCT__entry( | |
19 | __field( u32, state ) | |
20 | __field( u32, cpu_id ) | |
21 | ), | |
22 | ||
23 | TP_fast_assign( | |
d3ac4d63 PW |
24 | tp_assign(state, state) |
25 | tp_assign(cpu_id, cpu_id) | |
b283666f PW |
26 | ), |
27 | ||
28 | TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state, | |
29 | (unsigned long)__entry->cpu_id) | |
30 | ) | |
31 | ||
9cf29d3e MD |
32 | DEFINE_EVENT_MAP(power_cpu, cpu_idle, |
33 | ||
34 | power_cpu_idle, | |
b283666f PW |
35 | |
36 | TP_PROTO(unsigned int state, unsigned int cpu_id), | |
37 | ||
38 | TP_ARGS(state, cpu_id) | |
39 | ) | |
40 | ||
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 | |
44 | ||
45 | #define PWR_EVENT_EXIT -1 | |
46 | #endif | |
47 | ||
9cf29d3e MD |
48 | DEFINE_EVENT_MAP(power_cpu, cpu_frequency, |
49 | ||
50 | power_cpu_frequency, | |
b283666f PW |
51 | |
52 | TP_PROTO(unsigned int frequency, unsigned int cpu_id), | |
53 | ||
54 | TP_ARGS(frequency, cpu_id) | |
55 | ) | |
56 | ||
9cf29d3e MD |
57 | TRACE_EVENT_MAP(machine_suspend, |
58 | ||
59 | power_machine_suspend, | |
b283666f PW |
60 | |
61 | TP_PROTO(unsigned int state), | |
62 | ||
63 | TP_ARGS(state), | |
64 | ||
65 | TP_STRUCT__entry( | |
66 | __field( u32, state ) | |
67 | ), | |
68 | ||
69 | TP_fast_assign( | |
d3ac4d63 | 70 | tp_assign(state, state) |
b283666f PW |
71 | ), |
72 | ||
73 | TP_printk("state=%lu", (unsigned long)__entry->state) | |
74 | ) | |
7c68b363 AG |
75 | #endif |
76 | ||
77 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) | |
9cf29d3e | 78 | DECLARE_EVENT_CLASS(power_wakeup_source, |
7c68b363 AG |
79 | |
80 | TP_PROTO(const char *name, unsigned int state), | |
81 | ||
82 | TP_ARGS(name, state), | |
83 | ||
84 | TP_STRUCT__entry( | |
85 | __string( name, name ) | |
86 | __field( u64, state ) | |
87 | ), | |
88 | ||
89 | TP_fast_assign( | |
90 | tp_strcpy(name, name) | |
91 | tp_assign(state, state) | |
92 | ), | |
93 | ||
94 | TP_printk("%s state=0x%lx", __get_str(name), | |
95 | (unsigned long)__entry->state) | |
96 | ) | |
97 | ||
9cf29d3e MD |
98 | DEFINE_EVENT_MAP(power_wakeup_source, wakeup_source_activate, |
99 | ||
100 | power_wakeup_source_activate, | |
7c68b363 AG |
101 | |
102 | TP_PROTO(const char *name, unsigned int state), | |
103 | ||
104 | TP_ARGS(name, state) | |
105 | ) | |
106 | ||
9cf29d3e MD |
107 | DEFINE_EVENT_MAP(power_wakeup_source, wakeup_source_deactivate, |
108 | ||
109 | power_wakeup_source_deactivate, | |
7c68b363 AG |
110 | |
111 | TP_PROTO(const char *name, unsigned int state), | |
112 | ||
113 | TP_ARGS(name, state) | |
114 | ) | |
115 | #endif | |
116 | ||
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 | |
121 | #endif | |
b283666f | 122 | |
b283666f PW |
123 | #ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED |
124 | ||
125 | /* | |
126 | * The power events are used for cpuidle & suspend (power_start, power_end) | |
127 | * and for cpufreq (power_frequency) | |
128 | */ | |
129 | DECLARE_EVENT_CLASS(power, | |
130 | ||
7c68b363 | 131 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
b283666f PW |
132 | TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id), |
133 | ||
134 | TP_ARGS(type, state, cpu_id), | |
7c68b363 AG |
135 | #else |
136 | TP_PROTO(unsigned int type, unsigned int state), | |
137 | ||
138 | TP_ARGS(type, state), | |
139 | #endif | |
b283666f PW |
140 | |
141 | TP_STRUCT__entry( | |
142 | __field( u64, type ) | |
143 | __field( u64, state ) | |
7c68b363 | 144 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
b283666f | 145 | __field( u64, cpu_id ) |
7c68b363 | 146 | #endif |
b283666f PW |
147 | ), |
148 | ||
149 | TP_fast_assign( | |
d3ac4d63 PW |
150 | tp_assign(type, type) |
151 | tp_assign(state, state) | |
7c68b363 | 152 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
d3ac4d63 | 153 | tp_assign(cpu_id, cpu_id) |
7c68b363 | 154 | #endif |
b283666f PW |
155 | ), |
156 | ||
7c68b363 | 157 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
b283666f PW |
158 | TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type, |
159 | (unsigned long)__entry->state, (unsigned long)__entry->cpu_id) | |
7c68b363 AG |
160 | #else |
161 | TP_printk("type=%lu state=%lu", (unsigned long)__entry->type, | |
162 | (unsigned long)__entry->state) | |
163 | #endif | |
b283666f PW |
164 | ) |
165 | ||
166 | DEFINE_EVENT(power, power_start, | |
167 | ||
7c68b363 | 168 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
b283666f PW |
169 | TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id), |
170 | ||
171 | TP_ARGS(type, state, cpu_id) | |
7c68b363 AG |
172 | #else |
173 | TP_PROTO(unsigned int type, unsigned int state), | |
174 | ||
175 | TP_ARGS(type, state) | |
176 | #endif | |
b283666f PW |
177 | ) |
178 | ||
179 | DEFINE_EVENT(power, power_frequency, | |
180 | ||
7c68b363 | 181 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
b283666f PW |
182 | TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id), |
183 | ||
184 | TP_ARGS(type, state, cpu_id) | |
7c68b363 AG |
185 | #else |
186 | TP_PROTO(unsigned int type, unsigned int state), | |
187 | ||
188 | TP_ARGS(type, state) | |
189 | #endif | |
b283666f PW |
190 | ) |
191 | ||
192 | TRACE_EVENT(power_end, | |
193 | ||
7c68b363 | 194 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
b283666f PW |
195 | TP_PROTO(unsigned int cpu_id), |
196 | ||
197 | TP_ARGS(cpu_id), | |
7c68b363 AG |
198 | #else |
199 | TP_PROTO(int dummy), | |
200 | ||
201 | TP_ARGS(dummy), | |
202 | #endif | |
b283666f PW |
203 | |
204 | TP_STRUCT__entry( | |
7c68b363 | 205 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
b283666f | 206 | __field( u64, cpu_id ) |
7c68b363 AG |
207 | #else |
208 | __field( u64, dummy ) | |
209 | #endif | |
b283666f PW |
210 | ), |
211 | ||
212 | TP_fast_assign( | |
7c68b363 | 213 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
d3ac4d63 | 214 | tp_assign(cpu_id, cpu_id) |
7c68b363 AG |
215 | #else |
216 | tp_assign(dummy, 0xffff) | |
217 | #endif | |
b283666f PW |
218 | ), |
219 | ||
7c68b363 | 220 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
b283666f | 221 | TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id) |
7c68b363 AG |
222 | #else |
223 | TP_printk("dummy=%lu", (unsigned long)__entry->dummy) | |
224 | #endif | |
b283666f PW |
225 | ) |
226 | ||
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 | |
230 | ||
231 | enum { | |
232 | POWER_NONE = 0, | |
233 | POWER_CSTATE = 1, | |
234 | POWER_PSTATE = 2, | |
235 | }; | |
236 | #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */ | |
237 | ||
238 | #else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */ | |
239 | ||
240 | #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED | |
241 | #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED | |
242 | enum { | |
243 | POWER_NONE = 0, | |
244 | POWER_CSTATE = 1, | |
245 | POWER_PSTATE = 2, | |
246 | }; | |
247 | ||
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) {}; | |
7c68b363 AG |
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) {}; | |
255 | #endif | |
b283666f PW |
256 | static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {}; |
257 | #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */ | |
258 | ||
259 | #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */ | |
260 | ||
7c68b363 | 261 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) |
b283666f PW |
262 | /* |
263 | * The clock events are used for clock enable/disable and for | |
264 | * clock rate change | |
265 | */ | |
9cf29d3e | 266 | DECLARE_EVENT_CLASS(power_clock, |
b283666f PW |
267 | |
268 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), | |
269 | ||
270 | TP_ARGS(name, state, cpu_id), | |
271 | ||
272 | TP_STRUCT__entry( | |
273 | __string( name, name ) | |
274 | __field( u64, state ) | |
275 | __field( u64, cpu_id ) | |
276 | ), | |
277 | ||
278 | TP_fast_assign( | |
d3ac4d63 PW |
279 | tp_strcpy(name, name) |
280 | tp_assign(state, state) | |
281 | tp_assign(cpu_id, cpu_id) | |
b283666f PW |
282 | ), |
283 | ||
284 | TP_printk("%s state=%lu cpu_id=%lu", __get_str(name), | |
285 | (unsigned long)__entry->state, (unsigned long)__entry->cpu_id) | |
286 | ) | |
287 | ||
9cf29d3e MD |
288 | DEFINE_EVENT_MAP(power_clock, clock_enable, |
289 | ||
290 | power_clock_enable, | |
b283666f PW |
291 | |
292 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), | |
293 | ||
294 | TP_ARGS(name, state, cpu_id) | |
295 | ) | |
296 | ||
9cf29d3e MD |
297 | DEFINE_EVENT_MAP(power_clock, clock_disable, |
298 | ||
299 | power_clock_disable, | |
b283666f PW |
300 | |
301 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), | |
302 | ||
303 | TP_ARGS(name, state, cpu_id) | |
304 | ) | |
305 | ||
9cf29d3e MD |
306 | DEFINE_EVENT_MAP(power_clock, clock_set_rate, |
307 | ||
308 | power_clock_set_rate, | |
b283666f PW |
309 | |
310 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), | |
311 | ||
312 | TP_ARGS(name, state, cpu_id) | |
313 | ) | |
314 | ||
315 | /* | |
316 | * The power domain events are used for power domains transitions | |
317 | */ | |
318 | DECLARE_EVENT_CLASS(power_domain, | |
319 | ||
320 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), | |
321 | ||
322 | TP_ARGS(name, state, cpu_id), | |
323 | ||
324 | TP_STRUCT__entry( | |
325 | __string( name, name ) | |
326 | __field( u64, state ) | |
327 | __field( u64, cpu_id ) | |
328 | ), | |
329 | ||
330 | TP_fast_assign( | |
d3ac4d63 PW |
331 | tp_strcpy(name, name) |
332 | tp_assign(state, state) | |
333 | tp_assign(cpu_id, cpu_id) | |
b283666f PW |
334 | ), |
335 | ||
336 | TP_printk("%s state=%lu cpu_id=%lu", __get_str(name), | |
337 | (unsigned long)__entry->state, (unsigned long)__entry->cpu_id) | |
338 | ) | |
339 | ||
340 | DEFINE_EVENT(power_domain, power_domain_target, | |
341 | ||
342 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), | |
343 | ||
344 | TP_ARGS(name, state, cpu_id) | |
345 | ) | |
7c68b363 AG |
346 | #endif |
347 | ||
b283666f PW |
348 | #endif /* _TRACE_POWER_H */ |
349 | ||
350 | /* This part must be outside protection */ | |
351 | #include "../../../probes/define_trace.h" |