hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/include/uapi/gpu/arm/bifrost/jm/mali_base_jm_kernel.h
....@@ -1,7 +1,7 @@
11 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
22 /*
33 *
4
- * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2019-2022 ARM Limited. All rights reserved.
55 *
66 * This program is free software and is provided to you under the terms of the
77 * GNU General Public License version 2 as published by the Free Software
....@@ -23,153 +23,39 @@
2323 #define _UAPI_BASE_JM_KERNEL_H_
2424
2525 #include <linux/types.h>
26
+#include "../mali_base_common_kernel.h"
2627
27
-/* Memory allocation, access/hint flags.
28
+/* Memory allocation, access/hint flags & mask specific to JM GPU.
2829 *
2930 * See base_mem_alloc_flags.
3031 */
3132
32
-/* IN */
33
-/* Read access CPU side
34
- */
35
-#define BASE_MEM_PROT_CPU_RD ((base_mem_alloc_flags)1 << 0)
36
-
37
-/* Write access CPU side
38
- */
39
-#define BASE_MEM_PROT_CPU_WR ((base_mem_alloc_flags)1 << 1)
40
-
41
-/* Read access GPU side
42
- */
43
-#define BASE_MEM_PROT_GPU_RD ((base_mem_alloc_flags)1 << 2)
44
-
45
-/* Write access GPU side
46
- */
47
-#define BASE_MEM_PROT_GPU_WR ((base_mem_alloc_flags)1 << 3)
48
-
49
-/* Execute allowed on the GPU side
50
- */
51
-#define BASE_MEM_PROT_GPU_EX ((base_mem_alloc_flags)1 << 4)
52
-
53
-/* Will be permanently mapped in kernel space.
54
- * Flag is only allowed on allocations originating from kbase.
55
- */
56
-#define BASEP_MEM_PERMANENT_KERNEL_MAPPING ((base_mem_alloc_flags)1 << 5)
57
-
58
-/* The allocation will completely reside within the same 4GB chunk in the GPU
59
- * virtual space.
60
- * Since this flag is primarily required only for the TLS memory which will
61
- * not be used to contain executable code and also not used for Tiler heap,
62
- * it can't be used along with BASE_MEM_PROT_GPU_EX and TILER_ALIGN_TOP flags.
63
- */
64
-#define BASE_MEM_GPU_VA_SAME_4GB_PAGE ((base_mem_alloc_flags)1 << 6)
65
-
66
-/* Userspace is not allowed to free this memory.
67
- * Flag is only allowed on allocations originating from kbase.
68
- */
69
-#define BASEP_MEM_NO_USER_FREE ((base_mem_alloc_flags)1 << 7)
70
-
33
+/* Used as BASE_MEM_FIXED in other backends */
7134 #define BASE_MEM_RESERVED_BIT_8 ((base_mem_alloc_flags)1 << 8)
7235
73
-/* Grow backing store on GPU Page Fault
74
- */
75
-#define BASE_MEM_GROW_ON_GPF ((base_mem_alloc_flags)1 << 9)
76
-
77
-/* Page coherence Outer shareable, if available
78
- */
79
-#define BASE_MEM_COHERENT_SYSTEM ((base_mem_alloc_flags)1 << 10)
80
-
81
-/* Page coherence Inner shareable
82
- */
83
-#define BASE_MEM_COHERENT_LOCAL ((base_mem_alloc_flags)1 << 11)
84
-
85
-/* IN/OUT */
86
-/* Should be cached on the CPU, returned if actually cached
87
- */
88
-#define BASE_MEM_CACHED_CPU ((base_mem_alloc_flags)1 << 12)
89
-
90
-/* IN/OUT */
91
-/* Must have same VA on both the GPU and the CPU
92
- */
93
-#define BASE_MEM_SAME_VA ((base_mem_alloc_flags)1 << 13)
94
-
95
-/* OUT */
96
-/* Must call mmap to acquire a GPU address for the allocation
97
- */
98
-#define BASE_MEM_NEED_MMAP ((base_mem_alloc_flags)1 << 14)
99
-
100
-/* IN */
101
-/* Page coherence Outer shareable, required.
102
- */
103
-#define BASE_MEM_COHERENT_SYSTEM_REQUIRED ((base_mem_alloc_flags)1 << 15)
104
-
105
-/* Protected memory
106
- */
107
-#define BASE_MEM_PROTECTED ((base_mem_alloc_flags)1 << 16)
108
-
109
-/* Not needed physical memory
110
- */
111
-#define BASE_MEM_DONT_NEED ((base_mem_alloc_flags)1 << 17)
112
-
113
-/* Must use shared CPU/GPU zone (SAME_VA zone) but doesn't require the
114
- * addresses to be the same
115
- */
116
-#define BASE_MEM_IMPORT_SHARED ((base_mem_alloc_flags)1 << 18)
117
-
11836 /**
119
- * Bit 19 is reserved.
37
+ * BASE_MEM_RESERVED_BIT_19 - Bit 19 is reserved.
12038 *
12139 * Do not remove, use the next unreserved bit for new flags
12240 */
12341 #define BASE_MEM_RESERVED_BIT_19 ((base_mem_alloc_flags)1 << 19)
12442
12543 /**
126
- * Memory starting from the end of the initial commit is aligned to 'extension'
127
- * pages, where 'extension' must be a power of 2 and no more than
44
+ * BASE_MEM_TILER_ALIGN_TOP - Memory starting from the end of the initial commit is aligned
45
+ * to 'extension' pages, where 'extension' must be a power of 2 and no more than
12846 * BASE_MEM_TILER_ALIGN_TOP_EXTENSION_MAX_PAGES
12947 */
13048 #define BASE_MEM_TILER_ALIGN_TOP ((base_mem_alloc_flags)1 << 20)
13149
132
-/* Should be uncached on the GPU, will work only for GPUs using AARCH64 mmu
133
- * mode. Some components within the GPU might only be able to access memory
134
- * that is GPU cacheable. Refer to the specific GPU implementation for more
135
- * details. The 3 shareability flags will be ignored for GPU uncached memory.
136
- * If used while importing USER_BUFFER type memory, then the import will fail
137
- * if the memory is not aligned to GPU and CPU cache line width.
138
- */
139
-#define BASE_MEM_UNCACHED_GPU ((base_mem_alloc_flags)1 << 21)
140
-
141
-/*
142
- * Bits [22:25] for group_id (0~15).
143
- *
144
- * base_mem_group_id_set() should be used to pack a memory group ID into a
145
- * base_mem_alloc_flags value instead of accessing the bits directly.
146
- * base_mem_group_id_get() should be used to extract the memory group ID from
147
- * a base_mem_alloc_flags value.
148
- */
149
-#define BASEP_MEM_GROUP_ID_SHIFT 22
150
-#define BASE_MEM_GROUP_ID_MASK \
151
- ((base_mem_alloc_flags)0xF << BASEP_MEM_GROUP_ID_SHIFT)
152
-
153
-/* Must do CPU cache maintenance when imported memory is mapped/unmapped
154
- * on GPU. Currently applicable to dma-buf type only.
155
- */
156
-#define BASE_MEM_IMPORT_SYNC_ON_MAP_UNMAP ((base_mem_alloc_flags)1 << 26)
157
-
15850 /* Use the GPU VA chosen by the kernel client */
15951 #define BASE_MEM_FLAG_MAP_FIXED ((base_mem_alloc_flags)1 << 27)
160
-
161
-/* OUT */
162
-/* Kernel side cache sync ops required */
163
-#define BASE_MEM_KERNEL_SYNC ((base_mem_alloc_flags)1 << 28)
16452
16553 /* Force trimming of JIT allocations when creating a new allocation */
16654 #define BASEP_MEM_PERFORM_JIT_TRIM ((base_mem_alloc_flags)1 << 29)
16755
168
-/* Number of bits used as flags for base memory management
169
- *
170
- * Must be kept in sync with the base_mem_alloc_flags flags
56
+/* Note that the number of bits used for base_mem_alloc_flags
57
+ * must be less than BASE_MEM_FLAGS_NR_BITS !!!
17158 */
172
-#define BASE_MEM_FLAGS_NR_BITS 30
17359
17460 /* A mask of all the flags which are only valid for allocations within kbase,
17561 * and may not be passed from user space.
....@@ -178,29 +64,11 @@
17864 (BASEP_MEM_PERMANENT_KERNEL_MAPPING | BASEP_MEM_NO_USER_FREE | \
17965 BASE_MEM_FLAG_MAP_FIXED | BASEP_MEM_PERFORM_JIT_TRIM)
18066
181
-/* A mask for all output bits, excluding IN/OUT bits.
182
- */
183
-#define BASE_MEM_FLAGS_OUTPUT_MASK BASE_MEM_NEED_MMAP
184
-
185
-/* A mask for all input bits, including IN/OUT bits.
186
- */
187
-#define BASE_MEM_FLAGS_INPUT_MASK \
188
- (((1 << BASE_MEM_FLAGS_NR_BITS) - 1) & ~BASE_MEM_FLAGS_OUTPUT_MASK)
189
-
19067 /* A mask of all currently reserved flags
19168 */
19269 #define BASE_MEM_FLAGS_RESERVED \
19370 (BASE_MEM_RESERVED_BIT_8 | BASE_MEM_RESERVED_BIT_19)
19471
195
-#define BASEP_MEM_INVALID_HANDLE (0ull << 12)
196
-#define BASE_MEM_MMU_DUMP_HANDLE (1ull << 12)
197
-#define BASE_MEM_TRACE_BUFFER_HANDLE (2ull << 12)
198
-#define BASE_MEM_MAP_TRACKING_HANDLE (3ull << 12)
199
-#define BASEP_MEM_WRITE_ALLOC_PAGES_HANDLE (4ull << 12)
200
-/* reserved handles ..-47<<PAGE_SHIFT> for future special handles */
201
-#define BASE_MEM_COOKIE_BASE (64ul << 12)
202
-#define BASE_MEM_FIRST_FREE_ADDRESS ((BITS_PER_LONG << 12) + \
203
- BASE_MEM_COOKIE_BASE)
20472
20573 /* Similar to BASE_MEM_TILER_ALIGN_TOP, memory starting from the end of the
20674 * initial commit is aligned to 'extension' pages, where 'extension' must be a power
....@@ -209,13 +77,14 @@
20977 #define BASE_JIT_ALLOC_MEM_TILER_ALIGN_TOP (1 << 0)
21078
21179 /**
212
- * If set, the heap info address points to a __u32 holding the used size in bytes;
80
+ * BASE_JIT_ALLOC_HEAP_INFO_IS_SIZE - If set, the heap info address points
81
+ * to a __u32 holding the used size in bytes;
21382 * otherwise it points to a __u64 holding the lowest address of unused memory.
21483 */
21584 #define BASE_JIT_ALLOC_HEAP_INFO_IS_SIZE (1 << 1)
21685
21786 /**
218
- * Valid set of just-in-time memory allocation flags
87
+ * BASE_JIT_ALLOC_VALID_FLAGS - Valid set of just-in-time memory allocation flags
21988 *
22089 * Note: BASE_JIT_ALLOC_HEAP_INFO_IS_SIZE cannot be set if heap_info_gpu_addr
22190 * in %base_jit_alloc_info is 0 (atom with BASE_JIT_ALLOC_HEAP_INFO_IS_SIZE set
....@@ -223,47 +92,6 @@
22392 */
22493 #define BASE_JIT_ALLOC_VALID_FLAGS \
22594 (BASE_JIT_ALLOC_MEM_TILER_ALIGN_TOP | BASE_JIT_ALLOC_HEAP_INFO_IS_SIZE)
226
-
227
-/**
228
- * typedef base_context_create_flags - Flags to pass to ::base_context_init.
229
- *
230
- * Flags can be ORed together to enable multiple things.
231
- *
232
- * These share the same space as BASEP_CONTEXT_FLAG_*, and so must
233
- * not collide with them.
234
- */
235
-typedef __u32 base_context_create_flags;
236
-
237
-/* No flags set */
238
-#define BASE_CONTEXT_CREATE_FLAG_NONE ((base_context_create_flags)0)
239
-
240
-/* Base context is embedded in a cctx object (flag used for CINSTR
241
- * software counter macros)
242
- */
243
-#define BASE_CONTEXT_CCTX_EMBEDDED ((base_context_create_flags)1 << 0)
244
-
245
-/* Base context is a 'System Monitor' context for Hardware counters.
246
- *
247
- * One important side effect of this is that job submission is disabled.
248
- */
249
-#define BASE_CONTEXT_SYSTEM_MONITOR_SUBMIT_DISABLED \
250
- ((base_context_create_flags)1 << 1)
251
-
252
-/* Bit-shift used to encode a memory group ID in base_context_create_flags
253
- */
254
-#define BASEP_CONTEXT_MMU_GROUP_ID_SHIFT (3)
255
-
256
-/* Bitmask used to encode a memory group ID in base_context_create_flags
257
- */
258
-#define BASEP_CONTEXT_MMU_GROUP_ID_MASK \
259
- ((base_context_create_flags)0xF << BASEP_CONTEXT_MMU_GROUP_ID_SHIFT)
260
-
261
-/* Bitpattern describing the base_context_create_flags that can be
262
- * passed to the kernel
263
- */
264
-#define BASEP_CONTEXT_CREATE_KERNEL_FLAGS \
265
- (BASE_CONTEXT_SYSTEM_MONITOR_SUBMIT_DISABLED | \
266
- BASEP_CONTEXT_MMU_GROUP_ID_MASK)
26795
26896 /* Bitpattern describing the ::base_context_create_flags that can be
26997 * passed to base_context_init()
....@@ -284,16 +112,7 @@
284112 #define BASEP_CONTEXT_FLAG_JOB_DUMP_DISABLED \
285113 ((base_context_create_flags)(1 << 31))
286114
287
-/* Enable additional tracepoints for latency measurements (TL_ATOM_READY,
288
- * TL_ATOM_DONE, TL_ATOM_PRIO_CHANGE, TL_ATOM_EVENT_POST)
289
- */
290
-#define BASE_TLSTREAM_ENABLE_LATENCY_TRACEPOINTS (1 << 0)
291
-
292
-/* Indicate that job dumping is enabled. This could affect certain timers
293
- * to account for the performance impact.
294
- */
295
-#define BASE_TLSTREAM_JOB_DUMPING_ENABLED (1 << 1)
296
-
115
+/* Flags for base tracepoint specific to JM */
297116 #define BASE_TLSTREAM_FLAGS_MASK (BASE_TLSTREAM_ENABLE_LATENCY_TRACEPOINTS | \
298117 BASE_TLSTREAM_JOB_DUMPING_ENABLED)
299118 /*
....@@ -314,12 +133,12 @@
314133 /**
315134 * struct base_jd_udata - Per-job data
316135 *
136
+ * @blob: per-job data array
137
+ *
317138 * This structure is used to store per-job data, and is completely unused
318139 * by the Base driver. It can be used to store things such as callback
319140 * function pointer, data to handle job completion. It is guaranteed to be
320141 * untouched by the Base driver.
321
- *
322
- * @blob: per-job data array
323142 */
324143 struct base_jd_udata {
325144 __u64 blob[2];
....@@ -506,9 +325,6 @@
506325 * takes priority
507326 *
508327 * This is only guaranteed to work for BASE_JD_REQ_ONLY_COMPUTE atoms.
509
- *
510
- * If the core availability policy is keeping the required core group turned
511
- * off, then the job will fail with a BASE_JD_EVENT_PM_EVENT error code.
512328 */
513329 #define BASE_JD_REQ_SPECIFIC_COHERENT_GROUP ((base_jd_core_req)1 << 11)
514330
....@@ -611,7 +427,8 @@
611427 BASE_JD_REQ_V | BASE_JD_REQ_SOFT_JOB | BASE_JD_REQ_ONLY_COMPUTE)
612428
613429 /**
614
- * Mask of all bits in base_jd_core_req that control the type of a soft job.
430
+ * BASE_JD_REQ_SOFT_JOB_TYPE - Mask of all bits in base_jd_core_req that
431
+ * controls the type of a soft job.
615432 */
616433 #define BASE_JD_REQ_SOFT_JOB_TYPE (BASE_JD_REQ_SOFT_JOB | 0x1f)
617434
....@@ -623,7 +440,7 @@
623440 ((core_req) & BASE_JD_REQ_ATOM_TYPE) == BASE_JD_REQ_DEP)
624441
625442 /**
626
- * enum kbase_jd_atom_state
443
+ * enum kbase_jd_atom_state - Atom states
627444 *
628445 * @KBASE_JD_ATOM_STATE_UNUSED: Atom is not used.
629446 * @KBASE_JD_ATOM_STATE_QUEUED: Atom is queued in JD.
....@@ -648,7 +465,7 @@
648465 typedef __u8 base_atom_id;
649466
650467 /**
651
- * struct base_dependency -
468
+ * struct base_dependency - base dependency
652469 *
653470 * @atom_id: An atom number
654471 * @dependency_type: Dependency type
....@@ -765,6 +582,9 @@
765582 * BASE_JD_PRIO_MEDIUM, and BASE_JD_PRIO_LOW
766583 */
767584 #define BASE_JD_PRIO_REALTIME ((base_jd_prio)3)
585
+
586
+/* Invalid atom priority (max uint8_t value) */
587
+#define BASE_JD_PRIO_INVALID ((base_jd_prio)255)
768588
769589 /* Count of the number of priority levels. This itself is not a valid
770590 * base_jd_prio setting
....@@ -1012,11 +832,6 @@
1012832 * BASE_JD_EVENT_JOB_CONFIG_FAULT, or if the
1013833 * platform doesn't support the feature specified in
1014834 * the atom.
1015
- * @BASE_JD_EVENT_PM_EVENT: TODO: remove as it's not used
1016
- * @BASE_JD_EVENT_TIMED_OUT: TODO: remove as it's not used
1017
- * @BASE_JD_EVENT_BAG_INVALID: TODO: remove as it's not used
1018
- * @BASE_JD_EVENT_PROGRESS_REPORT: TODO: remove as it's not used
1019
- * @BASE_JD_EVENT_BAG_DONE: TODO: remove as it's not used
1020835 * @BASE_JD_EVENT_DRV_TERMINATED: this is a special event generated to indicate
1021836 * to userspace that the KBase context has been
1022837 * destroyed and Base should stop listening for
....@@ -1111,17 +926,10 @@
1111926 /* SW defined exceptions */
1112927 BASE_JD_EVENT_MEM_GROWTH_FAILED =
1113928 BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_JOB | 0x000,
1114
- BASE_JD_EVENT_TIMED_OUT =
1115
- BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_JOB | 0x001,
1116929 BASE_JD_EVENT_JOB_CANCELLED =
1117930 BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_JOB | 0x002,
1118931 BASE_JD_EVENT_JOB_INVALID =
1119932 BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_JOB | 0x003,
1120
- BASE_JD_EVENT_PM_EVENT =
1121
- BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_JOB | 0x004,
1122
-
1123
- BASE_JD_EVENT_BAG_INVALID =
1124
- BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_BAG | 0x003,
1125933
1126934 BASE_JD_EVENT_RANGE_HW_FAULT_OR_SW_ERROR_END = BASE_JD_SW_EVENT |
1127935 BASE_JD_SW_EVENT_RESERVED | 0x3FF,
....@@ -1129,10 +937,6 @@
1129937 BASE_JD_EVENT_RANGE_SW_SUCCESS_START = BASE_JD_SW_EVENT |
1130938 BASE_JD_SW_EVENT_SUCCESS | 0x000,
1131939
1132
- BASE_JD_EVENT_PROGRESS_REPORT = BASE_JD_SW_EVENT |
1133
- BASE_JD_SW_EVENT_SUCCESS | BASE_JD_SW_EVENT_JOB | 0x000,
1134
- BASE_JD_EVENT_BAG_DONE = BASE_JD_SW_EVENT | BASE_JD_SW_EVENT_SUCCESS |
1135
- BASE_JD_SW_EVENT_BAG | 0x000,
1136940 BASE_JD_EVENT_DRV_TERMINATED = BASE_JD_SW_EVENT |
1137941 BASE_JD_SW_EVENT_SUCCESS | BASE_JD_SW_EVENT_INFO | 0x000,
1138942
....@@ -1153,8 +957,9 @@
1153957 /**
1154958 * struct base_jd_event_v2 - Event reporting structure
1155959 *
1156
- * @event_code: event code.
960
+ * @event_code: event code of type @ref base_jd_event_code.
1157961 * @atom_number: the atom number that has completed.
962
+ * @padding: padding.
1158963 * @udata: user data.
1159964 *
1160965 * This structure is used by the kernel driver to report information
....@@ -1165,8 +970,9 @@
1165970 * by ANDing with BASE_JD_SW_EVENT_TYPE_MASK.
1166971 */
1167972 struct base_jd_event_v2 {
1168
- enum base_jd_event_code event_code;
973
+ __u32 event_code;
1169974 base_atom_id atom_number;
975
+ __u8 padding[3];
1170976 struct base_jd_udata udata;
1171977 };
1172978
....@@ -1197,4 +1003,53 @@
11971003 __u8 padding[36];
11981004 };
11991005
1006
+/**
1007
+ * struct mali_base_gpu_core_props - GPU core props info
1008
+ *
1009
+ * @product_id: Pro specific value.
1010
+ * @version_status: Status of the GPU release. No defined values, but starts at
1011
+ * 0 and increases by one for each release status (alpha, beta, EAC, etc.).
1012
+ * 4 bit values (0-15).
1013
+ * @minor_revision: Minor release number of the GPU. "P" part of an "RnPn"
1014
+ * release number.
1015
+ * 8 bit values (0-255).
1016
+ * @major_revision: Major release number of the GPU. "R" part of an "RnPn"
1017
+ * release number.
1018
+ * 4 bit values (0-15).
1019
+ * @padding: padding to align to 8-byte
1020
+ * @gpu_freq_khz_max: The maximum GPU frequency. Reported to applications by
1021
+ * clGetDeviceInfo()
1022
+ * @log2_program_counter_size: Size of the shader program counter, in bits.
1023
+ * @texture_features: TEXTURE_FEATURES_x registers, as exposed by the GPU. This
1024
+ * is a bitpattern where a set bit indicates that the format is supported.
1025
+ * Before using a texture format, it is recommended that the corresponding
1026
+ * bit be checked.
1027
+ * @paddings_1: Padding bytes.
1028
+ * @gpu_available_memory_size: Theoretical maximum memory available to the GPU.
1029
+ * It is unlikely that a client will be able to allocate all of this memory
1030
+ * for their own purposes, but this at least provides an upper bound on the
1031
+ * memory available to the GPU.
1032
+ * This is required for OpenCL's clGetDeviceInfo() call when
1033
+ * CL_DEVICE_GLOBAL_MEM_SIZE is requested, for OpenCL GPU devices. The
1034
+ * client will not be expecting to allocate anywhere near this value.
1035
+ * @num_exec_engines: The number of execution engines. Only valid for tGOX
1036
+ * (Bifrost) GPUs, where GPU_HAS_REG_CORE_FEATURES is defined. Otherwise,
1037
+ * this is always 0.
1038
+ * @paddings_2: Padding bytes.
1039
+ */
1040
+struct mali_base_gpu_core_props {
1041
+ __u32 product_id;
1042
+ __u16 version_status;
1043
+ __u16 minor_revision;
1044
+ __u16 major_revision;
1045
+ __u16 padding;
1046
+ __u32 gpu_freq_khz_max;
1047
+ __u32 log2_program_counter_size;
1048
+ __u32 texture_features[BASE_GPU_NUM_TEXTURE_FEATURES_REGISTERS];
1049
+ __u8 paddings_1[4];
1050
+ __u64 gpu_available_memory_size;
1051
+ __u8 num_exec_engines;
1052
+ __u8 paddings_2[7];
1053
+};
1054
+
12001055 #endif /* _UAPI_BASE_JM_KERNEL_H_ */