eccd469a86e8bc390df7de119440f1fe667c3a0d
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard_for_linux / mali_kbase_tlstream.h
1 /*
2  *
3  * (C) COPYRIGHT 2015 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
16
17
18 #if !defined(_KBASE_TLSTREAM_H)
19 #define _KBASE_TLSTREAM_H
20
21 #include <mali_kbase.h>
22
23 /*****************************************************************************/
24
25 /**
26  * kbase_tlstream_init - initialize timeline infrastructure in kernel
27  * Return: zero on success, negative number on error
28  */
29 int kbase_tlstream_init(void);
30
31 /**
32  * kbase_tlstream_term - terminate timeline infrastructure in kernel
33  *
34  * Timeline need have to been previously enabled with kbase_tlstream_init().
35  */
36 void kbase_tlstream_term(void);
37
38 /**
39  * kbase_tlstream_acquire - acquire timeline stream file descriptor
40  * @kctx: kernel common context
41  * @fd:   timeline stream file descriptor
42  *
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
45  * timeline client.
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.
49  *
50  * Return: zero on success (this does not necessarily mean that stream
51  *         descriptor could be returned), negative number on error
52  */
53 int kbase_tlstream_acquire(struct kbase_context *kctx, int *fd);
54
55 /**
56  * kbase_tlstream_flush_streams - flush timeline streams.
57  *
58  * Function will flush pending data in all timeline streams.
59  */
60 void kbase_tlstream_flush_streams(void);
61
62 /**
63  * kbase_tlstream_reset_body_streams - reset timeline body streams.
64  *
65  * Function will discard pending data in all timeline body streams.
66  */
67 void kbase_tlstream_reset_body_streams(void);
68
69 #if MALI_UNIT_TEST
70 /**
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
74  *             writer
75  * @msg_count: number of trace points written by one writer
76  * @aux_msg:   if non-zero aux messages will be included
77  *
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
87  * writers finish.
88  */
89 void kbase_tlstream_test(
90                 unsigned int tpw_count,
91                 unsigned int msg_delay,
92                 unsigned int msg_count,
93                 int          aux_msg);
94
95 /**
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
99  */
100 void kbase_tlstream_stats(u32 *bytes_collected, u32 *bytes_generated);
101 #endif /* MALI_UNIT_TEST */
102
103 /*****************************************************************************/
104
105 /**
106  * kbase_tlstream_tl_summary_new_ctx - create context object in timeline
107  *                                     summary
108  * @context: name of the context object
109  * @nr:      context number
110  *
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.
115  */
116 void kbase_tlstream_tl_summary_new_ctx(void *context, u32 nr);
117
118 /**
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
123  *
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.
127  */
128 void kbase_tlstream_tl_summary_new_gpu(void *gpu, u32 id, u32 core_count);
129
130 /**
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
135  *
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.
140  */
141 void kbase_tlstream_tl_summary_new_lpu(void *lpu, u32 nr, u32 fn);
142
143 /**
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
147  *
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.
151  */
152 void kbase_tlstream_tl_summary_lifelink_lpu_gpu(void *lpu, void *gpu);
153
154 /**
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
158  *
159  * Function emits a timeline message informing about address space creation.
160  * Address space is created with one attribute: number identifying this
161  * address space.
162  * This message is directed to timeline summary stream.
163  */
164 void kbase_tlstream_tl_summary_new_as(void *as, u32 nr);
165
166 /**
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
170  *
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.
174  */
175 void kbase_tlstream_tl_summary_lifelink_as_gpu(void *as, void *gpu);
176
177 /**
178  * kbase_tlstream_tl_new_ctx - create context object in timeline
179  * @context: name of the context object
180  * @nr:      context number
181  *
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.
185  */
186 void kbase_tlstream_tl_new_ctx(void *context, u32 nr);
187
188 /**
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
192  *
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.
196  */
197 void kbase_tlstream_tl_new_atom(void *atom, u32 nr);
198
199 /**
200  * kbase_tlstream_tl_del_ctx - destroy context object in timeline
201  * @context: name of the context object
202  *
203  * Function emits a timeline message informing that context object ceased to
204  * exist.
205  */
206 void kbase_tlstream_tl_del_ctx(void *context);
207
208 /**
209  * kbase_tlstream_tl_del_atom - destroy atom object in timeline
210  * @atom: name of the atom object
211  *
212  * Function emits a timeline message informing that atom object ceased to
213  * exist.
214  */
215 void kbase_tlstream_tl_del_atom(void *atom);
216
217 /**
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
221  *
222  * Function emits a timeline message informing that context is being held
223  * by LPU and must not be deleted unless it is released.
224  */
225 void kbase_tlstream_tl_ret_ctx_lpu(void *context, void *lpu);
226
227 /**
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
231  *
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.
234  */
235 void kbase_tlstream_tl_ret_atom_ctx(void *atom, void *context);
236
237 /**
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
242  *
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.
245  */
246 void kbase_tlstream_tl_ret_atom_lpu(
247                 void *atom, void *lpu, const char *attrib_match_list);
248
249 /**
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
253  *
254  * Function emits a timeline message informing that context is being released
255  * by LPU object.
256  */
257 void kbase_tlstream_tl_nret_ctx_lpu(void *context, void *lpu);
258
259 /**
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
263  *
264  * Function emits a timeline message informing that atom object is being
265  * released by context.
266  */
267 void kbase_tlstream_tl_nret_atom_ctx(void *atom, void *context);
268
269 /**
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
273  *
274  * Function emits a timeline message informing that atom object is being
275  * released by LPU.
276  */
277 void kbase_tlstream_tl_nret_atom_lpu(void *atom, void *lpu);
278
279 /**
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
283  *
284  * Function emits a timeline message informing that address space object
285  * is being held by the context object.
286  */
287 void kbase_tlstream_tl_ret_as_ctx(void *as, void *ctx);
288
289 /**
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
293  *
294  * Function emits a timeline message informing that address space object
295  * is being released by atom.
296  */
297 void kbase_tlstream_tl_nret_as_ctx(void *as, void *ctx);
298
299 /**
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
303  *
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.
306  */
307 void kbase_tlstream_tl_ret_atom_as(void *atom, void *as);
308
309 /**
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
313  *
314  * Function emits a timeline message informing that atom object is being
315  * released by address space.
316  */
317 void kbase_tlstream_tl_nret_atom_as(void *atom, void *as);
318
319 /**
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
323  *
324  * Function emits a timeline message informing that parent atom waits for
325  * child atom object to be completed before start its execution.
326  */
327 void kbase_tlstream_tl_dep_atom_atom(void *atom1, void *atom2);
328
329 /**
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
335  *
336  * Function emits a timeline message containing atom attributes.
337  */
338 void kbase_tlstream_tl_attrib_atom_config(
339                 void *atom, u64 jd, u64 affinity, u32 config);
340
341 /**
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)
347  *
348  * Function emits a timeline message containing address space attributes.
349  */
350 void kbase_tlstream_tl_attrib_as_config(
351                 void *as, u64 transtab, u64 memattr, u64 transcfg);
352
353 /**
354  * kbase_tlstream_jd_gpu_soft_reset - The GPU is being soft reset
355  * @gpu:        name of the GPU object
356  *
357  * This imperative tracepoint is specific to job dumping.
358  * Function emits a timeline message indicating GPU soft reset.
359  */
360 void kbase_tlstream_jd_gpu_soft_reset(void *gpu);
361
362 /**
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)
366  */
367 void kbase_tlstream_aux_pm_state(u32 core_type, u64 state);
368
369 /**
370  * kbase_tlstream_aux_job_softstop - soft job stop occurred
371  * @js_id: job slot id
372  */
373 void kbase_tlstream_aux_job_softstop(u32 js_id);
374
375 /**
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_change: number of pages to be added
380  */
381 void kbase_tlstream_aux_pagefault(u32 ctx_nr, u64 page_count_change);
382
383 /**
384  * kbase_tlstream_aux_pagesalloc - timeline message: total number of allocated
385  *                                 pages is changed
386  * @ctx_nr:     kernel context number
387  * @page_count: number of pages used by the context
388  */
389 void kbase_tlstream_aux_pagesalloc(u32 ctx_nr, u64 page_count);
390
391 #endif /* _KBASE_TLSTREAM_H */
392