power.h 5.1 KB

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