3 * (C) COPYRIGHT 2008-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.
24 #include "mali_base_kernel.h"
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)
34 #define SUPPORT_MALI_NO_MALI
38 #if defined(SUPPORT_MALI_NO_MALI) || defined(SUPPORT_MALI_ERROR_INJECT)
39 #include "backend/gpu/mali_kbase_model_dummy.h"
42 #include "mali_kbase_gpuprops_types.h"
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.
49 #define BASE_UK_VERSION_MAJOR 10
50 #define BASE_UK_VERSION_MINOR 1
52 struct kbase_uk_mem_alloc {
53 union uk_header header;
66 struct kbase_uk_mem_free {
67 union uk_header header;
73 struct kbase_uk_mem_alias {
74 union uk_header header;
80 union kbase_pointer ai;
86 struct kbase_uk_mem_import {
87 union uk_header header;
89 union kbase_pointer phandle;
99 struct kbase_uk_mem_flags_change {
100 union uk_header header;
107 struct kbase_uk_job_submit {
108 union uk_header header;
110 union kbase_pointer addr;
112 u32 stride; /* bytes between atoms, i.e. sizeof(base_jd_atom_v2) */
116 struct kbase_uk_post_term {
117 union uk_header header;
120 struct kbase_uk_sync_now {
121 union uk_header header;
124 struct base_syncset sset;
129 struct kbase_uk_hwcnt_setup {
130 union uk_header header;
137 u32 unused_1; /* keep for backwards compatibility */
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
153 * This structure sets up HWC dumper/reader for this context.
154 * Multiple instances can be created for single context.
156 struct kbase_uk_hwcnt_reader_setup {
157 union uk_header header;
170 struct kbase_uk_hwcnt_dump {
171 union uk_header header;
174 struct kbase_uk_hwcnt_clear {
175 union uk_header header;
178 struct kbase_uk_fence_validate {
179 union uk_header header;
186 struct kbase_uk_stream_create {
187 union uk_header header;
195 struct kbase_uk_gpuprops {
196 union uk_header header;
199 struct mali_base_gpu_props props;
203 struct kbase_uk_mem_query {
204 union uk_header header;
207 #define KBASE_MEM_QUERY_COMMIT_SIZE 1
208 #define KBASE_MEM_QUERY_VA_SIZE 2
209 #define KBASE_MEM_QUERY_FLAGS 3
215 struct kbase_uk_mem_commit {
216 union uk_header header;
225 struct kbase_uk_find_cpu_offset {
226 union uk_header header;
235 #define KBASE_GET_VERSION_BUFFER_SIZE 64
236 struct kbase_uk_get_ddk_version {
237 union uk_header header;
239 char version_buffer[KBASE_GET_VERSION_BUFFER_SIZE];
240 u32 version_string_size;
245 struct kbase_uk_disjoint_query {
246 union uk_header header;
252 struct kbase_uk_set_flags {
253 union uk_header header;
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 */
271 struct kbase_uk_set_test_data {
272 union uk_header header;
274 struct kbase_exported_test_data test_data;
277 #endif /* MALI_UNIT_TEST */
279 #ifdef SUPPORT_MALI_ERROR_INJECT
280 struct kbase_uk_error_params {
281 union uk_header header;
283 struct kbase_error_params params;
285 #endif /* SUPPORT_MALI_ERROR_INJECT */
287 #ifdef SUPPORT_MALI_NO_MALI
288 struct kbase_uk_model_control_params {
289 union uk_header header;
291 struct kbase_model_control_params params;
293 #endif /* SUPPORT_MALI_NO_MALI */
295 #define KBASE_MAXIMUM_EXT_RESOURCES 255
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 */
305 #ifdef BASE_LEGACY_UK8_SUPPORT
306 struct kbase_uk_keep_gpu_powered {
307 union uk_header header;
311 #endif /* BASE_LEGACY_UK8_SUPPORT */
313 struct kbase_uk_profiling_controls {
314 union uk_header header;
315 u32 profiling_controls[FBDUMP_CONTROL_MAX];
318 struct kbase_uk_debugfs_mem_profile_add {
319 union uk_header header;
321 union kbase_pointer buf;
324 struct kbase_uk_context_id {
325 union uk_header header;
330 #if (defined(MALI_KTLSTREAM_ENABLED) && MALI_KTLSTREAM_ENABLED) || \
331 defined(CONFIG_MALI_MIPE_ENABLED)
333 * struct kbase_uk_tlstream_acquire - User/Kernel space data exchange structure
334 * @header: UK structure header
335 * @fd: timeline stream file descriptor
337 * This structure is used used when performing a call to acquire kernel side
338 * timeline stream file descriptor.
340 struct kbase_uk_tlstream_acquire {
341 union uk_header header;
348 * struct kbase_uk_tlstream_flush - User/Kernel space data exchange structure
349 * @header: UK structure header
351 * This structure is used when performing a call to flush kernel side
354 struct kbase_uk_tlstream_flush {
355 union uk_header header;
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
369 * This structure is used when performing a call to start timeline stream test
370 * embedded in kernel.
372 struct kbase_uk_tlstream_test {
373 union uk_header header;
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
388 * This structure is used when performing a call to obtain timeline stream
391 struct kbase_uk_tlstream_stats {
392 union uk_header header; /**< UK structure header. */
398 #endif /* MALI_UNIT_TEST */
399 #endif /* MALI_KTLSTREAM_ENABLED */
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
407 struct kbase_uk_prfcnt_values {
408 union uk_header header;
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),
424 #ifdef BASE_LEGACY_UK6_SUPPORT
425 KBASE_FUNC_JOB_SUBMIT_UK6 = (UK_FUNC_ID + 7),
426 #endif /* BASE_LEGACY_UK6_SUPPORT */
428 KBASE_FUNC_SYNC = (UK_FUNC_ID + 8),
430 KBASE_FUNC_POST_TERM = (UK_FUNC_ID + 9),
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),
436 KBASE_FUNC_GPU_PROPS_REG_DUMP = (UK_FUNC_ID + 14),
438 KBASE_FUNC_FIND_CPU_OFFSET = (UK_FUNC_ID + 15),
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),
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),
448 #ifdef BASE_LEGACY_UK8_SUPPORT
449 KBASE_FUNC_KEEP_GPU_POWERED = (UK_FUNC_ID + 22),
450 #endif /* BASE_LEGACY_UK8_SUPPORT */
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 */
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),
464 KBASE_FUNC_GET_CONTEXT_ID = (UK_FUNC_ID + 31),
466 #if (defined(MALI_KTLSTREAM_ENABLED) && MALI_KTLSTREAM_ENABLED) || \
467 defined(CONFIG_MALI_MIPE_ENABLED)
468 KBASE_FUNC_TLSTREAM_ACQUIRE = (UK_FUNC_ID + 32),
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 */
476 KBASE_FUNC_HWCNT_READER_SETUP = (UK_FUNC_ID + 36),
478 #ifdef SUPPORT_MALI_NO_MALI
479 KBASE_FUNC_SET_PRFCNT_VALUES = (UK_FUNC_ID + 37),
485 #endif /* _KBASE_UKU_H_ */