fastrpc_trace.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #if !defined(TRACE_FASTRPC_H) || defined(TRACE_HEADER_MULTI_READ)
  7. #define TRACE_FASTRPC_H
  8. #undef TRACE_SYSTEM
  9. #define TRACE_SYSTEM fastrpc
  10. /*
  11. * Path must be relative to location of 'define_trace.h' header in kernel
  12. * Define path if not defined in bazel file
  13. */
  14. #ifndef DSP_TRACE_INCLUDE_PATH
  15. #define DSP_TRACE_INCLUDE_PATH ../../../../sm8650-modules/qcom/opensource/dsp-kernel/dsp
  16. #endif
  17. #undef TRACE_INCLUDE_PATH
  18. #define TRACE_INCLUDE_PATH DSP_TRACE_INCLUDE_PATH
  19. /* Name of trace header file */
  20. #undef TRACE_INCLUDE_FILE
  21. #define TRACE_INCLUDE_FILE fastrpc_trace
  22. #include <linux/tracepoint.h>
  23. TRACE_EVENT(fastrpc_transport_send,
  24. TP_PROTO(int cid, uint64_t smq_ctx,
  25. uint64_t ctx, uint32_t handle,
  26. uint32_t sc, uint64_t addr, uint64_t size),
  27. TP_ARGS(cid, smq_ctx, ctx, handle, sc, addr, size),
  28. TP_STRUCT__entry(
  29. __field(int, cid)
  30. __field(u64, smq_ctx)
  31. __field(u64, ctx)
  32. __field(u32, handle)
  33. __field(u32, sc)
  34. __field(u64, addr)
  35. __field(u64, size)
  36. ),
  37. TP_fast_assign(
  38. __entry->cid = cid;
  39. __entry->smq_ctx = smq_ctx;
  40. __entry->ctx = ctx;
  41. __entry->handle = handle;
  42. __entry->sc = sc;
  43. __entry->addr = addr;
  44. __entry->size = size;
  45. ),
  46. TP_printk("to cid %d: smq_ctx 0x%llx, ctx 0x%llx, handle 0x%x, sc 0x%x, addr 0x%llx, size %llu",
  47. __entry->cid, __entry->smq_ctx, __entry->ctx, __entry->handle,
  48. __entry->sc, __entry->addr, __entry->size)
  49. );
  50. TRACE_EVENT(fastrpc_transport_response,
  51. TP_PROTO(int cid, uint64_t ctx, int retval,
  52. uint32_t rsp_flags, uint32_t early_wake_time),
  53. TP_ARGS(cid, ctx, retval, rsp_flags, early_wake_time),
  54. TP_STRUCT__entry(
  55. __field(int, cid)
  56. __field(u64, ctx)
  57. __field(int, retval)
  58. __field(u32, rsp_flags)
  59. __field(u32, early_wake_time)
  60. ),
  61. TP_fast_assign(
  62. __entry->cid = cid;
  63. __entry->ctx = ctx;
  64. __entry->retval = retval;
  65. __entry->rsp_flags = rsp_flags;
  66. __entry->early_wake_time = early_wake_time;
  67. ),
  68. TP_printk("from cid %d: ctx 0x%llx, retval 0x%x, rsp_flags %u, early_wake_time %u",
  69. __entry->cid, __entry->ctx, __entry->retval,
  70. __entry->rsp_flags, __entry->early_wake_time)
  71. );
  72. TRACE_EVENT(fastrpc_context_interrupt,
  73. TP_PROTO(int cid, uint64_t smq_ctx, uint64_t ctx,
  74. uint32_t handle, uint32_t sc),
  75. TP_ARGS(cid, smq_ctx, ctx, handle, sc),
  76. TP_STRUCT__entry(
  77. __field(int, cid)
  78. __field(u64, smq_ctx)
  79. __field(u64, ctx)
  80. __field(u32, handle)
  81. __field(u32, sc)
  82. ),
  83. TP_fast_assign(
  84. __entry->cid = cid;
  85. __entry->smq_ctx = smq_ctx;
  86. __entry->ctx = ctx;
  87. __entry->handle = handle;
  88. __entry->sc = sc;
  89. ),
  90. TP_printk("to cid %d: smq_ctx 0x%llx, ctx 0x%llx, handle 0x%x, sc 0x%x",
  91. __entry->cid, __entry->smq_ctx,
  92. __entry->ctx, __entry->handle, __entry->sc)
  93. );
  94. TRACE_EVENT(fastrpc_context_restore,
  95. TP_PROTO(int cid, uint64_t smq_ctx, uint64_t ctx,
  96. uint32_t handle, uint32_t sc),
  97. TP_ARGS(cid, smq_ctx, ctx, handle, sc),
  98. TP_STRUCT__entry(
  99. __field(int, cid)
  100. __field(u64, smq_ctx)
  101. __field(u64, ctx)
  102. __field(u32, handle)
  103. __field(u32, sc)
  104. ),
  105. TP_fast_assign(
  106. __entry->cid = cid;
  107. __entry->smq_ctx = smq_ctx;
  108. __entry->ctx = ctx;
  109. __entry->handle = handle;
  110. __entry->sc = sc;
  111. ),
  112. TP_printk("for cid %d: smq_ctx 0x%llx, ctx 0x%llx, handle 0x%x, sc 0x%x",
  113. __entry->cid, __entry->smq_ctx,
  114. __entry->ctx, __entry->handle, __entry->sc)
  115. );
  116. TRACE_EVENT(fastrpc_dma_map,
  117. TP_PROTO(int cid, int fd, uint64_t phys, size_t size,
  118. size_t len, unsigned int attr, int mflags),
  119. TP_ARGS(cid, fd, phys, size, len, attr, mflags),
  120. TP_STRUCT__entry(
  121. __field(int, cid)
  122. __field(int, fd)
  123. __field(u64, phys)
  124. __field(size_t, size)
  125. __field(size_t, len)
  126. __field(unsigned int, attr)
  127. __field(int, mflags)
  128. ),
  129. TP_fast_assign(
  130. __entry->cid = cid;
  131. __entry->fd = fd;
  132. __entry->phys = phys;
  133. __entry->size = size;
  134. __entry->len = len;
  135. __entry->attr = attr;
  136. __entry->mflags = mflags;
  137. ),
  138. TP_printk("cid %d, fd %d, phys 0x%llx, size %zu (len %zu), attr 0x%x, flags 0x%x",
  139. __entry->cid, __entry->fd, __entry->phys, __entry->size,
  140. __entry->len, __entry->attr, __entry->mflags)
  141. );
  142. TRACE_EVENT(fastrpc_dma_unmap,
  143. TP_PROTO(int cid, uint64_t phys, size_t size),
  144. TP_ARGS(cid, phys, size),
  145. TP_STRUCT__entry(
  146. __field(int, cid)
  147. __field(u64, phys)
  148. __field(size_t, size)
  149. ),
  150. TP_fast_assign(
  151. __entry->cid = cid;
  152. __entry->phys = phys;
  153. __entry->size = size;
  154. ),
  155. TP_printk("cid %d, phys 0x%llx, size %zu",
  156. __entry->cid, __entry->phys, __entry->size)
  157. );
  158. TRACE_EVENT(fastrpc_dma_alloc,
  159. TP_PROTO(int cid, uint64_t phys, size_t size,
  160. unsigned long attr, int mflags),
  161. TP_ARGS(cid, phys, size, attr, mflags),
  162. TP_STRUCT__entry(
  163. __field(int, cid)
  164. __field(u64, phys)
  165. __field(size_t, size)
  166. __field(unsigned long, attr)
  167. __field(int, mflags)
  168. ),
  169. TP_fast_assign(
  170. __entry->cid = cid;
  171. __entry->phys = phys;
  172. __entry->size = size;
  173. __entry->attr = attr;
  174. __entry->mflags = mflags;
  175. ),
  176. TP_printk("cid %d, phys 0x%llx, size %zu, attr 0x%lx, flags 0x%x",
  177. __entry->cid, __entry->phys, __entry->size,
  178. __entry->attr, __entry->mflags)
  179. );
  180. TRACE_EVENT(fastrpc_dma_free,
  181. TP_PROTO(int cid, uint64_t phys, size_t size),
  182. TP_ARGS(cid, phys, size),
  183. TP_STRUCT__entry(
  184. __field(int, cid)
  185. __field(u64, phys)
  186. __field(size_t, size)
  187. ),
  188. TP_fast_assign(
  189. __entry->cid = cid;
  190. __entry->phys = phys;
  191. __entry->size = size;
  192. ),
  193. TP_printk("cid %d, phys 0x%llx, size %zu",
  194. __entry->cid, __entry->phys, __entry->size)
  195. );
  196. TRACE_EVENT(fastrpc_context_complete,
  197. TP_PROTO(int cid, uint64_t smq_ctx, int retval,
  198. uint64_t ctx, uint32_t handle, uint32_t sc),
  199. TP_ARGS(cid, smq_ctx, retval, ctx, handle, sc),
  200. TP_STRUCT__entry(
  201. __field(int, cid)
  202. __field(u64, smq_ctx)
  203. __field(int, retval)
  204. __field(u64, ctx)
  205. __field(u32, handle)
  206. __field(u32, sc)
  207. ),
  208. TP_fast_assign(
  209. __entry->cid = cid;
  210. __entry->smq_ctx = smq_ctx;
  211. __entry->retval = retval;
  212. __entry->ctx = ctx;
  213. __entry->handle = handle;
  214. __entry->sc = sc;
  215. ),
  216. TP_printk("from cid %d: smq_ctx 0x%llx, retval 0x%x, ctx 0x%llx, handle 0x%x, sc 0x%x",
  217. __entry->cid, __entry->smq_ctx, __entry->retval,
  218. __entry->ctx, __entry->handle, __entry->sc)
  219. );
  220. TRACE_EVENT(fastrpc_context_alloc,
  221. TP_PROTO(uint64_t smq_ctx, uint64_t ctx,
  222. uint32_t handle, uint32_t sc),
  223. TP_ARGS(smq_ctx, ctx, handle, sc),
  224. TP_STRUCT__entry(
  225. __field(u64, smq_ctx)
  226. __field(u64, ctx)
  227. __field(u32, handle)
  228. __field(u32, sc)
  229. ),
  230. TP_fast_assign(
  231. __entry->smq_ctx = smq_ctx;
  232. __entry->ctx = ctx;
  233. __entry->handle = handle;
  234. __entry->sc = sc;
  235. ),
  236. TP_printk("for: smq_ctx 0x%llx, ctx 0x%llx, handle 0x%x, sc 0x%x",
  237. __entry->smq_ctx, __entry->ctx, __entry->handle, __entry->sc)
  238. );
  239. TRACE_EVENT(fastrpc_context_free,
  240. TP_PROTO(uint64_t smq_ctx, uint64_t ctx,
  241. uint32_t handle, uint32_t sc),
  242. TP_ARGS(smq_ctx, ctx, handle, sc),
  243. TP_STRUCT__entry(
  244. __field(u64, smq_ctx)
  245. __field(u64, ctx)
  246. __field(u32, handle)
  247. __field(u32, sc)
  248. ),
  249. TP_fast_assign(
  250. __entry->smq_ctx = smq_ctx;
  251. __entry->ctx = ctx;
  252. __entry->handle = handle;
  253. __entry->sc = sc;
  254. ),
  255. TP_printk("for: smq_ctx 0x%llx, ctx 0x%llx, handle 0x%x, sc 0x%x",
  256. __entry->smq_ctx, __entry->ctx, __entry->handle, __entry->sc)
  257. );
  258. TRACE_EVENT(fastrpc_perf_counters,
  259. TP_PROTO(uint32_t handle, uint32_t sc,
  260. uint64_t count, uint64_t flush, uint64_t map,
  261. uint64_t copy, uint64_t link, uint64_t getargs,
  262. uint64_t putargs, uint64_t invargs, uint64_t invoke,
  263. uint64_t tid),
  264. TP_ARGS(handle, sc, count, flush, map, copy, link, getargs,
  265. putargs, invargs, invoke, tid),
  266. TP_STRUCT__entry(
  267. __field(u32, handle)
  268. __field(u32, sc)
  269. __field(u64, count)
  270. __field(u64, flush)
  271. __field(u64, map)
  272. __field(u64, copy)
  273. __field(u64, link)
  274. __field(u64, getargs)
  275. __field(u64, putargs)
  276. __field(u64, invargs)
  277. __field(u64, invoke)
  278. __field(u64, tid)
  279. ),
  280. TP_fast_assign(
  281. __entry->handle = handle;
  282. __entry->sc = sc;
  283. __entry->count = count;
  284. __entry->flush = flush;
  285. __entry->map = map;
  286. __entry->copy = copy;
  287. __entry->link = link;
  288. __entry->getargs = getargs;
  289. __entry->putargs = putargs;
  290. __entry->invargs = invargs;
  291. __entry->invoke = invoke;
  292. __entry->tid = tid;
  293. ),
  294. TP_printk("for: handle 0x%x, sc 0x%x, count %lld, flush %lld ns, map %lld ns, copy %lld ns, link %lld ns, getargs %lld ns, putargs %lld ns, invargs %lld ns, invoke %lld ns, tid %lld",
  295. __entry->handle, __entry->sc, __entry->count,
  296. __entry->flush, __entry->map, __entry->copy, __entry->link,
  297. __entry->getargs, __entry->putargs, __entry->invargs,
  298. __entry->invoke, __entry->tid)
  299. );
  300. TRACE_EVENT(fastrpc_msg,
  301. TP_PROTO(const char *message),
  302. TP_ARGS(message),
  303. TP_STRUCT__entry(__string(buf, message)),
  304. TP_fast_assign(
  305. #if IS_ENABLED(CONFIG_MSM_ADSPRPC_TRUSTED)
  306. memcpy(__get_str(buf), (message), (sizeof(message) - 1));
  307. __get_str(buf)[sizeof(message) - 1] = '\0';
  308. #else
  309. if (message)
  310. __assign_str_len(buf, message, (sizeof(message) - 1));
  311. else
  312. memcpy(__get_str(buf), "(null)", sizeof("(null)"));
  313. #endif
  314. ),
  315. TP_printk(" %s", __get_str(buf))
  316. );
  317. TRACE_EVENT(fastrpc_dspsignal,
  318. TP_PROTO(const char *event, uint32_t signal_id,
  319. int state, uint32_t timeout),
  320. TP_ARGS(event, signal_id, state, timeout),
  321. TP_STRUCT__entry(
  322. __string(buf, event)
  323. __field(u32, signal_id)
  324. __field(int, state)
  325. __field(u32, timeout)
  326. ),
  327. TP_fast_assign(
  328. #if IS_ENABLED(CONFIG_MSM_ADSPRPC_TRUSTED)
  329. memcpy(__get_str(buf), (event), (sizeof(event) - 1));
  330. __get_str(buf)[sizeof(event) - 1] = '\0';
  331. #else
  332. if (event)
  333. __assign_str_len(buf, event, (sizeof(event) - 1));
  334. else
  335. memcpy(__get_str(buf), "(null)", sizeof("(null)"));
  336. #endif
  337. __entry->signal_id = signal_id;
  338. __entry->state = state;
  339. __entry->timeout = timeout;
  340. ),
  341. TP_printk("%s for sig id %u, state %d, timeout %u",
  342. __get_str(buf), __entry->signal_id, __entry->state, __entry->timeout)
  343. );
  344. #endif
  345. /* This part must be outside protection */
  346. #include <trace/define_trace.h>