ufs.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. * Copyright (c) 2013-2015, 2017, 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. DECLARE_EVENT_CLASS(ufshcd_state_change_template,
  19. TP_PROTO(const char *dev_name, int state),
  20. TP_ARGS(dev_name, state),
  21. TP_STRUCT__entry(
  22. __string(dev_name, dev_name)
  23. __field(int, state)
  24. ),
  25. TP_fast_assign(
  26. __assign_str(dev_name, dev_name);
  27. __entry->state = state;
  28. ),
  29. TP_printk("%s: state changed to %s",
  30. __get_str(dev_name), __entry->state ? "ON" : "OFF")
  31. );
  32. DEFINE_EVENT_PRINT(ufshcd_state_change_template, ufshcd_clk_gating,
  33. TP_PROTO(const char *dev_name, int state),
  34. TP_ARGS(dev_name, state),
  35. TP_printk("%s: state changed to %s", __get_str(dev_name),
  36. __print_symbolic(__entry->state,
  37. { CLKS_OFF, "CLKS_OFF" },
  38. { CLKS_ON, "CLKS_ON" },
  39. { REQ_CLKS_OFF, "REQ_CLKS_OFF" },
  40. { REQ_CLKS_ON, "REQ_CLKS_ON" }))
  41. );
  42. DEFINE_EVENT_PRINT(ufshcd_state_change_template, ufshcd_hibern8_on_idle,
  43. TP_PROTO(const char *dev_name, int state),
  44. TP_ARGS(dev_name, state),
  45. TP_printk("%s: state changed to %s", __get_str(dev_name),
  46. __print_symbolic(__entry->state,
  47. { HIBERN8_ENTERED, "HIBERN8_ENTER" },
  48. { HIBERN8_EXITED, "HIBERN8_EXIT" },
  49. { REQ_HIBERN8_ENTER, "REQ_HIBERN8_ENTER" },
  50. { REQ_HIBERN8_EXIT, "REQ_HIBERN8_EXIT" }))
  51. );
  52. DEFINE_EVENT(ufshcd_state_change_template, ufshcd_auto_bkops_state,
  53. TP_PROTO(const char *dev_name, int state),
  54. TP_ARGS(dev_name, state));
  55. TRACE_EVENT(ufshcd_clk_scaling,
  56. TP_PROTO(const char *dev_name, const char *state, const char *clk,
  57. u32 prev_state, u32 curr_state),
  58. TP_ARGS(dev_name, state, clk, prev_state, curr_state),
  59. TP_STRUCT__entry(
  60. __string(dev_name, dev_name)
  61. __string(state, state)
  62. __string(clk, clk)
  63. __field(u32, prev_state)
  64. __field(u32, curr_state)
  65. ),
  66. TP_fast_assign(
  67. __assign_str(dev_name, dev_name);
  68. __assign_str(state, state);
  69. __assign_str(clk, clk);
  70. __entry->prev_state = prev_state;
  71. __entry->curr_state = curr_state;
  72. ),
  73. TP_printk("%s: %s %s from %u to %u Hz",
  74. __get_str(dev_name), __get_str(state), __get_str(clk),
  75. __entry->prev_state, __entry->curr_state)
  76. );
  77. DECLARE_EVENT_CLASS(ufshcd_profiling_template,
  78. TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
  79. int err),
  80. TP_ARGS(dev_name, profile_info, time_us, err),
  81. TP_STRUCT__entry(
  82. __string(dev_name, dev_name)
  83. __string(profile_info, profile_info)
  84. __field(s64, time_us)
  85. __field(int, err)
  86. ),
  87. TP_fast_assign(
  88. __assign_str(dev_name, dev_name);
  89. __assign_str(profile_info, profile_info);
  90. __entry->time_us = time_us;
  91. __entry->err = err;
  92. ),
  93. TP_printk("%s: %s: took %lld usecs, err %d",
  94. __get_str(dev_name), __get_str(profile_info),
  95. __entry->time_us, __entry->err)
  96. );
  97. DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_hibern8,
  98. TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
  99. int err),
  100. TP_ARGS(dev_name, profile_info, time_us, err));
  101. DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_gating,
  102. TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
  103. int err),
  104. TP_ARGS(dev_name, profile_info, time_us, err));
  105. DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_scaling,
  106. TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
  107. int err),
  108. TP_ARGS(dev_name, profile_info, time_us, err));
  109. DECLARE_EVENT_CLASS(ufshcd_template,
  110. TP_PROTO(const char *dev_name, int err, s64 usecs,
  111. int dev_state, int link_state),
  112. TP_ARGS(dev_name, err, usecs, dev_state, link_state),
  113. TP_STRUCT__entry(
  114. __field(s64, usecs)
  115. __field(int, err)
  116. __string(dev_name, dev_name)
  117. __field(int, dev_state)
  118. __field(int, link_state)
  119. ),
  120. TP_fast_assign(
  121. __entry->usecs = usecs;
  122. __entry->err = err;
  123. __assign_str(dev_name, dev_name);
  124. __entry->dev_state = dev_state;
  125. __entry->link_state = link_state;
  126. ),
  127. TP_printk(
  128. "%s: took %lld usecs, dev_state: %s, link_state: %s, err %d",
  129. __get_str(dev_name),
  130. __entry->usecs,
  131. __print_symbolic(__entry->dev_state,
  132. { UFS_ACTIVE_PWR_MODE, "ACTIVE" },
  133. { UFS_SLEEP_PWR_MODE, "SLEEP" },
  134. { UFS_POWERDOWN_PWR_MODE, "POWERDOWN" }),
  135. __print_symbolic(__entry->link_state,
  136. { UIC_LINK_OFF_STATE, "LINK_OFF" },
  137. { UIC_LINK_ACTIVE_STATE, "LINK_ACTIVE" },
  138. { UIC_LINK_HIBERN8_STATE, "LINK_HIBERN8" }),
  139. __entry->err
  140. )
  141. );
  142. DEFINE_EVENT(ufshcd_template, ufshcd_system_suspend,
  143. TP_PROTO(const char *dev_name, int err, s64 usecs,
  144. int dev_state, int link_state),
  145. TP_ARGS(dev_name, err, usecs, dev_state, link_state));
  146. DEFINE_EVENT(ufshcd_template, ufshcd_system_resume,
  147. TP_PROTO(const char *dev_name, int err, s64 usecs,
  148. int dev_state, int link_state),
  149. TP_ARGS(dev_name, err, usecs, dev_state, link_state));
  150. DEFINE_EVENT(ufshcd_template, ufshcd_runtime_suspend,
  151. TP_PROTO(const char *dev_name, int err, s64 usecs,
  152. int dev_state, int link_state),
  153. TP_ARGS(dev_name, err, usecs, dev_state, link_state));
  154. DEFINE_EVENT(ufshcd_template, ufshcd_runtime_resume,
  155. TP_PROTO(const char *dev_name, int err, s64 usecs,
  156. int dev_state, int link_state),
  157. TP_ARGS(dev_name, err, usecs, dev_state, link_state));
  158. DEFINE_EVENT(ufshcd_template, ufshcd_init,
  159. TP_PROTO(const char *dev_name, int err, s64 usecs,
  160. int dev_state, int link_state),
  161. TP_ARGS(dev_name, err, usecs, dev_state, link_state));
  162. TRACE_EVENT(ufshcd_command,
  163. TP_PROTO(const char *dev_name, const char *str, unsigned int tag,
  164. u32 doorbell, u32 transfer_len, u32 intr, u64 lba,
  165. u8 opcode),
  166. TP_ARGS(dev_name, str, tag, doorbell, transfer_len, intr, lba, opcode),
  167. TP_STRUCT__entry(
  168. __string(dev_name, dev_name)
  169. __string(str, str)
  170. __field(unsigned int, tag)
  171. __field(u32, doorbell)
  172. __field(u32, transfer_len)
  173. __field(u32, intr)
  174. __field(u64, lba)
  175. __field(u8, opcode)
  176. ),
  177. TP_fast_assign(
  178. __assign_str(dev_name, dev_name);
  179. __assign_str(str, str);
  180. __entry->tag = tag;
  181. __entry->doorbell = doorbell;
  182. __entry->transfer_len = transfer_len;
  183. __entry->intr = intr;
  184. __entry->lba = lba;
  185. __entry->opcode = opcode;
  186. ),
  187. TP_printk(
  188. "%s: %14s: tag: %-2u cmd: 0x%-2x lba: %-9llu size: %-7u DB: 0x%-8x IS: 0x%x",
  189. __get_str(dev_name), __get_str(str), __entry->tag,
  190. (u32)__entry->opcode, __entry->lba, __entry->transfer_len,
  191. __entry->doorbell, __entry->intr
  192. )
  193. );
  194. #endif /* if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ) */
  195. /* This part must be outside protection */
  196. #include <trace/define_trace.h>