My Project
mali_base_kernel.h
Go to the documentation of this file.
1 /*
2  *
3  * (C) COPYRIGHT 2010-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 
25 #ifndef _BASE_KERNEL_H_
26 #define _BASE_KERNEL_H_
27 
28 #ifndef __user
29 #define __user
30 #endif
31 
32 /* Support UK6 IOCTLS */
33 #define BASE_LEGACY_UK6_SUPPORT 1
34 
35 /* Support UK7 IOCTLS */
36 /* NB: To support UK6 we also need to support UK7 */
37 #define BASE_LEGACY_UK7_SUPPORT 1
38 
39 /* Support UK8 IOCTLS */
40 #define BASE_LEGACY_UK8_SUPPORT 1
41 
42 /* Support UK9 IOCTLS */
43 #define BASE_LEGACY_UK9_SUPPORT 1
44 
45 /* Support UK10_2 IOCTLS */
46 #define BASE_LEGACY_UK10_2_SUPPORT 1
47 
48 /* Support UK10_4 IOCTLS */
49 #define BASE_LEGACY_UK10_4_SUPPORT 1
50 
51 typedef struct base_mem_handle {
52  struct {
53  u64 handle;
54  } basep;
56 
57 #include "mali_base_mem_priv.h"
59 #include "mali_midg_coherency.h"
60 #include "mali_kbase_gpu_id.h"
61 
62 /*
63  * Dependency stuff, keep it private for now. May want to expose it if
64  * we decide to make the number of semaphores a configurable
65  * option.
66  */
67 #define BASE_JD_ATOM_COUNT 256
68 
69 #define BASEP_JD_SEM_PER_WORD_LOG2 5
70 #define BASEP_JD_SEM_PER_WORD (1 << BASEP_JD_SEM_PER_WORD_LOG2)
71 #define BASEP_JD_SEM_WORD_NR(x) ((x) >> BASEP_JD_SEM_PER_WORD_LOG2)
72 #define BASEP_JD_SEM_MASK_IN_WORD(x) (1 << ((x) & (BASEP_JD_SEM_PER_WORD - 1)))
73 #define BASEP_JD_SEM_ARRAY_SIZE BASEP_JD_SEM_WORD_NR(BASE_JD_ATOM_COUNT)
74 
75 /* Set/reset values for a software event */
76 #define BASE_JD_SOFT_EVENT_SET ((unsigned char)1)
77 #define BASE_JD_SOFT_EVENT_RESET ((unsigned char)0)
78 
79 #define BASE_GPU_NUM_TEXTURE_FEATURES_REGISTERS 3
80 
81 #define BASE_MAX_COHERENT_GROUPS 16
82 
83 #define BASE_DEBUG_FENCE_TIMEOUT 1
84 
85 #if defined CDBG_ASSERT
86 #define LOCAL_ASSERT CDBG_ASSERT
87 #elif defined KBASE_DEBUG_ASSERT
88 #define LOCAL_ASSERT KBASE_DEBUG_ASSERT
89 #else
90 #error assert macro not defined!
91 #endif
92 
93 #if defined PAGE_MASK
94 #define LOCAL_PAGE_LSB ~PAGE_MASK
95 #else
96 #include <osu/mali_osu.h>
97 
98 #if defined OSU_CONFIG_CPU_PAGE_SIZE_LOG2
99 #define LOCAL_PAGE_LSB ((1ul << OSU_CONFIG_CPU_PAGE_SIZE_LOG2) - 1)
100 #else
101 #error Failed to find page size
102 #endif
103 #endif
104 
106 typedef union kbase_pointer {
107  void __user *value;
109  u64 sizer;
110 } kbase_pointer;
111 
135 
142 enum {
143 /* IN */
144  BASE_MEM_PROT_CPU_RD = (1U << 0),
145  BASE_MEM_PROT_CPU_WR = (1U << 1),
146  BASE_MEM_PROT_GPU_RD = (1U << 2),
147  BASE_MEM_PROT_GPU_WR = (1U << 3),
148  BASE_MEM_PROT_GPU_EX = (1U << 4),
151  /* BASE_MEM_HINT flags have been removed, but their values are reserved
152  * for backwards compatibility with older user-space drivers. The values
153  * can be re-used once support for r5p0 user-space drivers is removed,
154  * presumably in r7p0.
155  *
156  * RESERVED: (1U << 5)
157  * RESERVED: (1U << 6)
158  * RESERVED: (1U << 7)
159  * RESERVED: (1U << 8)
160  */
161 
162  BASE_MEM_GROW_ON_GPF = (1U << 9),
167  BASE_MEM_COHERENT_LOCAL = (1U << 11),
169  BASE_MEM_CACHED_CPU = (1U << 12),
172 /* IN/OUT */
173  BASE_MEM_SAME_VA = (1U << 13),
175 /* OUT */
176  BASE_MEM_NEED_MMAP = (1U << 14),
178 /* IN */
181  BASE_MEM_SECURE = (1U << 16),
182  BASE_MEM_DONT_NEED = (1U << 17),
184  BASE_MEM_IMPORT_SHARED = (1U << 18),
188 };
189 
195 #define BASE_MEM_FLAGS_NR_BITS 19
196 
200 #define BASE_MEM_FLAGS_OUTPUT_MASK BASE_MEM_NEED_MMAP
201 
205 #define BASE_MEM_FLAGS_INPUT_MASK \
206  (((1 << BASE_MEM_FLAGS_NR_BITS) - 1) & ~BASE_MEM_FLAGS_OUTPUT_MASK)
207 
212 #define BASE_MEM_FLAGS_MODIFIABLE \
213  (BASE_MEM_DONT_NEED | BASE_MEM_COHERENT_SYSTEM | \
214  BASE_MEM_COHERENT_LOCAL)
215 
233 typedef enum base_mem_import_type {
234  BASE_MEM_IMPORT_TYPE_INVALID = 0,
235  BASE_MEM_IMPORT_TYPE_UMP = 1,
236  BASE_MEM_IMPORT_TYPE_UMM = 2,
237  BASE_MEM_IMPORT_TYPE_USER_BUFFER = 3
239 
250  kbase_pointer ptr;
251  u64 length;
252 };
253 
262 #define BASE_MEM_INVALID_HANDLE ((base_mem_handle) { {BASEP_MEM_INVALID_HANDLE} })
263 
274 #define BASE_MEM_WRITE_ALLOC_PAGES_HANDLE ((base_mem_handle) { {BASEP_MEM_WRITE_ALLOC_PAGES_HANDLE} })
275 
276 #define BASEP_MEM_INVALID_HANDLE (0ull << 12)
277 #define BASE_MEM_MMU_DUMP_HANDLE (1ull << 12)
278 #define BASE_MEM_TRACE_BUFFER_HANDLE (2ull << 12)
279 #define BASE_MEM_MAP_TRACKING_HANDLE (3ull << 12)
280 #define BASEP_MEM_WRITE_ALLOC_PAGES_HANDLE (4ull << 12)
281 /* reserved handles ..-64<<PAGE_SHIFT> for future special handles */
282 #define BASE_MEM_COOKIE_BASE (64ul << 12)
283 #define BASE_MEM_FIRST_FREE_ADDRESS ((BITS_PER_LONG << 12) + \
284  BASE_MEM_COOKIE_BASE)
285 
286 /* Mask to detect 4GB boundary alignment */
287 #define BASE_MEM_MASK_4GB 0xfffff000UL
288 
289 
290 /* Bit mask of cookies used for for memory allocation setup */
291 #define KBASE_COOKIE_MASK ~1UL /* bit 0 is reserved */
292 
293 
303 
315 typedef struct base_syncset {
316  struct basep_syncset basep_sset;
317 } base_syncset;
318 
326 typedef struct base_import_handle {
327  struct {
328  u64 handle;
329  } basep;
331 
339 typedef int platform_fence_type;
340 #define INVALID_PLATFORM_FENCE ((platform_fence_type)-1)
341 
347 typedef struct base_stream {
348  struct {
349  int fd;
350  } basep;
351 } base_stream;
352 
358 typedef struct base_fence {
359  struct {
360  int fd;
361  int stream_fd;
362  } basep;
363 } base_fence;
364 
373 typedef struct base_jd_udata {
374  u64 blob[2];
375 } base_jd_udata;
376 
399  base_mem_handle handle;
400  u64 offset;
401  u64 length;
402 };
403 
419  u64 gpu_alloc_addr;
420  u64 va_pages;
421  u64 commit_pages;
422  u64 extent;
423  u8 id;
424 };
425 
435 typedef u8 base_jd_dep_type;
436 
437 
438 #define BASE_JD_DEP_TYPE_INVALID (0)
439 #define BASE_JD_DEP_TYPE_DATA (1U << 0)
440 #define BASE_JD_DEP_TYPE_ORDER (1U << 1)
452 typedef u32 base_jd_core_req;
453 
454 /* Requirements that come from the HW */
455 
459 #define BASE_JD_REQ_DEP ((base_jd_core_req)0)
460 
464 #define BASE_JD_REQ_FS ((base_jd_core_req)1 << 0)
465 
477 #define BASE_JD_REQ_CS ((base_jd_core_req)1 << 1)
478 #define BASE_JD_REQ_T ((base_jd_core_req)1 << 2)
479 #define BASE_JD_REQ_CF ((base_jd_core_req)1 << 3)
480 #define BASE_JD_REQ_V ((base_jd_core_req)1 << 4)
482 /* SW-only requirements - the HW does not expose these as part of the job slot capabilities */
483 
484 /* Requires fragment job with AFBC encoding */
485 #define BASE_JD_REQ_FS_AFBC ((base_jd_core_req)1 << 13)
486 
495 #define BASE_JD_REQ_EVENT_COALESCE ((base_jd_core_req)1 << 5)
496 
501 #define BASE_JD_REQ_COHERENT_GROUP ((base_jd_core_req)1 << 6)
502 
508 #define BASE_JD_REQ_PERMON ((base_jd_core_req)1 << 7)
509 
519 #define BASE_JD_REQ_EXTERNAL_RESOURCES ((base_jd_core_req)1 << 8)
520 
525 #define BASE_JD_REQ_SOFT_JOB ((base_jd_core_req)1 << 9)
526 
527 #define BASE_JD_REQ_SOFT_DUMP_CPU_GPU_TIME (BASE_JD_REQ_SOFT_JOB | 0x1)
528 #define BASE_JD_REQ_SOFT_FENCE_TRIGGER (BASE_JD_REQ_SOFT_JOB | 0x2)
529 #define BASE_JD_REQ_SOFT_FENCE_WAIT (BASE_JD_REQ_SOFT_JOB | 0x3)
530 
567 #define BASE_JD_REQ_SOFT_REPLAY (BASE_JD_REQ_SOFT_JOB | 0x4)
568 
577 #define BASE_JD_REQ_SOFT_EVENT_WAIT (BASE_JD_REQ_SOFT_JOB | 0x5)
578 #define BASE_JD_REQ_SOFT_EVENT_SET (BASE_JD_REQ_SOFT_JOB | 0x6)
579 #define BASE_JD_REQ_SOFT_EVENT_RESET (BASE_JD_REQ_SOFT_JOB | 0x7)
580 
581 #define BASE_JD_REQ_SOFT_DEBUG_COPY (BASE_JD_REQ_SOFT_JOB | 0x8)
582 
598 #define BASE_JD_REQ_SOFT_JIT_ALLOC (BASE_JD_REQ_SOFT_JOB | 0x9)
599 
608 #define BASE_JD_REQ_SOFT_JIT_FREE (BASE_JD_REQ_SOFT_JOB | 0xa)
609 
618 #define BASE_JD_REQ_SOFT_EXT_RES_MAP (BASE_JD_REQ_SOFT_JOB | 0xb)
619 
627 #define BASE_JD_REQ_SOFT_EXT_RES_UNMAP (BASE_JD_REQ_SOFT_JOB | 0xc)
628 
637 #define BASE_JD_REQ_ONLY_COMPUTE ((base_jd_core_req)1 << 10)
638 
650 #define BASE_JD_REQ_SPECIFIC_COHERENT_GROUP ((base_jd_core_req)1 << 11)
651 
656 #define BASE_JD_REQ_EVENT_ONLY_ON_FAILURE ((base_jd_core_req)1 << 12)
657 
662 #define BASEP_JD_REQ_EVENT_NEVER ((base_jd_core_req)1 << 14)
663 
673 #define BASE_JD_REQ_SKIP_CACHE_START ((base_jd_core_req)1 << 15)
674 
684 #define BASE_JD_REQ_SKIP_CACHE_END ((base_jd_core_req)1 << 16)
685 
689 #define BASEP_JD_REQ_RESERVED \
690  (~(BASE_JD_REQ_ATOM_TYPE | BASE_JD_REQ_EXTERNAL_RESOURCES | \
691  BASE_JD_REQ_EVENT_ONLY_ON_FAILURE | BASEP_JD_REQ_EVENT_NEVER | \
692  BASE_JD_REQ_EVENT_COALESCE | \
693  BASE_JD_REQ_COHERENT_GROUP | BASE_JD_REQ_SPECIFIC_COHERENT_GROUP | \
694  BASE_JD_REQ_FS_AFBC | BASE_JD_REQ_PERMON | \
695  BASE_JD_REQ_SKIP_CACHE_START | BASE_JD_REQ_SKIP_CACHE_END))
696 
702 #define BASE_JD_REQ_ATOM_TYPE \
703  (BASE_JD_REQ_FS | BASE_JD_REQ_CS | BASE_JD_REQ_T | BASE_JD_REQ_CF | \
704  BASE_JD_REQ_V | BASE_JD_REQ_SOFT_JOB | BASE_JD_REQ_ONLY_COMPUTE)
705 
709 #define BASE_JD_REQ_SOFT_JOB_TYPE (BASE_JD_REQ_SOFT_JOB | 0x1f)
710 
711 /*
712  * Returns non-zero value if core requirements passed define a soft job or
713  * a dependency only job.
714  */
715 #define BASE_JD_REQ_SOFT_JOB_OR_DEP(core_req) \
716  ((core_req & BASE_JD_REQ_SOFT_JOB) || \
717  (core_req & BASE_JD_REQ_ATOM_TYPE) == BASE_JD_REQ_DEP)
718 
756 };
757 
758 /*
759  * Base Atom priority
760  *
761  * Only certain priority levels are actually implemented, as specified by the
762  * BASE_JD_PRIO_<...> definitions below. It is undefined to use a priority
763  * level that is not one of those defined below.
764  *
765  * Priority levels only affect scheduling between atoms of the same type within
766  * a base context, and only after the atoms have had dependencies resolved.
767  * Fragment atoms does not affect non-frament atoms with lower priorities, and
768  * the other way around. For example, a low priority atom that has had its
769  * dependencies resolved might run before a higher priority atom that has not
770  * had its dependencies resolved.
771  *
772  * The scheduling between base contexts/processes and between atoms from
773  * different base contexts/processes is unaffected by atom priority.
774  *
775  * The atoms are scheduled as follows with respect to their priorities:
776  * - Let atoms 'X' and 'Y' be for the same job slot who have dependencies
777  * resolved, and atom 'X' has a higher priority than atom 'Y'
778  * - If atom 'Y' is currently running on the HW, then it is interrupted to
779  * allow atom 'X' to run soon after
780  * - If instead neither atom 'Y' nor atom 'X' are running, then when choosing
781  * the next atom to run, atom 'X' will always be chosen instead of atom 'Y'
782  * - Any two atoms that have the same priority could run in any order with
783  * respect to each other. That is, there is no ordering constraint between
784  * atoms of the same priority.
785  */
786 typedef u8 base_jd_prio;
787 
788 /* Medium atom priority. This is a priority higher than BASE_JD_PRIO_LOW */
789 #define BASE_JD_PRIO_MEDIUM ((base_jd_prio)0)
790 /* High atom priority. This is a priority higher than BASE_JD_PRIO_MEDIUM and
791  * BASE_JD_PRIO_LOW */
792 #define BASE_JD_PRIO_HIGH ((base_jd_prio)1)
793 /* Low atom priority. */
794 #define BASE_JD_PRIO_LOW ((base_jd_prio)2)
795 
796 /* Count of the number of priority levels. This itself is not a valid
797  * base_jd_prio setting */
798 #define BASE_JD_NR_PRIO_LEVELS 3
799 
812 };
813 
814 typedef u8 base_atom_id;
817  base_atom_id atom_id;
818  base_jd_dep_type dependency_type;
819 };
820 
821 /* This structure has changed since UK 10.2 for which base_jd_core_req was a u16 value.
822  * In order to keep the size of the structure same, padding field has been adjusted
823  * accordingly and core_req field of a u32 type (to which UK 10.3 base_jd_core_req defines)
824  * is added at the end of the structure. Place in the structure previously occupied by u16 core_req
825  * is kept but renamed to compat_core_req and as such it can be used in ioctl call for job submission
826  * as long as UK 10.2 legacy is supported. Once when this support ends, this field can be left
827  * for possible future use. */
828 typedef struct base_jd_atom_v2 {
829  u64 jc;
830  struct base_jd_udata udata;
832  u16 nr_extres;
834  struct base_dependency pre_dep[2];
836  base_atom_id atom_number;
837  base_jd_prio prio;
839  u8 padding[1];
842 
843 #ifdef BASE_LEGACY_UK6_SUPPORT
845  u64 jc;
846  struct base_jd_udata udata;
848  u16 nr_extres;
849  u16 core_req;
850  base_atom_id pre_dep[2];
851  base_atom_id atom_number;
852  base_jd_prio prio;
854  u8 padding[7];
855 };
856 #endif /* BASE_LEGACY_UK6_SUPPORT */
857 
858 typedef enum base_external_resource_access {
859  BASE_EXT_RES_ACCESS_SHARED,
860  BASE_EXT_RES_ACCESS_EXCLUSIVE
861 } base_external_resource_access;
862 
863 typedef struct base_external_resource {
864  u64 ext_resource;
866 
867 
872 #define BASE_EXT_RES_COUNT_MAX 10
873 
882  u64 count;
883  struct base_external_resource ext_res[1];
884 };
885 
887  u64 address;
888  u64 size;
889  struct base_external_resource extres;
890 };
891 
900 static inline void base_jd_atom_dep_set(struct base_dependency *dep,
901  base_atom_id id, base_jd_dep_type dep_type)
902 {
903  LOCAL_ASSERT(dep != NULL);
904 
905  /*
906  * make sure we don't set not allowed combinations
907  * of atom_id/dependency_type.
908  */
909  LOCAL_ASSERT((id == 0 && dep_type == BASE_JD_DEP_TYPE_INVALID) ||
910  (id > 0 && dep_type != BASE_JD_DEP_TYPE_INVALID));
911 
912  dep->atom_id = id;
913  dep->dependency_type = dep_type;
914 }
915 
923 static inline void base_jd_atom_dep_copy(struct base_dependency *dep,
924  const struct base_dependency *from)
925 {
926  LOCAL_ASSERT(dep != NULL);
927 
928  base_jd_atom_dep_set(dep, from->atom_id, from->dependency_type);
929 }
930 
949 static inline void base_jd_fence_trigger_setup_v2(struct base_jd_atom_v2 *atom, struct base_fence *fence)
950 {
951  LOCAL_ASSERT(atom);
952  LOCAL_ASSERT(fence);
953  LOCAL_ASSERT(fence->basep.fd == INVALID_PLATFORM_FENCE);
954  LOCAL_ASSERT(fence->basep.stream_fd >= 0);
955  atom->jc = (uintptr_t) fence;
956  atom->core_req = BASE_JD_REQ_SOFT_FENCE_TRIGGER;
957 }
958 
978 static inline void base_jd_fence_wait_setup_v2(struct base_jd_atom_v2 *atom, struct base_fence *fence)
979 {
980  LOCAL_ASSERT(atom);
981  LOCAL_ASSERT(fence);
982  LOCAL_ASSERT(fence->basep.fd >= 0);
983  atom->jc = (uintptr_t) fence;
984  atom->core_req = BASE_JD_REQ_SOFT_FENCE_WAIT;
985 }
986 
998 static inline void base_external_resource_init(struct base_external_resource *res, struct base_import_handle handle, base_external_resource_access access)
999 {
1000  u64 address;
1001 
1002  address = handle.basep.handle;
1003 
1004  LOCAL_ASSERT(res != NULL);
1005  LOCAL_ASSERT(0 == (address & LOCAL_PAGE_LSB));
1006  LOCAL_ASSERT(access == BASE_EXT_RES_ACCESS_SHARED || access == BASE_EXT_RES_ACCESS_EXCLUSIVE);
1007 
1008  res->ext_resource = address | (access & LOCAL_PAGE_LSB);
1009 }
1010 
1015 enum {
1017  BASE_JD_SW_EVENT = (1u << 14),
1019  BASE_JD_SW_EVENT_JOB = (0u << 11),
1020  BASE_JD_SW_EVENT_BAG = (1u << 11),
1021  BASE_JD_SW_EVENT_INFO = (2u << 11),
1024 };
1025 
1057 typedef enum base_jd_event_code {
1058  /* HW defined exceptions */
1059 
1066 
1067  /* non-fatal exceptions */
1069  BASE_JD_EVENT_DONE = 0x01,
1080 
1083 
1084  /* job exceptions */
1085  BASE_JD_EVENT_JOB_CONFIG_FAULT = 0x40,
1086  BASE_JD_EVENT_JOB_POWER_FAULT = 0x41,
1087  BASE_JD_EVENT_JOB_READ_FAULT = 0x42,
1088  BASE_JD_EVENT_JOB_WRITE_FAULT = 0x43,
1089  BASE_JD_EVENT_JOB_AFFINITY_FAULT = 0x44,
1090  BASE_JD_EVENT_JOB_BUS_FAULT = 0x48,
1091  BASE_JD_EVENT_INSTR_INVALID_PC = 0x50,
1092  BASE_JD_EVENT_INSTR_INVALID_ENC = 0x51,
1093  BASE_JD_EVENT_INSTR_TYPE_MISMATCH = 0x52,
1094  BASE_JD_EVENT_INSTR_OPERAND_FAULT = 0x53,
1095  BASE_JD_EVENT_INSTR_TLS_FAULT = 0x54,
1096  BASE_JD_EVENT_INSTR_BARRIER_FAULT = 0x55,
1097  BASE_JD_EVENT_INSTR_ALIGN_FAULT = 0x56,
1098  BASE_JD_EVENT_DATA_INVALID_FAULT = 0x58,
1099  BASE_JD_EVENT_TILE_RANGE_FAULT = 0x59,
1100  BASE_JD_EVENT_STATE_FAULT = 0x5A,
1101  BASE_JD_EVENT_OUT_OF_MEMORY = 0x60,
1102  BASE_JD_EVENT_UNKNOWN = 0x7F,
1103 
1104  /* GPU exceptions */
1105  BASE_JD_EVENT_DELAYED_BUS_FAULT = 0x80,
1106  BASE_JD_EVENT_SHAREABILITY_FAULT = 0x88,
1107 
1108  /* MMU exceptions */
1109  BASE_JD_EVENT_TRANSLATION_FAULT_LEVEL1 = 0xC1,
1110  BASE_JD_EVENT_TRANSLATION_FAULT_LEVEL2 = 0xC2,
1111  BASE_JD_EVENT_TRANSLATION_FAULT_LEVEL3 = 0xC3,
1112  BASE_JD_EVENT_TRANSLATION_FAULT_LEVEL4 = 0xC4,
1113  BASE_JD_EVENT_PERMISSION_FAULT = 0xC8,
1114  BASE_JD_EVENT_TRANSTAB_BUS_FAULT_LEVEL1 = 0xD1,
1115  BASE_JD_EVENT_TRANSTAB_BUS_FAULT_LEVEL2 = 0xD2,
1116  BASE_JD_EVENT_TRANSTAB_BUS_FAULT_LEVEL3 = 0xD3,
1117  BASE_JD_EVENT_TRANSTAB_BUS_FAULT_LEVEL4 = 0xD4,
1118  BASE_JD_EVENT_ACCESS_FLAG = 0xD8,
1119 
1120  /* SW defined exceptions */
1121  BASE_JD_EVENT_MEM_GROWTH_FAILED = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_JOB | 0x000,
1122  BASE_JD_EVENT_TIMED_OUT = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_JOB | 0x001,
1123  BASE_JD_EVENT_JOB_CANCELLED = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_JOB | 0x002,
1124  BASE_JD_EVENT_JOB_INVALID = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_JOB | 0x003,
1125  BASE_JD_EVENT_PM_EVENT = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_JOB | 0x004,
1126  BASE_JD_EVENT_FORCE_REPLAY = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_JOB | 0x005,
1127 
1128  BASE_JD_EVENT_BAG_INVALID = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_BAG | 0x003,
1129 
1132 
1135 
1136  BASE_JD_EVENT_PROGRESS_REPORT = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_SUCCESS | BASE_JD_SW_EVENT_JOB | 0x000,
1137  BASE_JD_EVENT_BAG_DONE = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_SUCCESS | BASE_JD_SW_EVENT_BAG | 0x000,
1138  BASE_JD_EVENT_DRV_TERMINATED = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_SUCCESS | BASE_JD_SW_EVENT_INFO | 0x000,
1139 
1142 
1145  BASE_JD_EVENT_REMOVED_FROM_NEXT = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_KERNEL | BASE_JD_SW_EVENT_JOB | 0x000,
1146 
1150 
1168 typedef struct base_jd_event_v2 {
1170  base_atom_id atom_number;
1171  struct base_jd_udata udata;
1173 
1179 #define BASE_CPU_GPU_CACHE_LINE_PADDING (36)
1180 
1181 
1194  u64 system_time;
1195  u64 cycle_counter;
1196  u64 sec;
1197  u32 usec;
1198  u8 padding[BASE_CPU_GPU_CACHE_LINE_PADDING];
1200 
1201 
1202 
1205 #define GPU_MAX_JOB_SLOTS 16
1206 
1422 #define BASE_GPU_NUM_TEXTURE_FEATURES_REGISTERS 3
1423 
1424 #define BASE_MAX_COHERENT_GROUPS 16
1425 
1431 
1439 
1445 
1451 
1452  u16 padding;
1453 
1459 
1466  u32 gpu_freq_khz_min;
1467 
1472 
1480  u32 texture_features[BASE_GPU_NUM_TEXTURE_FEATURES_REGISTERS];
1481 
1493 };
1494 
1501  u8 log2_line_size;
1502  u8 log2_cache_size;
1503  u8 num_l2_slices; /* Number of L2C slices. 1 or higher */
1504  u8 padding[5];
1505 };
1506 
1508  u32 bin_size_bytes; /* Max is 4*2^15 */
1509  u32 max_active_levels; /* Max is 2^15 */
1510 };
1511 
1516  u32 max_threads; /* Max. number of threads per core */
1517  u32 max_workgroup_size; /* Max. number of threads per workgroup */
1518  u32 max_barrier_size; /* Max. number of threads that can synchronize on a simple barrier */
1519  u16 max_registers; /* Total size [1..65535] of the register file available per core. */
1520  u8 max_task_queue; /* Max. tasks [1..255] which may be sent to a core before it becomes blocked. */
1521  u8 max_thread_group_split; /* Max. allowed value [1..15] of the Thread Group Split field. */
1522  u8 impl_tech; /* 0 = Not specified, 1 = Silicon, 2 = FPGA, 3 = SW Model/Emulation */
1523  u8 padding[7];
1524 };
1525 
1540  u16 padding[3];
1541 };
1542 
1554  u32 num_groups;
1555 
1567 
1573 
1574  u32 padding;
1575 
1579  struct mali_base_gpu_coherent_group group[BASE_MAX_COHERENT_GROUPS];
1580 };
1581 
1599  u64 shader_present;
1600  u64 tiler_present;
1601  u64 l2_present;
1602  u64 stack_present;
1603 
1604  u32 l2_features;
1605  u32 suspend_size; /* API 8.2+ */
1606  u32 mem_features;
1607  u32 mmu_features;
1608 
1609  u32 as_present;
1610 
1611  u32 js_present;
1612  u32 js_features[GPU_MAX_JOB_SLOTS];
1613  u32 tiler_features;
1614  u32 texture_features[3];
1615 
1616  u32 gpu_id;
1617 
1618  u32 thread_max_threads;
1619  u32 thread_max_workgroup_size;
1620  u32 thread_max_barrier_size;
1621  u32 thread_features;
1622 
1623  /*
1624  * Note: This is the _selected_ coherency mode rather than the
1625  * available modes as exposed in the coherency_features register.
1626  */
1627  u32 coherency_mode;
1628 };
1629 
1639 typedef struct mali_base_gpu_props {
1640  struct mali_base_gpu_core_props core_props;
1641  struct mali_base_gpu_l2_cache_props l2_props;
1642  u64 unused_1; /* keep for backwards compatibility */
1643  struct mali_base_gpu_tiler_props tiler_props;
1644  struct mali_base_gpu_thread_props thread_props;
1645 
1647  struct gpu_raw_gpu_props raw_props;
1648 
1650  struct mali_base_gpu_coherent_group_info coherency_info;
1651 } base_gpu_props;
1652 
1674 
1677 
1682 };
1683 
1687 #define BASE_CONTEXT_CREATE_ALLOWED_FLAGS \
1688  (((u32)BASE_CONTEXT_CCTX_EMBEDDED) | \
1689  ((u32)BASE_CONTEXT_SYSTEM_MONITOR_SUBMIT_DISABLED))
1690 
1694 #define BASE_CONTEXT_CREATE_KERNEL_FLAGS \
1695  ((u32)BASE_CONTEXT_SYSTEM_MONITOR_SUBMIT_DISABLED)
1696 
1697 /*
1698  * Private flags used on the base context
1699  *
1700  * These start at bit 31, and run down to zero.
1701  *
1702  * They share the same space as @ref base_context_create_flags, and so must
1703  * not collide with them.
1704  */
1706 #define BASEP_CONTEXT_FLAG_JOB_DUMP_DISABLED ((u32)(1 << 31))
1707 
1736 typedef struct base_jd_replay_payload {
1743 
1748 
1753 
1758 
1763 
1769 
1774 
1780 
1781 #ifdef BASE_LEGACY_UK10_2_SUPPORT
1783  u64 tiler_jc_list;
1784  u64 fragment_jc;
1785  u64 tiler_heap_free;
1786  u16 fragment_hierarchy_mask;
1787  u16 tiler_hierarchy_mask;
1788  u32 hierarchy_default_weight;
1789  u16 tiler_core_req;
1790  u16 fragment_core_req;
1791  u8 padding[4];
1793 #endif /* BASE_LEGACY_UK10_2_SUPPORT */
1794 
1799 typedef struct base_jd_replay_jc {
1804  u64 next;
1805 
1809  u64 jc;
1810 
1812 
1813 /* Maximum number of jobs allowed in a fragment chain in the payload of a
1814  * replay job */
1815 #define BASE_JD_REPLAY_F_CHAIN_JOB_LIMIT 256
1816 
1819 typedef struct base_profiling_controls {
1820  u32 profiling_controls[FBDUMP_CONTROL_MAX];
1822 
1823 /* Enable additional tracepoints for latency measurements (TL_ATOM_READY,
1824  * TL_ATOM_DONE, TL_ATOM_PRIO_CHANGE, TL_ATOM_EVENT_POST) */
1825 #define BASE_TLSTREAM_ENABLE_LATENCY_TRACEPOINTS (1 << 0)
1826 
1827 /* Indicate that job dumping is enabled. This could affect certain timers
1828  * to account for the performance impact. */
1829 #define BASE_TLSTREAM_JOB_DUMPING_ENABLED (1 << 1)
1830 
1831 #define BASE_TLSTREAM_FLAGS_MASK (BASE_TLSTREAM_ENABLE_LATENCY_TRACEPOINTS | \
1832  BASE_TLSTREAM_JOB_DUMPING_ENABLED)
1833 
1834 #endif /* _BASE_KERNEL_H_ */
Definition: mali_base_kernel.h:106
Definition: mali_base_kernel.h:173
Definition: mali_base_kernel.h:299
Per-job data.
Definition: mali_base_kernel.h:373
u64 jc
Definition: mali_base_kernel.h:845
Definition: mali_base_kernel.h:1515
u64 tiler_jc_list
Definition: mali_base_kernel.h:1742
Definition: mali_base_kernel.h:1082
struct base_stream base_stream
Definition: mali_base_kernel.h:1020
Definition: mali_base_kernel.h:146
u8 device_nr
Definition: mali_base_kernel.h:853
Definition: mali_base_kernel.h:1782
Definition: mali_base_kernel.h:1021
Definition: mali_base_kernel.h:51
Definition: mali_base_kernel.h:753
#define BASE_JD_DEP_TYPE_INVALID
Definition: mali_base_kernel.h:438
base_jd_prio prio
Definition: mali_base_kernel.h:852
Definition: mali_base_kernel.h:298
Definition: mali_base_kernel.h:1673
base_jd_dep_type dependency_type
Definition: mali_base_kernel.h:818
u8 device_nr
Definition: mali_base_kernel.h:838
base_atom_id atom_id
Definition: mali_base_kernel.h:817
u64 tiler_heap_free
Definition: mali_base_kernel.h:1752
u16 nr_extres
Definition: mali_base_kernel.h:832
Definition: mali_base_kernel.h:1068
struct base_syncset base_syncset
a basic memory operation (sync-set).
Definition: mali_base_kernel.h:828
Definition: mali_base_kernel.h:886
Definition: mali_base_kernel.h:863
u64 jc
Definition: mali_base_kernel.h:829
base_mem_import_type
Definition: mali_base_kernel.h:233
Definition: mali_base_kernel.h:179
base_atom_id atom_number
Definition: mali_base_kernel.h:851
Definition: mali_base_kernel.h:1500
Definition: mali_base_kernel.h:1022
struct base_import_handle base_import_handle
u32 gpu_speed_mhz
Definition: mali_base_kernel.h:1458
u32 gpu_freq_khz_max
Definition: mali_base_kernel.h:1465
Definition: mali_base_kernel.h:326
base_jd_core_req core_req
Definition: mali_base_kernel.h:840
Definition: mali_base_kernel.h:1144
u16 tiler_hierarchy_mask
Definition: mali_base_kernel.h:1762
Definition: mali_base_kernel.h:182
base_jd_event_code
Job chain event codes.
Definition: mali_base_kernel.h:1057
Structure for BASE_JD_REQ_SOFT_DUMP_CPU_GPU_COUNTERS jobs.
Definition: mali_base_kernel.h:1193
u8 base_atom_id
Definition: mali_base_kernel.h:814
a basic memory operation (sync-set).
Definition: mali_base_kernel.h:315
Definition: mali_base_kernel.h:358
Memory aliasing info.
Definition: mali_base_kernel.h:398
u32 coherency
Definition: mali_base_kernel.h:1572
Definition: mali_base_kernel.h:751
u32 base_mem_alloc_flags
Memory allocation, access/hint flags.
Definition: mali_base_kernel.h:134
Definition: mali_base_kernel.h:806
struct base_jd_udata base_jd_udata
Per-job data.
Definition: mali_base_kernel.h:747
Coherency group information.
Definition: mali_base_kernel.h:1553
u32 base_jd_core_req
Job chain hardware requirements.
Definition: mali_base_kernel.h:452
Definition: mali_base_kernel.h:1141
Definition: mali_base_kernel.h:1018
base_context_create_flags
Definition: mali_base_kernel.h:1671
u8 base_jd_dep_type
Job dependency type.
Definition: mali_base_kernel.h:435
Definition: mali_base_kernel.h:844
Definition: mali_base_kernel.h:804
base_jd_event_code event_code
Definition: mali_base_kernel.h:1169
kbase_pointer extres_list
Definition: mali_base_kernel.h:831
Definition: mali_base_mem_priv.h:44
base_jd_prio prio
Definition: mali_base_kernel.h:837
u32 hierarchy_default_weight
Definition: mali_base_kernel.h:1768
struct base_dump_cpu_gpu_counters base_dump_cpu_gpu_counters
Structure for BASE_JD_REQ_SOFT_DUMP_CPU_GPU_COUNTERS jobs.
Definition: mali_base_kernel.h:1070
Definition: mali_base_kernel.h:1148
u16 version_status
Definition: mali_base_kernel.h:1438
struct base_jd_replay_jc base_jd_replay_jc
An entry in the linked list of job chains to be replayed. This must be in GPU memory.
base_backing_threshold_status
Result codes of changing the size of the backing store allocated to a tmem region.
Definition: mali_base_kernel.h:297
kbase_jd_atom_state
Definition: mali_base_kernel.h:800
Definition: mali_base_kernel.h:1065
Definition: mali_base_kernel.h:176
u16 major_revision
Definition: mali_base_kernel.h:1450
kbase_pointer extres_list
Definition: mali_base_kernel.h:847
u16 nr_extres
Definition: mali_base_kernel.h:848
u64 core_mask
Definition: mali_base_kernel.h:1538
u16 num_cores
Definition: mali_base_kernel.h:1539
Definition: mali_base_kernel.h:167
Definition: mali_base_kernel.h:181
Definition: mali_base_kernel.h:1019
struct base_jd_event_v2 base_jd_event_v2
Event reporting structure.
u16 core_req
Definition: mali_base_kernel.h:849
struct base_fence base_fence
Definition: mali_base_kernel.h:169
Definition: mali_base_kernel.h:1426
u32 compat_value
Definition: mali_base_kernel.h:108
Definition: mali_base_kernel.h:184
Definition: mali_base_kernel.h:1016
Definition: mali_base_kernel.h:144
Definition: mali_base_kernel.h:1598
Definition: mali_base_kernel.h:145
Definition: mali_base_kernel.h:1079
base_atom_id atom_number
Definition: mali_base_kernel.h:836
Definition: mali_base_kernel.h:418
u64 fragment_jc
Definition: mali_base_kernel.h:1747
u16 fragment_hierarchy_mask
Definition: mali_base_kernel.h:1757
Definition: mali_base_kernel.h:1131
An entry in the linked list of job chains to be replayed. This must be in GPU memory.
Definition: mali_base_kernel.h:1799
kbase_atom_coreref_state
States to model state machine processed by kbasep_js_job_check_ref_cores(), which handles retaining c...
Definition: mali_base_kernel.h:745
Definition: mali_base_kernel.h:1681
Definition: mali_base_kernel.h:165
Definition: mali_base_kernel.h:1017
#define BASE_CPU_GPU_CACHE_LINE_PADDING
Definition: mali_base_kernel.h:1179
descriptor for a coherent group
Definition: mali_base_kernel.h:1537
Definition: mali_base_kernel.h:1676
struct base_jd_replay_payload base_jd_replay_payload
The payload for a replay job. This must be in GPU memory.
u64 gpu_available_memory_size
Definition: mali_base_kernel.h:1492
Definition: mali_base_kernel.h:148
Definition: mali_base_kernel.h:811
union kbase_pointer kbase_pointer
Definition: mali_base_kernel.h:809
Definition: mali_base_kernel.h:755
u64 next
Definition: mali_base_kernel.h:1804
Definition: mali_base_kernel.h:1023
Definition: mali_base_kernel.h:1639
Definition: mali_base_kernel.h:802
Event reporting structure.
Definition: mali_base_kernel.h:1168
u32 log2_program_counter_size
Definition: mali_base_kernel.h:1471
Definition: mali_base_kernel.h:1507
Definition: mali_base_kernel.h:881
u32 product_id
Definition: mali_base_kernel.h:1430
u16 compat_core_req
Definition: mali_base_kernel.h:833
u64 sizer
Definition: mali_base_kernel.h:109
struct mali_base_gpu_props base_gpu_props
Definition: mali_base_kernel.h:300
Definition: mali_base_kernel.h:1134
Definition: mali_base_kernel.h:347
u32 num_core_groups
Definition: mali_base_kernel.h:1566
Definition: mali_base_kernel.h:1819
Definition: mali_base_kernel.h:249
Definition: mali_base_kernel.h:816
u64 jc
Definition: mali_base_kernel.h:1809
base_jd_core_req fragment_core_req
Definition: mali_base_kernel.h:1778
base_atom_id atom_number
Definition: mali_base_kernel.h:1170
Definition: mali_base_kernel.h:301
Definition: mali_base_kernel.h:162
The payload for a replay job. This must be in GPU memory.
Definition: mali_base_kernel.h:1736
Definition: mali_base_kernel.h:1072
base_jd_core_req tiler_core_req
Definition: mali_base_kernel.h:1773
Definition: mali_base_kernel.h:1071
Definition: mali_base_kernel.h:147
u16 minor_revision
Definition: mali_base_kernel.h:1444