1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 */ 5 6 #undef TRACE_SYSTEM 7 #define TRACE_SYSTEM mhi_host 8 9 #if !defined(_TRACE_EVENT_MHI_HOST_H) || defined(TRACE_HEADER_MULTI_READ) 10 #define _TRACE_EVENT_MHI_HOST_H 11 12 #include <linux/byteorder/generic.h> 13 #include <linux/tracepoint.h> 14 #include <linux/trace_seq.h> 15 #include "../common.h" 16 #include "internal.h" 17 18 #undef mhi_state 19 #undef mhi_state_end 20 21 #define mhi_state(a, b) TRACE_DEFINE_ENUM(MHI_STATE_##a); 22 #define mhi_state_end(a, b) TRACE_DEFINE_ENUM(MHI_STATE_##a); 23 24 MHI_STATE_LIST 25 26 #undef mhi_state 27 #undef mhi_state_end 28 29 #define mhi_state(a, b) { MHI_STATE_##a, b }, 30 #define mhi_state_end(a, b) { MHI_STATE_##a, b } 31 32 #undef mhi_pm_state 33 #undef mhi_pm_state_end 34 35 #define mhi_pm_state(a, b) TRACE_DEFINE_ENUM(MHI_PM_STATE_##a); 36 #define mhi_pm_state_end(a, b) TRACE_DEFINE_ENUM(MHI_PM_STATE_##a); 37 38 MHI_PM_STATE_LIST 39 40 #undef mhi_pm_state 41 #undef mhi_pm_state_end 42 43 #define mhi_pm_state(a, b) { MHI_PM_STATE_##a, b }, 44 #define mhi_pm_state_end(a, b) { MHI_PM_STATE_##a, b } 45 46 #undef mhi_ee 47 #undef mhi_ee_end 48 49 #define mhi_ee(a, b) TRACE_DEFINE_ENUM(MHI_EE_##a); 50 #define mhi_ee_end(a, b) TRACE_DEFINE_ENUM(MHI_EE_##a); 51 52 MHI_EE_LIST 53 54 #undef mhi_ee 55 #undef mhi_ee_end 56 57 #define mhi_ee(a, b) { MHI_EE_##a, b }, 58 #define mhi_ee_end(a, b) { MHI_EE_##a, b } 59 60 #undef ch_state_type 61 #undef ch_state_type_end 62 63 #define ch_state_type(a, b) TRACE_DEFINE_ENUM(MHI_CH_STATE_TYPE_##a); 64 #define ch_state_type_end(a, b) TRACE_DEFINE_ENUM(MHI_CH_STATE_TYPE_##a); 65 66 MHI_CH_STATE_TYPE_LIST 67 68 #undef ch_state_type 69 #undef ch_state_type_end 70 71 #define ch_state_type(a, b) { MHI_CH_STATE_TYPE_##a, b }, 72 #define ch_state_type_end(a, b) { MHI_CH_STATE_TYPE_##a, b } 73 74 #undef dev_st_trans 75 #undef dev_st_trans_end 76 77 #define dev_st_trans(a, b) TRACE_DEFINE_ENUM(DEV_ST_TRANSITION_##a); 78 #define dev_st_trans_end(a, b) TRACE_DEFINE_ENUM(DEV_ST_TRANSITION_##a); 79 80 DEV_ST_TRANSITION_LIST 81 82 #undef dev_st_trans 83 #undef dev_st_trans_end 84 85 #define dev_st_trans(a, b) { DEV_ST_TRANSITION_##a, b }, 86 #define dev_st_trans_end(a, b) { DEV_ST_TRANSITION_##a, b } 87 88 #define TPS(x) tracepoint_string(x) 89 90 TRACE_EVENT(mhi_gen_tre, 91 92 TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, 93 struct mhi_ring_element *mhi_tre), 94 95 TP_ARGS(mhi_cntrl, mhi_chan, mhi_tre), 96 97 TP_STRUCT__entry( 98 __string(name, mhi_cntrl->mhi_dev->name) 99 __field(int, ch_num) 100 __field(void *, wp) 101 __field(uint64_t, tre_ptr) 102 __field(uint32_t, dword0) 103 __field(uint32_t, dword1) 104 ), 105 106 TP_fast_assign( 107 __assign_str(name); 108 __entry->ch_num = mhi_chan->chan; 109 __entry->wp = mhi_tre; 110 __entry->tre_ptr = le64_to_cpu(mhi_tre->ptr); 111 __entry->dword0 = le32_to_cpu(mhi_tre->dword[0]); 112 __entry->dword1 = le32_to_cpu(mhi_tre->dword[1]); 113 ), 114 115 TP_printk("%s: Chan: %d TRE: 0x%p TRE buf: 0x%llx DWORD0: 0x%08x DWORD1: 0x%08x\n", 116 __get_str(name), __entry->ch_num, __entry->wp, __entry->tre_ptr, 117 __entry->dword0, __entry->dword1) 118 ); 119 120 TRACE_EVENT(mhi_intvec_states, 121 122 TP_PROTO(struct mhi_controller *mhi_cntrl, int dev_ee, int dev_state), 123 124 TP_ARGS(mhi_cntrl, dev_ee, dev_state), 125 126 TP_STRUCT__entry( 127 __string(name, mhi_cntrl->mhi_dev->name) 128 __field(int, local_ee) 129 __field(int, state) 130 __field(int, dev_ee) 131 __field(int, dev_state) 132 ), 133 134 TP_fast_assign( 135 __assign_str(name); 136 __entry->local_ee = mhi_cntrl->ee; 137 __entry->state = mhi_cntrl->dev_state; 138 __entry->dev_ee = dev_ee; 139 __entry->dev_state = dev_state; 140 ), 141 142 TP_printk("%s: Local EE: %s State: %s Device EE: %s Dev State: %s\n", 143 __get_str(name), 144 __print_symbolic(__entry->local_ee, MHI_EE_LIST), 145 __print_symbolic(__entry->state, MHI_STATE_LIST), 146 __print_symbolic(__entry->dev_ee, MHI_EE_LIST), 147 __print_symbolic(__entry->dev_state, MHI_STATE_LIST)) 148 ); 149 150 TRACE_EVENT(mhi_tryset_pm_state, 151 152 TP_PROTO(struct mhi_controller *mhi_cntrl, int pm_state), 153 154 TP_ARGS(mhi_cntrl, pm_state), 155 156 TP_STRUCT__entry( 157 __string(name, mhi_cntrl->mhi_dev->name) 158 __field(int, pm_state) 159 ), 160 161 TP_fast_assign( 162 __assign_str(name); 163 if (pm_state) 164 pm_state = __fls(pm_state); 165 __entry->pm_state = pm_state; 166 ), 167 168 TP_printk("%s: PM state: %s\n", __get_str(name), 169 __print_symbolic(__entry->pm_state, MHI_PM_STATE_LIST)) 170 ); 171 172 DECLARE_EVENT_CLASS(mhi_process_event_ring, 173 174 TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_ring_element *rp), 175 176 TP_ARGS(mhi_cntrl, rp), 177 178 TP_STRUCT__entry( 179 __string(name, mhi_cntrl->mhi_dev->name) 180 __field(uint32_t, dword0) 181 __field(uint32_t, dword1) 182 __field(int, state) 183 __field(uint64_t, ptr) 184 __field(void *, rp) 185 ), 186 187 TP_fast_assign( 188 __assign_str(name); 189 __entry->rp = rp; 190 __entry->ptr = le64_to_cpu(rp->ptr); 191 __entry->dword0 = le32_to_cpu(rp->dword[0]); 192 __entry->dword1 = le32_to_cpu(rp->dword[1]); 193 __entry->state = MHI_TRE_GET_EV_STATE(rp); 194 ), 195 196 TP_printk("%s: TRE: 0x%p TRE buf: 0x%llx DWORD0: 0x%08x DWORD1: 0x%08x State: %s\n", 197 __get_str(name), __entry->rp, __entry->ptr, __entry->dword0, 198 __entry->dword1, __print_symbolic(__entry->state, MHI_STATE_LIST)) 199 ); 200 201 DEFINE_EVENT(mhi_process_event_ring, mhi_data_event, 202 203 TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_ring_element *rp), 204 205 TP_ARGS(mhi_cntrl, rp) 206 ); 207 208 DEFINE_EVENT(mhi_process_event_ring, mhi_ctrl_event, 209 210 TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_ring_element *rp), 211 212 TP_ARGS(mhi_cntrl, rp) 213 ); 214 215 DECLARE_EVENT_CLASS(mhi_update_channel_state, 216 217 TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, int state, 218 const char *reason), 219 220 TP_ARGS(mhi_cntrl, mhi_chan, state, reason), 221 222 TP_STRUCT__entry( 223 __string(name, mhi_cntrl->mhi_dev->name) 224 __field(int, ch_num) 225 __field(int, state) 226 __field(const char *, reason) 227 ), 228 229 TP_fast_assign( 230 __assign_str(name); 231 __entry->ch_num = mhi_chan->chan; 232 __entry->state = state; 233 __entry->reason = reason; 234 ), 235 236 TP_printk("%s: chan%d: %s state to: %s\n", 237 __get_str(name), __entry->ch_num, __entry->reason, 238 __print_symbolic(__entry->state, MHI_CH_STATE_TYPE_LIST)) 239 ); 240 241 DEFINE_EVENT(mhi_update_channel_state, mhi_channel_command_start, 242 243 TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, int state, 244 const char *reason), 245 246 TP_ARGS(mhi_cntrl, mhi_chan, state, reason) 247 ); 248 249 DEFINE_EVENT(mhi_update_channel_state, mhi_channel_command_end, 250 251 TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, int state, 252 const char *reason), 253 254 TP_ARGS(mhi_cntrl, mhi_chan, state, reason) 255 ); 256 257 TRACE_EVENT(mhi_pm_st_transition, 258 259 TP_PROTO(struct mhi_controller *mhi_cntrl, int state), 260 261 TP_ARGS(mhi_cntrl, state), 262 263 TP_STRUCT__entry( 264 __string(name, mhi_cntrl->mhi_dev->name) 265 __field(int, state) 266 ), 267 268 TP_fast_assign( 269 __assign_str(name); 270 __entry->state = state; 271 ), 272 273 TP_printk("%s: Handling state transition: %s\n", __get_str(name), 274 __print_symbolic(__entry->state, DEV_ST_TRANSITION_LIST)) 275 ); 276 277 #endif 278 #undef TRACE_INCLUDE_PATH 279 #define TRACE_INCLUDE_PATH ../../drivers/bus/mhi/host 280 #undef TRACE_INCLUDE_FILE 281 #define TRACE_INCLUDE_FILE trace 282 283 #include <trace/define_trace.h> 284