summaryrefslogtreecommitdiffstats
path: root/drivers/bus/mhi/host/trace.h
blob: 368515dcb22d157db44c6458354390ad29ea1ffc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
 */

#undef TRACE_SYSTEM
#define TRACE_SYSTEM mhi_host

#if !defined(_TRACE_EVENT_MHI_HOST_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_EVENT_MHI_HOST_H

#include <linux/tracepoint.h>
#include <linux/trace_seq.h>
#include "../common.h"
#include "internal.h"

#undef mhi_state
#undef mhi_state_end

#define mhi_state(a, b)		TRACE_DEFINE_ENUM(MHI_STATE_##a);
#define mhi_state_end(a, b)	TRACE_DEFINE_ENUM(MHI_STATE_##a);

MHI_STATE_LIST

#undef mhi_state
#undef mhi_state_end

#define mhi_state(a, b)		{ MHI_STATE_##a, b },
#define mhi_state_end(a, b)	{ MHI_STATE_##a, b }

#undef mhi_pm_state
#undef mhi_pm_state_end

#define mhi_pm_state(a, b)		TRACE_DEFINE_ENUM(MHI_PM_STATE_##a);
#define mhi_pm_state_end(a, b)		TRACE_DEFINE_ENUM(MHI_PM_STATE_##a);

MHI_PM_STATE_LIST

#undef mhi_pm_state
#undef mhi_pm_state_end

#define mhi_pm_state(a, b)		{ MHI_PM_STATE_##a, b },
#define mhi_pm_state_end(a, b)		{ MHI_PM_STATE_##a, b }

#undef mhi_ee
#undef mhi_ee_end

#define mhi_ee(a, b)			TRACE_DEFINE_ENUM(MHI_EE_##a);
#define mhi_ee_end(a, b)		TRACE_DEFINE_ENUM(MHI_EE_##a);

MHI_EE_LIST

#undef mhi_ee
#undef mhi_ee_end

#define mhi_ee(a, b)			{ MHI_EE_##a, b },
#define mhi_ee_end(a, b)		{ MHI_EE_##a, b }

#undef ch_state_type
#undef ch_state_type_end

#define ch_state_type(a, b)		TRACE_DEFINE_ENUM(MHI_CH_STATE_TYPE_##a);
#define ch_state_type_end(a, b)		TRACE_DEFINE_ENUM(MHI_CH_STATE_TYPE_##a);

MHI_CH_STATE_TYPE_LIST

#undef ch_state_type
#undef ch_state_type_end

#define ch_state_type(a, b)		{ MHI_CH_STATE_TYPE_##a, b },
#define ch_state_type_end(a, b)		{ MHI_CH_STATE_TYPE_##a, b }

#undef dev_st_trans
#undef dev_st_trans_end

#define dev_st_trans(a, b)		TRACE_DEFINE_ENUM(DEV_ST_TRANSITION_##a);
#define dev_st_trans_end(a, b)		TRACE_DEFINE_ENUM(DEV_ST_TRANSITION_##a);

DEV_ST_TRANSITION_LIST

#undef dev_st_trans
#undef dev_st_trans_end

#define dev_st_trans(a, b)		{ DEV_ST_TRANSITION_##a, b },
#define dev_st_trans_end(a, b)		{ DEV_ST_TRANSITION_##a, b }

#define TPS(x)	tracepoint_string(x)

TRACE_EVENT(mhi_gen_tre,

	TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
		 struct mhi_ring_element *mhi_tre),

	TP_ARGS(mhi_cntrl, mhi_chan, mhi_tre),

	TP_STRUCT__entry(
		__string(name, mhi_cntrl->mhi_dev->name)
		__field(int, ch_num)
		__field(void *, wp)
		__field(__le64, tre_ptr)
		__field(__le32, dword0)
		__field(__le32, dword1)
	),

	TP_fast_assign(
		__assign_str(name, mhi_cntrl->mhi_dev->name);
		__entry->ch_num = mhi_chan->chan;
		__entry->wp = mhi_tre;
		__entry->tre_ptr = mhi_tre->ptr;
		__entry->dword0 = mhi_tre->dword[0];
		__entry->dword1 = mhi_tre->dword[1];
	),

	TP_printk("%s: Chan: %d TRE: 0x%p TRE buf: 0x%llx DWORD0: 0x%08x DWORD1: 0x%08x\n",
		  __get_str(name), __entry->ch_num, __entry->wp, __entry->tre_ptr,
		  __entry->dword0, __entry->dword1)
);

TRACE_EVENT(mhi_intvec_states,

	TP_PROTO(struct mhi_controller *mhi_cntrl, int dev_ee, int dev_state),

	TP_ARGS(mhi_cntrl, dev_ee, dev_state),

	TP_STRUCT__entry(
		__string(name, mhi_cntrl->mhi_dev->name)
		__field(int, local_ee)
		__field(int, state)
		__field(int, dev_ee)
		__field(int, dev_state)
	),

	TP_fast_assign(
		__assign_str(name, mhi_cntrl->mhi_dev->name);
		__entry->local_ee = mhi_cntrl->ee;
		__entry->state = mhi_cntrl->dev_state;
		__entry->dev_ee = dev_ee;
		__entry->dev_state = dev_state;
	),

	TP_printk("%s: Local EE: %s State: %s Device EE: %s Dev State: %s\n",
		  __get_str(name),
		  __print_symbolic(__entry->local_ee, MHI_EE_LIST),
		  __print_symbolic(__entry->state, MHI_STATE_LIST),
		  __print_symbolic(__entry->dev_ee, MHI_EE_LIST),
		  __print_symbolic(__entry->dev_state, MHI_STATE_LIST))
);

TRACE_EVENT(mhi_tryset_pm_state,

	TP_PROTO(struct mhi_controller *mhi_cntrl, int pm_state),

	TP_ARGS(mhi_cntrl, pm_state),

	TP_STRUCT__entry(
		__string(name, mhi_cntrl->mhi_dev->name)
		__field(int, pm_state)
	),

	TP_fast_assign(
		__assign_str(name, mhi_cntrl->mhi_dev->name);
		if (pm_state)
			pm_state = __fls(pm_state);
		__entry->pm_state = pm_state;
	),

	TP_printk("%s: PM state: %s\n", __get_str(name),
		  __print_symbolic(__entry->pm_state, MHI_PM_STATE_LIST))
);

DECLARE_EVENT_CLASS(mhi_process_event_ring,

	TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_ring_element *rp),

	TP_ARGS(mhi_cntrl, rp),

	TP_STRUCT__entry(
		__string(name, mhi_cntrl->mhi_dev->name)
		__field(__le32, dword0)
		__field(__le32, dword1)
		__field(int, state)
		__field(__le64, ptr)
		__field(void *, rp)
	),

	TP_fast_assign(
		__assign_str(name, mhi_cntrl->mhi_dev->name);
		__entry->rp = rp;
		__entry->ptr = rp->ptr;
		__entry->dword0 = rp->dword[0];
		__entry->dword1 = rp->dword[1];
		__entry->state = MHI_TRE_GET_EV_STATE(rp);
	),

	TP_printk("%s: TRE: 0x%p TRE buf: 0x%llx DWORD0: 0x%08x DWORD1: 0x%08x State: %s\n",
		  __get_str(name), __entry->rp, __entry->ptr, __entry->dword0,
		  __entry->dword1, __print_symbolic(__entry->state, MHI_STATE_LIST))
);

DEFINE_EVENT(mhi_process_event_ring, mhi_data_event,

	TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_ring_element *rp),

	TP_ARGS(mhi_cntrl, rp)
);

DEFINE_EVENT(mhi_process_event_ring, mhi_ctrl_event,

	TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_ring_element *rp),

	TP_ARGS(mhi_cntrl, rp)
);

DECLARE_EVENT_CLASS(mhi_update_channel_state,

	TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, int state,
		 const char *reason),

	TP_ARGS(mhi_cntrl, mhi_chan, state, reason),

	TP_STRUCT__entry(
		__string(name, mhi_cntrl->mhi_dev->name)
		__field(int, ch_num)
		__field(int, state)
		__field(const char *, reason)
	),

	TP_fast_assign(
		__assign_str(name, mhi_cntrl->mhi_dev->name);
		__entry->ch_num = mhi_chan->chan;
		__entry->state = state;
		__entry->reason = reason;
	),

	TP_printk("%s: chan%d: %s state to: %s\n",
		  __get_str(name),  __entry->ch_num, __entry->reason,
		  __print_symbolic(__entry->state, MHI_CH_STATE_TYPE_LIST))
);

DEFINE_EVENT(mhi_update_channel_state, mhi_channel_command_start,

	TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, int state,
		 const char *reason),

	TP_ARGS(mhi_cntrl, mhi_chan, state, reason)
);

DEFINE_EVENT(mhi_update_channel_state, mhi_channel_command_end,

	TP_PROTO(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, int state,
		 const char *reason),

	TP_ARGS(mhi_cntrl, mhi_chan, state, reason)
);

TRACE_EVENT(mhi_pm_st_transition,

	TP_PROTO(struct mhi_controller *mhi_cntrl, int state),

	TP_ARGS(mhi_cntrl, state),

	TP_STRUCT__entry(
		__string(name, mhi_cntrl->mhi_dev->name)
		__field(int, state)
	),

	TP_fast_assign(
		__assign_str(name, mhi_cntrl->mhi_dev->name);
		__entry->state = state;
	),

	TP_printk("%s: Handling state transition: %s\n", __get_str(name),
		  __print_symbolic(__entry->state, DEV_ST_TRANSITION_LIST))
);

#endif
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH ../../drivers/bus/mhi/host
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE trace

#include <trace/define_trace.h>