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