1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM power
5 #if !defined(LTTNG_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define LTTNG_TRACE_POWER_H
8 #include <probes/lttng-tracepoint-event.h>
9 #include <linux/ktime.h>
10 #include <linux/version.h>
12 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13 LTTNG_TRACEPOINT_EVENT_CLASS(power_cpu
,
15 TP_PROTO(unsigned int state
, unsigned int cpu_id
),
17 TP_ARGS(state
, cpu_id
),
20 ctf_integer(u32
, state
, state
)
21 ctf_integer(u32
, cpu_id
, cpu_id
)
25 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_cpu
, cpu_idle
,
29 TP_PROTO(unsigned int state
, unsigned int cpu_id
),
31 TP_ARGS(state
, cpu_id
)
34 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
35 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
36 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
38 #define PWR_EVENT_EXIT -1
41 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_cpu
, cpu_frequency
,
45 TP_PROTO(unsigned int frequency
, unsigned int cpu_id
),
47 TP_ARGS(frequency
, cpu_id
)
50 LTTNG_TRACEPOINT_EVENT_MAP(machine_suspend
,
52 power_machine_suspend
,
54 TP_PROTO(unsigned int state
),
59 ctf_integer(u32
, state
, state
)
64 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
65 LTTNG_TRACEPOINT_EVENT_CLASS(power_wakeup_source
,
67 TP_PROTO(const char *name
, unsigned int state
),
72 ctf_string(name
, name
)
73 ctf_integer(u64
, state
, state
)
77 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_wakeup_source
, wakeup_source_activate
,
79 power_wakeup_source_activate
,
81 TP_PROTO(const char *name
, unsigned int state
),
86 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_wakeup_source
, wakeup_source_deactivate
,
88 power_wakeup_source_deactivate
,
90 TP_PROTO(const char *name
, unsigned int state
),
96 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
97 #undef CONFIG_EVENT_POWER_TRACING_DEPRECATED
98 #define CONFIG_EVENT_POWER_TRACING_DEPRECATED
99 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
102 #ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
105 * The power events are used for cpuidle & suspend (power_start, power_end)
106 * and for cpufreq (power_frequency)
108 LTTNG_TRACEPOINT_EVENT_CLASS(power
,
110 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
111 TP_PROTO(unsigned int type
, unsigned int state
, unsigned int cpu_id
),
113 TP_ARGS(type
, state
, cpu_id
),
115 TP_PROTO(unsigned int type
, unsigned int state
),
117 TP_ARGS(type
, state
),
121 ctf_integer(u64
, type
, type
)
122 ctf_integer(u64
, state
, state
)
123 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
124 ctf_integer(u64
, cpu_id
, cpu_id
)
129 LTTNG_TRACEPOINT_EVENT_INSTANCE(power
, power_start
,
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
),
142 LTTNG_TRACEPOINT_EVENT_INSTANCE(power
, power_frequency
,
144 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
145 TP_PROTO(unsigned int type
, unsigned int state
, unsigned int cpu_id
),
147 TP_ARGS(type
, state
, cpu_id
)
149 TP_PROTO(unsigned int type
, unsigned int state
),
155 LTTNG_TRACEPOINT_EVENT(power_end
,
157 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
158 TP_PROTO(unsigned int cpu_id
),
168 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
169 ctf_integer(u64
, cpu_id
, cpu_id
)
171 ctf_integer(u64
, dummy
, 0xffff)
176 /* Deprecated dummy functions must be protected against multi-declartion */
177 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
178 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
185 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
187 #else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
189 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
190 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
197 /* These dummy declaration have to be ripped out when the deprecated
198 events get removed */
199 static inline void trace_power_start(u64 type
, u64 state
, u64 cpuid
) {};
200 static inline void trace_power_end(u64 cpuid
) {};
201 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
202 static inline void trace_power_start_rcuidle(u64 type
, u64 state
, u64 cpuid
) {};
203 static inline void trace_power_end_rcuidle(u64 cpuid
) {};
205 static inline void trace_power_frequency(u64 type
, u64 state
, u64 cpuid
) {};
206 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
208 #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
210 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
212 * The clock events are used for clock enable/disable and for
215 LTTNG_TRACEPOINT_EVENT_CLASS(power_clock
,
217 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
219 TP_ARGS(name
, state
, cpu_id
),
222 ctf_string(name
, name
)
223 ctf_integer(u64
, state
, state
)
224 ctf_integer(u64
, cpu_id
, cpu_id
)
228 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock
, clock_enable
,
232 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
234 TP_ARGS(name
, state
, cpu_id
)
237 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock
, clock_disable
,
241 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
243 TP_ARGS(name
, state
, cpu_id
)
246 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock
, clock_set_rate
,
248 power_clock_set_rate
,
250 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
252 TP_ARGS(name
, state
, cpu_id
)
256 * The power domain events are used for power domains transitions
258 LTTNG_TRACEPOINT_EVENT_CLASS(power_domain
,
260 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
262 TP_ARGS(name
, state
, cpu_id
),
265 ctf_string(name
, name
)
266 ctf_integer(u64
, state
, state
)
267 ctf_integer(u64
, cpu_id
, cpu_id
)
271 LTTNG_TRACEPOINT_EVENT_INSTANCE(power_domain
, power_domain_target
,
273 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
275 TP_ARGS(name
, state
, cpu_id
)
279 #endif /* LTTNG_TRACE_POWER_H */
281 /* This part must be outside protection */
282 #include <probes/define_trace.h>