power.h 5.3 KB

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