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 UFS_LINK_STATES \
15 EM(UIC_LINK_OFF_STATE) \
16 EM(UIC_LINK_ACTIVE_STATE) \
17 EMe(UIC_LINK_HIBERN8_STATE)
19 #define UFS_PWR_MODES \
20 EM(UFS_ACTIVE_PWR_MODE) \
21 EM(UFS_SLEEP_PWR_MODE) \
22 EMe(UFS_POWERDOWN_PWR_MODE)
24 #define UFSCHD_CLK_GATING_STATES \
30 /* Enums require being exported to userspace, for user tool parsing */
33 #define EM(a) TRACE_DEFINE_ENUM(a);
34 #define EMe(a) TRACE_DEFINE_ENUM(a);
38 UFSCHD_CLK_GATING_STATES
;
41 * Now redefine the EM() and EMe() macros to map the enums to the strings
42 * that will be printed in the output.
46 #define EM(a) { a, #a },
47 #define EMe(a) { a, #a }
49 TRACE_EVENT(ufshcd_clk_gating
,
51 TP_PROTO(const char *dev_name
, int state
),
53 TP_ARGS(dev_name
, state
),
56 __string(dev_name
, dev_name
)
61 __assign_str(dev_name
, dev_name
);
62 __entry
->state
= state
;
65 TP_printk("%s: gating state changed to %s",
67 __print_symbolic(__entry
->state
, UFSCHD_CLK_GATING_STATES
))
70 TRACE_EVENT(ufshcd_clk_scaling
,
72 TP_PROTO(const char *dev_name
, const char *state
, const char *clk
,
73 u32 prev_state
, u32 curr_state
),
75 TP_ARGS(dev_name
, state
, clk
, prev_state
, curr_state
),
78 __string(dev_name
, dev_name
)
79 __string(state
, state
)
81 __field(u32
, prev_state
)
82 __field(u32
, curr_state
)
86 __assign_str(dev_name
, dev_name
);
87 __assign_str(state
, state
);
88 __assign_str(clk
, clk
);
89 __entry
->prev_state
= prev_state
;
90 __entry
->curr_state
= curr_state
;
93 TP_printk("%s: %s %s from %u to %u Hz",
94 __get_str(dev_name
), __get_str(state
), __get_str(clk
),
95 __entry
->prev_state
, __entry
->curr_state
)
98 TRACE_EVENT(ufshcd_auto_bkops_state
,
100 TP_PROTO(const char *dev_name
, const char *state
),
102 TP_ARGS(dev_name
, state
),
105 __string(dev_name
, dev_name
)
106 __string(state
, state
)
110 __assign_str(dev_name
, dev_name
);
111 __assign_str(state
, state
);
114 TP_printk("%s: auto bkops - %s",
115 __get_str(dev_name
), __get_str(state
))
118 DECLARE_EVENT_CLASS(ufshcd_profiling_template
,
119 TP_PROTO(const char *dev_name
, const char *profile_info
, s64 time_us
,
122 TP_ARGS(dev_name
, profile_info
, time_us
, err
),
125 __string(dev_name
, dev_name
)
126 __string(profile_info
, profile_info
)
127 __field(s64
, time_us
)
132 __assign_str(dev_name
, dev_name
);
133 __assign_str(profile_info
, profile_info
);
134 __entry
->time_us
= time_us
;
138 TP_printk("%s: %s: took %lld usecs, err %d",
139 __get_str(dev_name
), __get_str(profile_info
),
140 __entry
->time_us
, __entry
->err
)
143 DEFINE_EVENT(ufshcd_profiling_template
, ufshcd_profile_hibern8
,
144 TP_PROTO(const char *dev_name
, const char *profile_info
, s64 time_us
,
146 TP_ARGS(dev_name
, profile_info
, time_us
, err
));
148 DEFINE_EVENT(ufshcd_profiling_template
, ufshcd_profile_clk_gating
,
149 TP_PROTO(const char *dev_name
, const char *profile_info
, s64 time_us
,
151 TP_ARGS(dev_name
, profile_info
, time_us
, err
));
153 DEFINE_EVENT(ufshcd_profiling_template
, ufshcd_profile_clk_scaling
,
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 DECLARE_EVENT_CLASS(ufshcd_template
,
159 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
160 int dev_state
, int link_state
),
162 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
),
167 __string(dev_name
, dev_name
)
168 __field(int, dev_state
)
169 __field(int, link_state
)
173 __entry
->usecs
= usecs
;
175 __assign_str(dev_name
, dev_name
);
176 __entry
->dev_state
= dev_state
;
177 __entry
->link_state
= link_state
;
181 "%s: took %lld usecs, dev_state: %s, link_state: %s, err %d",
184 __print_symbolic(__entry
->dev_state
, UFS_PWR_MODES
),
185 __print_symbolic(__entry
->link_state
, UFS_LINK_STATES
),
190 DEFINE_EVENT(ufshcd_template
, ufshcd_system_suspend
,
191 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
192 int dev_state
, int link_state
),
193 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
195 DEFINE_EVENT(ufshcd_template
, ufshcd_system_resume
,
196 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
197 int dev_state
, int link_state
),
198 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
200 DEFINE_EVENT(ufshcd_template
, ufshcd_runtime_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_runtime_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_init
,
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 TRACE_EVENT(ufshcd_command
,
216 TP_PROTO(const char *dev_name
, const char *str
, unsigned int tag
,
217 u32 doorbell
, int transfer_len
, u32 intr
, u64 lba
,
220 TP_ARGS(dev_name
, str
, tag
, doorbell
, transfer_len
, intr
, lba
, opcode
),
223 __string(dev_name
, dev_name
)
225 __field(unsigned int, tag
)
226 __field(u32
, doorbell
)
227 __field(int, transfer_len
)
234 __assign_str(dev_name
, dev_name
);
235 __assign_str(str
, str
);
237 __entry
->doorbell
= doorbell
;
238 __entry
->transfer_len
= transfer_len
;
239 __entry
->intr
= intr
;
241 __entry
->opcode
= opcode
;
245 "%s: %s: tag: %u, DB: 0x%x, size: %d, IS: %u, LBA: %llu, opcode: 0x%x",
246 __get_str(str
), __get_str(dev_name
), __entry
->tag
,
247 __entry
->doorbell
, __entry
->transfer_len
,
248 __entry
->intr
, __entry
->lba
, (u32
)__entry
->opcode
252 TRACE_EVENT(ufshcd_upiu
,
253 TP_PROTO(const char *dev_name
, const char *str
, void *hdr
, void *tsf
),
255 TP_ARGS(dev_name
, str
, hdr
, tsf
),
258 __string(dev_name
, dev_name
)
260 __array(unsigned char, hdr
, 12)
261 __array(unsigned char, tsf
, 16)
265 __assign_str(dev_name
, dev_name
);
266 __assign_str(str
, str
);
267 memcpy(__entry
->hdr
, hdr
, sizeof(__entry
->hdr
));
268 memcpy(__entry
->tsf
, tsf
, sizeof(__entry
->tsf
));
272 "%s: %s: HDR:%s, CDB:%s",
273 __get_str(str
), __get_str(dev_name
),
274 __print_hex(__entry
->hdr
, sizeof(__entry
->hdr
)),
275 __print_hex(__entry
->tsf
, sizeof(__entry
->tsf
))
279 #endif /* if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ) */
281 /* This part must be outside protection */
282 #include <trace/define_trace.h>