1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM power
5 #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
8 #include <linux/cpufreq.h>
9 #include <linux/ktime.h>
10 #include <linux/pm_qos.h>
11 #include <linux/tracepoint.h>
12 #include <linux/trace_events.h>
14 #define TPS(x) tracepoint_string(x)
16 DECLARE_EVENT_CLASS(cpu
,
18 TP_PROTO(unsigned int state
, unsigned int cpu_id
),
20 TP_ARGS(state
, cpu_id
),
24 __field( u32
, cpu_id
)
28 __entry
->state
= state
;
29 __entry
->cpu_id
= cpu_id
;
32 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry
->state
,
33 (unsigned long)__entry
->cpu_id
)
36 DEFINE_EVENT(cpu
, cpu_idle
,
38 TP_PROTO(unsigned int state
, unsigned int cpu_id
),
40 TP_ARGS(state
, cpu_id
)
43 TRACE_EVENT(cpu_idle_miss
,
45 TP_PROTO(unsigned int cpu_id
, unsigned int state
, bool below
),
47 TP_ARGS(cpu_id
, state
, below
),
56 __entry
->cpu_id
= cpu_id
;
57 __entry
->state
= state
;
58 __entry
->below
= below
;
61 TP_printk("cpu_id=%lu state=%lu type=%s", (unsigned long)__entry
->cpu_id
,
62 (unsigned long)__entry
->state
, (__entry
->below
)?"below":"above")
65 TRACE_EVENT(powernv_throttle
,
67 TP_PROTO(int chip_id
, const char *reason
, int pmax
),
69 TP_ARGS(chip_id
, reason
, pmax
),
73 __string(reason
, reason
)
78 __entry
->chip_id
= chip_id
;
83 TP_printk("Chip %d Pmax %d %s", __entry
->chip_id
,
84 __entry
->pmax
, __get_str(reason
))
87 TRACE_EVENT(pstate_sample
,
89 TP_PROTO(u32 core_busy
,
112 __field(u32
, core_busy
)
113 __field(u32
, scaled_busy
)
120 __field(u32
, io_boost
)
124 __entry
->core_busy
= core_busy
;
125 __entry
->scaled_busy
= scaled_busy
;
126 __entry
->from
= from
;
128 __entry
->mperf
= mperf
;
129 __entry
->aperf
= aperf
;
131 __entry
->freq
= freq
;
132 __entry
->io_boost
= io_boost
;
135 TP_printk("core_busy=%lu scaled=%lu from=%lu to=%lu mperf=%llu aperf=%llu tsc=%llu freq=%lu io_boost=%lu",
136 (unsigned long)__entry
->core_busy
,
137 (unsigned long)__entry
->scaled_busy
,
138 (unsigned long)__entry
->from
,
139 (unsigned long)__entry
->to
,
140 (unsigned long long)__entry
->mperf
,
141 (unsigned long long)__entry
->aperf
,
142 (unsigned long long)__entry
->tsc
,
143 (unsigned long)__entry
->freq
,
144 (unsigned long)__entry
->io_boost
149 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
150 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
151 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
153 #define PWR_EVENT_EXIT -1
156 #define pm_verb_symbolic(event) \
157 __print_symbolic(event, \
158 { PM_EVENT_SUSPEND, "suspend" }, \
159 { PM_EVENT_RESUME, "resume" }, \
160 { PM_EVENT_FREEZE, "freeze" }, \
161 { PM_EVENT_QUIESCE, "quiesce" }, \
162 { PM_EVENT_HIBERNATE, "hibernate" }, \
163 { PM_EVENT_THAW, "thaw" }, \
164 { PM_EVENT_RESTORE, "restore" }, \
165 { PM_EVENT_RECOVER, "recover" })
167 DEFINE_EVENT(cpu
, cpu_frequency
,
169 TP_PROTO(unsigned int frequency
, unsigned int cpu_id
),
171 TP_ARGS(frequency
, cpu_id
)
174 TRACE_EVENT(cpu_frequency_limits
,
176 TP_PROTO(struct cpufreq_policy
*policy
),
181 __field(u32
, min_freq
)
182 __field(u32
, max_freq
)
187 __entry
->min_freq
= policy
->min
;
188 __entry
->max_freq
= policy
->max
;
189 __entry
->cpu_id
= policy
->cpu
;
192 TP_printk("min=%lu max=%lu cpu_id=%lu",
193 (unsigned long)__entry
->min_freq
,
194 (unsigned long)__entry
->max_freq
,
195 (unsigned long)__entry
->cpu_id
)
198 TRACE_EVENT(device_pm_callback_start
,
200 TP_PROTO(struct device
*dev
, const char *pm_ops
, int event
),
202 TP_ARGS(dev
, pm_ops
, event
),
205 __string(device
, dev_name(dev
))
206 __string(driver
, dev_driver_string(dev
))
207 __string(parent
, dev
->parent
? dev_name(dev
->parent
) : "none")
208 __string(pm_ops
, pm_ops
? pm_ops
: "none ")
213 __assign_str(device
);
214 __assign_str(driver
);
215 __assign_str(parent
);
216 __assign_str(pm_ops
);
217 __entry
->event
= event
;
220 TP_printk("%s %s, parent: %s, %s[%s]", __get_str(driver
),
221 __get_str(device
), __get_str(parent
), __get_str(pm_ops
),
222 pm_verb_symbolic(__entry
->event
))
225 TRACE_EVENT(device_pm_callback_end
,
227 TP_PROTO(struct device
*dev
, int error
),
232 __string(device
, dev_name(dev
))
233 __string(driver
, dev_driver_string(dev
))
238 __assign_str(device
);
239 __assign_str(driver
);
240 __entry
->error
= error
;
243 TP_printk("%s %s, err=%d",
244 __get_str(driver
), __get_str(device
), __entry
->error
)
247 TRACE_EVENT(suspend_resume
,
249 TP_PROTO(const char *action
, int val
, bool start
),
251 TP_ARGS(action
, val
, start
),
254 __field(const char *, action
)
260 __entry
->action
= action
;
262 __entry
->start
= start
;
265 TP_printk("%s[%u] %s", __entry
->action
, (unsigned int)__entry
->val
,
266 (__entry
->start
)?"begin":"end")
269 DECLARE_EVENT_CLASS(wakeup_source
,
271 TP_PROTO(const char *name
, unsigned int state
),
273 TP_ARGS(name
, state
),
276 __string( name
, name
)
277 __field( u64
, state
)
282 __entry
->state
= state
;
285 TP_printk("%s state=0x%lx", __get_str(name
),
286 (unsigned long)__entry
->state
)
289 DEFINE_EVENT(wakeup_source
, wakeup_source_activate
,
291 TP_PROTO(const char *name
, unsigned int state
),
296 DEFINE_EVENT(wakeup_source
, wakeup_source_deactivate
,
298 TP_PROTO(const char *name
, unsigned int state
),
304 * The clock events are used for clock enable/disable and for
307 DECLARE_EVENT_CLASS(clock
,
309 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
311 TP_ARGS(name
, state
, cpu_id
),
314 __string( name
, name
)
315 __field( u64
, state
)
316 __field( u64
, cpu_id
)
321 __entry
->state
= state
;
322 __entry
->cpu_id
= cpu_id
;
325 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name
),
326 (unsigned long)__entry
->state
, (unsigned long)__entry
->cpu_id
)
329 DEFINE_EVENT(clock
, clock_enable
,
331 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
333 TP_ARGS(name
, state
, cpu_id
)
336 DEFINE_EVENT(clock
, clock_disable
,
338 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
340 TP_ARGS(name
, state
, cpu_id
)
343 DEFINE_EVENT(clock
, clock_set_rate
,
345 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
347 TP_ARGS(name
, state
, cpu_id
)
351 * The power domain events are used for power domains transitions
353 DECLARE_EVENT_CLASS(power_domain
,
355 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
357 TP_ARGS(name
, state
, cpu_id
),
360 __string( name
, name
)
361 __field( u64
, state
)
362 __field( u64
, cpu_id
)
367 __entry
->state
= state
;
368 __entry
->cpu_id
= cpu_id
;
371 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name
),
372 (unsigned long)__entry
->state
, (unsigned long)__entry
->cpu_id
)
375 DEFINE_EVENT(power_domain
, power_domain_target
,
377 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
379 TP_ARGS(name
, state
, cpu_id
)
383 * CPU latency QoS events used for global CPU latency QoS list updates
385 DECLARE_EVENT_CLASS(cpu_latency_qos_request
,
392 __field( s32
, value
)
396 __entry
->value
= value
;
399 TP_printk("CPU_DMA_LATENCY value=%d",
403 DEFINE_EVENT(cpu_latency_qos_request
, pm_qos_add_request
,
410 DEFINE_EVENT(cpu_latency_qos_request
, pm_qos_update_request
,
417 DEFINE_EVENT(cpu_latency_qos_request
, pm_qos_remove_request
,
425 * General PM QoS events used for updates of PM QoS request lists
427 DECLARE_EVENT_CLASS(pm_qos_update
,
429 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
431 TP_ARGS(action
, prev_value
, curr_value
),
434 __field( enum pm_qos_req_action
, action
)
435 __field( int, prev_value
)
436 __field( int, curr_value
)
440 __entry
->action
= action
;
441 __entry
->prev_value
= prev_value
;
442 __entry
->curr_value
= curr_value
;
445 TP_printk("action=%s prev_value=%d curr_value=%d",
446 __print_symbolic(__entry
->action
,
447 { PM_QOS_ADD_REQ
, "ADD_REQ" },
448 { PM_QOS_UPDATE_REQ
, "UPDATE_REQ" },
449 { PM_QOS_REMOVE_REQ
, "REMOVE_REQ" }),
450 __entry
->prev_value
, __entry
->curr_value
)
453 DEFINE_EVENT(pm_qos_update
, pm_qos_update_target
,
455 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
457 TP_ARGS(action
, prev_value
, curr_value
)
460 DEFINE_EVENT_PRINT(pm_qos_update
, pm_qos_update_flags
,
462 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
464 TP_ARGS(action
, prev_value
, curr_value
),
466 TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
467 __print_symbolic(__entry
->action
,
468 { PM_QOS_ADD_REQ
, "ADD_REQ" },
469 { PM_QOS_UPDATE_REQ
, "UPDATE_REQ" },
470 { PM_QOS_REMOVE_REQ
, "REMOVE_REQ" }),
471 __entry
->prev_value
, __entry
->curr_value
)
474 DECLARE_EVENT_CLASS(dev_pm_qos_request
,
476 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
479 TP_ARGS(name
, type
, new_value
),
482 __string( name
, name
)
483 __field( enum dev_pm_qos_req_type
, type
)
484 __field( s32
, new_value
)
489 __entry
->type
= type
;
490 __entry
->new_value
= new_value
;
493 TP_printk("device=%s type=%s new_value=%d",
495 __print_symbolic(__entry
->type
,
496 { DEV_PM_QOS_RESUME_LATENCY
, "DEV_PM_QOS_RESUME_LATENCY" },
497 { DEV_PM_QOS_FLAGS
, "DEV_PM_QOS_FLAGS" }),
501 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_add_request
,
503 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
506 TP_ARGS(name
, type
, new_value
)
509 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_update_request
,
511 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
514 TP_ARGS(name
, type
, new_value
)
517 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_remove_request
,
519 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
522 TP_ARGS(name
, type
, new_value
)
525 TRACE_EVENT(guest_halt_poll_ns
,
527 TP_PROTO(bool grow
, unsigned int new, unsigned int old
),
529 TP_ARGS(grow
, new, old
),
533 __field(unsigned int, new)
534 __field(unsigned int, old
)
538 __entry
->grow
= grow
;
543 TP_printk("halt_poll_ns %u (%s %u)",
545 __entry
->grow
? "grow" : "shrink",
549 #define trace_guest_halt_poll_ns_grow(new, old) \
550 trace_guest_halt_poll_ns(true, new, old)
551 #define trace_guest_halt_poll_ns_shrink(new, old) \
552 trace_guest_halt_poll_ns(false, new, old)
553 #endif /* _TRACE_POWER_H */
555 /* This part must be outside protection */
556 #include <trace/define_trace.h>