power.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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/tracepoint.h>
  7. DECLARE_EVENT_CLASS(cpu,
  8. TP_PROTO(unsigned int state, unsigned int cpu_id),
  9. TP_ARGS(state, cpu_id),
  10. TP_STRUCT__entry(
  11. __field( u32, state )
  12. __field( u32, cpu_id )
  13. ),
  14. TP_fast_assign(
  15. __entry->state = state;
  16. __entry->cpu_id = cpu_id;
  17. ),
  18. TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
  19. (unsigned long)__entry->cpu_id)
  20. );
  21. DEFINE_EVENT(cpu, cpu_idle,
  22. TP_PROTO(unsigned int state, unsigned int cpu_id),
  23. TP_ARGS(state, cpu_id)
  24. );
  25. /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
  26. #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
  27. #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
  28. #define PWR_EVENT_EXIT -1
  29. #endif
  30. DEFINE_EVENT(cpu, cpu_frequency,
  31. TP_PROTO(unsigned int frequency, unsigned int cpu_id),
  32. TP_ARGS(frequency, cpu_id)
  33. );
  34. TRACE_EVENT(machine_suspend,
  35. TP_PROTO(unsigned int state),
  36. TP_ARGS(state),
  37. TP_STRUCT__entry(
  38. __field( u32, state )
  39. ),
  40. TP_fast_assign(
  41. __entry->state = state;
  42. ),
  43. TP_printk("state=%lu", (unsigned long)__entry->state)
  44. );
  45. DECLARE_EVENT_CLASS(wakeup_source,
  46. TP_PROTO(const char *name, unsigned int state),
  47. TP_ARGS(name, state),
  48. TP_STRUCT__entry(
  49. __string( name, name )
  50. __field( u64, state )
  51. ),
  52. TP_fast_assign(
  53. __assign_str(name, name);
  54. __entry->state = state;
  55. ),
  56. TP_printk("%s state=0x%lx", __get_str(name),
  57. (unsigned long)__entry->state)
  58. );
  59. DEFINE_EVENT(wakeup_source, wakeup_source_activate,
  60. TP_PROTO(const char *name, unsigned int state),
  61. TP_ARGS(name, state)
  62. );
  63. DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
  64. TP_PROTO(const char *name, unsigned int state),
  65. TP_ARGS(name, state)
  66. );
  67. #ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
  68. /*
  69. * The power events are used for cpuidle & suspend (power_start, power_end)
  70. * and for cpufreq (power_frequency)
  71. */
  72. DECLARE_EVENT_CLASS(power,
  73. TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
  74. TP_ARGS(type, state, cpu_id),
  75. TP_STRUCT__entry(
  76. __field( u64, type )
  77. __field( u64, state )
  78. __field( u64, cpu_id )
  79. ),
  80. TP_fast_assign(
  81. __entry->type = type;
  82. __entry->state = state;
  83. __entry->cpu_id = cpu_id;
  84. ),
  85. TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type,
  86. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  87. );
  88. DEFINE_EVENT(power, power_start,
  89. TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
  90. TP_ARGS(type, state, cpu_id)
  91. );
  92. DEFINE_EVENT(power, power_frequency,
  93. TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
  94. TP_ARGS(type, state, cpu_id)
  95. );
  96. TRACE_EVENT(power_end,
  97. TP_PROTO(unsigned int cpu_id),
  98. TP_ARGS(cpu_id),
  99. TP_STRUCT__entry(
  100. __field( u64, cpu_id )
  101. ),
  102. TP_fast_assign(
  103. __entry->cpu_id = cpu_id;
  104. ),
  105. TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
  106. );
  107. /* Deprecated dummy functions must be protected against multi-declartion */
  108. #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  109. #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  110. enum {
  111. POWER_NONE = 0,
  112. POWER_CSTATE = 1,
  113. POWER_PSTATE = 2,
  114. };
  115. #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
  116. #else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
  117. #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  118. #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  119. enum {
  120. POWER_NONE = 0,
  121. POWER_CSTATE = 1,
  122. POWER_PSTATE = 2,
  123. };
  124. /* These dummy declaration have to be ripped out when the deprecated
  125. events get removed */
  126. static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
  127. static inline void trace_power_end(u64 cpuid) {};
  128. static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
  129. static inline void trace_power_end_rcuidle(u64 cpuid) {};
  130. static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
  131. #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
  132. #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
  133. /*
  134. * The clock events are used for clock enable/disable and for
  135. * clock rate change
  136. */
  137. DECLARE_EVENT_CLASS(clock,
  138. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  139. TP_ARGS(name, state, cpu_id),
  140. TP_STRUCT__entry(
  141. __string( name, name )
  142. __field( u64, state )
  143. __field( u64, cpu_id )
  144. ),
  145. TP_fast_assign(
  146. __assign_str(name, name);
  147. __entry->state = state;
  148. __entry->cpu_id = cpu_id;
  149. ),
  150. TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
  151. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  152. );
  153. DEFINE_EVENT(clock, clock_enable,
  154. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  155. TP_ARGS(name, state, cpu_id)
  156. );
  157. DEFINE_EVENT(clock, clock_disable,
  158. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  159. TP_ARGS(name, state, cpu_id)
  160. );
  161. DEFINE_EVENT(clock, clock_set_rate,
  162. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  163. TP_ARGS(name, state, cpu_id)
  164. );
  165. /*
  166. * The power domain events are used for power domains transitions
  167. */
  168. DECLARE_EVENT_CLASS(power_domain,
  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(power_domain, power_domain_target,
  185. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  186. TP_ARGS(name, state, cpu_id)
  187. );
  188. #endif /* _TRACE_POWER_H */
  189. /* This part must be outside protection */
  190. #include <trace/define_trace.h>