power.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM power
  3. #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_POWER_H
  5. #include <linux/ktime.h>
  6. #include <linux/pm_qos.h>
  7. #include <linux/tracepoint.h>
  8. #include <linux/trace_events.h>
  9. #define TPS(x) tracepoint_string(x)
  10. DECLARE_EVENT_CLASS(cpu,
  11. TP_PROTO(unsigned int state, unsigned int cpu_id),
  12. TP_ARGS(state, cpu_id),
  13. TP_STRUCT__entry(
  14. __field( u32, state )
  15. __field( u32, cpu_id )
  16. ),
  17. TP_fast_assign(
  18. __entry->state = state;
  19. __entry->cpu_id = cpu_id;
  20. ),
  21. TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
  22. (unsigned long)__entry->cpu_id)
  23. );
  24. DEFINE_EVENT(cpu, cpu_idle,
  25. TP_PROTO(unsigned int state, unsigned int cpu_id),
  26. TP_ARGS(state, cpu_id)
  27. );
  28. TRACE_EVENT(powernv_throttle,
  29. TP_PROTO(int chip_id, const char *reason, int pmax),
  30. TP_ARGS(chip_id, reason, pmax),
  31. TP_STRUCT__entry(
  32. __field(int, chip_id)
  33. __string(reason, reason)
  34. __field(int, pmax)
  35. ),
  36. TP_fast_assign(
  37. __entry->chip_id = chip_id;
  38. __assign_str(reason, reason);
  39. __entry->pmax = pmax;
  40. ),
  41. TP_printk("Chip %d Pmax %d %s", __entry->chip_id,
  42. __entry->pmax, __get_str(reason))
  43. );
  44. TRACE_EVENT(pstate_sample,
  45. TP_PROTO(u32 core_busy,
  46. u32 scaled_busy,
  47. u32 from,
  48. u32 to,
  49. u64 mperf,
  50. u64 aperf,
  51. u64 tsc,
  52. u32 freq,
  53. u32 io_boost
  54. ),
  55. TP_ARGS(core_busy,
  56. scaled_busy,
  57. from,
  58. to,
  59. mperf,
  60. aperf,
  61. tsc,
  62. freq,
  63. io_boost
  64. ),
  65. TP_STRUCT__entry(
  66. __field(u32, core_busy)
  67. __field(u32, scaled_busy)
  68. __field(u32, from)
  69. __field(u32, to)
  70. __field(u64, mperf)
  71. __field(u64, aperf)
  72. __field(u64, tsc)
  73. __field(u32, freq)
  74. __field(u32, io_boost)
  75. ),
  76. TP_fast_assign(
  77. __entry->core_busy = core_busy;
  78. __entry->scaled_busy = scaled_busy;
  79. __entry->from = from;
  80. __entry->to = to;
  81. __entry->mperf = mperf;
  82. __entry->aperf = aperf;
  83. __entry->tsc = tsc;
  84. __entry->freq = freq;
  85. __entry->io_boost = io_boost;
  86. ),
  87. TP_printk("core_busy=%lu scaled=%lu from=%lu to=%lu mperf=%llu aperf=%llu tsc=%llu freq=%lu io_boost=%lu",
  88. (unsigned long)__entry->core_busy,
  89. (unsigned long)__entry->scaled_busy,
  90. (unsigned long)__entry->from,
  91. (unsigned long)__entry->to,
  92. (unsigned long long)__entry->mperf,
  93. (unsigned long long)__entry->aperf,
  94. (unsigned long long)__entry->tsc,
  95. (unsigned long)__entry->freq,
  96. (unsigned long)__entry->io_boost
  97. )
  98. );
  99. /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
  100. #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
  101. #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
  102. #define PWR_EVENT_EXIT -1
  103. #endif
  104. #define pm_verb_symbolic(event) \
  105. __print_symbolic(event, \
  106. { PM_EVENT_SUSPEND, "suspend" }, \
  107. { PM_EVENT_RESUME, "resume" }, \
  108. { PM_EVENT_FREEZE, "freeze" }, \
  109. { PM_EVENT_QUIESCE, "quiesce" }, \
  110. { PM_EVENT_HIBERNATE, "hibernate" }, \
  111. { PM_EVENT_THAW, "thaw" }, \
  112. { PM_EVENT_RESTORE, "restore" }, \
  113. { PM_EVENT_RECOVER, "recover" })
  114. DEFINE_EVENT(cpu, cpu_frequency,
  115. TP_PROTO(unsigned int frequency, unsigned int cpu_id),
  116. TP_ARGS(frequency, cpu_id)
  117. );
  118. TRACE_EVENT(device_pm_callback_start,
  119. TP_PROTO(struct device *dev, const char *pm_ops, int event),
  120. TP_ARGS(dev, pm_ops, event),
  121. TP_STRUCT__entry(
  122. __string(device, dev_name(dev))
  123. __string(driver, dev_driver_string(dev))
  124. __string(parent, dev->parent ? dev_name(dev->parent) : "none")
  125. __string(pm_ops, pm_ops ? pm_ops : "none ")
  126. __field(int, event)
  127. ),
  128. TP_fast_assign(
  129. __assign_str(device, dev_name(dev));
  130. __assign_str(driver, dev_driver_string(dev));
  131. __assign_str(parent,
  132. dev->parent ? dev_name(dev->parent) : "none");
  133. __assign_str(pm_ops, pm_ops ? pm_ops : "none ");
  134. __entry->event = event;
  135. ),
  136. TP_printk("%s %s, parent: %s, %s[%s]", __get_str(driver),
  137. __get_str(device), __get_str(parent), __get_str(pm_ops),
  138. pm_verb_symbolic(__entry->event))
  139. );
  140. TRACE_EVENT(device_pm_callback_end,
  141. TP_PROTO(struct device *dev, int error),
  142. TP_ARGS(dev, error),
  143. TP_STRUCT__entry(
  144. __string(device, dev_name(dev))
  145. __string(driver, dev_driver_string(dev))
  146. __field(int, error)
  147. ),
  148. TP_fast_assign(
  149. __assign_str(device, dev_name(dev));
  150. __assign_str(driver, dev_driver_string(dev));
  151. __entry->error = error;
  152. ),
  153. TP_printk("%s %s, err=%d",
  154. __get_str(driver), __get_str(device), __entry->error)
  155. );
  156. TRACE_EVENT(suspend_resume,
  157. TP_PROTO(const char *action, int val, bool start),
  158. TP_ARGS(action, val, start),
  159. TP_STRUCT__entry(
  160. __field(const char *, action)
  161. __field(int, val)
  162. __field(bool, start)
  163. ),
  164. TP_fast_assign(
  165. __entry->action = action;
  166. __entry->val = val;
  167. __entry->start = start;
  168. ),
  169. TP_printk("%s[%u] %s", __entry->action, (unsigned int)__entry->val,
  170. (__entry->start)?"begin":"end")
  171. );
  172. DECLARE_EVENT_CLASS(wakeup_source,
  173. TP_PROTO(const char *name, unsigned int state),
  174. TP_ARGS(name, state),
  175. TP_STRUCT__entry(
  176. __string( name, name )
  177. __field( u64, state )
  178. ),
  179. TP_fast_assign(
  180. __assign_str(name, name);
  181. __entry->state = state;
  182. ),
  183. TP_printk("%s state=0x%lx", __get_str(name),
  184. (unsigned long)__entry->state)
  185. );
  186. DEFINE_EVENT(wakeup_source, wakeup_source_activate,
  187. TP_PROTO(const char *name, unsigned int state),
  188. TP_ARGS(name, state)
  189. );
  190. DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
  191. TP_PROTO(const char *name, unsigned int state),
  192. TP_ARGS(name, state)
  193. );
  194. /*
  195. * The clock events are used for clock enable/disable and for
  196. * clock rate change
  197. */
  198. DECLARE_EVENT_CLASS(clock,
  199. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  200. TP_ARGS(name, state, cpu_id),
  201. TP_STRUCT__entry(
  202. __string( name, name )
  203. __field( u64, state )
  204. __field( u64, cpu_id )
  205. ),
  206. TP_fast_assign(
  207. __assign_str(name, name);
  208. __entry->state = state;
  209. __entry->cpu_id = cpu_id;
  210. ),
  211. TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
  212. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  213. );
  214. DEFINE_EVENT(clock, clock_enable,
  215. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  216. TP_ARGS(name, state, cpu_id)
  217. );
  218. DEFINE_EVENT(clock, clock_disable,
  219. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  220. TP_ARGS(name, state, cpu_id)
  221. );
  222. DEFINE_EVENT(clock, clock_set_rate,
  223. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  224. TP_ARGS(name, state, cpu_id)
  225. );
  226. /*
  227. * The power domain events are used for power domains transitions
  228. */
  229. DECLARE_EVENT_CLASS(power_domain,
  230. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  231. TP_ARGS(name, state, cpu_id),
  232. TP_STRUCT__entry(
  233. __string( name, name )
  234. __field( u64, state )
  235. __field( u64, cpu_id )
  236. ),
  237. TP_fast_assign(
  238. __assign_str(name, name);
  239. __entry->state = state;
  240. __entry->cpu_id = cpu_id;
  241. ),
  242. TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
  243. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  244. );
  245. DEFINE_EVENT(power_domain, power_domain_target,
  246. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  247. TP_ARGS(name, state, cpu_id)
  248. );
  249. /*
  250. * The pm qos events are used for pm qos update
  251. */
  252. DECLARE_EVENT_CLASS(pm_qos_request,
  253. TP_PROTO(int pm_qos_class, s32 value),
  254. TP_ARGS(pm_qos_class, value),
  255. TP_STRUCT__entry(
  256. __field( int, pm_qos_class )
  257. __field( s32, value )
  258. ),
  259. TP_fast_assign(
  260. __entry->pm_qos_class = pm_qos_class;
  261. __entry->value = value;
  262. ),
  263. TP_printk("pm_qos_class=%s value=%d",
  264. __print_symbolic(__entry->pm_qos_class,
  265. { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
  266. { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
  267. { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
  268. __entry->value)
  269. );
  270. DEFINE_EVENT(pm_qos_request, pm_qos_add_request,
  271. TP_PROTO(int pm_qos_class, s32 value),
  272. TP_ARGS(pm_qos_class, value)
  273. );
  274. DEFINE_EVENT(pm_qos_request, pm_qos_update_request,
  275. TP_PROTO(int pm_qos_class, s32 value),
  276. TP_ARGS(pm_qos_class, value)
  277. );
  278. DEFINE_EVENT(pm_qos_request, pm_qos_remove_request,
  279. TP_PROTO(int pm_qos_class, s32 value),
  280. TP_ARGS(pm_qos_class, value)
  281. );
  282. TRACE_EVENT(pm_qos_update_request_timeout,
  283. TP_PROTO(int pm_qos_class, s32 value, unsigned long timeout_us),
  284. TP_ARGS(pm_qos_class, value, timeout_us),
  285. TP_STRUCT__entry(
  286. __field( int, pm_qos_class )
  287. __field( s32, value )
  288. __field( unsigned long, timeout_us )
  289. ),
  290. TP_fast_assign(
  291. __entry->pm_qos_class = pm_qos_class;
  292. __entry->value = value;
  293. __entry->timeout_us = timeout_us;
  294. ),
  295. TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld",
  296. __print_symbolic(__entry->pm_qos_class,
  297. { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
  298. { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
  299. { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
  300. __entry->value, __entry->timeout_us)
  301. );
  302. DECLARE_EVENT_CLASS(pm_qos_update,
  303. TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
  304. TP_ARGS(action, prev_value, curr_value),
  305. TP_STRUCT__entry(
  306. __field( enum pm_qos_req_action, action )
  307. __field( int, prev_value )
  308. __field( int, curr_value )
  309. ),
  310. TP_fast_assign(
  311. __entry->action = action;
  312. __entry->prev_value = prev_value;
  313. __entry->curr_value = curr_value;
  314. ),
  315. TP_printk("action=%s prev_value=%d curr_value=%d",
  316. __print_symbolic(__entry->action,
  317. { PM_QOS_ADD_REQ, "ADD_REQ" },
  318. { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
  319. { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
  320. __entry->prev_value, __entry->curr_value)
  321. );
  322. DEFINE_EVENT(pm_qos_update, pm_qos_update_target,
  323. TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
  324. TP_ARGS(action, prev_value, curr_value)
  325. );
  326. DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
  327. TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
  328. TP_ARGS(action, prev_value, curr_value),
  329. TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
  330. __print_symbolic(__entry->action,
  331. { PM_QOS_ADD_REQ, "ADD_REQ" },
  332. { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
  333. { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
  334. __entry->prev_value, __entry->curr_value)
  335. );
  336. DECLARE_EVENT_CLASS(dev_pm_qos_request,
  337. TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
  338. s32 new_value),
  339. TP_ARGS(name, type, new_value),
  340. TP_STRUCT__entry(
  341. __string( name, name )
  342. __field( enum dev_pm_qos_req_type, type )
  343. __field( s32, new_value )
  344. ),
  345. TP_fast_assign(
  346. __assign_str(name, name);
  347. __entry->type = type;
  348. __entry->new_value = new_value;
  349. ),
  350. TP_printk("device=%s type=%s new_value=%d",
  351. __get_str(name),
  352. __print_symbolic(__entry->type,
  353. { DEV_PM_QOS_RESUME_LATENCY, "DEV_PM_QOS_RESUME_LATENCY" },
  354. { DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS" }),
  355. __entry->new_value)
  356. );
  357. DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_add_request,
  358. TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
  359. s32 new_value),
  360. TP_ARGS(name, type, new_value)
  361. );
  362. DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_update_request,
  363. TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
  364. s32 new_value),
  365. TP_ARGS(name, type, new_value)
  366. );
  367. DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,
  368. TP_PROTO(const char *name, enum dev_pm_qos_req_type type,
  369. s32 new_value),
  370. TP_ARGS(name, type, new_value)
  371. );
  372. #endif /* _TRACE_POWER_H */
  373. /* This part must be outside protection */
  374. #include <trace/define_trace.h>