xref: /openbmc/linux/include/trace/events/ufs.h (revision fbb6b31a)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
4  */
5 
6 #undef TRACE_SYSTEM
7 #define TRACE_SYSTEM ufs
8 
9 #if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ)
10 #define _TRACE_UFS_H
11 
12 #include <linux/tracepoint.h>
13 
14 #define str_opcode(opcode)						\
15 	__print_symbolic(opcode,					\
16 		{ WRITE_16,		"WRITE_16" },			\
17 		{ WRITE_10,		"WRITE_10" },			\
18 		{ READ_16,		"READ_16" },			\
19 		{ READ_10,		"READ_10" },			\
20 		{ SYNCHRONIZE_CACHE,	"SYNC" },			\
21 		{ UNMAP,		"UNMAP" })
22 
23 #define UFS_LINK_STATES						\
24 	EM(UIC_LINK_OFF_STATE,		"UIC_LINK_OFF_STATE")		\
25 	EM(UIC_LINK_ACTIVE_STATE,	"UIC_LINK_ACTIVE_STATE")	\
26 	EMe(UIC_LINK_HIBERN8_STATE,	"UIC_LINK_HIBERN8_STATE")
27 
28 #define UFS_PWR_MODES							\
29 	EM(UFS_ACTIVE_PWR_MODE,		"UFS_ACTIVE_PWR_MODE")		\
30 	EM(UFS_SLEEP_PWR_MODE,		"UFS_SLEEP_PWR_MODE")		\
31 	EM(UFS_POWERDOWN_PWR_MODE,	"UFS_POWERDOWN_PWR_MODE")	\
32 	EMe(UFS_DEEPSLEEP_PWR_MODE,	"UFS_DEEPSLEEP_PWR_MODE")
33 
34 #define UFSCHD_CLK_GATING_STATES				\
35 	EM(CLKS_OFF,			"CLKS_OFF")		\
36 	EM(CLKS_ON,			"CLKS_ON")		\
37 	EM(REQ_CLKS_OFF,		"REQ_CLKS_OFF")		\
38 	EMe(REQ_CLKS_ON,		"REQ_CLKS_ON")
39 
40 #define UFS_CMD_TRACE_STRINGS					\
41 	EM(UFS_CMD_SEND,	"send_req")			\
42 	EM(UFS_CMD_COMP,	"complete_rsp")			\
43 	EM(UFS_DEV_COMP,	"dev_complete")			\
44 	EM(UFS_QUERY_SEND,	"query_send")			\
45 	EM(UFS_QUERY_COMP,	"query_complete")		\
46 	EM(UFS_QUERY_ERR,	"query_complete_err")		\
47 	EM(UFS_TM_SEND,		"tm_send")			\
48 	EM(UFS_TM_COMP,		"tm_complete")			\
49 	EMe(UFS_TM_ERR,		"tm_complete_err")
50 
51 #define UFS_CMD_TRACE_TSF_TYPES					\
52 	EM(UFS_TSF_CDB,		"CDB")		                \
53 	EM(UFS_TSF_OSF,		"OSF")		                \
54 	EM(UFS_TSF_TM_INPUT,	"TM_INPUT")                     \
55 	EMe(UFS_TSF_TM_OUTPUT,	"TM_OUTPUT")
56 
57 /* Enums require being exported to userspace, for user tool parsing */
58 #undef EM
59 #undef EMe
60 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
61 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
62 
63 UFS_LINK_STATES;
64 UFS_PWR_MODES;
65 UFSCHD_CLK_GATING_STATES;
66 UFS_CMD_TRACE_STRINGS
67 UFS_CMD_TRACE_TSF_TYPES
68 
69 /*
70  * Now redefine the EM() and EMe() macros to map the enums to the strings
71  * that will be printed in the output.
72  */
73 #undef EM
74 #undef EMe
75 #define EM(a, b)	{a, b},
76 #define EMe(a, b)	{a, b}
77 
78 #define show_ufs_cmd_trace_str(str_t)	\
79 				__print_symbolic(str_t, UFS_CMD_TRACE_STRINGS)
80 #define show_ufs_cmd_trace_tsf(tsf)	\
81 				__print_symbolic(tsf, UFS_CMD_TRACE_TSF_TYPES)
82 
83 TRACE_EVENT(ufshcd_clk_gating,
84 
85 	TP_PROTO(const char *dev_name, int state),
86 
87 	TP_ARGS(dev_name, state),
88 
89 	TP_STRUCT__entry(
90 		__string(dev_name, dev_name)
91 		__field(int, state)
92 	),
93 
94 	TP_fast_assign(
95 		__assign_str(dev_name, dev_name);
96 		__entry->state = state;
97 	),
98 
99 	TP_printk("%s: gating state changed to %s",
100 		__get_str(dev_name),
101 		__print_symbolic(__entry->state, UFSCHD_CLK_GATING_STATES))
102 );
103 
104 TRACE_EVENT(ufshcd_clk_scaling,
105 
106 	TP_PROTO(const char *dev_name, const char *state, const char *clk,
107 		u32 prev_state, u32 curr_state),
108 
109 	TP_ARGS(dev_name, state, clk, prev_state, curr_state),
110 
111 	TP_STRUCT__entry(
112 		__string(dev_name, dev_name)
113 		__string(state, state)
114 		__string(clk, clk)
115 		__field(u32, prev_state)
116 		__field(u32, curr_state)
117 	),
118 
119 	TP_fast_assign(
120 		__assign_str(dev_name, dev_name);
121 		__assign_str(state, state);
122 		__assign_str(clk, clk);
123 		__entry->prev_state = prev_state;
124 		__entry->curr_state = curr_state;
125 	),
126 
127 	TP_printk("%s: %s %s from %u to %u Hz",
128 		__get_str(dev_name), __get_str(state), __get_str(clk),
129 		__entry->prev_state, __entry->curr_state)
130 );
131 
132 TRACE_EVENT(ufshcd_auto_bkops_state,
133 
134 	TP_PROTO(const char *dev_name, const char *state),
135 
136 	TP_ARGS(dev_name, state),
137 
138 	TP_STRUCT__entry(
139 		__string(dev_name, dev_name)
140 		__string(state, state)
141 	),
142 
143 	TP_fast_assign(
144 		__assign_str(dev_name, dev_name);
145 		__assign_str(state, state);
146 	),
147 
148 	TP_printk("%s: auto bkops - %s",
149 		__get_str(dev_name), __get_str(state))
150 );
151 
152 DECLARE_EVENT_CLASS(ufshcd_profiling_template,
153 	TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
154 		 int err),
155 
156 	TP_ARGS(dev_name, profile_info, time_us, err),
157 
158 	TP_STRUCT__entry(
159 		__string(dev_name, dev_name)
160 		__string(profile_info, profile_info)
161 		__field(s64, time_us)
162 		__field(int, err)
163 	),
164 
165 	TP_fast_assign(
166 		__assign_str(dev_name, dev_name);
167 		__assign_str(profile_info, profile_info);
168 		__entry->time_us = time_us;
169 		__entry->err = err;
170 	),
171 
172 	TP_printk("%s: %s: took %lld usecs, err %d",
173 		__get_str(dev_name), __get_str(profile_info),
174 		__entry->time_us, __entry->err)
175 );
176 
177 DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_hibern8,
178 	TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
179 		 int err),
180 	TP_ARGS(dev_name, profile_info, time_us, err));
181 
182 DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_gating,
183 	TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
184 		 int err),
185 	TP_ARGS(dev_name, profile_info, time_us, err));
186 
187 DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_scaling,
188 	TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
189 		 int err),
190 	TP_ARGS(dev_name, profile_info, time_us, err));
191 
192 DECLARE_EVENT_CLASS(ufshcd_template,
193 	TP_PROTO(const char *dev_name, int err, s64 usecs,
194 		 int dev_state, int link_state),
195 
196 	TP_ARGS(dev_name, err, usecs, dev_state, link_state),
197 
198 	TP_STRUCT__entry(
199 		__field(s64, usecs)
200 		__field(int, err)
201 		__string(dev_name, dev_name)
202 		__field(int, dev_state)
203 		__field(int, link_state)
204 	),
205 
206 	TP_fast_assign(
207 		__entry->usecs = usecs;
208 		__entry->err = err;
209 		__assign_str(dev_name, dev_name);
210 		__entry->dev_state = dev_state;
211 		__entry->link_state = link_state;
212 	),
213 
214 	TP_printk(
215 		"%s: took %lld usecs, dev_state: %s, link_state: %s, err %d",
216 		__get_str(dev_name),
217 		__entry->usecs,
218 		__print_symbolic(__entry->dev_state, UFS_PWR_MODES),
219 		__print_symbolic(__entry->link_state, UFS_LINK_STATES),
220 		__entry->err
221 	)
222 );
223 
224 DEFINE_EVENT(ufshcd_template, ufshcd_system_suspend,
225 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
226 		      int dev_state, int link_state),
227 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
228 
229 DEFINE_EVENT(ufshcd_template, ufshcd_system_resume,
230 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
231 		      int dev_state, int link_state),
232 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
233 
234 DEFINE_EVENT(ufshcd_template, ufshcd_runtime_suspend,
235 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
236 		      int dev_state, int link_state),
237 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
238 
239 DEFINE_EVENT(ufshcd_template, ufshcd_runtime_resume,
240 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
241 		      int dev_state, int link_state),
242 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
243 
244 DEFINE_EVENT(ufshcd_template, ufshcd_init,
245 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
246 		      int dev_state, int link_state),
247 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
248 
249 DEFINE_EVENT(ufshcd_template, ufshcd_wl_suspend,
250 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
251 		      int dev_state, int link_state),
252 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
253 
254 DEFINE_EVENT(ufshcd_template, ufshcd_wl_resume,
255 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
256 		      int dev_state, int link_state),
257 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
258 
259 DEFINE_EVENT(ufshcd_template, ufshcd_wl_runtime_suspend,
260 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
261 		      int dev_state, int link_state),
262 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
263 
264 DEFINE_EVENT(ufshcd_template, ufshcd_wl_runtime_resume,
265 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
266 		      int dev_state, int link_state),
267 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
268 
269 TRACE_EVENT(ufshcd_command,
270 	TP_PROTO(const char *dev_name, enum ufs_trace_str_t str_t,
271 		 unsigned int tag, u32 doorbell, int transfer_len, u32 intr,
272 		 u64 lba, u8 opcode, u8 group_id),
273 
274 	TP_ARGS(dev_name, str_t, tag, doorbell, transfer_len,
275 				intr, lba, opcode, group_id),
276 
277 	TP_STRUCT__entry(
278 		__string(dev_name, dev_name)
279 		__field(enum ufs_trace_str_t, str_t)
280 		__field(unsigned int, tag)
281 		__field(u32, doorbell)
282 		__field(int, transfer_len)
283 		__field(u32, intr)
284 		__field(u64, lba)
285 		__field(u8, opcode)
286 		__field(u8, group_id)
287 	),
288 
289 	TP_fast_assign(
290 		__assign_str(dev_name, dev_name);
291 		__entry->str_t = str_t;
292 		__entry->tag = tag;
293 		__entry->doorbell = doorbell;
294 		__entry->transfer_len = transfer_len;
295 		__entry->intr = intr;
296 		__entry->lba = lba;
297 		__entry->opcode = opcode;
298 		__entry->group_id = group_id;
299 	),
300 
301 	TP_printk(
302 		"%s: %s: tag: %u, DB: 0x%x, size: %d, IS: %u, LBA: %llu, opcode: 0x%x (%s), group_id: 0x%x",
303 		show_ufs_cmd_trace_str(__entry->str_t), __get_str(dev_name),
304 		__entry->tag, __entry->doorbell, __entry->transfer_len,
305 		__entry->intr, __entry->lba, (u32)__entry->opcode,
306 		str_opcode(__entry->opcode), (u32)__entry->group_id
307 	)
308 );
309 
310 TRACE_EVENT(ufshcd_uic_command,
311 	TP_PROTO(const char *dev_name, enum ufs_trace_str_t str_t, u32 cmd,
312 		 u32 arg1, u32 arg2, u32 arg3),
313 
314 	TP_ARGS(dev_name, str_t, cmd, arg1, arg2, arg3),
315 
316 	TP_STRUCT__entry(
317 		__string(dev_name, dev_name)
318 		__field(enum ufs_trace_str_t, str_t)
319 		__field(u32, cmd)
320 		__field(u32, arg1)
321 		__field(u32, arg2)
322 		__field(u32, arg3)
323 	),
324 
325 	TP_fast_assign(
326 		__assign_str(dev_name, dev_name);
327 		__entry->str_t = str_t;
328 		__entry->cmd = cmd;
329 		__entry->arg1 = arg1;
330 		__entry->arg2 = arg2;
331 		__entry->arg3 = arg3;
332 	),
333 
334 	TP_printk(
335 		"%s: %s: cmd: 0x%x, arg1: 0x%x, arg2: 0x%x, arg3: 0x%x",
336 		show_ufs_cmd_trace_str(__entry->str_t), __get_str(dev_name),
337 		__entry->cmd, __entry->arg1, __entry->arg2, __entry->arg3
338 	)
339 );
340 
341 TRACE_EVENT(ufshcd_upiu,
342 	TP_PROTO(const char *dev_name, enum ufs_trace_str_t str_t, void *hdr,
343 		 void *tsf, enum ufs_trace_tsf_t tsf_t),
344 
345 	TP_ARGS(dev_name, str_t, hdr, tsf, tsf_t),
346 
347 	TP_STRUCT__entry(
348 		__string(dev_name, dev_name)
349 		__field(enum ufs_trace_str_t, str_t)
350 		__array(unsigned char, hdr, 12)
351 		__array(unsigned char, tsf, 16)
352 		__field(enum ufs_trace_tsf_t, tsf_t)
353 	),
354 
355 	TP_fast_assign(
356 		__assign_str(dev_name, dev_name);
357 		__entry->str_t = str_t;
358 		memcpy(__entry->hdr, hdr, sizeof(__entry->hdr));
359 		memcpy(__entry->tsf, tsf, sizeof(__entry->tsf));
360 		__entry->tsf_t = tsf_t;
361 	),
362 
363 	TP_printk(
364 		"%s: %s: HDR:%s, %s:%s",
365 		show_ufs_cmd_trace_str(__entry->str_t), __get_str(dev_name),
366 		__print_hex(__entry->hdr, sizeof(__entry->hdr)),
367 		show_ufs_cmd_trace_tsf(__entry->tsf_t),
368 		__print_hex(__entry->tsf, sizeof(__entry->tsf))
369 	)
370 );
371 
372 TRACE_EVENT(ufshcd_exception_event,
373 
374 	TP_PROTO(const char *dev_name, u16 status),
375 
376 	TP_ARGS(dev_name, status),
377 
378 	TP_STRUCT__entry(
379 		__string(dev_name, dev_name)
380 		__field(u16, status)
381 	),
382 
383 	TP_fast_assign(
384 		__assign_str(dev_name, dev_name);
385 		__entry->status = status;
386 	),
387 
388 	TP_printk("%s: status 0x%x",
389 		__get_str(dev_name), __entry->status
390 	)
391 );
392 
393 #endif /* if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ) */
394 
395 /* This part must be outside protection */
396 #include <trace/define_trace.h>
397