1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM power
4 #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_POWER_H
7 #include <linux/ktime.h>
8 #include <linux/tracepoint.h>
10 DECLARE_EVENT_CLASS(cpu,
12 TP_PROTO(unsigned int state, unsigned int cpu_id),
14 TP_ARGS(state, cpu_id),
16 TP_STRUCT__entry(
17 __field( u32, state )
18 __field( u32, cpu_id )
19 ),
21 TP_fast_assign(
22 __entry->state = state;
23 __entry->cpu_id = cpu_id;
24 ),
26 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
27 (unsigned long)__entry->cpu_id)
28 );
30 DEFINE_EVENT(cpu, cpu_idle,
32 TP_PROTO(unsigned int state, unsigned int cpu_id),
34 TP_ARGS(state, cpu_id)
35 );
37 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
38 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
39 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
41 #define PWR_EVENT_EXIT -1
42 #endif
44 DEFINE_EVENT(cpu, cpu_frequency,
46 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
48 TP_ARGS(frequency, cpu_id)
49 );
51 TRACE_EVENT(machine_suspend,
53 TP_PROTO(unsigned int state),
55 TP_ARGS(state),
57 TP_STRUCT__entry(
58 __field( u32, state )
59 ),
61 TP_fast_assign(
62 __entry->state = state;
63 ),
65 TP_printk("state=%lu", (unsigned long)__entry->state)
66 );
68 DECLARE_EVENT_CLASS(wakeup_source,
70 TP_PROTO(const char *name, unsigned int state),
72 TP_ARGS(name, state),
74 TP_STRUCT__entry(
75 __string( name, name )
76 __field( u64, state )
77 ),
79 TP_fast_assign(
80 __assign_str(name, name);
81 __entry->state = state;
82 ),
84 TP_printk("%s state=0x%lx", __get_str(name),
85 (unsigned long)__entry->state)
86 );
88 DEFINE_EVENT(wakeup_source, wakeup_source_activate,
90 TP_PROTO(const char *name, unsigned int state),
92 TP_ARGS(name, state)
93 );
95 DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
97 TP_PROTO(const char *name, unsigned int state),
99 TP_ARGS(name, state)
100 );
102 #ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
104 /*
105 * The power events are used for cpuidle & suspend (power_start, power_end)
106 * and for cpufreq (power_frequency)
107 */
108 DECLARE_EVENT_CLASS(power,
110 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
112 TP_ARGS(type, state, cpu_id),
114 TP_STRUCT__entry(
115 __field( u64, type )
116 __field( u64, state )
117 __field( u64, cpu_id )
118 ),
120 TP_fast_assign(
121 __entry->type = type;
122 __entry->state = state;
123 __entry->cpu_id = cpu_id;
124 ),
126 TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type,
127 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
128 );
130 DEFINE_EVENT(power, power_start,
132 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
134 TP_ARGS(type, state, cpu_id)
135 );
137 DEFINE_EVENT(power, power_frequency,
139 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
141 TP_ARGS(type, state, cpu_id)
142 );
144 TRACE_EVENT(power_end,
146 TP_PROTO(unsigned int cpu_id),
148 TP_ARGS(cpu_id),
150 TP_STRUCT__entry(
151 __field( u64, cpu_id )
152 ),
154 TP_fast_assign(
155 __entry->cpu_id = cpu_id;
156 ),
158 TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
160 );
162 /* Deprecated dummy functions must be protected against multi-declartion */
163 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
164 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
166 enum {
167 POWER_NONE = 0,
168 POWER_CSTATE = 1,
169 POWER_PSTATE = 2,
170 };
171 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
173 #else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
175 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
176 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
177 enum {
178 POWER_NONE = 0,
179 POWER_CSTATE = 1,
180 POWER_PSTATE = 2,
181 };
183 /* These dummy declaration have to be ripped out when the deprecated
184 events get removed */
185 static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
186 static inline void trace_power_end(u64 cpuid) {};
187 static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
188 static inline void trace_power_end_rcuidle(u64 cpuid) {};
189 static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
190 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
192 #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
194 /*
195 * The clock events are used for clock enable/disable and for
196 * clock rate change
197 */
198 DECLARE_EVENT_CLASS(clock,
200 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
202 TP_ARGS(name, state, cpu_id),
204 TP_STRUCT__entry(
205 __string( name, name )
206 __field( u64, state )
207 __field( u64, cpu_id )
208 ),
210 TP_fast_assign(
211 __assign_str(name, name);
212 __entry->state = state;
213 __entry->cpu_id = cpu_id;
214 ),
216 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
217 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
218 );
220 DEFINE_EVENT(clock, clock_enable,
222 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
224 TP_ARGS(name, state, cpu_id)
225 );
227 DEFINE_EVENT(clock, clock_disable,
229 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
231 TP_ARGS(name, state, cpu_id)
232 );
234 DEFINE_EVENT(clock, clock_set_rate,
236 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
238 TP_ARGS(name, state, cpu_id)
239 );
241 TRACE_EVENT(clock_set_parent,
243 TP_PROTO(const char *name, const char *parent_name),
245 TP_ARGS(name, parent_name),
247 TP_STRUCT__entry(
248 __string( name, name )
249 __string( parent_name, parent_name )
250 ),
252 TP_fast_assign(
253 __assign_str(name, name);
254 __assign_str(parent_name, parent_name);
255 ),
257 TP_printk("%s parent=%s", __get_str(name), __get_str(parent_name))
258 );
260 /*
261 * The power domain events are used for power domains transitions
262 */
263 DECLARE_EVENT_CLASS(power_domain,
265 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
267 TP_ARGS(name, state, cpu_id),
269 TP_STRUCT__entry(
270 __string( name, name )
271 __field( u64, state )
272 __field( u64, cpu_id )
273 ),
275 TP_fast_assign(
276 __assign_str(name, name);
277 __entry->state = state;
278 __entry->cpu_id = cpu_id;
279 ),
281 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
282 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
283 );
285 DEFINE_EVENT(power_domain, power_domain_target,
287 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
289 TP_ARGS(name, state, cpu_id)
290 );
291 #endif /* _TRACE_POWER_H */
293 /* This part must be outside protection */
294 #include <trace/define_trace.h>