2 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #define TRACE_SYSTEM ufs
17 #if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ)
20 #include <linux/tracepoint.h>
22 #define UFS_LINK_STATES \
23 EM(UIC_LINK_OFF_STATE) \
24 EM(UIC_LINK_ACTIVE_STATE) \
25 EMe(UIC_LINK_HIBERN8_STATE)
27 #define UFS_PWR_MODES \
28 EM(UFS_ACTIVE_PWR_MODE) \
29 EM(UFS_SLEEP_PWR_MODE) \
30 EMe(UFS_POWERDOWN_PWR_MODE)
32 #define UFSCHD_CLK_GATING_STATES \
38 /* Enums require being exported to userspace, for user tool parsing */
41 #define EM(a) TRACE_DEFINE_ENUM(a);
42 #define EMe(a) TRACE_DEFINE_ENUM(a);
46 UFSCHD_CLK_GATING_STATES
;
49 * Now redefine the EM() and EMe() macros to map the enums to the strings
50 * that will be printed in the output.
54 #define EM(a) { a, #a },
55 #define EMe(a) { a, #a }
57 TRACE_EVENT(ufshcd_clk_gating
,
59 TP_PROTO(const char *dev_name
, int state
),
61 TP_ARGS(dev_name
, state
),
64 __string(dev_name
, dev_name
)
69 __assign_str(dev_name
, dev_name
);
70 __entry
->state
= state
;
73 TP_printk("%s: gating state changed to %s",
75 __print_symbolic(__entry
->state
, UFSCHD_CLK_GATING_STATES
))
78 TRACE_EVENT(ufshcd_clk_scaling
,
80 TP_PROTO(const char *dev_name
, const char *state
, const char *clk
,
81 u32 prev_state
, u32 curr_state
),
83 TP_ARGS(dev_name
, state
, clk
, prev_state
, curr_state
),
86 __string(dev_name
, dev_name
)
87 __string(state
, state
)
89 __field(u32
, prev_state
)
90 __field(u32
, curr_state
)
94 __assign_str(dev_name
, dev_name
);
95 __assign_str(state
, state
);
96 __assign_str(clk
, clk
);
97 __entry
->prev_state
= prev_state
;
98 __entry
->curr_state
= curr_state
;
101 TP_printk("%s: %s %s from %u to %u Hz",
102 __get_str(dev_name
), __get_str(state
), __get_str(clk
),
103 __entry
->prev_state
, __entry
->curr_state
)
106 TRACE_EVENT(ufshcd_auto_bkops_state
,
108 TP_PROTO(const char *dev_name
, const char *state
),
110 TP_ARGS(dev_name
, state
),
113 __string(dev_name
, dev_name
)
114 __string(state
, state
)
118 __assign_str(dev_name
, dev_name
);
119 __assign_str(state
, state
);
122 TP_printk("%s: auto bkops - %s",
123 __get_str(dev_name
), __get_str(state
))
126 DECLARE_EVENT_CLASS(ufshcd_profiling_template
,
127 TP_PROTO(const char *dev_name
, const char *profile_info
, s64 time_us
,
130 TP_ARGS(dev_name
, profile_info
, time_us
, err
),
133 __string(dev_name
, dev_name
)
134 __string(profile_info
, profile_info
)
135 __field(s64
, time_us
)
140 __assign_str(dev_name
, dev_name
);
141 __assign_str(profile_info
, profile_info
);
142 __entry
->time_us
= time_us
;
146 TP_printk("%s: %s: took %lld usecs, err %d",
147 __get_str(dev_name
), __get_str(profile_info
),
148 __entry
->time_us
, __entry
->err
)
151 DEFINE_EVENT(ufshcd_profiling_template
, ufshcd_profile_hibern8
,
152 TP_PROTO(const char *dev_name
, const char *profile_info
, s64 time_us
,
154 TP_ARGS(dev_name
, profile_info
, time_us
, err
));
156 DEFINE_EVENT(ufshcd_profiling_template
, ufshcd_profile_clk_gating
,
157 TP_PROTO(const char *dev_name
, const char *profile_info
, s64 time_us
,
159 TP_ARGS(dev_name
, profile_info
, time_us
, err
));
161 DEFINE_EVENT(ufshcd_profiling_template
, ufshcd_profile_clk_scaling
,
162 TP_PROTO(const char *dev_name
, const char *profile_info
, s64 time_us
,
164 TP_ARGS(dev_name
, profile_info
, time_us
, err
));
166 DECLARE_EVENT_CLASS(ufshcd_template
,
167 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
168 int dev_state
, int link_state
),
170 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
),
175 __string(dev_name
, dev_name
)
176 __field(int, dev_state
)
177 __field(int, link_state
)
181 __entry
->usecs
= usecs
;
183 __assign_str(dev_name
, dev_name
);
184 __entry
->dev_state
= dev_state
;
185 __entry
->link_state
= link_state
;
189 "%s: took %lld usecs, dev_state: %s, link_state: %s, err %d",
192 __print_symbolic(__entry
->dev_state
, UFS_PWR_MODES
),
193 __print_symbolic(__entry
->link_state
, UFS_LINK_STATES
),
198 DEFINE_EVENT(ufshcd_template
, ufshcd_system_suspend
,
199 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
200 int dev_state
, int link_state
),
201 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
203 DEFINE_EVENT(ufshcd_template
, ufshcd_system_resume
,
204 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
205 int dev_state
, int link_state
),
206 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
208 DEFINE_EVENT(ufshcd_template
, ufshcd_runtime_suspend
,
209 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
210 int dev_state
, int link_state
),
211 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
213 DEFINE_EVENT(ufshcd_template
, ufshcd_runtime_resume
,
214 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
215 int dev_state
, int link_state
),
216 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
218 DEFINE_EVENT(ufshcd_template
, ufshcd_init
,
219 TP_PROTO(const char *dev_name
, int err
, s64 usecs
,
220 int dev_state
, int link_state
),
221 TP_ARGS(dev_name
, err
, usecs
, dev_state
, link_state
));
223 TRACE_EVENT(ufshcd_command
,
224 TP_PROTO(const char *dev_name
, const char *str
, unsigned int tag
,
225 u32 doorbell
, int transfer_len
, u32 intr
, u64 lba
,
228 TP_ARGS(dev_name
, str
, tag
, doorbell
, transfer_len
, intr
, lba
, opcode
),
231 __string(dev_name
, dev_name
)
233 __field(unsigned int, tag
)
234 __field(u32
, doorbell
)
235 __field(int, transfer_len
)
242 __assign_str(dev_name
, dev_name
);
243 __assign_str(str
, str
);
245 __entry
->doorbell
= doorbell
;
246 __entry
->transfer_len
= transfer_len
;
247 __entry
->intr
= intr
;
249 __entry
->opcode
= opcode
;
253 "%s: %s: tag: %u, DB: 0x%x, size: %d, IS: %u, LBA: %llu, opcode: 0x%x",
254 __get_str(str
), __get_str(dev_name
), __entry
->tag
,
255 __entry
->doorbell
, __entry
->transfer_len
,
256 __entry
->intr
, __entry
->lba
, (u32
)__entry
->opcode
260 #endif /* if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ) */
262 /* This part must be outside protection */
263 #include <trace/define_trace.h>