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(powernv_throttle
,
45 TP_PROTO(int chip_id
, const char *reason
, int pmax
),
47 TP_ARGS(chip_id
, reason
, pmax
),
51 __string(reason
, reason
)
56 __entry
->chip_id
= chip_id
;
57 __assign_str(reason
, reason
);
61 TP_printk("Chip %d Pmax %d %s", __entry
->chip_id
,
62 __entry
->pmax
, __get_str(reason
))
65 TRACE_EVENT(pstate_sample
,
67 TP_PROTO(u32 core_busy
,
90 __field(u32
, core_busy
)
91 __field(u32
, scaled_busy
)
98 __field(u32
, io_boost
)
102 __entry
->core_busy
= core_busy
;
103 __entry
->scaled_busy
= scaled_busy
;
104 __entry
->from
= from
;
106 __entry
->mperf
= mperf
;
107 __entry
->aperf
= aperf
;
109 __entry
->freq
= freq
;
110 __entry
->io_boost
= io_boost
;
113 TP_printk("core_busy=%lu scaled=%lu from=%lu to=%lu mperf=%llu aperf=%llu tsc=%llu freq=%lu io_boost=%lu",
114 (unsigned long)__entry
->core_busy
,
115 (unsigned long)__entry
->scaled_busy
,
116 (unsigned long)__entry
->from
,
117 (unsigned long)__entry
->to
,
118 (unsigned long long)__entry
->mperf
,
119 (unsigned long long)__entry
->aperf
,
120 (unsigned long long)__entry
->tsc
,
121 (unsigned long)__entry
->freq
,
122 (unsigned long)__entry
->io_boost
127 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
128 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
129 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
131 #define PWR_EVENT_EXIT -1
134 #define pm_verb_symbolic(event) \
135 __print_symbolic(event, \
136 { PM_EVENT_SUSPEND, "suspend" }, \
137 { PM_EVENT_RESUME, "resume" }, \
138 { PM_EVENT_FREEZE, "freeze" }, \
139 { PM_EVENT_QUIESCE, "quiesce" }, \
140 { PM_EVENT_HIBERNATE, "hibernate" }, \
141 { PM_EVENT_THAW, "thaw" }, \
142 { PM_EVENT_RESTORE, "restore" }, \
143 { PM_EVENT_RECOVER, "recover" })
145 DEFINE_EVENT(cpu
, cpu_frequency
,
147 TP_PROTO(unsigned int frequency
, unsigned int cpu_id
),
149 TP_ARGS(frequency
, cpu_id
)
152 TRACE_EVENT(cpu_frequency_limits
,
154 TP_PROTO(struct cpufreq_policy
*policy
),
159 __field(u32
, min_freq
)
160 __field(u32
, max_freq
)
165 __entry
->min_freq
= policy
->min
;
166 __entry
->max_freq
= policy
->max
;
167 __entry
->cpu_id
= policy
->cpu
;
170 TP_printk("min=%lu max=%lu cpu_id=%lu",
171 (unsigned long)__entry
->min_freq
,
172 (unsigned long)__entry
->max_freq
,
173 (unsigned long)__entry
->cpu_id
)
176 TRACE_EVENT(device_pm_callback_start
,
178 TP_PROTO(struct device
*dev
, const char *pm_ops
, int event
),
180 TP_ARGS(dev
, pm_ops
, event
),
183 __string(device
, dev_name(dev
))
184 __string(driver
, dev_driver_string(dev
))
185 __string(parent
, dev
->parent
? dev_name(dev
->parent
) : "none")
186 __string(pm_ops
, pm_ops
? pm_ops
: "none ")
191 __assign_str(device
, dev_name(dev
));
192 __assign_str(driver
, dev_driver_string(dev
));
194 dev
->parent
? dev_name(dev
->parent
) : "none");
195 __assign_str(pm_ops
, pm_ops
? pm_ops
: "none ");
196 __entry
->event
= event
;
199 TP_printk("%s %s, parent: %s, %s[%s]", __get_str(driver
),
200 __get_str(device
), __get_str(parent
), __get_str(pm_ops
),
201 pm_verb_symbolic(__entry
->event
))
204 TRACE_EVENT(device_pm_callback_end
,
206 TP_PROTO(struct device
*dev
, int error
),
211 __string(device
, dev_name(dev
))
212 __string(driver
, dev_driver_string(dev
))
217 __assign_str(device
, dev_name(dev
));
218 __assign_str(driver
, dev_driver_string(dev
));
219 __entry
->error
= error
;
222 TP_printk("%s %s, err=%d",
223 __get_str(driver
), __get_str(device
), __entry
->error
)
226 TRACE_EVENT(suspend_resume
,
228 TP_PROTO(const char *action
, int val
, bool start
),
230 TP_ARGS(action
, val
, start
),
233 __field(const char *, action
)
239 __entry
->action
= action
;
241 __entry
->start
= start
;
244 TP_printk("%s[%u] %s", __entry
->action
, (unsigned int)__entry
->val
,
245 (__entry
->start
)?"begin":"end")
248 DECLARE_EVENT_CLASS(wakeup_source
,
250 TP_PROTO(const char *name
, unsigned int state
),
252 TP_ARGS(name
, state
),
255 __string( name
, name
)
256 __field( u64
, state
)
260 __assign_str(name
, name
);
261 __entry
->state
= state
;
264 TP_printk("%s state=0x%lx", __get_str(name
),
265 (unsigned long)__entry
->state
)
268 DEFINE_EVENT(wakeup_source
, wakeup_source_activate
,
270 TP_PROTO(const char *name
, unsigned int state
),
275 DEFINE_EVENT(wakeup_source
, wakeup_source_deactivate
,
277 TP_PROTO(const char *name
, unsigned int state
),
283 * The clock events are used for clock enable/disable and for
286 DECLARE_EVENT_CLASS(clock
,
288 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
290 TP_ARGS(name
, state
, cpu_id
),
293 __string( name
, name
)
294 __field( u64
, state
)
295 __field( u64
, cpu_id
)
299 __assign_str(name
, name
);
300 __entry
->state
= state
;
301 __entry
->cpu_id
= cpu_id
;
304 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name
),
305 (unsigned long)__entry
->state
, (unsigned long)__entry
->cpu_id
)
308 DEFINE_EVENT(clock
, clock_enable
,
310 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
312 TP_ARGS(name
, state
, cpu_id
)
315 DEFINE_EVENT(clock
, clock_disable
,
317 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
319 TP_ARGS(name
, state
, cpu_id
)
322 DEFINE_EVENT(clock
, clock_set_rate
,
324 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
326 TP_ARGS(name
, state
, cpu_id
)
330 * The power domain events are used for power domains transitions
332 DECLARE_EVENT_CLASS(power_domain
,
334 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
336 TP_ARGS(name
, state
, cpu_id
),
339 __string( name
, name
)
340 __field( u64
, state
)
341 __field( u64
, cpu_id
)
345 __assign_str(name
, name
);
346 __entry
->state
= state
;
347 __entry
->cpu_id
= cpu_id
;
350 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name
),
351 (unsigned long)__entry
->state
, (unsigned long)__entry
->cpu_id
)
354 DEFINE_EVENT(power_domain
, power_domain_target
,
356 TP_PROTO(const char *name
, unsigned int state
, unsigned int cpu_id
),
358 TP_ARGS(name
, state
, cpu_id
)
362 * The pm qos events are used for pm qos update
364 DECLARE_EVENT_CLASS(pm_qos_request
,
366 TP_PROTO(int pm_qos_class
, s32 value
),
368 TP_ARGS(pm_qos_class
, value
),
371 __field( int, pm_qos_class
)
372 __field( s32
, value
)
376 __entry
->pm_qos_class
= pm_qos_class
;
377 __entry
->value
= value
;
380 TP_printk("pm_qos_class=%s value=%d",
381 __print_symbolic(__entry
->pm_qos_class
,
382 { PM_QOS_CPU_DMA_LATENCY
, "CPU_DMA_LATENCY" }),
386 DEFINE_EVENT(pm_qos_request
, pm_qos_add_request
,
388 TP_PROTO(int pm_qos_class
, s32 value
),
390 TP_ARGS(pm_qos_class
, value
)
393 DEFINE_EVENT(pm_qos_request
, pm_qos_update_request
,
395 TP_PROTO(int pm_qos_class
, s32 value
),
397 TP_ARGS(pm_qos_class
, value
)
400 DEFINE_EVENT(pm_qos_request
, pm_qos_remove_request
,
402 TP_PROTO(int pm_qos_class
, s32 value
),
404 TP_ARGS(pm_qos_class
, value
)
407 TRACE_EVENT(pm_qos_update_request_timeout
,
409 TP_PROTO(int pm_qos_class
, s32 value
, unsigned long timeout_us
),
411 TP_ARGS(pm_qos_class
, value
, timeout_us
),
414 __field( int, pm_qos_class
)
415 __field( s32
, value
)
416 __field( unsigned long, timeout_us
)
420 __entry
->pm_qos_class
= pm_qos_class
;
421 __entry
->value
= value
;
422 __entry
->timeout_us
= timeout_us
;
425 TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld",
426 __print_symbolic(__entry
->pm_qos_class
,
427 { PM_QOS_CPU_DMA_LATENCY
, "CPU_DMA_LATENCY" }),
428 __entry
->value
, __entry
->timeout_us
)
431 DECLARE_EVENT_CLASS(pm_qos_update
,
433 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
435 TP_ARGS(action
, prev_value
, curr_value
),
438 __field( enum pm_qos_req_action
, action
)
439 __field( int, prev_value
)
440 __field( int, curr_value
)
444 __entry
->action
= action
;
445 __entry
->prev_value
= prev_value
;
446 __entry
->curr_value
= curr_value
;
449 TP_printk("action=%s prev_value=%d curr_value=%d",
450 __print_symbolic(__entry
->action
,
451 { PM_QOS_ADD_REQ
, "ADD_REQ" },
452 { PM_QOS_UPDATE_REQ
, "UPDATE_REQ" },
453 { PM_QOS_REMOVE_REQ
, "REMOVE_REQ" }),
454 __entry
->prev_value
, __entry
->curr_value
)
457 DEFINE_EVENT(pm_qos_update
, pm_qos_update_target
,
459 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
461 TP_ARGS(action
, prev_value
, curr_value
)
464 DEFINE_EVENT_PRINT(pm_qos_update
, pm_qos_update_flags
,
466 TP_PROTO(enum pm_qos_req_action action
, int prev_value
, int curr_value
),
468 TP_ARGS(action
, prev_value
, curr_value
),
470 TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
471 __print_symbolic(__entry
->action
,
472 { PM_QOS_ADD_REQ
, "ADD_REQ" },
473 { PM_QOS_UPDATE_REQ
, "UPDATE_REQ" },
474 { PM_QOS_REMOVE_REQ
, "REMOVE_REQ" }),
475 __entry
->prev_value
, __entry
->curr_value
)
478 DECLARE_EVENT_CLASS(dev_pm_qos_request
,
480 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
483 TP_ARGS(name
, type
, new_value
),
486 __string( name
, name
)
487 __field( enum dev_pm_qos_req_type
, type
)
488 __field( s32
, new_value
)
492 __assign_str(name
, name
);
493 __entry
->type
= type
;
494 __entry
->new_value
= new_value
;
497 TP_printk("device=%s type=%s new_value=%d",
499 __print_symbolic(__entry
->type
,
500 { DEV_PM_QOS_RESUME_LATENCY
, "DEV_PM_QOS_RESUME_LATENCY" },
501 { DEV_PM_QOS_FLAGS
, "DEV_PM_QOS_FLAGS" }),
505 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_add_request
,
507 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
510 TP_ARGS(name
, type
, new_value
)
513 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_update_request
,
515 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
518 TP_ARGS(name
, type
, new_value
)
521 DEFINE_EVENT(dev_pm_qos_request
, dev_pm_qos_remove_request
,
523 TP_PROTO(const char *name
, enum dev_pm_qos_req_type type
,
526 TP_ARGS(name
, type
, new_value
)
528 #endif /* _TRACE_POWER_H */
530 /* This part must be outside protection */
531 #include <trace/define_trace.h>