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