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/ktime.h>
9 #include <linux/pm_qos.h>
10 #include <linux/tracepoint.h>
11 #include <linux/trace_events.h>
13 #define TPS(x) tracepoint_string(x)
15 DECLARE_EVENT_CLASS(cpu,
17 TP_PROTO(unsigned int state, unsigned int cpu_id),
19 TP_ARGS(state, cpu_id),
23 __field( u32, cpu_id )
27 __entry->state = state;
28 __entry->cpu_id = cpu_id;
31 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
32 (unsigned long)__entry->cpu_id)
35 DEFINE_EVENT(cpu, cpu_idle,
37 TP_PROTO(unsigned int state, unsigned int cpu_id),
39 TP_ARGS(state, cpu_id)
42 TRACE_EVENT(powernv_throttle,
44 TP_PROTO(int chip_id, const char *reason, int pmax),
46 TP_ARGS(chip_id, reason, pmax),
50 __string(reason, reason)
55 __entry->chip_id = chip_id;
56 __assign_str(reason, reason);
60 TP_printk("Chip %d Pmax %d %s", __entry->chip_id,
61 __entry->pmax, __get_str(reason))
64 TRACE_EVENT(pstate_sample,
66 TP_PROTO(u32 core_busy,
89 __field(u32, core_busy)
90 __field(u32, scaled_busy)
97 __field(u32, io_boost)
101 __entry->core_busy = core_busy;
102 __entry->scaled_busy = scaled_busy;
103 __entry->from = from;
105 __entry->mperf = mperf;
106 __entry->aperf = aperf;
108 __entry->freq = freq;
109 __entry->io_boost = io_boost;
112 TP_printk("core_busy=%lu scaled=%lu from=%lu to=%lu mperf=%llu aperf=%llu tsc=%llu freq=%lu io_boost=%lu",
113 (unsigned long)__entry->core_busy,
114 (unsigned long)__entry->scaled_busy,
115 (unsigned long)__entry->from,
116 (unsigned long)__entry->to,
117 (unsigned long long)__entry->mperf,
118 (unsigned long long)__entry->aperf,
119 (unsigned long long)__entry->tsc,
120 (unsigned long)__entry->freq,
121 (unsigned long)__entry->io_boost
126 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
127 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
128 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
130 #define PWR_EVENT_EXIT -1
133 #define pm_verb_symbolic(event) \
134 __print_symbolic(event, \
135 { PM_EVENT_SUSPEND, "suspend" }, \
136 { PM_EVENT_RESUME, "resume" }, \
137 { PM_EVENT_FREEZE, "freeze" }, \
138 { PM_EVENT_QUIESCE, "quiesce" }, \
139 { PM_EVENT_HIBERNATE, "hibernate" }, \
140 { PM_EVENT_THAW, "thaw" }, \
141 { PM_EVENT_RESTORE, "restore" }, \
142 { PM_EVENT_RECOVER, "recover" })
144 DEFINE_EVENT(cpu, cpu_frequency,
146 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
148 TP_ARGS(frequency, cpu_id)
151 TRACE_EVENT(device_pm_callback_start,
153 TP_PROTO(struct device *dev, const char *pm_ops, int event),
155 TP_ARGS(dev, pm_ops, event),
158 __string(device, dev_name(dev))
159 __string(driver, dev_driver_string(dev))
160 __string(parent, dev->parent ? dev_name(dev->parent) : "none")
161 __string(pm_ops, pm_ops ? pm_ops : "none ")
166 __assign_str(device, dev_name(dev));
167 __assign_str(driver, dev_driver_string(dev));
169 dev->parent ? dev_name(dev->parent) : "none");
170 __assign_str(pm_ops, pm_ops ? pm_ops : "none ");
171 __entry->event = event;
174 TP_printk("%s %s, parent: %s, %s[%s]", __get_str(driver),
175 __get_str(device), __get_str(parent), __get_str(pm_ops),
176 pm_verb_symbolic(__entry->event))
179 TRACE_EVENT(device_pm_callback_end,
181 TP_PROTO(struct device *dev, int error),
186 __string(device, dev_name(dev))
187 __string(driver, dev_driver_string(dev))
192 __assign_str(device, dev_name(dev));
193 __assign_str(driver, dev_driver_string(dev));
194 __entry->error = error;
197 TP_printk("%s %s, err=%d",
198 __get_str(driver), __get_str(device), __entry->error)
201 TRACE_EVENT(suspend_resume,
203 TP_PROTO(const char *action, int val, bool start),
205 TP_ARGS(action, val, start),
208 __field(const char *, action)
214 __entry->action = action;
216 __entry->start = start;
219 TP_printk("%s[%u] %s", __entry->action, (unsigned int)__entry->val,
220 (__entry->start)?"begin":"end")
223 DECLARE_EVENT_CLASS(wakeup_source,
225 TP_PROTO(const char *name, unsigned int state),
227 TP_ARGS(name, state),
230 __string( name, name )
231 __field( u64, state )
235 __assign_str(name, name);
236 __entry->state = state;
239 TP_printk("%s state=0x%lx", __get_str(name),
240 (unsigned long)__entry->state)
243 DEFINE_EVENT(wakeup_source, wakeup_source_activate,
245 TP_PROTO(const char *name, unsigned int state),
250 DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
252 TP_PROTO(const char *name, unsigned int state),
258 * The clock events are used for clock enable/disable and for
261 DECLARE_EVENT_CLASS(clock,
263 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
265 TP_ARGS(name, state, cpu_id),
268 __string( name, name )
269 __field( u64, state )
270 __field( u64, cpu_id )
274 __assign_str(name, name);
275 __entry->state = state;
276 __entry->cpu_id = cpu_id;
279 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
280 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
283 DEFINE_EVENT(clock, clock_enable,
285 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
287 TP_ARGS(name, state, cpu_id)
290 DEFINE_EVENT(clock, clock_disable,
292 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
294 TP_ARGS(name, state, cpu_id)
297 DEFINE_EVENT(clock, clock_set_rate,
299 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
301 TP_ARGS(name, state, cpu_id)
305 * The power domain events are used for power domains transitions
307 DECLARE_EVENT_CLASS(power_domain,
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 )
320 __assign_str(name, name);
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(power_domain, power_domain_target,
331 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
333 TP_ARGS(name, state, cpu_id)
337 * The pm qos events are used for pm qos update
339 DECLARE_EVENT_CLASS(pm_qos_request,
341 TP_PROTO(int pm_qos_class, s32 value),
343 TP_ARGS(pm_qos_class, value),
346 __field( int, pm_qos_class )
347 __field( s32, value )
351 __entry->pm_qos_class = pm_qos_class;
352 __entry->value = value;
355 TP_printk("pm_qos_class=%s value=%d",
356 __print_symbolic(__entry->pm_qos_class,
357 { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
358 { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
359 { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
363 DEFINE_EVENT(pm_qos_request, pm_qos_add_request,
365 TP_PROTO(int pm_qos_class, s32 value),
367 TP_ARGS(pm_qos_class, value)
370 DEFINE_EVENT(pm_qos_request, pm_qos_update_request,
372 TP_PROTO(int pm_qos_class, s32 value),
374 TP_ARGS(pm_qos_class, value)
377 DEFINE_EVENT(pm_qos_request, pm_qos_remove_request,
379 TP_PROTO(int pm_qos_class, s32 value),
381 TP_ARGS(pm_qos_class, value)
384 TRACE_EVENT(pm_qos_update_request_timeout,
386 TP_PROTO(int pm_qos_class, s32 value, unsigned long timeout_us),
388 TP_ARGS(pm_qos_class, value, timeout_us),
391 __field( int, pm_qos_class )
392 __field( s32, value )
393 __field( unsigned long, timeout_us )
397 __entry->pm_qos_class = pm_qos_class;
398 __entry->value = value;
399 __entry->timeout_us = timeout_us;
402 TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld",
403 __print_symbolic(__entry->pm_qos_class,
404 { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
405 { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
406 { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
407 __entry->value, __entry->timeout_us)
410 DECLARE_EVENT_CLASS(pm_qos_update,
412 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
414 TP_ARGS(action, prev_value, curr_value),
417 __field( enum pm_qos_req_action, action )
418 __field( int, prev_value )
419 __field( int, curr_value )
423 __entry->action = action;
424 __entry->prev_value = prev_value;
425 __entry->curr_value = curr_value;
428 TP_printk("action=%s prev_value=%d curr_value=%d",
429 __print_symbolic(__entry->action,
430 { PM_QOS_ADD_REQ, "ADD_REQ" },
431 { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
432 { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
433 __entry->prev_value, __entry->curr_value)
436 DEFINE_EVENT(pm_qos_update, pm_qos_update_target,
438 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
440 TP_ARGS(action, prev_value, curr_value)
443 DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
445 TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
447 TP_ARGS(action, prev_value, curr_value),
449 TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
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 DECLARE_EVENT_CLASS(dev_pm_qos_request,
459 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
462 TP_ARGS(name, type, new_value),
465 __string( name, name )
466 __field( enum dev_pm_qos_req_type, type )
467 __field( s32, new_value )
471 __assign_str(name, name);
472 __entry->type = type;
473 __entry->new_value = new_value;
476 TP_printk("device=%s type=%s new_value=%d",
478 __print_symbolic(__entry->type,
479 { DEV_PM_QOS_RESUME_LATENCY, "DEV_PM_QOS_RESUME_LATENCY" },
480 { DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS" }),
484 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_add_request,
486 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
489 TP_ARGS(name, type, new_value)
492 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_update_request,
494 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
497 TP_ARGS(name, type, new_value)
500 DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,
502 TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
505 TP_ARGS(name, type, new_value)
507 #endif /* _TRACE_POWER_H */
509 /* This part must be outside protection */
510 #include <trace/define_trace.h>