thermal.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM thermal
  4. #if !defined(_TRACE_THERMAL_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_THERMAL_H
  6. #include <linux/devfreq.h>
  7. #include <linux/thermal.h>
  8. #include <linux/tracepoint.h>
  9. TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL);
  10. TRACE_DEFINE_ENUM(THERMAL_TRIP_HOT);
  11. TRACE_DEFINE_ENUM(THERMAL_TRIP_PASSIVE);
  12. TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
  13. #define show_tzt_type(type) \
  14. __print_symbolic(type, \
  15. { THERMAL_TRIP_CRITICAL, "CRITICAL"}, \
  16. { THERMAL_TRIP_HOT, "HOT"}, \
  17. { THERMAL_TRIP_PASSIVE, "PASSIVE"}, \
  18. { THERMAL_TRIP_ACTIVE, "ACTIVE"})
  19. TRACE_EVENT(thermal_temperature,
  20. TP_PROTO(struct thermal_zone_device *tz),
  21. TP_ARGS(tz),
  22. TP_STRUCT__entry(
  23. __string(thermal_zone, tz->type)
  24. __field(int, id)
  25. __field(int, temp_prev)
  26. __field(int, temp)
  27. ),
  28. TP_fast_assign(
  29. __assign_str(thermal_zone, tz->type);
  30. __entry->id = tz->id;
  31. __entry->temp_prev = tz->last_temperature;
  32. __entry->temp = tz->temperature;
  33. ),
  34. TP_printk("thermal_zone=%s id=%d temp_prev=%d temp=%d",
  35. __get_str(thermal_zone), __entry->id, __entry->temp_prev,
  36. __entry->temp)
  37. );
  38. TRACE_EVENT(cdev_update,
  39. TP_PROTO(struct thermal_cooling_device *cdev, unsigned long target),
  40. TP_ARGS(cdev, target),
  41. TP_STRUCT__entry(
  42. __string(type, cdev->type)
  43. __field(unsigned long, target)
  44. ),
  45. TP_fast_assign(
  46. __assign_str(type, cdev->type);
  47. __entry->target = target;
  48. ),
  49. TP_printk("type=%s target=%lu", __get_str(type), __entry->target)
  50. );
  51. TRACE_EVENT(thermal_zone_trip,
  52. TP_PROTO(struct thermal_zone_device *tz, int trip,
  53. enum thermal_trip_type trip_type),
  54. TP_ARGS(tz, trip, trip_type),
  55. TP_STRUCT__entry(
  56. __string(thermal_zone, tz->type)
  57. __field(int, id)
  58. __field(int, trip)
  59. __field(enum thermal_trip_type, trip_type)
  60. ),
  61. TP_fast_assign(
  62. __assign_str(thermal_zone, tz->type);
  63. __entry->id = tz->id;
  64. __entry->trip = trip;
  65. __entry->trip_type = trip_type;
  66. ),
  67. TP_printk("thermal_zone=%s id=%d trip=%d trip_type=%s",
  68. __get_str(thermal_zone), __entry->id, __entry->trip,
  69. show_tzt_type(__entry->trip_type))
  70. );
  71. #ifdef CONFIG_CPU_THERMAL
  72. TRACE_EVENT(thermal_power_cpu_get_power,
  73. TP_PROTO(const struct cpumask *cpus, unsigned long freq, u32 *load,
  74. size_t load_len, u32 dynamic_power),
  75. TP_ARGS(cpus, freq, load, load_len, dynamic_power),
  76. TP_STRUCT__entry(
  77. __bitmask(cpumask, num_possible_cpus())
  78. __field(unsigned long, freq )
  79. __dynamic_array(u32, load, load_len)
  80. __field(size_t, load_len )
  81. __field(u32, dynamic_power )
  82. ),
  83. TP_fast_assign(
  84. __assign_bitmask(cpumask, cpumask_bits(cpus),
  85. num_possible_cpus());
  86. __entry->freq = freq;
  87. memcpy(__get_dynamic_array(load), load,
  88. load_len * sizeof(*load));
  89. __entry->load_len = load_len;
  90. __entry->dynamic_power = dynamic_power;
  91. ),
  92. TP_printk("cpus=%s freq=%lu load={%s} dynamic_power=%d",
  93. __get_bitmask(cpumask), __entry->freq,
  94. __print_array(__get_dynamic_array(load), __entry->load_len, 4),
  95. __entry->dynamic_power)
  96. );
  97. TRACE_EVENT(thermal_power_cpu_limit,
  98. TP_PROTO(const struct cpumask *cpus, unsigned int freq,
  99. unsigned long cdev_state, u32 power),
  100. TP_ARGS(cpus, freq, cdev_state, power),
  101. TP_STRUCT__entry(
  102. __bitmask(cpumask, num_possible_cpus())
  103. __field(unsigned int, freq )
  104. __field(unsigned long, cdev_state)
  105. __field(u32, power )
  106. ),
  107. TP_fast_assign(
  108. __assign_bitmask(cpumask, cpumask_bits(cpus),
  109. num_possible_cpus());
  110. __entry->freq = freq;
  111. __entry->cdev_state = cdev_state;
  112. __entry->power = power;
  113. ),
  114. TP_printk("cpus=%s freq=%u cdev_state=%lu power=%u",
  115. __get_bitmask(cpumask), __entry->freq, __entry->cdev_state,
  116. __entry->power)
  117. );
  118. #endif /* CONFIG_CPU_THERMAL */
  119. #ifdef CONFIG_DEVFREQ_THERMAL
  120. TRACE_EVENT(thermal_power_devfreq_get_power,
  121. TP_PROTO(struct thermal_cooling_device *cdev,
  122. struct devfreq_dev_status *status, unsigned long freq,
  123. u32 dynamic_power, u32 static_power, u32 power),
  124. TP_ARGS(cdev, status, freq, dynamic_power, static_power, power),
  125. TP_STRUCT__entry(
  126. __string(type, cdev->type )
  127. __field(unsigned long, freq )
  128. __field(u32, load )
  129. __field(u32, dynamic_power )
  130. __field(u32, static_power )
  131. __field(u32, power)
  132. ),
  133. TP_fast_assign(
  134. __assign_str(type, cdev->type);
  135. __entry->freq = freq;
  136. __entry->load = (100 * status->busy_time) / status->total_time;
  137. __entry->dynamic_power = dynamic_power;
  138. __entry->static_power = static_power;
  139. __entry->power = power;
  140. ),
  141. TP_printk("type=%s freq=%lu load=%u dynamic_power=%u static_power=%u power=%u",
  142. __get_str(type), __entry->freq,
  143. __entry->load, __entry->dynamic_power, __entry->static_power,
  144. __entry->power)
  145. );
  146. TRACE_EVENT(thermal_power_devfreq_limit,
  147. TP_PROTO(struct thermal_cooling_device *cdev, unsigned long freq,
  148. unsigned long cdev_state, u32 power),
  149. TP_ARGS(cdev, freq, cdev_state, power),
  150. TP_STRUCT__entry(
  151. __string(type, cdev->type)
  152. __field(unsigned int, freq )
  153. __field(unsigned long, cdev_state)
  154. __field(u32, power )
  155. ),
  156. TP_fast_assign(
  157. __assign_str(type, cdev->type);
  158. __entry->freq = freq;
  159. __entry->cdev_state = cdev_state;
  160. __entry->power = power;
  161. ),
  162. TP_printk("type=%s freq=%u cdev_state=%lu power=%u",
  163. __get_str(type), __entry->freq, __entry->cdev_state,
  164. __entry->power)
  165. );
  166. #endif /* CONFIG_DEVFREQ_THERMAL */
  167. #endif /* _TRACE_THERMAL_H */
  168. /* This part must be outside protection */
  169. #include <trace/define_trace.h>