power.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. #ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
  46. /*
  47. * The power events are used for cpuidle & suspend (power_start, power_end)
  48. * and for cpufreq (power_frequency)
  49. */
  50. DECLARE_EVENT_CLASS(power,
  51. TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
  52. TP_ARGS(type, state, cpu_id),
  53. TP_STRUCT__entry(
  54. __field( u64, type )
  55. __field( u64, state )
  56. __field( u64, cpu_id )
  57. ),
  58. TP_fast_assign(
  59. __entry->type = type;
  60. __entry->state = state;
  61. __entry->cpu_id = cpu_id;
  62. ),
  63. TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type,
  64. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  65. );
  66. DEFINE_EVENT(power, power_start,
  67. TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
  68. TP_ARGS(type, state, cpu_id)
  69. );
  70. DEFINE_EVENT(power, power_frequency,
  71. TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
  72. TP_ARGS(type, state, cpu_id)
  73. );
  74. TRACE_EVENT(power_end,
  75. TP_PROTO(unsigned int cpu_id),
  76. TP_ARGS(cpu_id),
  77. TP_STRUCT__entry(
  78. __field( u64, cpu_id )
  79. ),
  80. TP_fast_assign(
  81. __entry->cpu_id = cpu_id;
  82. ),
  83. TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
  84. );
  85. /* Deprecated dummy functions must be protected against multi-declartion */
  86. #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  87. #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  88. enum {
  89. POWER_NONE = 0,
  90. POWER_CSTATE = 1,
  91. POWER_PSTATE = 2,
  92. };
  93. #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
  94. #else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
  95. #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  96. #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
  97. enum {
  98. POWER_NONE = 0,
  99. POWER_CSTATE = 1,
  100. POWER_PSTATE = 2,
  101. };
  102. /* These dummy declaration have to be ripped out when the deprecated
  103. events get removed */
  104. static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
  105. static inline void trace_power_end(u64 cpuid) {};
  106. static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
  107. static inline void trace_power_end_rcuidle(u64 cpuid) {};
  108. static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
  109. #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
  110. #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
  111. /*
  112. * The clock events are used for clock enable/disable and for
  113. * clock rate change
  114. */
  115. DECLARE_EVENT_CLASS(clock,
  116. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  117. TP_ARGS(name, state, cpu_id),
  118. TP_STRUCT__entry(
  119. __string( name, name )
  120. __field( u64, state )
  121. __field( u64, cpu_id )
  122. ),
  123. TP_fast_assign(
  124. __assign_str(name, name);
  125. __entry->state = state;
  126. __entry->cpu_id = cpu_id;
  127. ),
  128. TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
  129. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  130. );
  131. DEFINE_EVENT(clock, clock_enable,
  132. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  133. TP_ARGS(name, state, cpu_id)
  134. );
  135. DEFINE_EVENT(clock, clock_disable,
  136. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  137. TP_ARGS(name, state, cpu_id)
  138. );
  139. DEFINE_EVENT(clock, clock_set_rate,
  140. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  141. TP_ARGS(name, state, cpu_id)
  142. );
  143. /*
  144. * The power domain events are used for power domains transitions
  145. */
  146. DECLARE_EVENT_CLASS(power_domain,
  147. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  148. TP_ARGS(name, state, cpu_id),
  149. TP_STRUCT__entry(
  150. __string( name, name )
  151. __field( u64, state )
  152. __field( u64, cpu_id )
  153. ),
  154. TP_fast_assign(
  155. __assign_str(name, name);
  156. __entry->state = state;
  157. __entry->cpu_id = cpu_id;
  158. ),
  159. TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
  160. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  161. );
  162. DEFINE_EVENT(power_domain, power_domain_target,
  163. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  164. TP_ARGS(name, state, cpu_id)
  165. );
  166. #endif /* _TRACE_POWER_H */
  167. /* This part must be outside protection */
  168. #include <trace/define_trace.h>