power.h 5.2 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. /* 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_frequency(u64 type, u64 state, u64 cpuid) {};
  108. #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
  109. #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
  110. /*
  111. * The clock events are used for clock enable/disable and for
  112. * clock rate change
  113. */
  114. DECLARE_EVENT_CLASS(clock,
  115. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  116. TP_ARGS(name, state, cpu_id),
  117. TP_STRUCT__entry(
  118. __string( name, name )
  119. __field( u64, state )
  120. __field( u64, cpu_id )
  121. ),
  122. TP_fast_assign(
  123. __assign_str(name, name);
  124. __entry->state = state;
  125. __entry->cpu_id = cpu_id;
  126. ),
  127. TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
  128. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  129. );
  130. DEFINE_EVENT(clock, clock_enable,
  131. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  132. TP_ARGS(name, state, cpu_id)
  133. );
  134. DEFINE_EVENT(clock, clock_disable,
  135. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  136. TP_ARGS(name, state, cpu_id)
  137. );
  138. DEFINE_EVENT(clock, clock_set_rate,
  139. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  140. TP_ARGS(name, state, cpu_id)
  141. );
  142. /*
  143. * The power domain events are used for power domains transitions
  144. */
  145. DECLARE_EVENT_CLASS(power_domain,
  146. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  147. TP_ARGS(name, state, cpu_id),
  148. TP_STRUCT__entry(
  149. __string( name, name )
  150. __field( u64, state )
  151. __field( u64, cpu_id )
  152. ),
  153. TP_fast_assign(
  154. __assign_str(name, name);
  155. __entry->state = state;
  156. __entry->cpu_id = cpu_id;
  157. ),
  158. TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
  159. (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
  160. );
  161. DEFINE_EVENT(power_domain, power_domain_target,
  162. TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
  163. TP_ARGS(name, state, cpu_id)
  164. );
  165. #endif /* _TRACE_POWER_H */
  166. /* This part must be outside protection */
  167. #include <trace/define_trace.h>