mali_kbase_tlstream.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. /*
  2. *
  3. * (C) COPYRIGHT 2015-2016 ARM Limited. All rights reserved.
  4. *
  5. * This program is free software and is provided to you under the terms of the
  6. * GNU General Public License version 2 as published by the Free Software
  7. * Foundation, and any use by you of this program is subject to the terms
  8. * of such GNU licence.
  9. *
  10. * A copy of the licence is included with the program, and can also be obtained
  11. * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  12. * Boston, MA 02110-1301, USA.
  13. *
  14. */
  15. #ifndef _KBASE_TLSTREAM_H
  16. #define _KBASE_TLSTREAM_H
  17. #include <mali_kbase.h>
  18. /*****************************************************************************/
  19. /**
  20. * kbase_tlstream_init - initialize timeline infrastructure in kernel
  21. * Return: zero on success, negative number on error
  22. */
  23. int kbase_tlstream_init(void);
  24. /**
  25. * kbase_tlstream_term - terminate timeline infrastructure in kernel
  26. *
  27. * Timeline need have to been previously enabled with kbase_tlstream_init().
  28. */
  29. void kbase_tlstream_term(void);
  30. /**
  31. * kbase_tlstream_acquire - acquire timeline stream file descriptor
  32. * @kctx: kernel common context
  33. * @fd: timeline stream file descriptor
  34. *
  35. * This descriptor is meant to be used by userspace timeline to gain access to
  36. * kernel timeline stream. This stream is later broadcasted by user space to the
  37. * timeline client.
  38. * Only one entity can own the descriptor at any given time. Descriptor shall be
  39. * closed if unused. If descriptor cannot be obtained (i.e. when it is already
  40. * being used) argument fd will contain negative value.
  41. *
  42. * Return: zero on success (this does not necessarily mean that stream
  43. * descriptor could be returned), negative number on error
  44. */
  45. int kbase_tlstream_acquire(struct kbase_context *kctx, int *fd);
  46. /**
  47. * kbase_tlstream_flush_streams - flush timeline streams.
  48. *
  49. * Function will flush pending data in all timeline streams.
  50. */
  51. void kbase_tlstream_flush_streams(void);
  52. /**
  53. * kbase_tlstream_reset_body_streams - reset timeline body streams.
  54. *
  55. * Function will discard pending data in all timeline body streams.
  56. */
  57. void kbase_tlstream_reset_body_streams(void);
  58. /*****************************************************************************/
  59. void __kbase_tlstream_tl_summary_new_ctx(void *context, u32 nr, u32 tgid);
  60. void __kbase_tlstream_tl_summary_new_gpu(void *gpu, u32 id, u32 core_count);
  61. void __kbase_tlstream_tl_summary_new_lpu(void *lpu, u32 nr, u32 fn);
  62. void __kbase_tlstream_tl_summary_lifelink_lpu_gpu(void *lpu, void *gpu);
  63. void __kbase_tlstream_tl_summary_new_as(void *as, u32 nr);
  64. void __kbase_tlstream_tl_summary_lifelink_as_gpu(void *as, void *gpu);
  65. void __kbase_tlstream_tl_new_ctx(void *context, u32 nr, u32 tgid);
  66. void __kbase_tlstream_tl_new_atom(void *atom, u32 nr);
  67. void __kbase_tlstream_tl_del_ctx(void *context);
  68. void __kbase_tlstream_tl_del_atom(void *atom);
  69. void __kbase_tlstream_tl_ret_ctx_lpu(void *context, void *lpu);
  70. void __kbase_tlstream_tl_ret_atom_ctx(void *atom, void *context);
  71. void __kbase_tlstream_tl_ret_atom_lpu(
  72. void *atom, void *lpu, const char *attrib_match_list);
  73. void __kbase_tlstream_tl_nret_ctx_lpu(void *context, void *lpu);
  74. void __kbase_tlstream_tl_nret_atom_ctx(void *atom, void *context);
  75. void __kbase_tlstream_tl_nret_atom_lpu(void *atom, void *lpu);
  76. void __kbase_tlstream_tl_ret_as_ctx(void *as, void *ctx);
  77. void __kbase_tlstream_tl_nret_as_ctx(void *as, void *ctx);
  78. void __kbase_tlstream_tl_ret_atom_as(void *atom, void *as);
  79. void __kbase_tlstream_tl_nret_atom_as(void *atom, void *as);
  80. void __kbase_tlstream_tl_dep_atom_atom(void *atom1, void *atom2);
  81. void __kbase_tlstream_tl_ndep_atom_atom(void *atom1, void *atom2);
  82. void __kbase_tlstream_tl_rdep_atom_atom(void *atom1, void *atom2);
  83. void __kbase_tlstream_tl_attrib_atom_config(
  84. void *atom, u64 jd, u64 affinity, u32 config);
  85. void __kbase_tlstream_tl_attrib_as_config(
  86. void *as, u64 transtab, u64 memattr, u64 transcfg);
  87. void __kbase_tlstream_jd_gpu_soft_reset(void *gpu);
  88. void __kbase_tlstream_aux_pm_state(u32 core_type, u64 state);
  89. void __kbase_tlstream_aux_issue_job_softstop(void *katom);
  90. void __kbase_tlstream_aux_job_softstop(u32 js_id);
  91. void __kbase_tlstream_aux_job_softstop_ex(struct kbase_jd_atom *katom);
  92. void __kbase_tlstream_aux_pagefault(u32 ctx_nr, u64 page_count_change);
  93. void __kbase_tlstream_aux_pagesalloc(u32 ctx_nr, u64 page_count);
  94. extern atomic_t kbase_tlstream_enabled;
  95. #define __TRACE_IF_ENABLED(trace_name, ...) \
  96. do { \
  97. int enabled = atomic_read(&kbase_tlstream_enabled); \
  98. if (enabled) \
  99. __kbase_tlstream_##trace_name(__VA_ARGS__); \
  100. } while (0)
  101. /*****************************************************************************/
  102. /**
  103. * kbase_tlstream_tl_summary_new_ctx - create context object in timeline
  104. * summary
  105. * @context: name of the context object
  106. * @nr: context number
  107. * @tgid: thread Group Id
  108. *
  109. * Function emits a timeline message informing about context creation. Context
  110. * is created with context number (its attribute), that can be used to link
  111. * kbase context with userspace context.
  112. * This message is directed to timeline summary stream.
  113. */
  114. #define kbase_tlstream_tl_summary_new_ctx(context, nr, tgid) \
  115. __TRACE_IF_ENABLED(tl_summary_new_ctx, context, nr, tgid)
  116. /**
  117. * kbase_tlstream_tl_summary_new_gpu - create GPU object in timeline summary
  118. * @gpu: name of the GPU object
  119. * @id: id value of this GPU
  120. * @core_count: number of cores this GPU hosts
  121. *
  122. * Function emits a timeline message informing about GPU creation. GPU is
  123. * created with two attributes: id and core count.
  124. * This message is directed to timeline summary stream.
  125. */
  126. #define kbase_tlstream_tl_summary_new_gpu(gpu, id, core_count) \
  127. __TRACE_IF_ENABLED(tl_summary_new_gpu, gpu, id, core_count)
  128. /**
  129. * kbase_tlstream_tl_summary_new_lpu - create LPU object in timeline summary
  130. * @lpu: name of the Logical Processing Unit object
  131. * @nr: sequential number assigned to this LPU
  132. * @fn: property describing this LPU's functional abilities
  133. *
  134. * Function emits a timeline message informing about LPU creation. LPU is
  135. * created with two attributes: number linking this LPU with GPU's job slot
  136. * and function bearing information about this LPU abilities.
  137. * This message is directed to timeline summary stream.
  138. */
  139. #define kbase_tlstream_tl_summary_new_lpu(lpu, nr, fn) \
  140. __TRACE_IF_ENABLED(tl_summary_new_lpu, lpu, nr, fn)
  141. /**
  142. * kbase_tlstream_tl_summary_lifelink_lpu_gpu - lifelink LPU object to GPU
  143. * @lpu: name of the Logical Processing Unit object
  144. * @gpu: name of the GPU object
  145. *
  146. * Function emits a timeline message informing that LPU object shall be deleted
  147. * along with GPU object.
  148. * This message is directed to timeline summary stream.
  149. */
  150. #define kbase_tlstream_tl_summary_lifelink_lpu_gpu(lpu, gpu) \
  151. __TRACE_IF_ENABLED(tl_summary_lifelink_lpu_gpu, lpu, gpu)
  152. /**
  153. * kbase_tlstream_tl_summary_new_as - create address space object in timeline summary
  154. * @as: name of the address space object
  155. * @nr: sequential number assigned to this address space
  156. *
  157. * Function emits a timeline message informing about address space creation.
  158. * Address space is created with one attribute: number identifying this
  159. * address space.
  160. * This message is directed to timeline summary stream.
  161. */
  162. #define kbase_tlstream_tl_summary_new_as(as, nr) \
  163. __TRACE_IF_ENABLED(tl_summary_new_as, as, nr)
  164. /**
  165. * kbase_tlstream_tl_summary_lifelink_as_gpu - lifelink address space object to GPU
  166. * @as: name of the address space object
  167. * @gpu: name of the GPU object
  168. *
  169. * Function emits a timeline message informing that address space object
  170. * shall be deleted along with GPU object.
  171. * This message is directed to timeline summary stream.
  172. */
  173. #define kbase_tlstream_tl_summary_lifelink_as_gpu(as, gpu) \
  174. __TRACE_IF_ENABLED(tl_summary_lifelink_as_gpu, as, gpu)
  175. /**
  176. * kbase_tlstream_tl_new_ctx - create context object in timeline
  177. * @context: name of the context object
  178. * @nr: context number
  179. * @tgid: thread Group Id
  180. *
  181. * Function emits a timeline message informing about context creation. Context
  182. * is created with context number (its attribute), that can be used to link
  183. * kbase context with userspace context.
  184. */
  185. #define kbase_tlstream_tl_new_ctx(context, nr, tgid) \
  186. __TRACE_IF_ENABLED(tl_new_ctx, context, nr, tgid)
  187. /**
  188. * kbase_tlstream_tl_new_atom - create atom object in timeline
  189. * @atom: name of the atom object
  190. * @nr: sequential number assigned to this atom
  191. *
  192. * Function emits a timeline message informing about atom creation. Atom is
  193. * created with atom number (its attribute) that links it with actual work
  194. * bucket id understood by hardware.
  195. */
  196. #define kbase_tlstream_tl_new_atom(atom, nr) \
  197. __TRACE_IF_ENABLED(tl_new_atom, atom, nr)
  198. /**
  199. * kbase_tlstream_tl_del_ctx - destroy context object in timeline
  200. * @context: name of the context object
  201. *
  202. * Function emits a timeline message informing that context object ceased to
  203. * exist.
  204. */
  205. #define kbase_tlstream_tl_del_ctx(context) \
  206. __TRACE_IF_ENABLED(tl_del_ctx, context)
  207. /**
  208. * kbase_tlstream_tl_del_atom - destroy atom object in timeline
  209. * @atom: name of the atom object
  210. *
  211. * Function emits a timeline message informing that atom object ceased to
  212. * exist.
  213. */
  214. #define kbase_tlstream_tl_del_atom(atom) \
  215. __TRACE_IF_ENABLED(tl_del_atom, atom)
  216. /**
  217. * kbase_tlstream_tl_ret_ctx_lpu - retain context by LPU
  218. * @context: name of the context object
  219. * @lpu: name of the Logical Processing Unit object
  220. *
  221. * Function emits a timeline message informing that context is being held
  222. * by LPU and must not be deleted unless it is released.
  223. */
  224. #define kbase_tlstream_tl_ret_ctx_lpu(context, lpu) \
  225. __TRACE_IF_ENABLED(tl_ret_ctx_lpu, context, lpu)
  226. /**
  227. * kbase_tlstream_tl_ret_atom_ctx - retain atom by context
  228. * @atom: name of the atom object
  229. * @context: name of the context object
  230. *
  231. * Function emits a timeline message informing that atom object is being held
  232. * by context and must not be deleted unless it is released.
  233. */
  234. #define kbase_tlstream_tl_ret_atom_ctx(atom, context) \
  235. __TRACE_IF_ENABLED(tl_ret_atom_ctx, atom, context)
  236. /**
  237. * kbase_tlstream_tl_ret_atom_lpu - retain atom by LPU
  238. * @atom: name of the atom object
  239. * @lpu: name of the Logical Processing Unit object
  240. * @attrib_match_list: list containing match operator attributes
  241. *
  242. * Function emits a timeline message informing that atom object is being held
  243. * by LPU and must not be deleted unless it is released.
  244. */
  245. #define kbase_tlstream_tl_ret_atom_lpu(atom, lpu, attrib_match_list) \
  246. __TRACE_IF_ENABLED(tl_ret_atom_lpu, atom, lpu, attrib_match_list)
  247. /**
  248. * kbase_tlstream_tl_nret_ctx_lpu - release context by LPU
  249. * @context: name of the context object
  250. * @lpu: name of the Logical Processing Unit object
  251. *
  252. * Function emits a timeline message informing that context is being released
  253. * by LPU object.
  254. */
  255. #define kbase_tlstream_tl_nret_ctx_lpu(context, lpu) \
  256. __TRACE_IF_ENABLED(tl_nret_ctx_lpu, context, lpu)
  257. /**
  258. * kbase_tlstream_tl_nret_atom_ctx - release atom by context
  259. * @atom: name of the atom object
  260. * @context: name of the context object
  261. *
  262. * Function emits a timeline message informing that atom object is being
  263. * released by context.
  264. */
  265. #define kbase_tlstream_tl_nret_atom_ctx(atom, context) \
  266. __TRACE_IF_ENABLED(tl_nret_atom_ctx, atom, context)
  267. /**
  268. * kbase_tlstream_tl_nret_atom_lpu - release atom by LPU
  269. * @atom: name of the atom object
  270. * @lpu: name of the Logical Processing Unit object
  271. *
  272. * Function emits a timeline message informing that atom object is being
  273. * released by LPU.
  274. */
  275. #define kbase_tlstream_tl_nret_atom_lpu(atom, lpu) \
  276. __TRACE_IF_ENABLED(tl_nret_atom_lpu, atom, lpu)
  277. /**
  278. * kbase_tlstream_tl_ret_as_ctx - lifelink address space object to context
  279. * @as: name of the address space object
  280. * @ctx: name of the context object
  281. *
  282. * Function emits a timeline message informing that address space object
  283. * is being held by the context object.
  284. */
  285. #define kbase_tlstream_tl_ret_as_ctx(as, ctx) \
  286. __TRACE_IF_ENABLED(tl_ret_as_ctx, as, ctx)
  287. /**
  288. * kbase_tlstream_tl_nret_as_ctx - release address space by context
  289. * @as: name of the address space object
  290. * @ctx: name of the context object
  291. *
  292. * Function emits a timeline message informing that address space object
  293. * is being released by atom.
  294. */
  295. #define kbase_tlstream_tl_nret_as_ctx(as, ctx) \
  296. __TRACE_IF_ENABLED(tl_nret_as_ctx, as, ctx)
  297. /**
  298. * kbase_tlstream_tl_ret_atom_as - retain atom by address space
  299. * @atom: name of the atom object
  300. * @as: name of the address space object
  301. *
  302. * Function emits a timeline message informing that atom object is being held
  303. * by address space and must not be deleted unless it is released.
  304. */
  305. #define kbase_tlstream_tl_ret_atom_as(atom, as) \
  306. __TRACE_IF_ENABLED(tl_ret_atom_as, atom, as)
  307. /**
  308. * kbase_tlstream_tl_nret_atom_as - release atom by address space
  309. * @atom: name of the atom object
  310. * @as: name of the address space object
  311. *
  312. * Function emits a timeline message informing that atom object is being
  313. * released by address space.
  314. */
  315. #define kbase_tlstream_tl_nret_atom_as(atom, as) \
  316. __TRACE_IF_ENABLED(tl_nret_atom_as, atom, as)
  317. /**
  318. * kbase_tlstream_tl_dep_atom_atom - parent atom depends on child atom
  319. * @atom1: name of the child atom object
  320. * @atom2: name of the parent atom object that depends on child atom
  321. *
  322. * Function emits a timeline message informing that parent atom waits for
  323. * child atom object to be completed before start its execution.
  324. */
  325. #define kbase_tlstream_tl_dep_atom_atom(atom1, atom2) \
  326. __TRACE_IF_ENABLED(tl_dep_atom_atom, atom1, atom2)
  327. /**
  328. * kbase_tlstream_tl_ndep_atom_atom - dependency between atoms resolved
  329. * @atom1: name of the child atom object
  330. * @atom2: name of the parent atom object that depended on child atom
  331. *
  332. * Function emits a timeline message informing that parent atom execution
  333. * dependency on child atom has been resolved.
  334. */
  335. #define kbase_tlstream_tl_ndep_atom_atom(atom1, atom2) \
  336. __TRACE_IF_ENABLED(tl_ndep_atom_atom, atom1, atom2)
  337. /**
  338. * kbase_tlstream_tl_rdep_atom_atom - information about already resolved dependency between atoms
  339. * @atom1: name of the child atom object
  340. * @atom2: name of the parent atom object that depended on child atom
  341. *
  342. * Function emits a timeline message informing that parent atom execution
  343. * dependency on child atom has been resolved.
  344. */
  345. #define kbase_tlstream_tl_rdep_atom_atom(atom1, atom2) \
  346. __TRACE_IF_ENABLED(tl_rdep_atom_atom, atom1, atom2)
  347. /**
  348. * kbase_tlstream_tl_attrib_atom_config - atom job slot attributes
  349. * @atom: name of the atom object
  350. * @jd: job descriptor address
  351. * @affinity: job affinity
  352. * @config: job config
  353. *
  354. * Function emits a timeline message containing atom attributes.
  355. */
  356. #define kbase_tlstream_tl_attrib_atom_config(atom, jd, affinity, config) \
  357. __TRACE_IF_ENABLED(tl_attrib_atom_config, atom, jd, affinity, config)
  358. /**
  359. * kbase_tlstream_tl_attrib_as_config - address space attributes
  360. * @as: assigned address space
  361. * @transtab: configuration of the TRANSTAB register
  362. * @memattr: configuration of the MEMATTR register
  363. * @transcfg: configuration of the TRANSCFG register (or zero if not present)
  364. *
  365. * Function emits a timeline message containing address space attributes.
  366. */
  367. #define kbase_tlstream_tl_attrib_as_config(as, transtab, memattr, transcfg) \
  368. __TRACE_IF_ENABLED(tl_attrib_as_config, as, transtab, memattr, transcfg)
  369. /**
  370. * kbase_tlstream_jd_gpu_soft_reset - The GPU is being soft reset
  371. * @gpu: name of the GPU object
  372. *
  373. * This imperative tracepoint is specific to job dumping.
  374. * Function emits a timeline message indicating GPU soft reset.
  375. */
  376. #define kbase_tlstream_jd_gpu_soft_reset(gpu) \
  377. __TRACE_IF_ENABLED(jd_gpu_soft_reset, gpu)
  378. /**
  379. * kbase_tlstream_aux_pm_state - timeline message: power management state
  380. * @core_type: core type (shader, tiler, l2 cache, l3 cache)
  381. * @state: 64bits bitmask reporting power state of the cores (1-ON, 0-OFF)
  382. */
  383. #define kbase_tlstream_aux_pm_state(core_type, state) \
  384. __TRACE_IF_ENABLED(aux_pm_state, core_type, state)
  385. /**
  386. * kbase_tlstream_aux_issue_job_softstop - a soft-stop command is being issued
  387. * @katom: the atom that is being soft-stopped
  388. */
  389. #define kbase_tlstream_aux_issue_job_softstop(katom) \
  390. __TRACE_IF_ENABLED(aux_issue_job_softstop, katom)
  391. /**
  392. * kbase_tlstream_aux_job_softstop - soft job stop occurred
  393. * @js_id: job slot id
  394. */
  395. #define kbase_tlstream_aux_job_softstop(js_id) \
  396. __TRACE_IF_ENABLED(aux_job_softstop, js_id)
  397. /**
  398. * kbase_tlstream_aux_job_softstop_ex - extra info about soft-stopped atom
  399. * @katom: the atom that has been soft-stopped
  400. *
  401. * This trace point adds more details about the soft-stopped atom. These details
  402. * can't be safety collected inside the interrupt handler so we're doing it
  403. * inside a worker.
  404. *
  405. * Note: this is not the same information that is recorded in the trace point,
  406. * refer to __kbase_tlstream_aux_job_softstop_ex() for more details.
  407. */
  408. #define kbase_tlstream_aux_job_softstop_ex(katom) \
  409. __TRACE_IF_ENABLED(aux_job_softstop_ex, katom)
  410. /**
  411. * kbase_tlstream_aux_pagefault - timeline message: MMU page fault event
  412. * resulting in new pages being mapped
  413. * @ctx_nr: kernel context number
  414. * @page_count_change: number of pages to be added
  415. */
  416. #define kbase_tlstream_aux_pagefault(ctx_nr, page_count_change) \
  417. __TRACE_IF_ENABLED(aux_pagefault, ctx_nr, page_count_change)
  418. /**
  419. * kbase_tlstream_aux_pagesalloc - timeline message: total number of allocated
  420. * pages is changed
  421. * @ctx_nr: kernel context number
  422. * @page_count: number of pages used by the context
  423. */
  424. #define kbase_tlstream_aux_pagesalloc(ctx_nr, page_count) \
  425. __TRACE_IF_ENABLED(aux_pagesalloc, ctx_nr, page_count)
  426. #endif // ifndef _KBASE_TLSTREAM_H