power.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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. DECLARE_EVENT_CLASS(cpu,
  9. TP_PROTO(unsigned int state, unsigned int cpu_id),
  10. TP_ARGS(state, cpu_id),
  11. TP_STRUCT__entry(
  12. __field( u32, state )
  13. __field( u32, cpu_id )
  14. ),
  15. TP_fast_assign(
  16. __entry->state = state;
  17. __entry->cpu_id = cpu_id;
  18. ),
  19. TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
  20. (unsigned long)__entry->cpu_id)
  21. );
  22. DEFINE_EVENT(cpu, cpu_idle,
  23. TP_PROTO(unsigned int state, unsigned int cpu_id),
  24. TP_ARGS(state, cpu_id)
  25. );
  26. /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
  27. #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
  28. #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
  29. #define PWR_EVENT_EXIT -1
  30. #endif
  31. DEFINE_EVENT(cpu, cpu_frequency,
  32. TP_PROTO(unsigned int frequency, unsigned int cpu_id),
  33. TP_ARGS(frequency, cpu_id)
  34. );
  35. TRACE_EVENT(cpu_frequency_switch_start,
  36. TP_PROTO(unsigned int start_freq, unsigned int end_freq,
  37. unsigned int cpu_id),
  38. TP_ARGS(start_freq, end_freq, cpu_id),
  39. TP_STRUCT__entry(
  40. __field( u32, start_freq )
  41. __field( u32, end_freq )
  42. __field( u32, cpu_id )
  43. ),
  44. TP_fast_assign(
  45. __entry->start_freq = start_freq;
  46. __entry->end_freq = end_freq;
  47. __entry->cpu_id = cpu_id;
  48. ),
  49. TP_printk("start=%lu end=%lu cpu_id=%lu",
  50. (unsigned long)__entry->start_freq,
  51. (unsigned long)__entry->end_freq,
  52. (unsigned long)__entry->cpu_id)
  53. );
  54. TRACE_EVENT(cpu_frequency_switch_end,
  55. TP_PROTO(unsigned int cpu_id),
  56. TP_ARGS(cpu_id),
  57. TP_STRUCT__entry(
  58. __field( u32, cpu_id )
  59. ),
  60. TP_fast_assign(
  61. __entry->cpu_id = cpu_id;
  62. ),
  63. TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
  64. );
  65. TRACE_EVENT(machine_suspend,
  66. TP_PROTO(unsigned int state),
  67. TP_ARGS(state),
  68. TP_STRUCT__entry(
  69. __field( u32, state )
  70. ),
  71. TP_fast_assign(
  72. __entry->state = state;
  73. ),
  74. TP_printk("state=%lu", (unsigned long)__entry->state)
  75. );
  76. DECLARE_EVENT_CLASS(wakeup_source,
  77. TP_PROTO(const char *name, unsigned int state),
  78. TP_ARGS(name, state),
  79. TP_STRUCT__entry(
  80. __string( name, name )
  81. __field( u64, state )
  82. ),
  83. TP_fast_assign(
  84. __assign_str(name, name);
  85. __entry->state = state;
  86. ),
  87. TP_printk("%s state=0x%lx", __get_str(name),
  88. (unsigned long)__entry->state)
  89. );
  90. DEFINE_EVENT(wakeup_source, wakeup_source_activate,
  91. TP_PROTO(const char *name, unsigned int state),
  92. TP_ARGS(name, state)
  93. );
  94. DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
  95. TP_PROTO(const char *name, unsigned int state),
  96. TP_ARGS(name, state)
  97. );
  98. #ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
  99. /*
  100. * The power events are used for cpuidle & suspend (power_start, power_end)
  101. * and for cpufreq (power_frequency)
  102. */
  103. DECLARE_EVENT_CLASS(power,
  104. TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
  105. TP_ARGS(type, state, cpu_id),
  106. TP_STRUCT__entry(
  107. __field( u64, type )
  108. __field( u64, state )
  109. __field( u64, cpu_id )
  110. ),
  111. TP_fast_assign(
  112. __entry->type = type;
  113. __entry->state = state;
  114. __entry->cpu_id = cpu_id;
  115. ),
  116. TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type,
  117. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  118. );
  119. DEFINE_EVENT(power, power_start,
  120. TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
  121. TP_ARGS(type, state, cpu_id)
  122. );
  123. DEFINE_EVENT(power, power_frequency,
  124. TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
  125. TP_ARGS(type, state, cpu_id)
  126. );
  127. TRACE_EVENT(power_end,
  128. TP_PROTO(unsigned int cpu_id),
  129. TP_ARGS(cpu_id),
  130. TP_STRUCT__entry(
  131. __field( u64, cpu_id )
  132. ),
  133. TP_fast_assign(
  134. __entry->cpu_id = cpu_id;
  135. ),
  136. TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
  137. );
  138. /* Deprecated dummy functions must be protected against multi-declartion */
  139. #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  140. #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  141. enum {
  142. POWER_NONE = 0,
  143. POWER_CSTATE = 1,
  144. POWER_PSTATE = 2,
  145. };
  146. #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
  147. #else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
  148. #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  149. #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  150. enum {
  151. POWER_NONE = 0,
  152. POWER_CSTATE = 1,
  153. POWER_PSTATE = 2,
  154. };
  155. /* These dummy declaration have to be ripped out when the deprecated
  156. events get removed */
  157. static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
  158. static inline void trace_power_end(u64 cpuid) {};
  159. static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
  160. static inline void trace_power_end_rcuidle(u64 cpuid) {};
  161. static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
  162. #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
  163. #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
  164. /*
  165. * The clock events are used for clock enable/disable and for
  166. * clock rate change
  167. */
  168. DECLARE_EVENT_CLASS(clock,
  169. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  170. TP_ARGS(name, state, cpu_id),
  171. TP_STRUCT__entry(
  172. __string( name, name )
  173. __field( u64, state )
  174. __field( u64, cpu_id )
  175. ),
  176. TP_fast_assign(
  177. __assign_str(name, name);
  178. __entry->state = state;
  179. __entry->cpu_id = cpu_id;
  180. ),
  181. TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
  182. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  183. );
  184. DEFINE_EVENT(clock, clock_enable,
  185. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  186. TP_ARGS(name, state, cpu_id)
  187. );
  188. DEFINE_EVENT(clock, clock_disable,
  189. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  190. TP_ARGS(name, state, cpu_id)
  191. );
  192. DEFINE_EVENT(clock, clock_set_rate,
  193. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  194. TP_ARGS(name, state, cpu_id)
  195. );
  196. TRACE_EVENT(clock_set_parent,
  197. TP_PROTO(const char *name, const char *parent_name),
  198. TP_ARGS(name, parent_name),
  199. TP_STRUCT__entry(
  200. __string( name, name )
  201. __string( parent_name, parent_name )
  202. ),
  203. TP_fast_assign(
  204. __assign_str(name, name);
  205. __assign_str(parent_name, parent_name);
  206. ),
  207. TP_printk("%s parent=%s", __get_str(name), __get_str(parent_name))
  208. );
  209. /*
  210. * The power domain events are used for power domains transitions
  211. */
  212. DECLARE_EVENT_CLASS(power_domain,
  213. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  214. TP_ARGS(name, state, cpu_id),
  215. TP_STRUCT__entry(
  216. __string( name, name )
  217. __field( u64, state )
  218. __field( u64, cpu_id )
  219. ),
  220. TP_fast_assign(
  221. __assign_str(name, name);
  222. __entry->state = state;
  223. __entry->cpu_id = cpu_id;
  224. ),
  225. TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
  226. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  227. );
  228. DEFINE_EVENT(power_domain, power_domain_target,
  229. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  230. TP_ARGS(name, state, cpu_id)
  231. );
  232. TRACE_EVENT(bus_update_request,
  233. TP_PROTO(int sec, int nsec, const char *name, unsigned int index,
  234. int src, int dest, unsigned long long ab, unsigned long long ib),
  235. TP_ARGS(sec, nsec, name, index, src, dest, ab, ib),
  236. TP_STRUCT__entry(
  237. __field(int, sec)
  238. __field(int, nsec)
  239. __string(name, name)
  240. __field(u32, index)
  241. __field(int, src)
  242. __field(int, dest)
  243. __field(u64, ab)
  244. __field(u64, ib)
  245. ),
  246. TP_fast_assign(
  247. __entry->sec = sec;
  248. __entry->nsec = nsec;
  249. __assign_str(name, name);
  250. __entry->index = index;
  251. __entry->src = src;
  252. __entry->dest = dest;
  253. __entry->ab = ab;
  254. __entry->ib = ib;
  255. ),
  256. TP_printk("time= %d.%d name=%s index=%u src=%d dest=%d ab=%llu ib=%llu",
  257. __entry->sec,
  258. __entry->nsec,
  259. __get_str(name),
  260. (unsigned int)__entry->index,
  261. __entry->src,
  262. __entry->dest,
  263. (unsigned long long)__entry->ab,
  264. (unsigned long long)__entry->ib)
  265. );
  266. /*
  267. * The pm qos events are used for pm qos update
  268. */
  269. DECLARE_EVENT_CLASS(pm_qos_request,
  270. TP_PROTO(int pm_qos_class, s32 value),
  271. TP_ARGS(pm_qos_class, value),
  272. TP_STRUCT__entry(
  273. __field( int, pm_qos_class )
  274. __field( s32, value )
  275. ),
  276. TP_fast_assign(
  277. __entry->pm_qos_class = pm_qos_class;
  278. __entry->value = value;
  279. ),
  280. TP_printk("pm_qos_class=%s value=%d",
  281. __print_symbolic(__entry->pm_qos_class,
  282. { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
  283. { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
  284. { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
  285. __entry->value)
  286. );
  287. DEFINE_EVENT(pm_qos_request, pm_qos_add_request,
  288. TP_PROTO(int pm_qos_class, s32 value),
  289. TP_ARGS(pm_qos_class, value)
  290. );
  291. DEFINE_EVENT(pm_qos_request, pm_qos_update_request,
  292. TP_PROTO(int pm_qos_class, s32 value),
  293. TP_ARGS(pm_qos_class, value)
  294. );
  295. DEFINE_EVENT(pm_qos_request, pm_qos_remove_request,
  296. TP_PROTO(int pm_qos_class, s32 value),
  297. TP_ARGS(pm_qos_class, value)
  298. );
  299. TRACE_EVENT(pm_qos_update_request_timeout,
  300. TP_PROTO(int pm_qos_class, s32 value, unsigned long timeout_us),
  301. TP_ARGS(pm_qos_class, value, timeout_us),
  302. TP_STRUCT__entry(
  303. __field( int, pm_qos_class )
  304. __field( s32, value )
  305. __field( unsigned long, timeout_us )
  306. ),
  307. TP_fast_assign(
  308. __entry->pm_qos_class = pm_qos_class;
  309. __entry->value = value;
  310. __entry->timeout_us = timeout_us;
  311. ),
  312. TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld",
  313. __print_symbolic(__entry->pm_qos_class,
  314. { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" },
  315. { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" },
  316. { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }),
  317. __entry->value, __entry->timeout_us)
  318. );
  319. DECLARE_EVENT_CLASS(pm_qos_update,
  320. TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
  321. TP_ARGS(action, prev_value, curr_value),
  322. TP_STRUCT__entry(
  323. __field( enum pm_qos_req_action, action )
  324. __field( int, prev_value )
  325. __field( int, curr_value )
  326. ),
  327. TP_fast_assign(
  328. __entry->action = action;
  329. __entry->prev_value = prev_value;
  330. __entry->curr_value = curr_value;
  331. ),
  332. TP_printk("action=%s prev_value=%d curr_value=%d",
  333. __print_symbolic(__entry->action,
  334. { PM_QOS_ADD_REQ, "ADD_REQ" },
  335. { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
  336. { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
  337. __entry->prev_value, __entry->curr_value)
  338. );
  339. DEFINE_EVENT(pm_qos_update, pm_qos_update_target,
  340. TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
  341. TP_ARGS(action, prev_value, curr_value)
  342. );
  343. DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags,
  344. TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value),
  345. TP_ARGS(action, prev_value, curr_value),
  346. TP_printk("action=%s prev_value=0x%x curr_value=0x%x",
  347. __print_symbolic(__entry->action,
  348. { PM_QOS_ADD_REQ, "ADD_REQ" },
  349. { PM_QOS_UPDATE_REQ, "UPDATE_REQ" },
  350. { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }),
  351. __entry->prev_value, __entry->curr_value)
  352. );
  353. #endif /* _TRACE_POWER_H */
  354. /* This part must be outside protection */
  355. #include <trace/define_trace.h>