1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
7 #define TRACE_SYSTEM ufs
9 #if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ)
12 #include <linux/tracepoint.h>
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" }, \
23 #define UFS_LINK_STATES \
24 EM(UIC_LINK_OFF_STATE) \
25 EM(UIC_LINK_ACTIVE_STATE) \
26 EMe(UIC_LINK_HIBERN8_STATE)
28 #define UFS_PWR_MODES \
29 EM(UFS_ACTIVE_PWR_MODE) \
30 EM(UFS_SLEEP_PWR_MODE) \
31 EM(UFS_POWERDOWN_PWR_MODE) \
32 EMe(UFS_DEEPSLEEP_PWR_MODE)
34 #define UFSCHD_CLK_GATING_STATES \
40 /* Enums require being exported to userspace, for user tool parsing */
43 #define EM(a) TRACE_DEFINE_ENUM(a);
44 #define EMe(a) TRACE_DEFINE_ENUM(a);
48 UFSCHD_CLK_GATING_STATES
;
51 * Now redefine the EM() and EMe() macros to map the enums to the strings
52 * that will be printed in the output.
56 #define EM(a) { a, #a },
57 #define EMe(a) { a, #a }
59 TRACE_EVENT(ufshcd_clk_gating
,
61 TP_PROTO(const char *dev_name
, int state
),
63 TP_ARGS(dev_name
, state
),
66 __string(dev_name
, dev_name
)
71 __assign_str(dev_name
, dev_name
);
72 __entry
->state
= state
;
75 TP_printk("%s: gating state changed to %s",
77 __print_symbolic(__entry
->state
, UFSCHD_CLK_GATING_STATES
))
80 TRACE_EVENT(ufshcd_clk_scaling
,
82 TP_PROTO(const char *dev_name
, const char *state
, const char *clk
,
83 u32 prev_state
, u32 curr_state
),
85 TP_ARGS(dev_name
, state
, clk
, prev_state
, curr_state
),
88 __string(dev_name
, dev_name
)
89 __string(state
, state
)
91 __field(u32
, prev_state
)
92 __field(u32
, curr_state
)
96 __assign_str(dev_name
, dev_name
);
97 __assign_str(state
, state
);
98 __assign_str(clk
, clk
);
99 __entry
->prev_state
= prev_state
;
100 __entry
->curr_state
= curr_state
;
103 TP_printk("%s: %s %s from %u to %u Hz",
104 __get_str(dev_name
), __get_str(state
), __get_str(clk
),
105 __entry
->prev_state
, __entry
->curr_state
)
108 TRACE_EVENT(ufshcd_auto_bkops_state
,
110 TP_PROTO(const char *dev_name
, const char *state
),
112 TP_ARGS(dev_name
, state
),
115 __string(dev_name
, dev_name
)
116 __string(state
, state
)
120 __assign_str(dev_name
, dev_name
);
121 __assign_str(state
, state
);
124 TP_printk("%s: auto bkops - %s",
125 __get_str(dev_name
), __get_str(state
))
128 DECLARE_EVENT_CLASS(ufshcd_profiling_template
,
129 TP_PROTO(const char *dev_name
, const char *profile_info
, s64 time_us
,
132 TP_ARGS(dev_name
, profile_info
, time_us
, err
),
135 __string(dev_name
, dev_name
)
136 __string(profile_info
, profile_info
)
137 __field(s64
, time_us
)
142 __assign_str(dev_name
, dev_name
);
143 __assign_str(profile_info
, profile_info
);
144 __entry
->time_us
= time_us
;
148 TP_printk("%s: %s: took %lld usecs, err %d",
149 __get_str(dev_name
), __get_str(profile_info
),
150 __entry
->time_us
, __entry
->err
)
153 DEFINE_EVENT(ufshcd_profiling_template
, ufshcd_profile_hibern8
,
154 TP_PROTO(const char *dev_name
, const char *profile_info
, s64 time_us
,
156 TP_ARGS(dev_name
, profile_info
, time_us
, err
));
158 DEFINE_EVENT(ufshcd_profiling_template
, ufshcd_profile_clk_gating
,
159 TP_PROTO(const char *dev_name
, const char *profile_info
, s64 time_us
,
161 TP_ARGS(dev_name
, profile_info
, time_us
, err
));
163 DEFINE_EVENT(ufshcd_profiling_template
, ufshcd_profile_clk_scaling
,
164 TP_PROTO(const char *dev_name
, const char *profile_info
, s64 time_us
,
166 TP_ARGS(dev_name
, profile_info
, time_us
, err
));
168 DECLARE_EVENT_CLASS(ufshcd_template
,
169 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
170 int dev_state
, int link_state
),
172 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
),
177 __string(dev_name
, dev_name
)
178 __field(int, dev_state
)
179 __field(int, link_state
)
183 __entry
->usecs
= usecs
;
185 __assign_str(dev_name
, dev_name
);
186 __entry
->dev_state
= dev_state
;
187 __entry
->link_state
= link_state
;
191 "%s: took %lld usecs, dev_state: %s, link_state: %s, err %d",
194 __print_symbolic(__entry
->dev_state
, UFS_PWR_MODES
),
195 __print_symbolic(__entry
->link_state
, UFS_LINK_STATES
),
200 DEFINE_EVENT(ufshcd_template
, ufshcd_system_suspend
,
201 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
202 int dev_state
, int link_state
),
203 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
205 DEFINE_EVENT(ufshcd_template
, ufshcd_system_resume
,
206 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
207 int dev_state
, int link_state
),
208 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
210 DEFINE_EVENT(ufshcd_template
, ufshcd_runtime_suspend
,
211 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
212 int dev_state
, int link_state
),
213 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
215 DEFINE_EVENT(ufshcd_template
, ufshcd_runtime_resume
,
216 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
217 int dev_state
, int link_state
),
218 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
220 DEFINE_EVENT(ufshcd_template
, ufshcd_init
,
221 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
222 int dev_state
, int link_state
),
223 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
225 TRACE_EVENT(ufshcd_command
,
226 TP_PROTO(const char *dev_name
, const char *str
, unsigned int tag
,
227 u32 doorbell
, int transfer_len
, u32 intr
, u64 lba
,
228 u8 opcode
, u8 group_id
),
230 TP_ARGS(dev_name
, str
, tag
, doorbell
, transfer_len
,
231 intr
, lba
, opcode
, group_id
),
234 __string(dev_name
, dev_name
)
236 __field(unsigned int, tag
)
237 __field(u32
, doorbell
)
238 __field(int, transfer_len
)
242 __field(u8
, group_id
)
246 __assign_str(dev_name
, dev_name
);
247 __assign_str(str
, str
);
249 __entry
->doorbell
= doorbell
;
250 __entry
->transfer_len
= transfer_len
;
251 __entry
->intr
= intr
;
253 __entry
->opcode
= opcode
;
254 __entry
->group_id
= group_id
;
258 "%s: %s: tag: %u, DB: 0x%x, size: %d, IS: %u, LBA: %llu, opcode: 0x%x (%s), group_id: 0x%x",
259 __get_str(str
), __get_str(dev_name
), __entry
->tag
,
260 __entry
->doorbell
, __entry
->transfer_len
,
261 __entry
->intr
, __entry
->lba
, (u32
)__entry
->opcode
,
262 str_opcode(__entry
->opcode
), (u32
)__entry
->group_id
266 TRACE_EVENT(ufshcd_uic_command
,
267 TP_PROTO(const char *dev_name
, const char *str
, u32 cmd
,
268 u32 arg1
, u32 arg2
, u32 arg3
),
270 TP_ARGS(dev_name
, str
, cmd
, arg1
, arg2
, arg3
),
273 __string(dev_name
, dev_name
)
282 __assign_str(dev_name
, dev_name
);
283 __assign_str(str
, str
);
285 __entry
->arg1
= arg1
;
286 __entry
->arg2
= arg2
;
287 __entry
->arg3
= arg3
;
291 "%s: %s: cmd: 0x%x, arg1: 0x%x, arg2: 0x%x, arg3: 0x%x",
292 __get_str(str
), __get_str(dev_name
), __entry
->cmd
,
293 __entry
->arg1
, __entry
->arg2
, __entry
->arg3
297 TRACE_EVENT(ufshcd_upiu
,
298 TP_PROTO(const char *dev_name
, const char *str
, void *hdr
, void *tsf
),
300 TP_ARGS(dev_name
, str
, hdr
, tsf
),
303 __string(dev_name
, dev_name
)
305 __array(unsigned char, hdr
, 12)
306 __array(unsigned char, tsf
, 16)
310 __assign_str(dev_name
, dev_name
);
311 __assign_str(str
, str
);
312 memcpy(__entry
->hdr
, hdr
, sizeof(__entry
->hdr
));
313 memcpy(__entry
->tsf
, tsf
, sizeof(__entry
->tsf
));
317 "%s: %s: HDR:%s, CDB:%s",
318 __get_str(str
), __get_str(dev_name
),
319 __print_hex(__entry
->hdr
, sizeof(__entry
->hdr
)),
320 __print_hex(__entry
->tsf
, sizeof(__entry
->tsf
))
324 #endif /* if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ) */
326 /* This part must be outside protection */
327 #include <trace/define_trace.h>