ufs.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /*
  2. * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
  3. *
  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.
  7. *
  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.
  12. */
  13. #undef TRACE_SYSTEM
  14. #define TRACE_SYSTEM ufs
  15. #if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ)
  16. #define _TRACE_UFS_H
  17. #include <linux/tracepoint.h>
  18. #define UFS_LINK_STATES \
  19. EM(UIC_LINK_OFF_STATE) \
  20. EM(UIC_LINK_ACTIVE_STATE) \
  21. EMe(UIC_LINK_HIBERN8_STATE)
  22. #define UFS_PWR_MODES \
  23. EM(UFS_ACTIVE_PWR_MODE) \
  24. EM(UFS_SLEEP_PWR_MODE) \
  25. EMe(UFS_POWERDOWN_PWR_MODE)
  26. #define UFSCHD_CLK_GATING_STATES \
  27. EM(CLKS_OFF) \
  28. EM(CLKS_ON) \
  29. EM(REQ_CLKS_OFF) \
  30. EMe(REQ_CLKS_ON)
  31. /* Enums require being exported to userspace, for user tool parsing */
  32. #undef EM
  33. #undef EMe
  34. #define EM(a) TRACE_DEFINE_ENUM(a);
  35. #define EMe(a) TRACE_DEFINE_ENUM(a);
  36. UFS_LINK_STATES;
  37. UFS_PWR_MODES;
  38. UFSCHD_CLK_GATING_STATES;
  39. /*
  40. * Now redefine the EM() and EMe() macros to map the enums to the strings
  41. * that will be printed in the output.
  42. */
  43. #undef EM
  44. #undef EMe
  45. #define EM(a) { a, #a },
  46. #define EMe(a) { a, #a }
  47. TRACE_EVENT(ufshcd_clk_gating,
  48. TP_PROTO(const char *dev_name, int state),
  49. TP_ARGS(dev_name, state),
  50. TP_STRUCT__entry(
  51. __string(dev_name, dev_name)
  52. __field(int, state)
  53. ),
  54. TP_fast_assign(
  55. __assign_str(dev_name, dev_name);
  56. __entry->state = state;
  57. ),
  58. TP_printk("%s: gating state changed to %s",
  59. __get_str(dev_name),
  60. __print_symbolic(__entry->state, UFSCHD_CLK_GATING_STATES))
  61. );
  62. TRACE_EVENT(ufshcd_clk_scaling,
  63. TP_PROTO(const char *dev_name, const char *state, const char *clk,
  64. u32 prev_state, u32 curr_state),
  65. TP_ARGS(dev_name, state, clk, prev_state, curr_state),
  66. TP_STRUCT__entry(
  67. __string(dev_name, dev_name)
  68. __string(state, state)
  69. __string(clk, clk)
  70. __field(u32, prev_state)
  71. __field(u32, curr_state)
  72. ),
  73. TP_fast_assign(
  74. __assign_str(dev_name, dev_name);
  75. __assign_str(state, state);
  76. __assign_str(clk, clk);
  77. __entry->prev_state = prev_state;
  78. __entry->curr_state = curr_state;
  79. ),
  80. TP_printk("%s: %s %s from %u to %u Hz",
  81. __get_str(dev_name), __get_str(state), __get_str(clk),
  82. __entry->prev_state, __entry->curr_state)
  83. );
  84. TRACE_EVENT(ufshcd_auto_bkops_state,
  85. TP_PROTO(const char *dev_name, const char *state),
  86. TP_ARGS(dev_name, state),
  87. TP_STRUCT__entry(
  88. __string(dev_name, dev_name)
  89. __string(state, state)
  90. ),
  91. TP_fast_assign(
  92. __assign_str(dev_name, dev_name);
  93. __assign_str(state, state);
  94. ),
  95. TP_printk("%s: auto bkops - %s",
  96. __get_str(dev_name), __get_str(state))
  97. );
  98. DECLARE_EVENT_CLASS(ufshcd_profiling_template,
  99. TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
  100. int err),
  101. TP_ARGS(dev_name, profile_info, time_us, err),
  102. TP_STRUCT__entry(
  103. __string(dev_name, dev_name)
  104. __string(profile_info, profile_info)
  105. __field(s64, time_us)
  106. __field(int, err)
  107. ),
  108. TP_fast_assign(
  109. __assign_str(dev_name, dev_name);
  110. __assign_str(profile_info, profile_info);
  111. __entry->time_us = time_us;
  112. __entry->err = err;
  113. ),
  114. TP_printk("%s: %s: took %lld usecs, err %d",
  115. __get_str(dev_name), __get_str(profile_info),
  116. __entry->time_us, __entry->err)
  117. );
  118. DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_hibern8,
  119. TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
  120. int err),
  121. TP_ARGS(dev_name, profile_info, time_us, err));
  122. DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_gating,
  123. TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
  124. int err),
  125. TP_ARGS(dev_name, profile_info, time_us, err));
  126. DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_scaling,
  127. TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
  128. int err),
  129. TP_ARGS(dev_name, profile_info, time_us, err));
  130. DECLARE_EVENT_CLASS(ufshcd_template,
  131. TP_PROTO(const char *dev_name, int err, s64 usecs,
  132. int dev_state, int link_state),
  133. TP_ARGS(dev_name, err, usecs, dev_state, link_state),
  134. TP_STRUCT__entry(
  135. __field(s64, usecs)
  136. __field(int, err)
  137. __string(dev_name, dev_name)
  138. __field(int, dev_state)
  139. __field(int, link_state)
  140. ),
  141. TP_fast_assign(
  142. __entry->usecs = usecs;
  143. __entry->err = err;
  144. __assign_str(dev_name, dev_name);
  145. __entry->dev_state = dev_state;
  146. __entry->link_state = link_state;
  147. ),
  148. TP_printk(
  149. "%s: took %lld usecs, dev_state: %s, link_state: %s, err %d",
  150. __get_str(dev_name),
  151. __entry->usecs,
  152. __print_symbolic(__entry->dev_state, UFS_PWR_MODES),
  153. __print_symbolic(__entry->link_state, UFS_LINK_STATES),
  154. __entry->err
  155. )
  156. );
  157. DEFINE_EVENT(ufshcd_template, ufshcd_system_suspend,
  158. TP_PROTO(const char *dev_name, int err, s64 usecs,
  159. int dev_state, int link_state),
  160. TP_ARGS(dev_name, err, usecs, dev_state, link_state));
  161. DEFINE_EVENT(ufshcd_template, ufshcd_system_resume,
  162. TP_PROTO(const char *dev_name, int err, s64 usecs,
  163. int dev_state, int link_state),
  164. TP_ARGS(dev_name, err, usecs, dev_state, link_state));
  165. DEFINE_EVENT(ufshcd_template, ufshcd_runtime_suspend,
  166. TP_PROTO(const char *dev_name, int err, s64 usecs,
  167. int dev_state, int link_state),
  168. TP_ARGS(dev_name, err, usecs, dev_state, link_state));
  169. DEFINE_EVENT(ufshcd_template, ufshcd_runtime_resume,
  170. TP_PROTO(const char *dev_name, int err, s64 usecs,
  171. int dev_state, int link_state),
  172. TP_ARGS(dev_name, err, usecs, dev_state, link_state));
  173. DEFINE_EVENT(ufshcd_template, ufshcd_init,
  174. TP_PROTO(const char *dev_name, int err, s64 usecs,
  175. int dev_state, int link_state),
  176. TP_ARGS(dev_name, err, usecs, dev_state, link_state));
  177. TRACE_EVENT(ufshcd_command,
  178. TP_PROTO(const char *dev_name, const char *str, unsigned int tag,
  179. u32 doorbell, int transfer_len, u32 intr, u64 lba,
  180. u8 opcode),
  181. TP_ARGS(dev_name, str, tag, doorbell, transfer_len, intr, lba, opcode),
  182. TP_STRUCT__entry(
  183. __string(dev_name, dev_name)
  184. __string(str, str)
  185. __field(unsigned int, tag)
  186. __field(u32, doorbell)
  187. __field(int, transfer_len)
  188. __field(u32, intr)
  189. __field(u64, lba)
  190. __field(u8, opcode)
  191. ),
  192. TP_fast_assign(
  193. __assign_str(dev_name, dev_name);
  194. __assign_str(str, str);
  195. __entry->tag = tag;
  196. __entry->doorbell = doorbell;
  197. __entry->transfer_len = transfer_len;
  198. __entry->intr = intr;
  199. __entry->lba = lba;
  200. __entry->opcode = opcode;
  201. ),
  202. TP_printk(
  203. "%s: %s: tag: %u, DB: 0x%x, size: %d, IS: %u, LBA: %llu, opcode: 0x%x",
  204. __get_str(str), __get_str(dev_name), __entry->tag,
  205. __entry->doorbell, __entry->transfer_len,
  206. __entry->intr, __entry->lba, (u32)__entry->opcode
  207. )
  208. );
  209. TRACE_EVENT(ufshcd_upiu,
  210. TP_PROTO(const char *dev_name, const char *str, void *hdr, void *tsf),
  211. TP_ARGS(dev_name, str, hdr, tsf),
  212. TP_STRUCT__entry(
  213. __string(dev_name, dev_name)
  214. __string(str, str)
  215. __array(unsigned char, hdr, 12)
  216. __array(unsigned char, tsf, 16)
  217. ),
  218. TP_fast_assign(
  219. __assign_str(dev_name, dev_name);
  220. __assign_str(str, str);
  221. memcpy(__entry->hdr, hdr, sizeof(__entry->hdr));
  222. memcpy(__entry->tsf, tsf, sizeof(__entry->tsf));
  223. ),
  224. TP_printk(
  225. "%s: %s: HDR:%s, CDB:%s",
  226. __get_str(str), __get_str(dev_name),
  227. __print_hex(__entry->hdr, sizeof(__entry->hdr)),
  228. __print_hex(__entry->tsf, sizeof(__entry->tsf))
  229. )
  230. );
  231. #endif /* if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ) */
  232. /* This part must be outside protection */
  233. #include <trace/define_trace.h>