MALI: rockchip: upgrade midgard DDK to r14p0-01rel0
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard / mali_kbase_uku.h
1 /*
2  *
3  * (C) COPYRIGHT 2008-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
16
17
18
19
20 #ifndef _KBASE_UKU_H_
21 #define _KBASE_UKU_H_
22
23 #include "mali_uk.h"
24 #include "mali_base_kernel.h"
25
26 /* This file needs to support being included from kernel and userside (which use different defines) */
27 #if defined(CONFIG_MALI_ERROR_INJECT) || MALI_ERROR_INJECT_ON
28 #define SUPPORT_MALI_ERROR_INJECT
29 #endif /* defined(CONFIG_MALI_ERROR_INJECT) || MALI_ERROR_INJECT_ON */
30 #if defined(CONFIG_MALI_NO_MALI)
31 #define SUPPORT_MALI_NO_MALI
32 #elif defined(MALI_NO_MALI)
33 #if MALI_NO_MALI
34 #define SUPPORT_MALI_NO_MALI
35 #endif
36 #endif
37
38 #if defined(SUPPORT_MALI_NO_MALI) || defined(SUPPORT_MALI_ERROR_INJECT)
39 #include "backend/gpu/mali_kbase_model_dummy.h"
40 #endif
41
42 #include "mali_kbase_gpuprops_types.h"
43
44 /*
45  * 10.1:
46  * - Do mmap in kernel for SAME_VA memory allocations rather then
47  *   calling back into the kernel as a 2nd stage of the allocation request.
48  *
49  * 10.2:
50  * - Add KBASE_FUNC_MEM_JIT_INIT which allows clients to request a custom VA
51  *   region for use with JIT (ignored on 32-bit platforms)
52  *
53  * 10.3:
54  * - base_jd_core_req typedef-ed to u32 (instead of to u16)
55  * - two flags added: BASE_JD_REQ_SKIP_CACHE_STAT / _END
56  *
57  * 10.4:
58  * - Removed KBASE_FUNC_EXT_BUFFER_LOCK used only in internal tests
59  *
60  * 10.5:
61  * - Reverted to performing mmap in user space so that tools like valgrind work.
62  *
63  * 10.6:
64  * - Add flags input variable to KBASE_FUNC_TLSTREAM_ACQUIRE
65  */
66 #define BASE_UK_VERSION_MAJOR 10
67 #define BASE_UK_VERSION_MINOR 6
68
69 struct kbase_uk_mem_alloc {
70         union uk_header header;
71         /* IN */
72         u64 va_pages;
73         u64 commit_pages;
74         u64 extent;
75         /* IN/OUT */
76         u64 flags;
77         /* OUT */
78         u64 gpu_va;
79         u16 va_alignment;
80         u8  padding[6];
81 };
82
83 struct kbase_uk_mem_free {
84         union uk_header header;
85         /* IN */
86         u64 gpu_addr;
87         /* OUT */
88 };
89
90 struct kbase_uk_mem_alias {
91         union uk_header header;
92         /* IN/OUT */
93         u64 flags;
94         /* IN */
95         u64 stride;
96         u64 nents;
97         union kbase_pointer ai;
98         /* OUT */
99         u64         gpu_va;
100         u64         va_pages;
101 };
102
103 struct kbase_uk_mem_import {
104         union uk_header header;
105         /* IN */
106         union kbase_pointer phandle;
107         u32 type;
108         u32 padding;
109         /* IN/OUT */
110         u64         flags;
111         /* OUT */
112         u64 gpu_va;
113         u64         va_pages;
114 };
115
116 struct kbase_uk_mem_flags_change {
117         union uk_header header;
118         /* IN */
119         u64 gpu_va;
120         u64 flags;
121         u64 mask;
122 };
123
124 struct kbase_uk_job_submit {
125         union uk_header header;
126         /* IN */
127         union kbase_pointer addr;
128         u32 nr_atoms;
129         u32 stride;             /* bytes between atoms, i.e. sizeof(base_jd_atom_v2) */
130         /* OUT */
131 };
132
133 struct kbase_uk_post_term {
134         union uk_header header;
135 };
136
137 struct kbase_uk_sync_now {
138         union uk_header header;
139
140         /* IN */
141         struct base_syncset sset;
142
143         /* OUT */
144 };
145
146 struct kbase_uk_hwcnt_setup {
147         union uk_header header;
148
149         /* IN */
150         u64 dump_buffer;
151         u32 jm_bm;
152         u32 shader_bm;
153         u32 tiler_bm;
154         u32 unused_1; /* keep for backwards compatibility */
155         u32 mmu_l2_bm;
156         u32 padding;
157         /* OUT */
158 };
159
160 /**
161  * struct kbase_uk_hwcnt_reader_setup - User/Kernel space data exchange structure
162  * @header:       UK structure header
163  * @buffer_count: requested number of dumping buffers
164  * @jm_bm:        counters selection bitmask (JM)
165  * @shader_bm:    counters selection bitmask (Shader)
166  * @tiler_bm:     counters selection bitmask (Tiler)
167  * @mmu_l2_bm:    counters selection bitmask (MMU_L2)
168  * @fd:           dumping notification file descriptor
169  *
170  * This structure sets up HWC dumper/reader for this context.
171  * Multiple instances can be created for single context.
172  */
173 struct kbase_uk_hwcnt_reader_setup {
174         union uk_header header;
175
176         /* IN */
177         u32 buffer_count;
178         u32 jm_bm;
179         u32 shader_bm;
180         u32 tiler_bm;
181         u32 mmu_l2_bm;
182
183         /* OUT */
184         s32 fd;
185 };
186
187 struct kbase_uk_hwcnt_dump {
188         union uk_header header;
189 };
190
191 struct kbase_uk_hwcnt_clear {
192         union uk_header header;
193 };
194
195 struct kbase_uk_fence_validate {
196         union uk_header header;
197         /* IN */
198         s32 fd;
199         u32 padding;
200         /* OUT */
201 };
202
203 struct kbase_uk_stream_create {
204         union uk_header header;
205         /* IN */
206         char name[32];
207         /* OUT */
208         s32 fd;
209         u32 padding;
210 };
211
212 struct kbase_uk_gpuprops {
213         union uk_header header;
214
215         /* IN */
216         struct mali_base_gpu_props props;
217         /* OUT */
218 };
219
220 struct kbase_uk_mem_query {
221         union uk_header header;
222         /* IN */
223         u64 gpu_addr;
224 #define KBASE_MEM_QUERY_COMMIT_SIZE  1
225 #define KBASE_MEM_QUERY_VA_SIZE      2
226 #define KBASE_MEM_QUERY_FLAGS        3
227         u64         query;
228         /* OUT */
229         u64         value;
230 };
231
232 struct kbase_uk_mem_commit {
233         union uk_header header;
234         /* IN */
235         u64 gpu_addr;
236         u64         pages;
237         /* OUT */
238         u32 result_subcode;
239         u32 padding;
240 };
241
242 struct kbase_uk_find_cpu_offset {
243         union uk_header header;
244         /* IN */
245         u64 gpu_addr;
246         u64 cpu_addr;
247         u64 size;
248         /* OUT */
249         u64 offset;
250 };
251
252 #define KBASE_GET_VERSION_BUFFER_SIZE 64
253 struct kbase_uk_get_ddk_version {
254         union uk_header header;
255         /* OUT */
256         char version_buffer[KBASE_GET_VERSION_BUFFER_SIZE];
257         u32 version_string_size;
258         u32 padding;
259         u32 rk_version;
260 };
261
262 struct kbase_uk_disjoint_query {
263         union uk_header header;
264         /* OUT */
265         u32 counter;
266         u32 padding;
267 };
268
269 struct kbase_uk_set_flags {
270         union uk_header header;
271         /* IN */
272         u32 create_flags;
273         u32 padding;
274 };
275
276 #if MALI_UNIT_TEST
277 #define TEST_ADDR_COUNT 4
278 #define KBASE_TEST_BUFFER_SIZE 128
279 struct kbase_exported_test_data {
280         u64 test_addr[TEST_ADDR_COUNT];         /**< memory address */
281         u32 test_addr_pages[TEST_ADDR_COUNT];           /**<  memory size in pages */
282         union kbase_pointer kctx;                               /**<  base context created by process */
283         union kbase_pointer mm;                         /**< pointer to process address space */
284         u8 buffer1[KBASE_TEST_BUFFER_SIZE];   /**<  unit test defined parameter */
285         u8 buffer2[KBASE_TEST_BUFFER_SIZE];   /**<  unit test defined parameter */
286 };
287
288 struct kbase_uk_set_test_data {
289         union uk_header header;
290         /* IN */
291         struct kbase_exported_test_data test_data;
292 };
293
294 #endif                          /* MALI_UNIT_TEST */
295
296 #ifdef SUPPORT_MALI_ERROR_INJECT
297 struct kbase_uk_error_params {
298         union uk_header header;
299         /* IN */
300         struct kbase_error_params params;
301 };
302 #endif                          /* SUPPORT_MALI_ERROR_INJECT */
303
304 #ifdef SUPPORT_MALI_NO_MALI
305 struct kbase_uk_model_control_params {
306         union uk_header header;
307         /* IN */
308         struct kbase_model_control_params params;
309 };
310 #endif                          /* SUPPORT_MALI_NO_MALI */
311
312 #ifdef BASE_LEGACY_UK8_SUPPORT
313 struct kbase_uk_keep_gpu_powered {
314         union uk_header header;
315         u32       enabled;
316         u32       padding;
317 };
318 #endif /* BASE_LEGACY_UK8_SUPPORT */
319
320 struct kbase_uk_profiling_controls {
321         union uk_header header;
322         u32 profiling_controls[FBDUMP_CONTROL_MAX];
323 };
324
325 struct kbase_uk_debugfs_mem_profile_add {
326         union uk_header header;
327         u32 len;
328         u32 padding;
329         union kbase_pointer buf;
330 };
331
332 struct kbase_uk_context_id {
333         union uk_header header;
334         /* OUT */
335         int id;
336 };
337
338 #if (defined(MALI_MIPE_ENABLED) && MALI_MIPE_ENABLED) || \
339         !defined(MALI_MIPE_ENABLED)
340 /**
341  * struct kbase_uk_tlstream_acquire - User/Kernel space data exchange structure
342  * @header: UK structure header
343  * @flags:  timeline stream flags
344  * @fd:     timeline stream file descriptor
345  *
346  * This structure is used when performing a call to acquire kernel side timeline
347  * stream file descriptor.
348  */
349 struct kbase_uk_tlstream_acquire {
350         union uk_header header;
351         /* IN */
352         u32 flags;
353         /* OUT */
354         s32  fd;
355 };
356
357 /**
358  * struct kbase_uk_tlstream_acquire_v10_4 - User/Kernel space data exchange
359  *                                          structure
360  * @header: UK structure header
361  * @fd:     timeline stream file descriptor
362  *
363  * This structure is used when performing a call to acquire kernel side timeline
364  * stream file descriptor.
365  */
366 struct kbase_uk_tlstream_acquire_v10_4 {
367         union uk_header header;
368         /* IN */
369         /* OUT */
370         s32  fd;
371 };
372
373 /**
374  * struct kbase_uk_tlstream_flush - User/Kernel space data exchange structure
375  * @header: UK structure header
376  *
377  * This structure is used when performing a call to flush kernel side
378  * timeline streams.
379  */
380 struct kbase_uk_tlstream_flush {
381         union uk_header header;
382         /* IN */
383         /* OUT */
384 };
385
386 #if MALI_UNIT_TEST
387 /**
388  * struct kbase_uk_tlstream_test - User/Kernel space data exchange structure
389  * @header:    UK structure header
390  * @tpw_count: number of trace point writers in each context
391  * @msg_delay: time delay between tracepoints from one writer in milliseconds
392  * @msg_count: number of trace points written by one writer
393  * @aux_msg:   if non-zero aux messages will be included
394  *
395  * This structure is used when performing a call to start timeline stream test
396  * embedded in kernel.
397  */
398 struct kbase_uk_tlstream_test {
399         union uk_header header;
400         /* IN */
401         u32 tpw_count;
402         u32 msg_delay;
403         u32 msg_count;
404         u32 aux_msg;
405         /* OUT */
406 };
407
408 /**
409  * struct kbase_uk_tlstream_stats - User/Kernel space data exchange structure
410  * @header:          UK structure header
411  * @bytes_collected: number of bytes read by user
412  * @bytes_generated: number of bytes generated by tracepoints
413  *
414  * This structure is used when performing a call to obtain timeline stream
415  * statistics.
416  */
417 struct kbase_uk_tlstream_stats {
418         union uk_header header; /**< UK structure header. */
419         /* IN */
420         /* OUT */
421         u32 bytes_collected;
422         u32 bytes_generated;
423 };
424 #endif /* MALI_UNIT_TEST */
425 #endif /* MALI_MIPE_ENABLED */
426
427 /**
428  * struct struct kbase_uk_prfcnt_value for the KBASE_FUNC_SET_PRFCNT_VALUES ioctl
429  * @header:          UK structure header
430  * @data:            Counter samples for the dummy model
431  * @size:............Size of the counter sample data
432  */
433 struct kbase_uk_prfcnt_values {
434         union uk_header header;
435         /* IN */
436         u32 *data;
437         u32 size;
438 };
439
440 /**
441  * struct kbase_uk_soft_event_update - User/Kernel space data exchange structure
442  * @header:     UK structure header
443  * @evt:        the GPU address containing the event
444  * @new_status: the new event status, must be either BASE_JD_SOFT_EVENT_SET or
445  *              BASE_JD_SOFT_EVENT_RESET
446  * @flags:      reserved for future uses, must be set to 0
447  *
448  * This structure is used to update the status of a software event. If the
449  * event's status is set to BASE_JD_SOFT_EVENT_SET, any job currently waiting
450  * on this event will complete.
451  */
452 struct kbase_uk_soft_event_update {
453         union uk_header header;
454         /* IN */
455         u64 evt;
456         u32 new_status;
457         u32 flags;
458 };
459
460 /**
461  * struct kbase_uk_mem_jit_init - User/Kernel space data exchange structure
462  * @header:     UK structure header
463  * @va_pages:   Number of virtual pages required for JIT
464  *
465  * This structure is used when requesting initialization of JIT.
466  */
467 struct kbase_uk_mem_jit_init {
468         union uk_header header;
469         /* IN */
470         u64 va_pages;
471 };
472
473 enum kbase_uk_function_id {
474         KBASE_FUNC_MEM_ALLOC = (UK_FUNC_ID + 0),
475         KBASE_FUNC_MEM_IMPORT = (UK_FUNC_ID + 1),
476         KBASE_FUNC_MEM_COMMIT = (UK_FUNC_ID + 2),
477         KBASE_FUNC_MEM_QUERY = (UK_FUNC_ID + 3),
478         KBASE_FUNC_MEM_FREE = (UK_FUNC_ID + 4),
479         KBASE_FUNC_MEM_FLAGS_CHANGE = (UK_FUNC_ID + 5),
480         KBASE_FUNC_MEM_ALIAS = (UK_FUNC_ID + 6),
481
482 #ifdef BASE_LEGACY_UK6_SUPPORT
483         KBASE_FUNC_JOB_SUBMIT_UK6 = (UK_FUNC_ID + 7),
484 #endif /* BASE_LEGACY_UK6_SUPPORT */
485
486         KBASE_FUNC_SYNC  = (UK_FUNC_ID + 8),
487
488         KBASE_FUNC_POST_TERM = (UK_FUNC_ID + 9),
489
490         KBASE_FUNC_HWCNT_SETUP = (UK_FUNC_ID + 10),
491         KBASE_FUNC_HWCNT_DUMP = (UK_FUNC_ID + 11),
492         KBASE_FUNC_HWCNT_CLEAR = (UK_FUNC_ID + 12),
493
494         KBASE_FUNC_GPU_PROPS_REG_DUMP = (UK_FUNC_ID + 14),
495
496         KBASE_FUNC_FIND_CPU_OFFSET = (UK_FUNC_ID + 15),
497
498         KBASE_FUNC_GET_VERSION = (UK_FUNC_ID + 16),
499         KBASE_FUNC_SET_FLAGS = (UK_FUNC_ID + 18),
500
501         KBASE_FUNC_SET_TEST_DATA = (UK_FUNC_ID + 19),
502         KBASE_FUNC_INJECT_ERROR = (UK_FUNC_ID + 20),
503         KBASE_FUNC_MODEL_CONTROL = (UK_FUNC_ID + 21),
504
505 #ifdef BASE_LEGACY_UK8_SUPPORT
506         KBASE_FUNC_KEEP_GPU_POWERED = (UK_FUNC_ID + 22),
507 #endif /* BASE_LEGACY_UK8_SUPPORT */
508
509         KBASE_FUNC_FENCE_VALIDATE = (UK_FUNC_ID + 23),
510         KBASE_FUNC_STREAM_CREATE = (UK_FUNC_ID + 24),
511         KBASE_FUNC_GET_PROFILING_CONTROLS = (UK_FUNC_ID + 25),
512         KBASE_FUNC_SET_PROFILING_CONTROLS = (UK_FUNC_ID + 26),
513                                             /* to be used only for testing
514                                             * purposes, otherwise these controls
515                                             * are set through gator API */
516
517         KBASE_FUNC_DEBUGFS_MEM_PROFILE_ADD = (UK_FUNC_ID + 27),
518         KBASE_FUNC_JOB_SUBMIT = (UK_FUNC_ID + 28),
519         KBASE_FUNC_DISJOINT_QUERY = (UK_FUNC_ID + 29),
520
521         KBASE_FUNC_GET_CONTEXT_ID = (UK_FUNC_ID + 31),
522
523 #if (defined(MALI_MIPE_ENABLED) && MALI_MIPE_ENABLED) || \
524         !defined(MALI_MIPE_ENABLED)
525         KBASE_FUNC_TLSTREAM_ACQUIRE_V10_4 = (UK_FUNC_ID + 32),
526 #if MALI_UNIT_TEST
527         KBASE_FUNC_TLSTREAM_TEST = (UK_FUNC_ID + 33),
528         KBASE_FUNC_TLSTREAM_STATS = (UK_FUNC_ID + 34),
529 #endif /* MALI_UNIT_TEST */
530         KBASE_FUNC_TLSTREAM_FLUSH = (UK_FUNC_ID + 35),
531 #endif /* MALI_MIPE_ENABLED */
532
533         KBASE_FUNC_HWCNT_READER_SETUP = (UK_FUNC_ID + 36),
534
535 #ifdef SUPPORT_MALI_NO_MALI
536         KBASE_FUNC_SET_PRFCNT_VALUES = (UK_FUNC_ID + 37),
537 #endif
538
539         KBASE_FUNC_SOFT_EVENT_UPDATE = (UK_FUNC_ID + 38),
540
541         KBASE_FUNC_MEM_JIT_INIT = (UK_FUNC_ID + 39),
542
543 #if (defined(MALI_MIPE_ENABLED) && MALI_MIPE_ENABLED) || \
544         !defined(MALI_MIPE_ENABLED)
545         KBASE_FUNC_TLSTREAM_ACQUIRE = (UK_FUNC_ID + 40),
546 #endif /* MALI_MIPE_ENABLED */
547
548         KBASE_FUNC_MAX
549 };
550
551 #endif                          /* _KBASE_UKU_H_ */
552