thermal.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM thermal
  3. #if !defined(_TRACE_THERMAL_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_THERMAL_H
  5. #include <linux/devfreq.h>
  6. #include <linux/thermal.h>
  7. #include <linux/tracepoint.h>
  8. TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL);
  9. TRACE_DEFINE_ENUM(THERMAL_TRIP_HOT);
  10. TRACE_DEFINE_ENUM(THERMAL_TRIP_PASSIVE);
  11. TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
  12. #define show_tzt_type(type) \
  13. __print_symbolic(type, \
  14. { THERMAL_TRIP_CRITICAL, "CRITICAL"}, \
  15. { THERMAL_TRIP_HOT, "HOT"}, \
  16. { THERMAL_TRIP_PASSIVE, "PASSIVE"}, \
  17. { THERMAL_TRIP_ACTIVE, "ACTIVE"})
  18. TRACE_EVENT(thermal_query_temp,
  19. TP_PROTO(struct thermal_zone_device *tz, int temp),
  20. TP_ARGS(tz, temp),
  21. TP_STRUCT__entry(
  22. __string(thermal_zone, tz->type)
  23. __field(int, id)
  24. __field(int, temp)
  25. ),
  26. TP_fast_assign(
  27. __assign_str(thermal_zone, tz->type);
  28. __entry->id = tz->id;
  29. __entry->temp = temp;
  30. ),
  31. TP_printk("thermal_zone=%s id=%d temp=%d",
  32. __get_str(thermal_zone), __entry->id,
  33. __entry->temp)
  34. );
  35. TRACE_EVENT(thermal_temperature,
  36. TP_PROTO(struct thermal_zone_device *tz),
  37. TP_ARGS(tz),
  38. TP_STRUCT__entry(
  39. __string(thermal_zone, tz->type)
  40. __field(int, id)
  41. __field(int, temp_prev)
  42. __field(int, temp)
  43. ),
  44. TP_fast_assign(
  45. __assign_str(thermal_zone, tz->type);
  46. __entry->id = tz->id;
  47. __entry->temp_prev = tz->last_temperature;
  48. __entry->temp = tz->temperature;
  49. ),
  50. TP_printk("thermal_zone=%s id=%d temp_prev=%d temp=%d",
  51. __get_str(thermal_zone), __entry->id, __entry->temp_prev,
  52. __entry->temp)
  53. );
  54. TRACE_EVENT(cdev_update_start,
  55. TP_PROTO(struct thermal_cooling_device *cdev),
  56. TP_ARGS(cdev),
  57. TP_STRUCT__entry(
  58. __string(type, cdev->type)
  59. ),
  60. TP_fast_assign(
  61. __assign_str(type, cdev->type);
  62. ),
  63. TP_printk("type=%s update start", __get_str(type))
  64. );
  65. TRACE_EVENT(cdev_update,
  66. TP_PROTO(struct thermal_cooling_device *cdev, unsigned long target,
  67. unsigned long min_target),
  68. TP_ARGS(cdev, target, min_target),
  69. TP_STRUCT__entry(
  70. __string(type, cdev->type)
  71. __field(unsigned long, target)
  72. __field(unsigned long, min_target)
  73. ),
  74. TP_fast_assign(
  75. __assign_str(type, cdev->type);
  76. __entry->target = target;
  77. __entry->min_target = min_target;
  78. ),
  79. TP_printk("type=%s target=%lu min_target=%lu", __get_str(type),
  80. __entry->target, __entry->min_target)
  81. );
  82. TRACE_EVENT(thermal_zone_trip,
  83. TP_PROTO(struct thermal_zone_device *tz, int trip,
  84. enum thermal_trip_type trip_type, bool is_trip),
  85. TP_ARGS(tz, trip, trip_type, is_trip),
  86. TP_STRUCT__entry(
  87. __string(thermal_zone, tz->type)
  88. __field(int, id)
  89. __field(int, trip)
  90. __field(enum thermal_trip_type, trip_type)
  91. __field(bool, is_trip)
  92. ),
  93. TP_fast_assign(
  94. __assign_str(thermal_zone, tz->type);
  95. __entry->id = tz->id;
  96. __entry->trip = trip;
  97. __entry->trip_type = trip_type;
  98. __entry->is_trip = is_trip;
  99. ),
  100. TP_printk("thermal_zone=%s id=%d %s=%d trip_type=%s",
  101. __get_str(thermal_zone), __entry->id,
  102. (__entry->is_trip) ? "trip" : "hyst",
  103. __entry->trip,
  104. show_tzt_type(__entry->trip_type))
  105. );
  106. TRACE_EVENT(thermal_handle_trip,
  107. TP_PROTO(struct thermal_zone_device *tz, int trip),
  108. TP_ARGS(tz, trip),
  109. TP_STRUCT__entry(
  110. __string(thermal_zone, tz->type)
  111. __field(int, id)
  112. __field(int, trip)
  113. ),
  114. TP_fast_assign(
  115. __assign_str(thermal_zone, tz->type);
  116. __entry->id = tz->id;
  117. __entry->trip = trip;
  118. ),
  119. TP_printk("thermal_zone=%s id=%d handle trip=%d",
  120. __get_str(thermal_zone), __entry->id, __entry->trip)
  121. );
  122. TRACE_EVENT(thermal_device_update,
  123. TP_PROTO(struct thermal_zone_device *tz, int event),
  124. TP_ARGS(tz, event),
  125. TP_STRUCT__entry(
  126. __string(thermal_zone, tz->type)
  127. __field(int, id)
  128. __field(int, event)
  129. ),
  130. TP_fast_assign(
  131. __assign_str(thermal_zone, tz->type);
  132. __entry->id = tz->id;
  133. __entry->event = event;
  134. ),
  135. TP_printk("thermal_zone=%s id=%d received event:%d",
  136. __get_str(thermal_zone), __entry->id, __entry->event)
  137. );
  138. TRACE_EVENT(thermal_set_trip,
  139. TP_PROTO(struct thermal_zone_device *tz),
  140. TP_ARGS(tz),
  141. TP_STRUCT__entry(
  142. __string(thermal_zone, tz->type)
  143. __field(int, id)
  144. __field(int, low)
  145. __field(int, high)
  146. ),
  147. TP_fast_assign(
  148. __assign_str(thermal_zone, tz->type);
  149. __entry->id = tz->id;
  150. __entry->low = tz->prev_low_trip;
  151. __entry->high = tz->prev_high_trip;
  152. ),
  153. TP_printk("thermal_zone=%s id=%d low trip=%d high trip=%d",
  154. __get_str(thermal_zone), __entry->id, __entry->low,
  155. __entry->high)
  156. );
  157. TRACE_EVENT(thermal_power_cpu_get_power,
  158. TP_PROTO(const struct cpumask *cpus, unsigned long freq, u32 *load,
  159. size_t load_len, u32 dynamic_power, u32 static_power),
  160. TP_ARGS(cpus, freq, load, load_len, dynamic_power, static_power),
  161. TP_STRUCT__entry(
  162. __bitmask(cpumask, num_possible_cpus())
  163. __field(unsigned long, freq )
  164. __dynamic_array(u32, load, load_len)
  165. __field(size_t, load_len )
  166. __field(u32, dynamic_power )
  167. __field(u32, static_power )
  168. ),
  169. TP_fast_assign(
  170. __assign_bitmask(cpumask, cpumask_bits(cpus),
  171. num_possible_cpus());
  172. __entry->freq = freq;
  173. memcpy(__get_dynamic_array(load), load,
  174. load_len * sizeof(*load));
  175. __entry->load_len = load_len;
  176. __entry->dynamic_power = dynamic_power;
  177. __entry->static_power = static_power;
  178. ),
  179. TP_printk("cpus=%s freq=%lu load={%s} dynamic_power=%d static_power=%d",
  180. __get_bitmask(cpumask), __entry->freq,
  181. __print_array(__get_dynamic_array(load), __entry->load_len, 4),
  182. __entry->dynamic_power, __entry->static_power)
  183. );
  184. TRACE_EVENT(thermal_power_cpu_limit,
  185. TP_PROTO(const struct cpumask *cpus, unsigned int freq,
  186. unsigned long cdev_state, u32 power),
  187. TP_ARGS(cpus, freq, cdev_state, power),
  188. TP_STRUCT__entry(
  189. __bitmask(cpumask, num_possible_cpus())
  190. __field(unsigned int, freq )
  191. __field(unsigned long, cdev_state)
  192. __field(u32, power )
  193. ),
  194. TP_fast_assign(
  195. __assign_bitmask(cpumask, cpumask_bits(cpus),
  196. num_possible_cpus());
  197. __entry->freq = freq;
  198. __entry->cdev_state = cdev_state;
  199. __entry->power = power;
  200. ),
  201. TP_printk("cpus=%s freq=%u cdev_state=%lu power=%u",
  202. __get_bitmask(cpumask), __entry->freq, __entry->cdev_state,
  203. __entry->power)
  204. );
  205. TRACE_EVENT(thermal_power_devfreq_get_power,
  206. TP_PROTO(struct thermal_cooling_device *cdev,
  207. struct devfreq_dev_status *status, unsigned long freq,
  208. u32 dynamic_power, u32 static_power),
  209. TP_ARGS(cdev, status, freq, dynamic_power, static_power),
  210. TP_STRUCT__entry(
  211. __string(type, cdev->type )
  212. __field(unsigned long, freq )
  213. __field(u32, load )
  214. __field(u32, dynamic_power )
  215. __field(u32, static_power )
  216. ),
  217. TP_fast_assign(
  218. __assign_str(type, cdev->type);
  219. __entry->freq = freq;
  220. __entry->load = (100 * status->busy_time) / status->total_time;
  221. __entry->dynamic_power = dynamic_power;
  222. __entry->static_power = static_power;
  223. ),
  224. TP_printk("type=%s freq=%lu load=%u dynamic_power=%u static_power=%u",
  225. __get_str(type), __entry->freq,
  226. __entry->load, __entry->dynamic_power, __entry->static_power)
  227. );
  228. TRACE_EVENT(thermal_power_devfreq_limit,
  229. TP_PROTO(struct thermal_cooling_device *cdev, unsigned long freq,
  230. unsigned long cdev_state, u32 power),
  231. TP_ARGS(cdev, freq, cdev_state, power),
  232. TP_STRUCT__entry(
  233. __string(type, cdev->type)
  234. __field(unsigned int, freq )
  235. __field(unsigned long, cdev_state)
  236. __field(u32, power )
  237. ),
  238. TP_fast_assign(
  239. __assign_str(type, cdev->type);
  240. __entry->freq = freq;
  241. __entry->cdev_state = cdev_state;
  242. __entry->power = power;
  243. ),
  244. TP_printk("type=%s freq=%u cdev_state=%lu power=%u",
  245. __get_str(type), __entry->freq, __entry->cdev_state,
  246. __entry->power)
  247. );
  248. #endif /* _TRACE_THERMAL_H */
  249. /* This part must be outside protection */
  250. #include <trace/define_trace.h>