1 #undef TRACE_SYSTEM 2 #define TRACE_SYSTEM power 3 4 #if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ) 5 #define _TRACE_POWER_H 6 7 #include <linux/ktime.h> 8 #include <linux/tracepoint.h> 9 10 DECLARE_EVENT_CLASS(cpu, 11 12 TP_PROTO(unsigned int state, unsigned int cpu_id), 13 14 TP_ARGS(state, cpu_id), 15 16 TP_STRUCT__entry( 17 __field( u32, state ) 18 __field( u32, cpu_id ) 19 ), 20 21 TP_fast_assign( 22 __entry->state = state; 23 __entry->cpu_id = cpu_id; 24 ), 25 26 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state, 27 (unsigned long)__entry->cpu_id) 28 ); 29 30 DEFINE_EVENT(cpu, cpu_idle, 31 32 TP_PROTO(unsigned int state, unsigned int cpu_id), 33 34 TP_ARGS(state, cpu_id) 35 ); 36 37 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */ 38 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING 39 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING 40 41 #define PWR_EVENT_EXIT -1 42 #endif 43 44 DEFINE_EVENT(cpu, cpu_frequency, 45 46 TP_PROTO(unsigned int frequency, unsigned int cpu_id), 47 48 TP_ARGS(frequency, cpu_id) 49 ); 50 51 TRACE_EVENT(machine_suspend, 52 53 TP_PROTO(unsigned int state), 54 55 TP_ARGS(state), 56 57 TP_STRUCT__entry( 58 __field( u32, state ) 59 ), 60 61 TP_fast_assign( 62 __entry->state = state; 63 ), 64 65 TP_printk("state=%lu", (unsigned long)__entry->state) 66 ); 67 68 #ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED 69 70 /* 71 * The power events are used for cpuidle & suspend (power_start, power_end) 72 * and for cpufreq (power_frequency) 73 */ 74 DECLARE_EVENT_CLASS(power, 75 76 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id), 77 78 TP_ARGS(type, state, cpu_id), 79 80 TP_STRUCT__entry( 81 __field( u64, type ) 82 __field( u64, state ) 83 __field( u64, cpu_id ) 84 ), 85 86 TP_fast_assign( 87 __entry->type = type; 88 __entry->state = state; 89 __entry->cpu_id = cpu_id; 90 ), 91 92 TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type, 93 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id) 94 ); 95 96 DEFINE_EVENT(power, power_start, 97 98 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id), 99 100 TP_ARGS(type, state, cpu_id) 101 ); 102 103 DEFINE_EVENT(power, power_frequency, 104 105 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id), 106 107 TP_ARGS(type, state, cpu_id) 108 ); 109 110 TRACE_EVENT(power_end, 111 112 TP_PROTO(unsigned int cpu_id), 113 114 TP_ARGS(cpu_id), 115 116 TP_STRUCT__entry( 117 __field( u64, cpu_id ) 118 ), 119 120 TP_fast_assign( 121 __entry->cpu_id = cpu_id; 122 ), 123 124 TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id) 125 126 ); 127 128 /* Deprecated dummy functions must be protected against multi-declartion */ 129 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED 130 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED 131 132 enum { 133 POWER_NONE = 0, 134 POWER_CSTATE = 1, 135 POWER_PSTATE = 2, 136 }; 137 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */ 138 139 #else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */ 140 141 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED 142 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED 143 enum { 144 POWER_NONE = 0, 145 POWER_CSTATE = 1, 146 POWER_PSTATE = 2, 147 }; 148 149 /* These dummy declaration have to be ripped out when the deprecated 150 events get removed */ 151 static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {}; 152 static inline void trace_power_end(u64 cpuid) {}; 153 static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {}; 154 static inline void trace_power_end_rcuidle(u64 cpuid) {}; 155 static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {}; 156 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */ 157 158 #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */ 159 160 /* 161 * The clock events are used for clock enable/disable and for 162 * clock rate change 163 */ 164 DECLARE_EVENT_CLASS(clock, 165 166 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), 167 168 TP_ARGS(name, state, cpu_id), 169 170 TP_STRUCT__entry( 171 __string( name, name ) 172 __field( u64, state ) 173 __field( u64, cpu_id ) 174 ), 175 176 TP_fast_assign( 177 __assign_str(name, name); 178 __entry->state = state; 179 __entry->cpu_id = cpu_id; 180 ), 181 182 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name), 183 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id) 184 ); 185 186 DEFINE_EVENT(clock, clock_enable, 187 188 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), 189 190 TP_ARGS(name, state, cpu_id) 191 ); 192 193 DEFINE_EVENT(clock, clock_disable, 194 195 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), 196 197 TP_ARGS(name, state, cpu_id) 198 ); 199 200 DEFINE_EVENT(clock, clock_set_rate, 201 202 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), 203 204 TP_ARGS(name, state, cpu_id) 205 ); 206 207 /* 208 * The power domain events are used for power domains transitions 209 */ 210 DECLARE_EVENT_CLASS(power_domain, 211 212 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), 213 214 TP_ARGS(name, state, cpu_id), 215 216 TP_STRUCT__entry( 217 __string( name, name ) 218 __field( u64, state ) 219 __field( u64, cpu_id ) 220 ), 221 222 TP_fast_assign( 223 __assign_str(name, name); 224 __entry->state = state; 225 __entry->cpu_id = cpu_id; 226 ), 227 228 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name), 229 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id) 230 ); 231 232 DEFINE_EVENT(power_domain, power_domain_target, 233 234 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id), 235 236 TP_ARGS(name, state, cpu_id) 237 ); 238 #endif /* _TRACE_POWER_H */ 239 240 /* This part must be outside protection */ 241 #include <trace/define_trace.h> 242