3 * (C) COPYRIGHT 2015 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 /*****************************************************************************/
106 * kbase_tlstream_tl_summary_new_ctx - create context object in timeline
108 * @context: name of the context object
109 * @nr: context number
111 * Function emits a timeline message informing about context creation. Context
112 * is created with context number (its attribute), that can be used to link
113 * kbase context with userspace context.
114 * This message is directed to timeline summary stream.
116 void kbase_tlstream_tl_summary_new_ctx(void *context, u32 nr);
119 * kbase_tlstream_tl_summary_new_gpu - create GPU object in timeline summary
120 * @gpu: name of the GPU object
121 * @id: id value of this GPU
122 * @core_count: number of cores this GPU hosts
124 * Function emits a timeline message informing about GPU creation. GPU is
125 * created with two attributes: id and core count.
126 * This message is directed to timeline summary stream.
128 void kbase_tlstream_tl_summary_new_gpu(void *gpu, u32 id, u32 core_count);
131 * kbase_tlstream_tl_summary_new_lpu - create LPU object in timeline summary
132 * @lpu: name of the Logical Processing Unit object
133 * @nr: sequential number assigned to this LPU
134 * @fn: property describing this LPU's functional abilities
136 * Function emits a timeline message informing about LPU creation. LPU is
137 * created with two attributes: number linking this LPU with GPU's job slot
138 * and function bearing information about this LPU abilities.
139 * This message is directed to timeline summary stream.
141 void kbase_tlstream_tl_summary_new_lpu(void *lpu, u32 nr, u32 fn);
144 * kbase_tlstream_tl_summary_lifelink_lpu_gpu - lifelink LPU object to GPU
145 * @lpu: name of the Logical Processing Unit object
146 * @gpu: name of the GPU object
148 * Function emits a timeline message informing that LPU object shall be deleted
149 * along with GPU object.
150 * This message is directed to timeline summary stream.
152 void kbase_tlstream_tl_summary_lifelink_lpu_gpu(void *lpu, void *gpu);
155 * kbase_tlstream_tl_summary_new_as - create address space object in timeline summary
156 * @as: name of the address space object
157 * @nr: sequential number assigned to this address space
159 * Function emits a timeline message informing about address space creation.
160 * Address space is created with one attribute: number identifying this
162 * This message is directed to timeline summary stream.
164 void kbase_tlstream_tl_summary_new_as(void *as, u32 nr);
167 * kbase_tlstream_tl_summary_lifelink_as_gpu - lifelink address space object to GPU
168 * @as: name of the address space object
169 * @gpu: name of the GPU object
171 * Function emits a timeline message informing that address space object
172 * shall be deleted along with GPU object.
173 * This message is directed to timeline summary stream.
175 void kbase_tlstream_tl_summary_lifelink_as_gpu(void *as, void *gpu);
178 * kbase_tlstream_tl_new_ctx - create context object in timeline
179 * @context: name of the context object
180 * @nr: context number
182 * Function emits a timeline message informing about context creation. Context
183 * is created with context number (its attribute), that can be used to link
184 * kbase context with userspace context.
186 void kbase_tlstream_tl_new_ctx(void *context, u32 nr);
189 * kbase_tlstream_tl_new_atom - create atom object in timeline
190 * @atom: name of the atom object
191 * @nr: sequential number assigned to this atom
193 * Function emits a timeline message informing about atom creation. Atom is
194 * created with atom number (its attribute) that links it with actual work
195 * bucket id understood by hardware.
197 void kbase_tlstream_tl_new_atom(void *atom, u32 nr);
200 * kbase_tlstream_tl_del_ctx - destroy context object in timeline
201 * @context: name of the context object
203 * Function emits a timeline message informing that context object ceased to
206 void kbase_tlstream_tl_del_ctx(void *context);
209 * kbase_tlstream_tl_del_atom - destroy atom object in timeline
210 * @atom: name of the atom object
212 * Function emits a timeline message informing that atom object ceased to
215 void kbase_tlstream_tl_del_atom(void *atom);
218 * kbase_tlstream_tl_ret_ctx_lpu - retain context by LPU
219 * @context: name of the context object
220 * @lpu: name of the Logical Processing Unit object
222 * Function emits a timeline message informing that context is being held
223 * by LPU and must not be deleted unless it is released.
225 void kbase_tlstream_tl_ret_ctx_lpu(void *context, void *lpu);
228 * kbase_tlstream_tl_ret_atom_ctx - retain atom by context
229 * @atom: name of the atom object
230 * @context: name of the context object
232 * Function emits a timeline message informing that atom object is being held
233 * by context and must not be deleted unless it is released.
235 void kbase_tlstream_tl_ret_atom_ctx(void *atom, void *context);
238 * kbase_tlstream_tl_ret_atom_lpu - retain atom by LPU
239 * @atom: name of the atom object
240 * @lpu: name of the Logical Processing Unit object
241 * @attrib_match_list: list containing match operator attributes
243 * Function emits a timeline message informing that atom object is being held
244 * by LPU and must not be deleted unless it is released.
246 void kbase_tlstream_tl_ret_atom_lpu(
247 void *atom, void *lpu, const char *attrib_match_list);
250 * kbase_tlstream_tl_nret_ctx_lpu - release context by LPU
251 * @context: name of the context object
252 * @lpu: name of the Logical Processing Unit object
254 * Function emits a timeline message informing that context is being released
257 void kbase_tlstream_tl_nret_ctx_lpu(void *context, void *lpu);
260 * kbase_tlstream_tl_nret_atom_ctx - release atom by context
261 * @atom: name of the atom object
262 * @context: name of the context object
264 * Function emits a timeline message informing that atom object is being
265 * released by context.
267 void kbase_tlstream_tl_nret_atom_ctx(void *atom, void *context);
270 * kbase_tlstream_tl_nret_atom_lpu - release atom by LPU
271 * @atom: name of the atom object
272 * @lpu: name of the Logical Processing Unit object
274 * Function emits a timeline message informing that atom object is being
277 void kbase_tlstream_tl_nret_atom_lpu(void *atom, void *lpu);
280 * kbase_tlstream_tl_ret_as_ctx - lifelink address space object to context
281 * @as: name of the address space object
282 * @ctx: name of the context object
284 * Function emits a timeline message informing that address space object
285 * is being held by the context object.
287 void kbase_tlstream_tl_ret_as_ctx(void *as, void *ctx);
290 * kbase_tlstream_tl_nret_as_ctx - release address space by context
291 * @as: name of the address space object
292 * @ctx: name of the context object
294 * Function emits a timeline message informing that address space object
295 * is being released by atom.
297 void kbase_tlstream_tl_nret_as_ctx(void *as, void *ctx);
300 * kbase_tlstream_tl_ret_atom_as - retain atom by address space
301 * @atom: name of the atom object
302 * @as: name of the address space object
304 * Function emits a timeline message informing that atom object is being held
305 * by address space and must not be deleted unless it is released.
307 void kbase_tlstream_tl_ret_atom_as(void *atom, void *as);
310 * kbase_tlstream_tl_nret_atom_as - release atom by address space
311 * @atom: name of the atom object
312 * @as: name of the address space object
314 * Function emits a timeline message informing that atom object is being
315 * released by address space.
317 void kbase_tlstream_tl_nret_atom_as(void *atom, void *as);
320 * kbase_tlstream_tl_dep_atom_atom - parent atom depends on child atom
321 * @atom1: name of the child atom object
322 * @atom2: name of the parent atom object that depends on child atom
324 * Function emits a timeline message informing that parent atom waits for
325 * child atom object to be completed before start its execution.
327 void kbase_tlstream_tl_dep_atom_atom(void *atom1, void *atom2);
330 * kbase_tlstream_tl_attrib_atom_config - atom job slot attributes
331 * @atom: name of the atom object
332 * @jd: job descriptor address
333 * @affinity: job affinity
334 * @config: job config
336 * Function emits a timeline message containing atom attributes.
338 void kbase_tlstream_tl_attrib_atom_config(
339 void *atom, u64 jd, u64 affinity, u32 config);
342 * kbase_tlstream_tl_attrib_as_config - address space attributes
343 * @as: assigned address space
344 * @transtab: configuration of the TRANSTAB register
345 * @memattr: configuration of the MEMATTR register
346 * @transcfg: configuration of the TRANSCFG register (or zero if not present)
348 * Function emits a timeline message containing address space attributes.
350 void kbase_tlstream_tl_attrib_as_config(
351 void *as, u64 transtab, u64 memattr, u64 transcfg);
354 * kbase_tlstream_jd_gpu_soft_reset - The GPU is being soft reset
355 * @gpu: name of the GPU object
357 * This imperative tracepoint is specific to job dumping.
358 * Function emits a timeline message indicating GPU soft reset.
360 void kbase_tlstream_jd_gpu_soft_reset(void *gpu);
363 * kbase_tlstream_aux_pm_state - timeline message: power management state
364 * @core_type: core type (shader, tiler, l2 cache, l3 cache)
365 * @state: 64bits bitmask reporting power state of the cores (1-ON, 0-OFF)
367 void kbase_tlstream_aux_pm_state(u32 core_type, u64 state);
370 * kbase_tlstream_aux_job_softstop - soft job stop occurred
371 * @js_id: job slot id
373 void kbase_tlstream_aux_job_softstop(u32 js_id);
376 * kbase_tlstream_aux_pagefault - timeline message: MMU page fault event
377 * resulting in new pages being mapped
378 * @ctx_nr: kernel context number
379 * @page_count: number of currently used pages
381 void kbase_tlstream_aux_pagefault(u32 ctx_nr, u32 page_count);
384 * kbase_tlstream_aux_pagesalloc - timeline message: total number of allocated
386 * @page_count_change: number of pages to be added or subtracted (according to
389 void kbase_tlstream_aux_pagesalloc(s64 page_count_change);
391 #endif /* _KBASE_TLSTREAM_H */