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 UFS_LINK_STATES \ 15 EM(UIC_LINK_OFF_STATE) \ 16 EM(UIC_LINK_ACTIVE_STATE) \ 17 EMe(UIC_LINK_HIBERN8_STATE) 18 19 #define UFS_PWR_MODES \ 20 EM(UFS_ACTIVE_PWR_MODE) \ 21 EM(UFS_SLEEP_PWR_MODE) \ 22 EMe(UFS_POWERDOWN_PWR_MODE) 23 24 #define UFSCHD_CLK_GATING_STATES \ 25 EM(CLKS_OFF) \ 26 EM(CLKS_ON) \ 27 EM(REQ_CLKS_OFF) \ 28 EMe(REQ_CLKS_ON) 29 30 /* Enums require being exported to userspace, for user tool parsing */ 31 #undef EM 32 #undef EMe 33 #define EM(a) TRACE_DEFINE_ENUM(a); 34 #define EMe(a) TRACE_DEFINE_ENUM(a); 35 36 UFS_LINK_STATES; 37 UFS_PWR_MODES; 38 UFSCHD_CLK_GATING_STATES; 39 40 /* 41 * Now redefine the EM() and EMe() macros to map the enums to the strings 42 * that will be printed in the output. 43 */ 44 #undef EM 45 #undef EMe 46 #define EM(a) { a, #a }, 47 #define EMe(a) { a, #a } 48 49 TRACE_EVENT(ufshcd_clk_gating, 50 51 TP_PROTO(const char *dev_name, int state), 52 53 TP_ARGS(dev_name, state), 54 55 TP_STRUCT__entry( 56 __string(dev_name, dev_name) 57 __field(int, state) 58 ), 59 60 TP_fast_assign( 61 __assign_str(dev_name, dev_name); 62 __entry->state = state; 63 ), 64 65 TP_printk("%s: gating state changed to %s", 66 __get_str(dev_name), 67 __print_symbolic(__entry->state, UFSCHD_CLK_GATING_STATES)) 68 ); 69 70 TRACE_EVENT(ufshcd_clk_scaling, 71 72 TP_PROTO(const char *dev_name, const char *state, const char *clk, 73 u32 prev_state, u32 curr_state), 74 75 TP_ARGS(dev_name, state, clk, prev_state, curr_state), 76 77 TP_STRUCT__entry( 78 __string(dev_name, dev_name) 79 __string(state, state) 80 __string(clk, clk) 81 __field(u32, prev_state) 82 __field(u32, curr_state) 83 ), 84 85 TP_fast_assign( 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; 91 ), 92 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) 96 ); 97 98 TRACE_EVENT(ufshcd_auto_bkops_state, 99 100 TP_PROTO(const char *dev_name, const char *state), 101 102 TP_ARGS(dev_name, state), 103 104 TP_STRUCT__entry( 105 __string(dev_name, dev_name) 106 __string(state, state) 107 ), 108 109 TP_fast_assign( 110 __assign_str(dev_name, dev_name); 111 __assign_str(state, state); 112 ), 113 114 TP_printk("%s: auto bkops - %s", 115 __get_str(dev_name), __get_str(state)) 116 ); 117 118 DECLARE_EVENT_CLASS(ufshcd_profiling_template, 119 TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us, 120 int err), 121 122 TP_ARGS(dev_name, profile_info, time_us, err), 123 124 TP_STRUCT__entry( 125 __string(dev_name, dev_name) 126 __string(profile_info, profile_info) 127 __field(s64, time_us) 128 __field(int, err) 129 ), 130 131 TP_fast_assign( 132 __assign_str(dev_name, dev_name); 133 __assign_str(profile_info, profile_info); 134 __entry->time_us = time_us; 135 __entry->err = err; 136 ), 137 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) 141 ); 142 143 DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_hibern8, 144 TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us, 145 int err), 146 TP_ARGS(dev_name, profile_info, time_us, err)); 147 148 DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_gating, 149 TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us, 150 int err), 151 TP_ARGS(dev_name, profile_info, time_us, err)); 152 153 DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_scaling, 154 TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us, 155 int err), 156 TP_ARGS(dev_name, profile_info, time_us, err)); 157 158 DECLARE_EVENT_CLASS(ufshcd_template, 159 TP_PROTO(const char *dev_name, int err, s64 usecs, 160 int dev_state, int link_state), 161 162 TP_ARGS(dev_name, err, usecs, dev_state, link_state), 163 164 TP_STRUCT__entry( 165 __field(s64, usecs) 166 __field(int, err) 167 __string(dev_name, dev_name) 168 __field(int, dev_state) 169 __field(int, link_state) 170 ), 171 172 TP_fast_assign( 173 __entry->usecs = usecs; 174 __entry->err = err; 175 __assign_str(dev_name, dev_name); 176 __entry->dev_state = dev_state; 177 __entry->link_state = link_state; 178 ), 179 180 TP_printk( 181 "%s: took %lld usecs, dev_state: %s, link_state: %s, err %d", 182 __get_str(dev_name), 183 __entry->usecs, 184 __print_symbolic(__entry->dev_state, UFS_PWR_MODES), 185 __print_symbolic(__entry->link_state, UFS_LINK_STATES), 186 __entry->err 187 ) 188 ); 189 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)); 194 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)); 199 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)); 204 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)); 209 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)); 214 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, 218 u8 opcode), 219 220 TP_ARGS(dev_name, str, tag, doorbell, transfer_len, intr, lba, opcode), 221 222 TP_STRUCT__entry( 223 __string(dev_name, dev_name) 224 __string(str, str) 225 __field(unsigned int, tag) 226 __field(u32, doorbell) 227 __field(int, transfer_len) 228 __field(u32, intr) 229 __field(u64, lba) 230 __field(u8, opcode) 231 ), 232 233 TP_fast_assign( 234 __assign_str(dev_name, dev_name); 235 __assign_str(str, str); 236 __entry->tag = tag; 237 __entry->doorbell = doorbell; 238 __entry->transfer_len = transfer_len; 239 __entry->intr = intr; 240 __entry->lba = lba; 241 __entry->opcode = opcode; 242 ), 243 244 TP_printk( 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 249 ) 250 ); 251 252 TRACE_EVENT(ufshcd_uic_command, 253 TP_PROTO(const char *dev_name, const char *str, u32 cmd, 254 u32 arg1, u32 arg2, u32 arg3), 255 256 TP_ARGS(dev_name, str, cmd, arg1, arg2, arg3), 257 258 TP_STRUCT__entry( 259 __string(dev_name, dev_name) 260 __string(str, str) 261 __field(u32, cmd) 262 __field(u32, arg1) 263 __field(u32, arg2) 264 __field(u32, arg3) 265 ), 266 267 TP_fast_assign( 268 __assign_str(dev_name, dev_name); 269 __assign_str(str, str); 270 __entry->cmd = cmd; 271 __entry->arg1 = arg1; 272 __entry->arg2 = arg2; 273 __entry->arg3 = arg3; 274 ), 275 276 TP_printk( 277 "%s: %s: cmd: 0x%x, arg1: 0x%x, arg2: 0x%x, arg3: 0x%x", 278 __get_str(str), __get_str(dev_name), __entry->cmd, 279 __entry->arg1, __entry->arg2, __entry->arg3 280 ) 281 ); 282 283 TRACE_EVENT(ufshcd_upiu, 284 TP_PROTO(const char *dev_name, const char *str, void *hdr, void *tsf), 285 286 TP_ARGS(dev_name, str, hdr, tsf), 287 288 TP_STRUCT__entry( 289 __string(dev_name, dev_name) 290 __string(str, str) 291 __array(unsigned char, hdr, 12) 292 __array(unsigned char, tsf, 16) 293 ), 294 295 TP_fast_assign( 296 __assign_str(dev_name, dev_name); 297 __assign_str(str, str); 298 memcpy(__entry->hdr, hdr, sizeof(__entry->hdr)); 299 memcpy(__entry->tsf, tsf, sizeof(__entry->tsf)); 300 ), 301 302 TP_printk( 303 "%s: %s: HDR:%s, CDB:%s", 304 __get_str(str), __get_str(dev_name), 305 __print_hex(__entry->hdr, sizeof(__entry->hdr)), 306 __print_hex(__entry->tsf, sizeof(__entry->tsf)) 307 ) 308 ); 309 310 #endif /* if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ) */ 311 312 /* This part must be outside protection */ 313 #include <trace/define_trace.h> 314