MALI: midgard: RK: add separate src dir of Midgard driver for RK Linux device
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard_for_linux / mali_kbase_uku.h
1 /*
2  *
3  * (C) COPYRIGHT 2008-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
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 #define BASE_UK_VERSION_MAJOR 10
50 #define BASE_UK_VERSION_MINOR 1
51
52 struct kbase_uk_mem_alloc {
53         union uk_header header;
54         /* IN */
55         u64 va_pages;
56         u64 commit_pages;
57         u64 extent;
58         /* IN/OUT */
59         u64 flags;
60         /* OUT */
61         u64 gpu_va;
62         u16 va_alignment;
63         u8  padding[6];
64 };
65
66 struct kbase_uk_mem_free {
67         union uk_header header;
68         /* IN */
69         u64 gpu_addr;
70         /* OUT */
71 };
72
73 struct kbase_uk_mem_alias {
74         union uk_header header;
75         /* IN/OUT */
76         u64 flags;
77         /* IN */
78         u64 stride;
79         u64 nents;
80         union kbase_pointer ai;
81         /* OUT */
82         u64         gpu_va;
83         u64         va_pages;
84 };
85
86 struct kbase_uk_mem_import {
87         union uk_header header;
88         /* IN */
89         union kbase_pointer phandle;
90         u32 type;
91         u32 padding;
92         /* IN/OUT */
93         u64         flags;
94         /* OUT */
95         u64 gpu_va;
96         u64         va_pages;
97 };
98
99 struct kbase_uk_mem_flags_change {
100         union uk_header header;
101         /* IN */
102         u64 gpu_va;
103         u64 flags;
104         u64 mask;
105 };
106
107 struct kbase_uk_job_submit {
108         union uk_header header;
109         /* IN */
110         union kbase_pointer addr;
111         u32 nr_atoms;
112         u32 stride;             /* bytes between atoms, i.e. sizeof(base_jd_atom_v2) */
113         /* OUT */
114 };
115
116 struct kbase_uk_post_term {
117         union uk_header header;
118 };
119
120 struct kbase_uk_sync_now {
121         union uk_header header;
122
123         /* IN */
124         struct base_syncset sset;
125
126         /* OUT */
127 };
128
129 struct kbase_uk_hwcnt_setup {
130         union uk_header header;
131
132         /* IN */
133         u64 dump_buffer;
134         u32 jm_bm;
135         u32 shader_bm;
136         u32 tiler_bm;
137         u32 unused_1; /* keep for backwards compatibility */
138         u32 mmu_l2_bm;
139         u32 padding;
140         /* OUT */
141 };
142
143 /**
144  * struct kbase_uk_hwcnt_reader_setup - User/Kernel space data exchange structure
145  * @header:       UK structure header
146  * @buffer_count: requested number of dumping buffers
147  * @jm_bm:        counters selection bitmask (JM)
148  * @shader_bm:    counters selection bitmask (Shader)
149  * @tiler_bm:     counters selection bitmask (Tiler)
150  * @mmu_l2_bm:    counters selection bitmask (MMU_L2)
151  * @fd:           dumping notification file descriptor
152  *
153  * This structure sets up HWC dumper/reader for this context.
154  * Multiple instances can be created for single context.
155  */
156 struct kbase_uk_hwcnt_reader_setup {
157         union uk_header header;
158
159         /* IN */
160         u32 buffer_count;
161         u32 jm_bm;
162         u32 shader_bm;
163         u32 tiler_bm;
164         u32 mmu_l2_bm;
165
166         /* OUT */
167         s32 fd;
168 };
169
170 struct kbase_uk_hwcnt_dump {
171         union uk_header header;
172 };
173
174 struct kbase_uk_hwcnt_clear {
175         union uk_header header;
176 };
177
178 struct kbase_uk_fence_validate {
179         union uk_header header;
180         /* IN */
181         s32 fd;
182         u32 padding;
183         /* OUT */
184 };
185
186 struct kbase_uk_stream_create {
187         union uk_header header;
188         /* IN */
189         char name[32];
190         /* OUT */
191         s32 fd;
192         u32 padding;
193 };
194
195 struct kbase_uk_gpuprops {
196         union uk_header header;
197
198         /* IN */
199         struct mali_base_gpu_props props;
200         /* OUT */
201 };
202
203 struct kbase_uk_mem_query {
204         union uk_header header;
205         /* IN */
206         u64 gpu_addr;
207 #define KBASE_MEM_QUERY_COMMIT_SIZE  1
208 #define KBASE_MEM_QUERY_VA_SIZE      2
209 #define KBASE_MEM_QUERY_FLAGS        3
210         u64         query;
211         /* OUT */
212         u64         value;
213 };
214
215 struct kbase_uk_mem_commit {
216         union uk_header header;
217         /* IN */
218         u64 gpu_addr;
219         u64         pages;
220         /* OUT */
221         u32 result_subcode;
222         u32 padding;
223 };
224
225 struct kbase_uk_find_cpu_offset {
226         union uk_header header;
227         /* IN */
228         u64 gpu_addr;
229         u64 cpu_addr;
230         u64 size;
231         /* OUT */
232         u64 offset;
233 };
234
235 #define KBASE_GET_VERSION_BUFFER_SIZE 64
236 struct kbase_uk_get_ddk_version {
237         union uk_header header;
238         /* OUT */
239         char version_buffer[KBASE_GET_VERSION_BUFFER_SIZE];
240         u32 version_string_size;
241         u32 padding;
242         u32 rk_version;
243 };
244
245 struct kbase_uk_disjoint_query {
246         union uk_header header;
247         /* OUT */
248         u32 counter;
249         u32 padding;
250 };
251
252 struct kbase_uk_set_flags {
253         union uk_header header;
254         /* IN */
255         u32 create_flags;
256         u32 padding;
257 };
258
259 #if MALI_UNIT_TEST
260 #define TEST_ADDR_COUNT 4
261 #define KBASE_TEST_BUFFER_SIZE 128
262 struct kbase_exported_test_data {
263         u64 test_addr[TEST_ADDR_COUNT];         /**< memory address */
264         u32 test_addr_pages[TEST_ADDR_COUNT];           /**<  memory size in pages */
265         union kbase_pointer kctx;                               /**<  base context created by process */
266         union kbase_pointer mm;                         /**< pointer to process address space */
267         u8 buffer1[KBASE_TEST_BUFFER_SIZE];   /**<  unit test defined parameter */
268         u8 buffer2[KBASE_TEST_BUFFER_SIZE];   /**<  unit test defined parameter */
269 };
270
271 struct kbase_uk_set_test_data {
272         union uk_header header;
273         /* IN */
274         struct kbase_exported_test_data test_data;
275 };
276
277 #endif                          /* MALI_UNIT_TEST */
278
279 #ifdef SUPPORT_MALI_ERROR_INJECT
280 struct kbase_uk_error_params {
281         union uk_header header;
282         /* IN */
283         struct kbase_error_params params;
284 };
285 #endif                          /* SUPPORT_MALI_ERROR_INJECT */
286
287 #ifdef SUPPORT_MALI_NO_MALI
288 struct kbase_uk_model_control_params {
289         union uk_header header;
290         /* IN */
291         struct kbase_model_control_params params;
292 };
293 #endif                          /* SUPPORT_MALI_NO_MALI */
294
295 #define KBASE_MAXIMUM_EXT_RESOURCES       255
296
297 struct kbase_uk_ext_buff_kds_data {
298         union uk_header header;
299         union kbase_pointer external_resource;
300         union kbase_pointer file_descriptor;
301         u32 num_res;            /* limited to KBASE_MAXIMUM_EXT_RESOURCES */
302         u32 padding;
303 };
304
305 #ifdef BASE_LEGACY_UK8_SUPPORT
306 struct kbase_uk_keep_gpu_powered {
307         union uk_header header;
308         u32       enabled;
309         u32       padding;
310 };
311 #endif /* BASE_LEGACY_UK8_SUPPORT */
312
313 struct kbase_uk_profiling_controls {
314         union uk_header header;
315         u32 profiling_controls[FBDUMP_CONTROL_MAX];
316 };
317
318 struct kbase_uk_debugfs_mem_profile_add {
319         union uk_header header;
320         u32 len;
321         union kbase_pointer buf;
322 };
323
324 struct kbase_uk_context_id {
325         union uk_header header;
326         /* OUT */
327         int id;
328 };
329
330 #if (defined(MALI_KTLSTREAM_ENABLED) && MALI_KTLSTREAM_ENABLED) || \
331         defined(CONFIG_MALI_MIPE_ENABLED)
332 /**
333  * struct kbase_uk_tlstream_acquire - User/Kernel space data exchange structure
334  * @header: UK structure header
335  * @fd:     timeline stream file descriptor
336  *
337  * This structure is used used when performing a call to acquire kernel side
338  * timeline stream file descriptor.
339  */
340 struct kbase_uk_tlstream_acquire {
341         union uk_header header;
342         /* IN */
343         /* OUT */
344         s32  fd;
345 };
346
347 /**
348  * struct kbase_uk_tlstream_flush - User/Kernel space data exchange structure
349  * @header: UK structure header
350  *
351  * This structure is used when performing a call to flush kernel side
352  * timeline streams.
353  */
354 struct kbase_uk_tlstream_flush {
355         union uk_header header;
356         /* IN */
357         /* OUT */
358 };
359
360 #if MALI_UNIT_TEST
361 /**
362  * struct kbase_uk_tlstream_test - User/Kernel space data exchange structure
363  * @header:    UK structure header
364  * @tpw_count: number of trace point writers in each context
365  * @msg_delay: time delay between tracepoints from one writer in milliseconds
366  * @msg_count: number of trace points written by one writer
367  * @aux_msg:   if non-zero aux messages will be included
368  *
369  * This structure is used when performing a call to start timeline stream test
370  * embedded in kernel.
371  */
372 struct kbase_uk_tlstream_test {
373         union uk_header header;
374         /* IN */
375         u32 tpw_count;
376         u32 msg_delay;
377         u32 msg_count;
378         u32 aux_msg;
379         /* OUT */
380 };
381
382 /**
383  * struct kbase_uk_tlstream_stats - User/Kernel space data exchange structure
384  * @header:          UK structure header
385  * @bytes_collected: number of bytes read by user
386  * @bytes_generated: number of bytes generated by tracepoints
387  *
388  * This structure is used when performing a call to obtain timeline stream
389  * statistics.
390  */
391 struct kbase_uk_tlstream_stats {
392         union uk_header header; /**< UK structure header. */
393         /* IN */
394         /* OUT */
395         u32 bytes_collected;
396         u32 bytes_generated;
397 };
398 #endif /* MALI_UNIT_TEST */
399 #endif /* MALI_KTLSTREAM_ENABLED */
400
401 /**
402  * struct struct kbase_uk_prfcnt_value for the KBASE_FUNC_SET_PRFCNT_VALUES ioctl
403  * @header:          UK structure header
404  * @data:            Counter samples for the dummy model
405  * @size:............Size of the counter sample data
406  */
407 struct kbase_uk_prfcnt_values {
408         union uk_header header;
409         /* IN */
410         u32 *data;
411         u32 size;
412 };
413
414
415 enum kbase_uk_function_id {
416         KBASE_FUNC_MEM_ALLOC = (UK_FUNC_ID + 0),
417         KBASE_FUNC_MEM_IMPORT = (UK_FUNC_ID + 1),
418         KBASE_FUNC_MEM_COMMIT = (UK_FUNC_ID + 2),
419         KBASE_FUNC_MEM_QUERY = (UK_FUNC_ID + 3),
420         KBASE_FUNC_MEM_FREE = (UK_FUNC_ID + 4),
421         KBASE_FUNC_MEM_FLAGS_CHANGE = (UK_FUNC_ID + 5),
422         KBASE_FUNC_MEM_ALIAS = (UK_FUNC_ID + 6),
423
424 #ifdef BASE_LEGACY_UK6_SUPPORT
425         KBASE_FUNC_JOB_SUBMIT_UK6 = (UK_FUNC_ID + 7),
426 #endif /* BASE_LEGACY_UK6_SUPPORT */
427
428         KBASE_FUNC_SYNC  = (UK_FUNC_ID + 8),
429
430         KBASE_FUNC_POST_TERM = (UK_FUNC_ID + 9),
431
432         KBASE_FUNC_HWCNT_SETUP = (UK_FUNC_ID + 10),
433         KBASE_FUNC_HWCNT_DUMP = (UK_FUNC_ID + 11),
434         KBASE_FUNC_HWCNT_CLEAR = (UK_FUNC_ID + 12),
435
436         KBASE_FUNC_GPU_PROPS_REG_DUMP = (UK_FUNC_ID + 14),
437
438         KBASE_FUNC_FIND_CPU_OFFSET = (UK_FUNC_ID + 15),
439
440         KBASE_FUNC_GET_VERSION = (UK_FUNC_ID + 16),
441         KBASE_FUNC_EXT_BUFFER_LOCK = (UK_FUNC_ID + 17),
442         KBASE_FUNC_SET_FLAGS = (UK_FUNC_ID + 18),
443
444         KBASE_FUNC_SET_TEST_DATA = (UK_FUNC_ID + 19),
445         KBASE_FUNC_INJECT_ERROR = (UK_FUNC_ID + 20),
446         KBASE_FUNC_MODEL_CONTROL = (UK_FUNC_ID + 21),
447
448 #ifdef BASE_LEGACY_UK8_SUPPORT
449         KBASE_FUNC_KEEP_GPU_POWERED = (UK_FUNC_ID + 22),
450 #endif /* BASE_LEGACY_UK8_SUPPORT */
451
452         KBASE_FUNC_FENCE_VALIDATE = (UK_FUNC_ID + 23),
453         KBASE_FUNC_STREAM_CREATE = (UK_FUNC_ID + 24),
454         KBASE_FUNC_GET_PROFILING_CONTROLS = (UK_FUNC_ID + 25),
455         KBASE_FUNC_SET_PROFILING_CONTROLS = (UK_FUNC_ID + 26),
456                                             /* to be used only for testing
457                                             * purposes, otherwise these controls
458                                             * are set through gator API */
459
460         KBASE_FUNC_DEBUGFS_MEM_PROFILE_ADD = (UK_FUNC_ID + 27),
461         KBASE_FUNC_JOB_SUBMIT = (UK_FUNC_ID + 28),
462         KBASE_FUNC_DISJOINT_QUERY = (UK_FUNC_ID + 29),
463
464         KBASE_FUNC_GET_CONTEXT_ID = (UK_FUNC_ID + 31),
465
466 #if (defined(MALI_KTLSTREAM_ENABLED) && MALI_KTLSTREAM_ENABLED) || \
467         defined(CONFIG_MALI_MIPE_ENABLED)
468         KBASE_FUNC_TLSTREAM_ACQUIRE = (UK_FUNC_ID + 32),
469 #if MALI_UNIT_TEST
470         KBASE_FUNC_TLSTREAM_TEST = (UK_FUNC_ID + 33),
471         KBASE_FUNC_TLSTREAM_STATS = (UK_FUNC_ID + 34),
472 #endif /* MALI_UNIT_TEST */
473         KBASE_FUNC_TLSTREAM_FLUSH = (UK_FUNC_ID + 35),
474 #endif /* MALI_KTLSTREAM_ENABLED */
475
476         KBASE_FUNC_HWCNT_READER_SETUP = (UK_FUNC_ID + 36),
477
478 #ifdef SUPPORT_MALI_NO_MALI
479         KBASE_FUNC_SET_PRFCNT_VALUES = (UK_FUNC_ID + 37),
480 #endif
481
482         KBASE_FUNC_MAX
483 };
484
485 #endif                          /* _KBASE_UKU_H_ */
486