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