Arjan van de Ven | 6161352 | 2009-09-17 16:11:28 +0200 | [diff] [blame] | 1 | #undef TRACE_SYSTEM |
| 2 | #define TRACE_SYSTEM power |
| 3 | |
| 4 | #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ) |
| 5 | #define _TRACE_POWER_H |
| 6 | |
| 7 | #include <linux/ktime.h> |
Sahara | 247e9ee | 2013-06-21 11:12:28 +0900 | [diff] [blame] | 8 | #include <linux/pm_qos.h> |
Arjan van de Ven | 6161352 | 2009-09-17 16:11:28 +0200 | [diff] [blame] | 9 | #include <linux/tracepoint.h> |
| 10 | |
Thomas Renninger | 25e4193 | 2011-01-03 17:50:44 +0100 | [diff] [blame] | 11 | DECLARE_EVENT_CLASS(cpu, |
| 12 | |
| 13 | TP_PROTO(unsigned int state, unsigned int cpu_id), |
| 14 | |
| 15 | TP_ARGS(state, cpu_id), |
| 16 | |
| 17 | TP_STRUCT__entry( |
| 18 | __field( u32, state ) |
| 19 | __field( u32, cpu_id ) |
| 20 | ), |
| 21 | |
| 22 | TP_fast_assign( |
| 23 | __entry->state = state; |
| 24 | __entry->cpu_id = cpu_id; |
| 25 | ), |
| 26 | |
| 27 | TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state, |
| 28 | (unsigned long)__entry->cpu_id) |
| 29 | ); |
| 30 | |
| 31 | DEFINE_EVENT(cpu, cpu_idle, |
| 32 | |
| 33 | TP_PROTO(unsigned int state, unsigned int cpu_id), |
| 34 | |
| 35 | TP_ARGS(state, cpu_id) |
| 36 | ); |
| 37 | |
Dirk Brandewie | b69880f | 2014-01-16 10:32:25 -0800 | [diff] [blame] | 38 | TRACE_EVENT(pstate_sample, |
| 39 | |
| 40 | TP_PROTO(u32 core_busy, |
| 41 | u32 scaled_busy, |
| 42 | u32 state, |
| 43 | u64 mperf, |
| 44 | u64 aperf, |
Dirk Brandewie | b69880f | 2014-01-16 10:32:25 -0800 | [diff] [blame] | 45 | u32 freq |
| 46 | ), |
| 47 | |
| 48 | TP_ARGS(core_busy, |
| 49 | scaled_busy, |
| 50 | state, |
| 51 | mperf, |
| 52 | aperf, |
Dirk Brandewie | b69880f | 2014-01-16 10:32:25 -0800 | [diff] [blame] | 53 | freq |
| 54 | ), |
| 55 | |
| 56 | TP_STRUCT__entry( |
| 57 | __field(u32, core_busy) |
| 58 | __field(u32, scaled_busy) |
| 59 | __field(u32, state) |
| 60 | __field(u64, mperf) |
| 61 | __field(u64, aperf) |
Dirk Brandewie | b69880f | 2014-01-16 10:32:25 -0800 | [diff] [blame] | 62 | __field(u32, freq) |
| 63 | |
| 64 | ), |
| 65 | |
| 66 | TP_fast_assign( |
| 67 | __entry->core_busy = core_busy; |
| 68 | __entry->scaled_busy = scaled_busy; |
| 69 | __entry->state = state; |
| 70 | __entry->mperf = mperf; |
| 71 | __entry->aperf = aperf; |
Dirk Brandewie | b69880f | 2014-01-16 10:32:25 -0800 | [diff] [blame] | 72 | __entry->freq = freq; |
| 73 | ), |
| 74 | |
Dirk Brandewie | 709c078 | 2014-02-12 10:01:03 -0800 | [diff] [blame] | 75 | TP_printk("core_busy=%lu scaled=%lu state=%lu mperf=%llu aperf=%llu freq=%lu ", |
Dirk Brandewie | b69880f | 2014-01-16 10:32:25 -0800 | [diff] [blame] | 76 | (unsigned long)__entry->core_busy, |
| 77 | (unsigned long)__entry->scaled_busy, |
| 78 | (unsigned long)__entry->state, |
| 79 | (unsigned long long)__entry->mperf, |
| 80 | (unsigned long long)__entry->aperf, |
Dirk Brandewie | b69880f | 2014-01-16 10:32:25 -0800 | [diff] [blame] | 81 | (unsigned long)__entry->freq |
| 82 | ) |
| 83 | |
| 84 | ); |
| 85 | |
Thomas Renninger | 25e4193 | 2011-01-03 17:50:44 +0100 | [diff] [blame] | 86 | /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */ |
| 87 | #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING |
| 88 | #define _PWR_EVENT_AVOID_DOUBLE_DEFINING |
| 89 | |
| 90 | #define PWR_EVENT_EXIT -1 |
Arjan van de Ven | 6161352 | 2009-09-17 16:11:28 +0200 | [diff] [blame] | 91 | #endif |
| 92 | |
Thomas Renninger | 25e4193 | 2011-01-03 17:50:44 +0100 | [diff] [blame] | 93 | DEFINE_EVENT(cpu, cpu_frequency, |
| 94 | |
| 95 | TP_PROTO(unsigned int frequency, unsigned int cpu_id), |
| 96 | |
| 97 | TP_ARGS(frequency, cpu_id) |
| 98 | ); |
| 99 | |
| 100 | TRACE_EVENT(machine_suspend, |
| 101 | |
| 102 | TP_PROTO(unsigned int state), |
| 103 | |
| 104 | TP_ARGS(state), |
| 105 | |
| 106 | TP_STRUCT__entry( |
| 107 | __field( u32, state ) |
| 108 | ), |
| 109 | |
| 110 | TP_fast_assign( |
| 111 | __entry->state = state; |
| 112 | ), |
| 113 | |
| 114 | TP_printk("state=%lu", (unsigned long)__entry->state) |
| 115 | ); |
| 116 | |
Shuah Khan | 5364467 | 2013-07-26 13:30:20 -0600 | [diff] [blame] | 117 | TRACE_EVENT(device_pm_report_time, |
| 118 | |
| 119 | TP_PROTO(struct device *dev, const char *pm_ops, s64 ops_time, |
| 120 | char *pm_event_str, int error), |
| 121 | |
| 122 | TP_ARGS(dev, pm_ops, ops_time, pm_event_str, error), |
| 123 | |
| 124 | TP_STRUCT__entry( |
| 125 | __string(device, dev_name(dev)) |
| 126 | __string(driver, dev_driver_string(dev)) |
| 127 | __string(parent, dev->parent ? dev_name(dev->parent) : "none") |
| 128 | __string(pm_ops, pm_ops ? pm_ops : "none ") |
| 129 | __string(pm_event_str, pm_event_str) |
| 130 | __field(s64, ops_time) |
| 131 | __field(int, error) |
| 132 | ), |
| 133 | |
| 134 | TP_fast_assign( |
| 135 | const char *tmp = dev->parent ? dev_name(dev->parent) : "none"; |
| 136 | const char *tmp_i = pm_ops ? pm_ops : "none "; |
| 137 | |
| 138 | __assign_str(device, dev_name(dev)); |
| 139 | __assign_str(driver, dev_driver_string(dev)); |
| 140 | __assign_str(parent, tmp); |
| 141 | __assign_str(pm_ops, tmp_i); |
| 142 | __assign_str(pm_event_str, pm_event_str); |
| 143 | __entry->ops_time = ops_time; |
| 144 | __entry->error = error; |
| 145 | ), |
| 146 | |
| 147 | /* ops_str has an extra space at the end */ |
| 148 | TP_printk("%s %s parent=%s state=%s ops=%snsecs=%lld err=%d", |
| 149 | __get_str(driver), __get_str(device), __get_str(parent), |
| 150 | __get_str(pm_event_str), __get_str(pm_ops), |
| 151 | __entry->ops_time, __entry->error) |
| 152 | ); |
| 153 | |
Arve Hjønnevåg | 6791e36 | 2012-04-29 22:53:02 +0200 | [diff] [blame] | 154 | DECLARE_EVENT_CLASS(wakeup_source, |
| 155 | |
| 156 | TP_PROTO(const char *name, unsigned int state), |
| 157 | |
| 158 | TP_ARGS(name, state), |
| 159 | |
| 160 | TP_STRUCT__entry( |
| 161 | __string( name, name ) |
| 162 | __field( u64, state ) |
| 163 | ), |
| 164 | |
| 165 | TP_fast_assign( |
| 166 | __assign_str(name, name); |
| 167 | __entry->state = state; |
| 168 | ), |
| 169 | |
| 170 | TP_printk("%s state=0x%lx", __get_str(name), |
| 171 | (unsigned long)__entry->state) |
| 172 | ); |
| 173 | |
| 174 | DEFINE_EVENT(wakeup_source, wakeup_source_activate, |
| 175 | |
| 176 | TP_PROTO(const char *name, unsigned int state), |
| 177 | |
| 178 | TP_ARGS(name, state) |
| 179 | ); |
| 180 | |
| 181 | DEFINE_EVENT(wakeup_source, wakeup_source_deactivate, |
| 182 | |
| 183 | TP_PROTO(const char *name, unsigned int state), |
| 184 | |
| 185 | TP_ARGS(name, state) |
| 186 | ); |
| 187 | |
Jean Pihet | 74704ac | 2010-09-07 09:21:32 +0200 | [diff] [blame] | 188 | /* |
| 189 | * The clock events are used for clock enable/disable and for |
| 190 | * clock rate change |
| 191 | */ |
| 192 | DECLARE_EVENT_CLASS(clock, |
| 193 | |
| 194 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 195 | |
| 196 | TP_ARGS(name, state, cpu_id), |
| 197 | |
| 198 | TP_STRUCT__entry( |
| 199 | __string( name, name ) |
| 200 | __field( u64, state ) |
| 201 | __field( u64, cpu_id ) |
| 202 | ), |
| 203 | |
| 204 | TP_fast_assign( |
| 205 | __assign_str(name, name); |
| 206 | __entry->state = state; |
| 207 | __entry->cpu_id = cpu_id; |
| 208 | ), |
| 209 | |
| 210 | TP_printk("%s state=%lu cpu_id=%lu", __get_str(name), |
| 211 | (unsigned long)__entry->state, (unsigned long)__entry->cpu_id) |
| 212 | ); |
| 213 | |
| 214 | DEFINE_EVENT(clock, clock_enable, |
| 215 | |
| 216 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 217 | |
| 218 | TP_ARGS(name, state, cpu_id) |
| 219 | ); |
| 220 | |
| 221 | DEFINE_EVENT(clock, clock_disable, |
| 222 | |
| 223 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 224 | |
| 225 | TP_ARGS(name, state, cpu_id) |
| 226 | ); |
| 227 | |
| 228 | DEFINE_EVENT(clock, clock_set_rate, |
| 229 | |
| 230 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 231 | |
| 232 | TP_ARGS(name, state, cpu_id) |
| 233 | ); |
| 234 | |
| 235 | /* |
| 236 | * The power domain events are used for power domains transitions |
| 237 | */ |
| 238 | DECLARE_EVENT_CLASS(power_domain, |
| 239 | |
| 240 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 241 | |
| 242 | TP_ARGS(name, state, cpu_id), |
| 243 | |
| 244 | TP_STRUCT__entry( |
| 245 | __string( name, name ) |
| 246 | __field( u64, state ) |
| 247 | __field( u64, cpu_id ) |
| 248 | ), |
| 249 | |
| 250 | TP_fast_assign( |
| 251 | __assign_str(name, name); |
| 252 | __entry->state = state; |
| 253 | __entry->cpu_id = cpu_id; |
| 254 | ), |
| 255 | |
| 256 | TP_printk("%s state=%lu cpu_id=%lu", __get_str(name), |
| 257 | (unsigned long)__entry->state, (unsigned long)__entry->cpu_id) |
| 258 | ); |
| 259 | |
| 260 | DEFINE_EVENT(power_domain, power_domain_target, |
| 261 | |
| 262 | TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), |
| 263 | |
| 264 | TP_ARGS(name, state, cpu_id) |
| 265 | ); |
Sahara | 247e9ee | 2013-06-21 11:12:28 +0900 | [diff] [blame] | 266 | |
| 267 | /* |
| 268 | * The pm qos events are used for pm qos update |
| 269 | */ |
Sahara | ae8822b | 2013-06-21 11:12:29 +0900 | [diff] [blame] | 270 | DECLARE_EVENT_CLASS(pm_qos_request, |
| 271 | |
| 272 | TP_PROTO(int pm_qos_class, s32 value), |
| 273 | |
| 274 | TP_ARGS(pm_qos_class, value), |
| 275 | |
| 276 | TP_STRUCT__entry( |
| 277 | __field( int, pm_qos_class ) |
| 278 | __field( s32, value ) |
| 279 | ), |
| 280 | |
| 281 | TP_fast_assign( |
| 282 | __entry->pm_qos_class = pm_qos_class; |
| 283 | __entry->value = value; |
| 284 | ), |
| 285 | |
| 286 | TP_printk("pm_qos_class=%s value=%d", |
| 287 | __print_symbolic(__entry->pm_qos_class, |
| 288 | { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" }, |
| 289 | { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" }, |
| 290 | { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }), |
| 291 | __entry->value) |
| 292 | ); |
| 293 | |
| 294 | DEFINE_EVENT(pm_qos_request, pm_qos_add_request, |
| 295 | |
| 296 | TP_PROTO(int pm_qos_class, s32 value), |
| 297 | |
| 298 | TP_ARGS(pm_qos_class, value) |
| 299 | ); |
| 300 | |
| 301 | DEFINE_EVENT(pm_qos_request, pm_qos_update_request, |
| 302 | |
| 303 | TP_PROTO(int pm_qos_class, s32 value), |
| 304 | |
| 305 | TP_ARGS(pm_qos_class, value) |
| 306 | ); |
| 307 | |
| 308 | DEFINE_EVENT(pm_qos_request, pm_qos_remove_request, |
| 309 | |
| 310 | TP_PROTO(int pm_qos_class, s32 value), |
| 311 | |
| 312 | TP_ARGS(pm_qos_class, value) |
| 313 | ); |
| 314 | |
| 315 | TRACE_EVENT(pm_qos_update_request_timeout, |
| 316 | |
| 317 | TP_PROTO(int pm_qos_class, s32 value, unsigned long timeout_us), |
| 318 | |
| 319 | TP_ARGS(pm_qos_class, value, timeout_us), |
| 320 | |
| 321 | TP_STRUCT__entry( |
| 322 | __field( int, pm_qos_class ) |
| 323 | __field( s32, value ) |
| 324 | __field( unsigned long, timeout_us ) |
| 325 | ), |
| 326 | |
| 327 | TP_fast_assign( |
| 328 | __entry->pm_qos_class = pm_qos_class; |
| 329 | __entry->value = value; |
| 330 | __entry->timeout_us = timeout_us; |
| 331 | ), |
| 332 | |
| 333 | TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld", |
| 334 | __print_symbolic(__entry->pm_qos_class, |
| 335 | { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" }, |
| 336 | { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" }, |
| 337 | { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }), |
| 338 | __entry->value, __entry->timeout_us) |
| 339 | ); |
| 340 | |
Sahara | 247e9ee | 2013-06-21 11:12:28 +0900 | [diff] [blame] | 341 | DECLARE_EVENT_CLASS(pm_qos_update, |
| 342 | |
| 343 | TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value), |
| 344 | |
| 345 | TP_ARGS(action, prev_value, curr_value), |
| 346 | |
| 347 | TP_STRUCT__entry( |
| 348 | __field( enum pm_qos_req_action, action ) |
| 349 | __field( int, prev_value ) |
| 350 | __field( int, curr_value ) |
| 351 | ), |
| 352 | |
| 353 | TP_fast_assign( |
| 354 | __entry->action = action; |
| 355 | __entry->prev_value = prev_value; |
| 356 | __entry->curr_value = curr_value; |
| 357 | ), |
| 358 | |
| 359 | TP_printk("action=%s prev_value=%d curr_value=%d", |
| 360 | __print_symbolic(__entry->action, |
| 361 | { PM_QOS_ADD_REQ, "ADD_REQ" }, |
| 362 | { PM_QOS_UPDATE_REQ, "UPDATE_REQ" }, |
| 363 | { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }), |
| 364 | __entry->prev_value, __entry->curr_value) |
| 365 | ); |
| 366 | |
| 367 | DEFINE_EVENT(pm_qos_update, pm_qos_update_target, |
| 368 | |
| 369 | TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value), |
| 370 | |
| 371 | TP_ARGS(action, prev_value, curr_value) |
| 372 | ); |
| 373 | |
| 374 | DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags, |
| 375 | |
| 376 | TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value), |
| 377 | |
| 378 | TP_ARGS(action, prev_value, curr_value), |
| 379 | |
| 380 | TP_printk("action=%s prev_value=0x%x curr_value=0x%x", |
| 381 | __print_symbolic(__entry->action, |
| 382 | { PM_QOS_ADD_REQ, "ADD_REQ" }, |
| 383 | { PM_QOS_UPDATE_REQ, "UPDATE_REQ" }, |
| 384 | { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }), |
| 385 | __entry->prev_value, __entry->curr_value) |
| 386 | ); |
Sahara | 96d9d0b | 2013-06-21 11:12:30 +0900 | [diff] [blame] | 387 | |
| 388 | DECLARE_EVENT_CLASS(dev_pm_qos_request, |
| 389 | |
| 390 | TP_PROTO(const char *name, enum dev_pm_qos_req_type type, |
| 391 | s32 new_value), |
| 392 | |
| 393 | TP_ARGS(name, type, new_value), |
| 394 | |
| 395 | TP_STRUCT__entry( |
| 396 | __string( name, name ) |
| 397 | __field( enum dev_pm_qos_req_type, type ) |
| 398 | __field( s32, new_value ) |
| 399 | ), |
| 400 | |
| 401 | TP_fast_assign( |
| 402 | __assign_str(name, name); |
| 403 | __entry->type = type; |
| 404 | __entry->new_value = new_value; |
| 405 | ), |
| 406 | |
| 407 | TP_printk("device=%s type=%s new_value=%d", |
| 408 | __get_str(name), |
| 409 | __print_symbolic(__entry->type, |
Rafael J. Wysocki | b02f669 | 2014-02-11 00:35:23 +0100 | [diff] [blame] | 410 | { DEV_PM_QOS_RESUME_LATENCY, "DEV_PM_QOS_RESUME_LATENCY" }, |
| 411 | { DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS" }), |
Sahara | 96d9d0b | 2013-06-21 11:12:30 +0900 | [diff] [blame] | 412 | __entry->new_value) |
| 413 | ); |
| 414 | |
| 415 | DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_add_request, |
| 416 | |
| 417 | TP_PROTO(const char *name, enum dev_pm_qos_req_type type, |
| 418 | s32 new_value), |
| 419 | |
| 420 | TP_ARGS(name, type, new_value) |
| 421 | ); |
| 422 | |
| 423 | DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_update_request, |
| 424 | |
| 425 | TP_PROTO(const char *name, enum dev_pm_qos_req_type type, |
| 426 | s32 new_value), |
| 427 | |
| 428 | TP_ARGS(name, type, new_value) |
| 429 | ); |
| 430 | |
| 431 | DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request, |
| 432 | |
| 433 | TP_PROTO(const char *name, enum dev_pm_qos_req_type type, |
| 434 | s32 new_value), |
| 435 | |
| 436 | TP_ARGS(name, type, new_value) |
| 437 | ); |
Arjan van de Ven | 6161352 | 2009-09-17 16:11:28 +0200 | [diff] [blame] | 438 | #endif /* _TRACE_POWER_H */ |
| 439 | |
| 440 | /* This part must be outside protection */ |
| 441 | #include <trace/define_trace.h> |