3 * (C) COPYRIGHT 2015-2016 ARM Limited. All rights reserved.
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
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.
18 #if !defined(_KBASE_TLSTREAM_H)
19 #define _KBASE_TLSTREAM_H
21 #include <mali_kbase.h>
23 /*****************************************************************************/
26 * kbase_tlstream_init - initialize timeline infrastructure in kernel
27 * Return: zero on success, negative number on error
29 int kbase_tlstream_init(void);
32 * kbase_tlstream_term - terminate timeline infrastructure in kernel
34 * Timeline need have to been previously enabled with kbase_tlstream_init().
36 void kbase_tlstream_term(void);
39 * kbase_tlstream_acquire - acquire timeline stream file descriptor
40 * @kctx: kernel common context
41 * @fd: timeline stream file descriptor
43 * This descriptor is meant to be used by userspace timeline to gain access to
44 * kernel timeline stream. This stream is later broadcasted by user space to the
46 * Only one entity can own the descriptor at any given time. Descriptor shall be
47 * closed if unused. If descriptor cannot be obtained (i.e. when it is already
48 * being used) argument fd will contain negative value.
50 * Return: zero on success (this does not necessarily mean that stream
51 * descriptor could be returned), negative number on error
53 int kbase_tlstream_acquire(struct kbase_context *kctx, int *fd);
56 * kbase_tlstream_flush_streams - flush timeline streams.
58 * Function will flush pending data in all timeline streams.
60 void kbase_tlstream_flush_streams(void);
63 * kbase_tlstream_reset_body_streams - reset timeline body streams.
65 * Function will discard pending data in all timeline body streams.
67 void kbase_tlstream_reset_body_streams(void);
71 * kbase_tlstream_test - start timeline stream data generator
72 * @tpw_count: number of trace point writers in each context
73 * @msg_delay: time delay in milliseconds between trace points written by one
75 * @msg_count: number of trace points written by one writer
76 * @aux_msg: if non-zero aux messages will be included
78 * This test starts a requested number of asynchronous writers in both IRQ and
79 * thread context. Each writer will generate required number of test
80 * tracepoints (tracepoints with embedded information about writer that
81 * should be verified by user space reader). Tracepoints will be emitted in
82 * all timeline body streams. If aux_msg is non-zero writer will also
83 * generate not testable tracepoints (tracepoints without information about
84 * writer). These tracepoints are used to check correctness of remaining
85 * timeline message generating functions. Writer will wait requested time
86 * between generating another set of messages. This call blocks until all
89 void kbase_tlstream_test(
90 unsigned int tpw_count,
91 unsigned int msg_delay,
92 unsigned int msg_count,
96 * kbase_tlstream_stats - read timeline stream statistics
97 * @bytes_collected: will hold number of bytes read by the user
98 * @bytes_generated: will hold number of bytes generated by trace points
100 void kbase_tlstream_stats(u32 *bytes_collected, u32 *bytes_generated);
101 #endif /* MALI_UNIT_TEST */
103 /*****************************************************************************/
105 void __kbase_tlstream_tl_summary_new_ctx(void *context, u32 nr, u32 tgid);
106 void __kbase_tlstream_tl_summary_new_gpu(void *gpu, u32 id, u32 core_count);
107 void __kbase_tlstream_tl_summary_new_lpu(void *lpu, u32 nr, u32 fn);
108 void __kbase_tlstream_tl_summary_lifelink_lpu_gpu(void *lpu, void *gpu);
109 void __kbase_tlstream_tl_summary_new_as(void *as, u32 nr);
110 void __kbase_tlstream_tl_summary_lifelink_as_gpu(void *as, void *gpu);
111 void __kbase_tlstream_tl_new_ctx(void *context, u32 nr, u32 tgid);
112 void __kbase_tlstream_tl_new_atom(void *atom, u32 nr);
113 void __kbase_tlstream_tl_del_ctx(void *context);
114 void __kbase_tlstream_tl_del_atom(void *atom);
115 void __kbase_tlstream_tl_ret_ctx_lpu(void *context, void *lpu);
116 void __kbase_tlstream_tl_ret_atom_ctx(void *atom, void *context);
117 void __kbase_tlstream_tl_ret_atom_lpu(
118 void *atom, void *lpu, const char *attrib_match_list);
119 void __kbase_tlstream_tl_nret_ctx_lpu(void *context, void *lpu);
120 void __kbase_tlstream_tl_nret_atom_ctx(void *atom, void *context);
121 void __kbase_tlstream_tl_nret_atom_lpu(void *atom, void *lpu);
122 void __kbase_tlstream_tl_ret_as_ctx(void *as, void *ctx);
123 void __kbase_tlstream_tl_nret_as_ctx(void *as, void *ctx);
124 void __kbase_tlstream_tl_ret_atom_as(void *atom, void *as);
125 void __kbase_tlstream_tl_nret_atom_as(void *atom, void *as);
126 void __kbase_tlstream_tl_dep_atom_atom(void *atom1, void *atom2);
127 void __kbase_tlstream_tl_ndep_atom_atom(void *atom1, void *atom2);
128 void __kbase_tlstream_tl_rdep_atom_atom(void *atom1, void *atom2);
129 void __kbase_tlstream_tl_attrib_atom_config(
130 void *atom, u64 jd, u64 affinity, u32 config);
131 void __kbase_tlstream_tl_attrib_as_config(
132 void *as, u64 transtab, u64 memattr, u64 transcfg);
133 void __kbase_tlstream_jd_gpu_soft_reset(void *gpu);
134 void __kbase_tlstream_aux_pm_state(u32 core_type, u64 state);
135 void __kbase_tlstream_aux_issue_job_softstop(void *katom);
136 void __kbase_tlstream_aux_job_softstop(u32 js_id);
137 void __kbase_tlstream_aux_job_softstop_ex(struct kbase_jd_atom *katom);
138 void __kbase_tlstream_aux_pagefault(u32 ctx_nr, u64 page_count_change);
139 void __kbase_tlstream_aux_pagesalloc(u32 ctx_nr, u64 page_count);
141 extern atomic_t kbase_tlstream_enabled;
143 #define __TRACE_IF_ENABLED(trace_name, ...) \
145 int enabled = atomic_read(&kbase_tlstream_enabled); \
147 __kbase_tlstream_##trace_name(__VA_ARGS__); \
150 /*****************************************************************************/
153 * kbase_tlstream_tl_summary_new_ctx - create context object in timeline
155 * @context: name of the context object
156 * @nr: context number
157 * @tgid: thread Group Id
159 * Function emits a timeline message informing about context creation. Context
160 * is created with context number (its attribute), that can be used to link
161 * kbase context with userspace context.
162 * This message is directed to timeline summary stream.
164 #define kbase_tlstream_tl_summary_new_ctx(context, nr, tgid) \
165 __TRACE_IF_ENABLED(tl_summary_new_ctx, context, nr, tgid)
168 * kbase_tlstream_tl_summary_new_gpu - create GPU object in timeline summary
169 * @gpu: name of the GPU object
170 * @id: id value of this GPU
171 * @core_count: number of cores this GPU hosts
173 * Function emits a timeline message informing about GPU creation. GPU is
174 * created with two attributes: id and core count.
175 * This message is directed to timeline summary stream.
177 #define kbase_tlstream_tl_summary_new_gpu(gpu, id, core_count) \
178 __TRACE_IF_ENABLED(tl_summary_new_gpu, gpu, id, core_count)
181 * kbase_tlstream_tl_summary_new_lpu - create LPU object in timeline summary
182 * @lpu: name of the Logical Processing Unit object
183 * @nr: sequential number assigned to this LPU
184 * @fn: property describing this LPU's functional abilities
186 * Function emits a timeline message informing about LPU creation. LPU is
187 * created with two attributes: number linking this LPU with GPU's job slot
188 * and function bearing information about this LPU abilities.
189 * This message is directed to timeline summary stream.
191 #define kbase_tlstream_tl_summary_new_lpu(lpu, nr, fn) \
192 __TRACE_IF_ENABLED(tl_summary_new_lpu, lpu, nr, fn)
195 * kbase_tlstream_tl_summary_lifelink_lpu_gpu - lifelink LPU object to GPU
196 * @lpu: name of the Logical Processing Unit object
197 * @gpu: name of the GPU object
199 * Function emits a timeline message informing that LPU object shall be deleted
200 * along with GPU object.
201 * This message is directed to timeline summary stream.
203 #define kbase_tlstream_tl_summary_lifelink_lpu_gpu(lpu, gpu) \
204 __TRACE_IF_ENABLED(tl_summary_lifelink_lpu_gpu, lpu, gpu)
207 * kbase_tlstream_tl_summary_new_as - create address space object in timeline summary
208 * @as: name of the address space object
209 * @nr: sequential number assigned to this address space
211 * Function emits a timeline message informing about address space creation.
212 * Address space is created with one attribute: number identifying this
214 * This message is directed to timeline summary stream.
216 #define kbase_tlstream_tl_summary_new_as(as, nr) \
217 __TRACE_IF_ENABLED(tl_summary_new_as, as, nr)
220 * kbase_tlstream_tl_summary_lifelink_as_gpu - lifelink address space object to GPU
221 * @as: name of the address space object
222 * @gpu: name of the GPU object
224 * Function emits a timeline message informing that address space object
225 * shall be deleted along with GPU object.
226 * This message is directed to timeline summary stream.
228 #define kbase_tlstream_tl_summary_lifelink_as_gpu(as, gpu) \
229 __TRACE_IF_ENABLED(tl_summary_lifelink_as_gpu, as, gpu)
232 * kbase_tlstream_tl_new_ctx - create context object in timeline
233 * @context: name of the context object
234 * @nr: context number
235 * @tgid: thread Group Id
237 * Function emits a timeline message informing about context creation. Context
238 * is created with context number (its attribute), that can be used to link
239 * kbase context with userspace context.
241 #define kbase_tlstream_tl_new_ctx(context, nr, tgid) \
242 __TRACE_IF_ENABLED(tl_new_ctx, context, nr, tgid)
245 * kbase_tlstream_tl_new_atom - create atom object in timeline
246 * @atom: name of the atom object
247 * @nr: sequential number assigned to this atom
249 * Function emits a timeline message informing about atom creation. Atom is
250 * created with atom number (its attribute) that links it with actual work
251 * bucket id understood by hardware.
253 #define kbase_tlstream_tl_new_atom(atom, nr) \
254 __TRACE_IF_ENABLED(tl_new_atom, atom, nr)
257 * kbase_tlstream_tl_del_ctx - destroy context object in timeline
258 * @context: name of the context object
260 * Function emits a timeline message informing that context object ceased to
263 #define kbase_tlstream_tl_del_ctx(context) \
264 __TRACE_IF_ENABLED(tl_del_ctx, context)
267 * kbase_tlstream_tl_del_atom - destroy atom object in timeline
268 * @atom: name of the atom object
270 * Function emits a timeline message informing that atom object ceased to
273 #define kbase_tlstream_tl_del_atom(atom) \
274 __TRACE_IF_ENABLED(tl_del_atom, atom)
277 * kbase_tlstream_tl_ret_ctx_lpu - retain context by LPU
278 * @context: name of the context object
279 * @lpu: name of the Logical Processing Unit object
281 * Function emits a timeline message informing that context is being held
282 * by LPU and must not be deleted unless it is released.
284 #define kbase_tlstream_tl_ret_ctx_lpu(context, lpu) \
285 __TRACE_IF_ENABLED(tl_ret_ctx_lpu, context, lpu)
288 * kbase_tlstream_tl_ret_atom_ctx - retain atom by context
289 * @atom: name of the atom object
290 * @context: name of the context object
292 * Function emits a timeline message informing that atom object is being held
293 * by context and must not be deleted unless it is released.
295 #define kbase_tlstream_tl_ret_atom_ctx(atom, context) \
296 __TRACE_IF_ENABLED(tl_ret_atom_ctx, atom, context)
299 * kbase_tlstream_tl_ret_atom_lpu - retain atom by LPU
300 * @atom: name of the atom object
301 * @lpu: name of the Logical Processing Unit object
302 * @attrib_match_list: list containing match operator attributes
304 * Function emits a timeline message informing that atom object is being held
305 * by LPU and must not be deleted unless it is released.
307 #define kbase_tlstream_tl_ret_atom_lpu(atom, lpu, attrib_match_list) \
308 __TRACE_IF_ENABLED(tl_ret_atom_lpu, atom, lpu, attrib_match_list)
311 * kbase_tlstream_tl_nret_ctx_lpu - release context by LPU
312 * @context: name of the context object
313 * @lpu: name of the Logical Processing Unit object
315 * Function emits a timeline message informing that context is being released
318 #define kbase_tlstream_tl_nret_ctx_lpu(context, lpu) \
319 __TRACE_IF_ENABLED(tl_nret_ctx_lpu, context, lpu)
322 * kbase_tlstream_tl_nret_atom_ctx - release atom by context
323 * @atom: name of the atom object
324 * @context: name of the context object
326 * Function emits a timeline message informing that atom object is being
327 * released by context.
329 #define kbase_tlstream_tl_nret_atom_ctx(atom, context) \
330 __TRACE_IF_ENABLED(tl_nret_atom_ctx, atom, context)
333 * kbase_tlstream_tl_nret_atom_lpu - release atom by LPU
334 * @atom: name of the atom object
335 * @lpu: name of the Logical Processing Unit object
337 * Function emits a timeline message informing that atom object is being
340 #define kbase_tlstream_tl_nret_atom_lpu(atom, lpu) \
341 __TRACE_IF_ENABLED(tl_nret_atom_lpu, atom, lpu)
344 * kbase_tlstream_tl_ret_as_ctx - lifelink address space object to context
345 * @as: name of the address space object
346 * @ctx: name of the context object
348 * Function emits a timeline message informing that address space object
349 * is being held by the context object.
351 #define kbase_tlstream_tl_ret_as_ctx(as, ctx) \
352 __TRACE_IF_ENABLED(tl_ret_as_ctx, as, ctx)
355 * kbase_tlstream_tl_nret_as_ctx - release address space by context
356 * @as: name of the address space object
357 * @ctx: name of the context object
359 * Function emits a timeline message informing that address space object
360 * is being released by atom.
362 #define kbase_tlstream_tl_nret_as_ctx(as, ctx) \
363 __TRACE_IF_ENABLED(tl_nret_as_ctx, as, ctx)
366 * kbase_tlstream_tl_ret_atom_as - retain atom by address space
367 * @atom: name of the atom object
368 * @as: name of the address space object
370 * Function emits a timeline message informing that atom object is being held
371 * by address space and must not be deleted unless it is released.
373 #define kbase_tlstream_tl_ret_atom_as(atom, as) \
374 __TRACE_IF_ENABLED(tl_ret_atom_as, atom, as)
377 * kbase_tlstream_tl_nret_atom_as - release atom by address space
378 * @atom: name of the atom object
379 * @as: name of the address space object
381 * Function emits a timeline message informing that atom object is being
382 * released by address space.
384 #define kbase_tlstream_tl_nret_atom_as(atom, as) \
385 __TRACE_IF_ENABLED(tl_nret_atom_as, atom, as)
388 * kbase_tlstream_tl_dep_atom_atom - parent atom depends on child atom
389 * @atom1: name of the child atom object
390 * @atom2: name of the parent atom object that depends on child atom
392 * Function emits a timeline message informing that parent atom waits for
393 * child atom object to be completed before start its execution.
395 #define kbase_tlstream_tl_dep_atom_atom(atom1, atom2) \
396 __TRACE_IF_ENABLED(tl_dep_atom_atom, atom1, atom2)
399 * kbase_tlstream_tl_ndep_atom_atom - dependency between atoms resolved
400 * @atom1: name of the child atom object
401 * @atom2: name of the parent atom object that depended on child atom
403 * Function emits a timeline message informing that parent atom execution
404 * dependency on child atom has been resolved.
406 #define kbase_tlstream_tl_ndep_atom_atom(atom1, atom2) \
407 __TRACE_IF_ENABLED(tl_ndep_atom_atom, atom1, atom2)
410 * kbase_tlstream_tl_rdep_atom_atom - information about already resolved dependency between atoms
411 * @atom1: name of the child atom object
412 * @atom2: name of the parent atom object that depended on child atom
414 * Function emits a timeline message informing that parent atom execution
415 * dependency on child atom has been resolved.
417 #define kbase_tlstream_tl_rdep_atom_atom(atom1, atom2) \
418 __TRACE_IF_ENABLED(tl_rdep_atom_atom, atom1, atom2)
421 * kbase_tlstream_tl_attrib_atom_config - atom job slot attributes
422 * @atom: name of the atom object
423 * @jd: job descriptor address
424 * @affinity: job affinity
425 * @config: job config
427 * Function emits a timeline message containing atom attributes.
429 #define kbase_tlstream_tl_attrib_atom_config(atom, jd, affinity, config) \
430 __TRACE_IF_ENABLED(tl_attrib_atom_config, atom, jd, affinity, config)
433 * kbase_tlstream_tl_attrib_as_config - address space attributes
434 * @as: assigned address space
435 * @transtab: configuration of the TRANSTAB register
436 * @memattr: configuration of the MEMATTR register
437 * @transcfg: configuration of the TRANSCFG register (or zero if not present)
439 * Function emits a timeline message containing address space attributes.
441 #define kbase_tlstream_tl_attrib_as_config(as, transtab, memattr, transcfg) \
442 __TRACE_IF_ENABLED(tl_attrib_as_config, as, transtab, memattr, transcfg)
445 * kbase_tlstream_jd_gpu_soft_reset - The GPU is being soft reset
446 * @gpu: name of the GPU object
448 * This imperative tracepoint is specific to job dumping.
449 * Function emits a timeline message indicating GPU soft reset.
451 #define kbase_tlstream_jd_gpu_soft_reset(gpu) \
452 __TRACE_IF_ENABLED(jd_gpu_soft_reset, gpu)
455 * kbase_tlstream_aux_pm_state - timeline message: power management state
456 * @core_type: core type (shader, tiler, l2 cache, l3 cache)
457 * @state: 64bits bitmask reporting power state of the cores (1-ON, 0-OFF)
459 #define kbase_tlstream_aux_pm_state(core_type, state) \
460 __TRACE_IF_ENABLED(aux_pm_state, core_type, state)
463 * kbase_tlstream_aux_issue_job_softstop - a soft-stop command is being issued
464 * @katom: the atom that is being soft-stopped
466 #define kbase_tlstream_aux_issue_job_softstop(katom) \
467 __TRACE_IF_ENABLED(aux_issue_job_softstop, katom)
470 * kbase_tlstream_aux_job_softstop - soft job stop occurred
471 * @js_id: job slot id
473 #define kbase_tlstream_aux_job_softstop(js_id) \
474 __TRACE_IF_ENABLED(aux_job_softstop, js_id)
477 * kbase_tlstream_aux_job_softstop_ex - extra info about soft-stopped atom
478 * @katom: the atom that has been soft-stopped
480 * This trace point adds more details about the soft-stopped atom. These details
481 * can't be safety collected inside the interrupt handler so we're doing it
484 * Note: this is not the same information that is recorded in the trace point,
485 * refer to __kbase_tlstream_aux_job_softstop_ex() for more details.
487 #define kbase_tlstream_aux_job_softstop_ex(katom) \
488 __TRACE_IF_ENABLED(aux_job_softstop_ex, katom)
491 * kbase_tlstream_aux_pagefault - timeline message: MMU page fault event
492 * resulting in new pages being mapped
493 * @ctx_nr: kernel context number
494 * @page_count_change: number of pages to be added
496 #define kbase_tlstream_aux_pagefault(ctx_nr, page_count_change) \
497 __TRACE_IF_ENABLED(aux_pagefault, ctx_nr, page_count_change)
500 * kbase_tlstream_aux_pagesalloc - timeline message: total number of allocated
502 * @ctx_nr: kernel context number
503 * @page_count: number of pages used by the context
505 #define kbase_tlstream_aux_pagesalloc(ctx_nr, page_count) \
506 __TRACE_IF_ENABLED(aux_pagesalloc, ctx_nr, page_count)
508 #endif /* _KBASE_TLSTREAM_H */