Commit | Line | Data |
---|---|---|
81629cba AD |
1 | /* amdgpu_drm.h -- Public header for the amdgpu driver -*- linux-c -*- |
2 | * | |
3 | * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. | |
4 | * Copyright 2000 VA Linux Systems, Inc., Fremont, California. | |
5 | * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas. | |
6 | * Copyright 2014 Advanced Micro Devices, Inc. | |
7 | * | |
8 | * Permission is hereby granted, free of charge, to any person obtaining a | |
9 | * copy of this software and associated documentation files (the "Software"), | |
10 | * to deal in the Software without restriction, including without limitation | |
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
12 | * and/or sell copies of the Software, and to permit persons to whom the | |
13 | * Software is furnished to do so, subject to the following conditions: | |
14 | * | |
15 | * The above copyright notice and this permission notice shall be included in | |
16 | * all copies or substantial portions of the Software. | |
17 | * | |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
21 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
22 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
23 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
24 | * OTHER DEALINGS IN THE SOFTWARE. | |
25 | * | |
26 | * Authors: | |
27 | * Kevin E. Martin <martin@valinux.com> | |
28 | * Gareth Hughes <gareth@valinux.com> | |
29 | * Keith Whitwell <keith@tungstengraphics.com> | |
30 | */ | |
31 | ||
32 | #ifndef __AMDGPU_DRM_H__ | |
33 | #define __AMDGPU_DRM_H__ | |
34 | ||
b3fcf36a | 35 | #include "drm.h" |
81629cba | 36 | |
cfa7152f EV |
37 | #if defined(__cplusplus) |
38 | extern "C" { | |
39 | #endif | |
40 | ||
81629cba AD |
41 | #define DRM_AMDGPU_GEM_CREATE 0x00 |
42 | #define DRM_AMDGPU_GEM_MMAP 0x01 | |
43 | #define DRM_AMDGPU_CTX 0x02 | |
44 | #define DRM_AMDGPU_BO_LIST 0x03 | |
45 | #define DRM_AMDGPU_CS 0x04 | |
46 | #define DRM_AMDGPU_INFO 0x05 | |
47 | #define DRM_AMDGPU_GEM_METADATA 0x06 | |
48 | #define DRM_AMDGPU_GEM_WAIT_IDLE 0x07 | |
49 | #define DRM_AMDGPU_GEM_VA 0x08 | |
50 | #define DRM_AMDGPU_WAIT_CS 0x09 | |
51 | #define DRM_AMDGPU_GEM_OP 0x10 | |
52 | #define DRM_AMDGPU_GEM_USERPTR 0x11 | |
eef18a82 | 53 | #define DRM_AMDGPU_WAIT_FENCES 0x12 |
cfbcacf4 | 54 | #define DRM_AMDGPU_VM 0x13 |
7ca24cf2 | 55 | #define DRM_AMDGPU_FENCE_TO_HANDLE 0x14 |
52c6a62c | 56 | #define DRM_AMDGPU_SCHED 0x15 |
81629cba AD |
57 | |
58 | #define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create) | |
59 | #define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap) | |
60 | #define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx) | |
61 | #define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list) | |
62 | #define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs) | |
63 | #define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info) | |
64 | #define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata) | |
65 | #define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle) | |
34b5f6a6 | 66 | #define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va) |
81629cba AD |
67 | #define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs) |
68 | #define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op) | |
69 | #define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr) | |
eef18a82 | 70 | #define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences) |
cfbcacf4 | 71 | #define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm) |
7ca24cf2 | 72 | #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle) |
52c6a62c | 73 | #define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched) |
81629cba | 74 | |
b646c1dc SL |
75 | /** |
76 | * DOC: memory domains | |
77 | * | |
78 | * %AMDGPU_GEM_DOMAIN_CPU System memory that is not GPU accessible. | |
79 | * Memory in this pool could be swapped out to disk if there is pressure. | |
80 | * | |
81 | * %AMDGPU_GEM_DOMAIN_GTT GPU accessible system memory, mapped into the | |
82 | * GPU's virtual address space via gart. Gart memory linearizes non-contiguous | |
326db0dc | 83 | * pages of system memory, allows GPU access system memory in a linearized |
b646c1dc SL |
84 | * fashion. |
85 | * | |
86 | * %AMDGPU_GEM_DOMAIN_VRAM Local video memory. For APUs, it is memory | |
87 | * carved out by the BIOS. | |
88 | * | |
89 | * %AMDGPU_GEM_DOMAIN_GDS Global on-chip data storage used to share data | |
90 | * across shader threads. | |
91 | * | |
92 | * %AMDGPU_GEM_DOMAIN_GWS Global wave sync, used to synchronize the | |
93 | * execution of all the waves on a device. | |
94 | * | |
95 | * %AMDGPU_GEM_DOMAIN_OA Ordered append, used by 3D or Compute engines | |
96 | * for appending data. | |
97 | */ | |
81629cba AD |
98 | #define AMDGPU_GEM_DOMAIN_CPU 0x1 |
99 | #define AMDGPU_GEM_DOMAIN_GTT 0x2 | |
100 | #define AMDGPU_GEM_DOMAIN_VRAM 0x4 | |
101 | #define AMDGPU_GEM_DOMAIN_GDS 0x8 | |
102 | #define AMDGPU_GEM_DOMAIN_GWS 0x10 | |
103 | #define AMDGPU_GEM_DOMAIN_OA 0x20 | |
3f188453 CZ |
104 | #define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \ |
105 | AMDGPU_GEM_DOMAIN_GTT | \ | |
106 | AMDGPU_GEM_DOMAIN_VRAM | \ | |
107 | AMDGPU_GEM_DOMAIN_GDS | \ | |
108 | AMDGPU_GEM_DOMAIN_GWS | \ | |
109 | AMDGPU_GEM_DOMAIN_OA) | |
81629cba | 110 | |
81629cba AD |
111 | /* Flag that CPU access will be required for the case of VRAM domain */ |
112 | #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0) | |
113 | /* Flag that CPU access will not work, this VRAM domain is invisible */ | |
114 | #define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1) | |
81629cba | 115 | /* Flag that USWC attributes should be used for GTT */ |
88671288 | 116 | #define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2) |
4fea83ff FC |
117 | /* Flag that the memory should be in VRAM and cleared */ |
118 | #define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3) | |
03f48dd5 CK |
119 | /* Flag that allocating the BO should use linear VRAM */ |
120 | #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5) | |
e1eb899b CK |
121 | /* Flag that BO is always valid in this VM */ |
122 | #define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6) | |
177ae09b AR |
123 | /* Flag that BO sharing will be explicitly synchronized */ |
124 | #define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7) | |
959a2091 | 125 | /* Flag that indicates allocating MQD gart on GFX9, where the mtype |
fa5bde80 YZ |
126 | * for the second page onward should be set to NC. It should never |
127 | * be used by user space applications. | |
959a2091 | 128 | */ |
fa5bde80 | 129 | #define AMDGPU_GEM_CREATE_CP_MQD_GFX9 (1 << 8) |
d8f4981e FK |
130 | /* Flag that BO may contain sensitive data that must be wiped before |
131 | * releasing the memory | |
132 | */ | |
133 | #define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE (1 << 9) | |
35ce0060 AD |
134 | /* Flag that BO will be encrypted and that the TMZ bit should be |
135 | * set in the PTEs when mapping this buffer via GPUVM or | |
136 | * accessing it with various hw blocks | |
137 | */ | |
138 | #define AMDGPU_GEM_CREATE_ENCRYPTED (1 << 10) | |
b453e42a FK |
139 | /* Flag that BO will be used only in preemptible context, which does |
140 | * not require GTT memory accounting | |
141 | */ | |
142 | #define AMDGPU_GEM_CREATE_PREEMPTIBLE (1 << 11) | |
81629cba | 143 | |
81629cba AD |
144 | struct drm_amdgpu_gem_create_in { |
145 | /** the requested memory size */ | |
2ce9dde0 | 146 | __u64 bo_size; |
81629cba | 147 | /** physical start_addr alignment in bytes for some HW requirements */ |
2ce9dde0 | 148 | __u64 alignment; |
81629cba | 149 | /** the requested memory domains */ |
2ce9dde0 | 150 | __u64 domains; |
81629cba | 151 | /** allocation flags */ |
2ce9dde0 | 152 | __u64 domain_flags; |
81629cba AD |
153 | }; |
154 | ||
155 | struct drm_amdgpu_gem_create_out { | |
156 | /** returned GEM object handle */ | |
2ce9dde0 MR |
157 | __u32 handle; |
158 | __u32 _pad; | |
81629cba AD |
159 | }; |
160 | ||
161 | union drm_amdgpu_gem_create { | |
162 | struct drm_amdgpu_gem_create_in in; | |
163 | struct drm_amdgpu_gem_create_out out; | |
164 | }; | |
165 | ||
166 | /** Opcode to create new residency list. */ | |
167 | #define AMDGPU_BO_LIST_OP_CREATE 0 | |
168 | /** Opcode to destroy previously created residency list */ | |
169 | #define AMDGPU_BO_LIST_OP_DESTROY 1 | |
170 | /** Opcode to update resource information in the list */ | |
171 | #define AMDGPU_BO_LIST_OP_UPDATE 2 | |
172 | ||
173 | struct drm_amdgpu_bo_list_in { | |
174 | /** Type of operation */ | |
2ce9dde0 | 175 | __u32 operation; |
81629cba | 176 | /** Handle of list or 0 if we want to create one */ |
2ce9dde0 | 177 | __u32 list_handle; |
81629cba | 178 | /** Number of BOs in list */ |
2ce9dde0 | 179 | __u32 bo_number; |
81629cba | 180 | /** Size of each element describing BO */ |
2ce9dde0 | 181 | __u32 bo_info_size; |
81629cba | 182 | /** Pointer to array describing BOs */ |
2ce9dde0 | 183 | __u64 bo_info_ptr; |
81629cba AD |
184 | }; |
185 | ||
186 | struct drm_amdgpu_bo_list_entry { | |
187 | /** Handle of BO */ | |
2ce9dde0 | 188 | __u32 bo_handle; |
81629cba | 189 | /** New (if specified) BO priority to be used during migration */ |
2ce9dde0 | 190 | __u32 bo_priority; |
81629cba AD |
191 | }; |
192 | ||
193 | struct drm_amdgpu_bo_list_out { | |
194 | /** Handle of resource list */ | |
2ce9dde0 MR |
195 | __u32 list_handle; |
196 | __u32 _pad; | |
81629cba AD |
197 | }; |
198 | ||
199 | union drm_amdgpu_bo_list { | |
200 | struct drm_amdgpu_bo_list_in in; | |
201 | struct drm_amdgpu_bo_list_out out; | |
202 | }; | |
203 | ||
204 | /* context related */ | |
205 | #define AMDGPU_CTX_OP_ALLOC_CTX 1 | |
206 | #define AMDGPU_CTX_OP_FREE_CTX 2 | |
207 | #define AMDGPU_CTX_OP_QUERY_STATE 3 | |
bc1b1bf6 | 208 | #define AMDGPU_CTX_OP_QUERY_STATE2 4 |
8cda7a4f AD |
209 | #define AMDGPU_CTX_OP_GET_STABLE_PSTATE 5 |
210 | #define AMDGPU_CTX_OP_SET_STABLE_PSTATE 6 | |
81629cba | 211 | |
d94aed5a MO |
212 | /* GPU reset status */ |
213 | #define AMDGPU_CTX_NO_RESET 0 | |
675da0dd CK |
214 | /* this the context caused it */ |
215 | #define AMDGPU_CTX_GUILTY_RESET 1 | |
216 | /* some other context caused it */ | |
217 | #define AMDGPU_CTX_INNOCENT_RESET 2 | |
218 | /* unknown cause */ | |
219 | #define AMDGPU_CTX_UNKNOWN_RESET 3 | |
d94aed5a | 220 | |
bc1b1bf6 ML |
221 | /* indicate gpu reset occured after ctx created */ |
222 | #define AMDGPU_CTX_QUERY2_FLAGS_RESET (1<<0) | |
223 | /* indicate vram lost occured after ctx created */ | |
224 | #define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1) | |
225 | /* indicate some job from this context once cause gpu hang */ | |
226 | #define AMDGPU_CTX_QUERY2_FLAGS_GUILTY (1<<2) | |
ae363a21 | 227 | /* indicate some errors are detected by RAS */ |
228 | #define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE (1<<3) | |
229 | #define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE (1<<4) | |
bc1b1bf6 | 230 | |
c2636dc5 | 231 | /* Context priority level */ |
f3d19bf8 | 232 | #define AMDGPU_CTX_PRIORITY_UNSET -2048 |
8bc4c256 AR |
233 | #define AMDGPU_CTX_PRIORITY_VERY_LOW -1023 |
234 | #define AMDGPU_CTX_PRIORITY_LOW -512 | |
c2636dc5 | 235 | #define AMDGPU_CTX_PRIORITY_NORMAL 0 |
cf034477 EV |
236 | /* |
237 | * When used in struct drm_amdgpu_ctx_in, a priority above NORMAL requires | |
238 | * CAP_SYS_NICE or DRM_MASTER | |
239 | */ | |
8bc4c256 AR |
240 | #define AMDGPU_CTX_PRIORITY_HIGH 512 |
241 | #define AMDGPU_CTX_PRIORITY_VERY_HIGH 1023 | |
c2636dc5 | 242 | |
8cda7a4f AD |
243 | /* select a stable profiling pstate for perfmon tools */ |
244 | #define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK 0xf | |
245 | #define AMDGPU_CTX_STABLE_PSTATE_NONE 0 | |
246 | #define AMDGPU_CTX_STABLE_PSTATE_STANDARD 1 | |
247 | #define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK 2 | |
248 | #define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK 3 | |
249 | #define AMDGPU_CTX_STABLE_PSTATE_PEAK 4 | |
250 | ||
81629cba | 251 | struct drm_amdgpu_ctx_in { |
675da0dd | 252 | /** AMDGPU_CTX_OP_* */ |
2ce9dde0 | 253 | __u32 op; |
8cda7a4f | 254 | /** Flags */ |
2ce9dde0 MR |
255 | __u32 flags; |
256 | __u32 ctx_id; | |
cf034477 | 257 | /** AMDGPU_CTX_PRIORITY_* */ |
c2636dc5 | 258 | __s32 priority; |
81629cba AD |
259 | }; |
260 | ||
261 | union drm_amdgpu_ctx_out { | |
262 | struct { | |
2ce9dde0 MR |
263 | __u32 ctx_id; |
264 | __u32 _pad; | |
81629cba AD |
265 | } alloc; |
266 | ||
267 | struct { | |
675da0dd | 268 | /** For future use, no flags defined so far */ |
2ce9dde0 | 269 | __u64 flags; |
d94aed5a | 270 | /** Number of resets caused by this context so far. */ |
2ce9dde0 | 271 | __u32 hangs; |
d94aed5a | 272 | /** Reset status since the last call of the ioctl. */ |
2ce9dde0 | 273 | __u32 reset_status; |
81629cba | 274 | } state; |
8cda7a4f AD |
275 | |
276 | struct { | |
277 | __u32 flags; | |
278 | __u32 _pad; | |
279 | } pstate; | |
81629cba AD |
280 | }; |
281 | ||
282 | union drm_amdgpu_ctx { | |
283 | struct drm_amdgpu_ctx_in in; | |
284 | union drm_amdgpu_ctx_out out; | |
285 | }; | |
286 | ||
cfbcacf4 CZ |
287 | /* vm ioctl */ |
288 | #define AMDGPU_VM_OP_RESERVE_VMID 1 | |
289 | #define AMDGPU_VM_OP_UNRESERVE_VMID 2 | |
290 | ||
291 | struct drm_amdgpu_vm_in { | |
292 | /** AMDGPU_VM_OP_* */ | |
293 | __u32 op; | |
294 | __u32 flags; | |
295 | }; | |
296 | ||
297 | struct drm_amdgpu_vm_out { | |
298 | /** For future use, no flags defined so far */ | |
299 | __u64 flags; | |
300 | }; | |
301 | ||
302 | union drm_amdgpu_vm { | |
303 | struct drm_amdgpu_vm_in in; | |
304 | struct drm_amdgpu_vm_out out; | |
305 | }; | |
306 | ||
52c6a62c AR |
307 | /* sched ioctl */ |
308 | #define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE 1 | |
b5bb37ed | 309 | #define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE 2 |
52c6a62c AR |
310 | |
311 | struct drm_amdgpu_sched_in { | |
312 | /* AMDGPU_SCHED_OP_* */ | |
313 | __u32 op; | |
314 | __u32 fd; | |
cf034477 | 315 | /** AMDGPU_CTX_PRIORITY_* */ |
52c6a62c | 316 | __s32 priority; |
b5bb37ed | 317 | __u32 ctx_id; |
52c6a62c AR |
318 | }; |
319 | ||
320 | union drm_amdgpu_sched { | |
321 | struct drm_amdgpu_sched_in in; | |
322 | }; | |
323 | ||
81629cba AD |
324 | /* |
325 | * This is not a reliable API and you should expect it to fail for any | |
326 | * number of reasons and have fallback path that do not use userptr to | |
327 | * perform any operation. | |
328 | */ | |
329 | #define AMDGPU_GEM_USERPTR_READONLY (1 << 0) | |
330 | #define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1) | |
331 | #define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2) | |
332 | #define AMDGPU_GEM_USERPTR_REGISTER (1 << 3) | |
333 | ||
334 | struct drm_amdgpu_gem_userptr { | |
2ce9dde0 MR |
335 | __u64 addr; |
336 | __u64 size; | |
675da0dd | 337 | /* AMDGPU_GEM_USERPTR_* */ |
2ce9dde0 | 338 | __u32 flags; |
675da0dd | 339 | /* Resulting GEM handle */ |
2ce9dde0 | 340 | __u32 handle; |
81629cba AD |
341 | }; |
342 | ||
00ac6f6b | 343 | /* SI-CI-VI: */ |
fbd76d59 MO |
344 | /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */ |
345 | #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0 | |
346 | #define AMDGPU_TILING_ARRAY_MODE_MASK 0xf | |
347 | #define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4 | |
348 | #define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f | |
349 | #define AMDGPU_TILING_TILE_SPLIT_SHIFT 9 | |
350 | #define AMDGPU_TILING_TILE_SPLIT_MASK 0x7 | |
351 | #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12 | |
352 | #define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7 | |
353 | #define AMDGPU_TILING_BANK_WIDTH_SHIFT 15 | |
354 | #define AMDGPU_TILING_BANK_WIDTH_MASK 0x3 | |
355 | #define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17 | |
356 | #define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3 | |
357 | #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19 | |
358 | #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3 | |
359 | #define AMDGPU_TILING_NUM_BANKS_SHIFT 21 | |
360 | #define AMDGPU_TILING_NUM_BANKS_MASK 0x3 | |
361 | ||
00ac6f6b AD |
362 | /* GFX9 and later: */ |
363 | #define AMDGPU_TILING_SWIZZLE_MODE_SHIFT 0 | |
364 | #define AMDGPU_TILING_SWIZZLE_MODE_MASK 0x1f | |
ce331f8f NK |
365 | #define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT 5 |
366 | #define AMDGPU_TILING_DCC_OFFSET_256B_MASK 0xFFFFFF | |
367 | #define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT 29 | |
368 | #define AMDGPU_TILING_DCC_PITCH_MAX_MASK 0x3FFF | |
369 | #define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT 43 | |
370 | #define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK 0x1 | |
c5705372 MO |
371 | #define AMDGPU_TILING_DCC_INDEPENDENT_128B_SHIFT 44 |
372 | #define AMDGPU_TILING_DCC_INDEPENDENT_128B_MASK 0x1 | |
373 | #define AMDGPU_TILING_SCANOUT_SHIFT 63 | |
374 | #define AMDGPU_TILING_SCANOUT_MASK 0x1 | |
00ac6f6b AD |
375 | |
376 | /* Set/Get helpers for tiling flags. */ | |
fbd76d59 | 377 | #define AMDGPU_TILING_SET(field, value) \ |
00ac6f6b | 378 | (((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT) |
fbd76d59 | 379 | #define AMDGPU_TILING_GET(value, field) \ |
00ac6f6b | 380 | (((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK) |
81629cba AD |
381 | |
382 | #define AMDGPU_GEM_METADATA_OP_SET_METADATA 1 | |
383 | #define AMDGPU_GEM_METADATA_OP_GET_METADATA 2 | |
384 | ||
385 | /** The same structure is shared for input/output */ | |
386 | struct drm_amdgpu_gem_metadata { | |
675da0dd | 387 | /** GEM Object handle */ |
2ce9dde0 | 388 | __u32 handle; |
675da0dd | 389 | /** Do we want get or set metadata */ |
2ce9dde0 | 390 | __u32 op; |
81629cba | 391 | struct { |
675da0dd | 392 | /** For future use, no flags defined so far */ |
2ce9dde0 | 393 | __u64 flags; |
675da0dd | 394 | /** family specific tiling info */ |
2ce9dde0 MR |
395 | __u64 tiling_info; |
396 | __u32 data_size_bytes; | |
397 | __u32 data[64]; | |
81629cba AD |
398 | } data; |
399 | }; | |
400 | ||
401 | struct drm_amdgpu_gem_mmap_in { | |
675da0dd | 402 | /** the GEM object handle */ |
2ce9dde0 MR |
403 | __u32 handle; |
404 | __u32 _pad; | |
81629cba AD |
405 | }; |
406 | ||
407 | struct drm_amdgpu_gem_mmap_out { | |
675da0dd | 408 | /** mmap offset from the vma offset manager */ |
2ce9dde0 | 409 | __u64 addr_ptr; |
81629cba AD |
410 | }; |
411 | ||
412 | union drm_amdgpu_gem_mmap { | |
413 | struct drm_amdgpu_gem_mmap_in in; | |
414 | struct drm_amdgpu_gem_mmap_out out; | |
415 | }; | |
416 | ||
417 | struct drm_amdgpu_gem_wait_idle_in { | |
675da0dd | 418 | /** GEM object handle */ |
2ce9dde0 | 419 | __u32 handle; |
675da0dd | 420 | /** For future use, no flags defined so far */ |
2ce9dde0 | 421 | __u32 flags; |
675da0dd | 422 | /** Absolute timeout to wait */ |
2ce9dde0 | 423 | __u64 timeout; |
81629cba AD |
424 | }; |
425 | ||
426 | struct drm_amdgpu_gem_wait_idle_out { | |
675da0dd | 427 | /** BO status: 0 - BO is idle, 1 - BO is busy */ |
2ce9dde0 | 428 | __u32 status; |
675da0dd | 429 | /** Returned current memory domain */ |
2ce9dde0 | 430 | __u32 domain; |
81629cba AD |
431 | }; |
432 | ||
433 | union drm_amdgpu_gem_wait_idle { | |
434 | struct drm_amdgpu_gem_wait_idle_in in; | |
435 | struct drm_amdgpu_gem_wait_idle_out out; | |
436 | }; | |
437 | ||
438 | struct drm_amdgpu_wait_cs_in { | |
d7b1eeb2 ML |
439 | /* Command submission handle |
440 | * handle equals 0 means none to wait for | |
080b24eb | 441 | * handle equals ~0ull means wait for the latest sequence number |
d7b1eeb2 | 442 | */ |
2ce9dde0 | 443 | __u64 handle; |
675da0dd | 444 | /** Absolute timeout to wait */ |
2ce9dde0 MR |
445 | __u64 timeout; |
446 | __u32 ip_type; | |
447 | __u32 ip_instance; | |
448 | __u32 ring; | |
449 | __u32 ctx_id; | |
81629cba AD |
450 | }; |
451 | ||
452 | struct drm_amdgpu_wait_cs_out { | |
675da0dd | 453 | /** CS status: 0 - CS completed, 1 - CS still busy */ |
2ce9dde0 | 454 | __u64 status; |
81629cba AD |
455 | }; |
456 | ||
457 | union drm_amdgpu_wait_cs { | |
458 | struct drm_amdgpu_wait_cs_in in; | |
459 | struct drm_amdgpu_wait_cs_out out; | |
460 | }; | |
461 | ||
eef18a82 JZ |
462 | struct drm_amdgpu_fence { |
463 | __u32 ctx_id; | |
464 | __u32 ip_type; | |
465 | __u32 ip_instance; | |
466 | __u32 ring; | |
467 | __u64 seq_no; | |
468 | }; | |
469 | ||
470 | struct drm_amdgpu_wait_fences_in { | |
471 | /** This points to uint64_t * which points to fences */ | |
472 | __u64 fences; | |
473 | __u32 fence_count; | |
474 | __u32 wait_all; | |
475 | __u64 timeout_ns; | |
476 | }; | |
477 | ||
478 | struct drm_amdgpu_wait_fences_out { | |
479 | __u32 status; | |
480 | __u32 first_signaled; | |
481 | }; | |
482 | ||
483 | union drm_amdgpu_wait_fences { | |
484 | struct drm_amdgpu_wait_fences_in in; | |
485 | struct drm_amdgpu_wait_fences_out out; | |
486 | }; | |
487 | ||
675da0dd CK |
488 | #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0 |
489 | #define AMDGPU_GEM_OP_SET_PLACEMENT 1 | |
490 | ||
81629cba AD |
491 | /* Sets or returns a value associated with a buffer. */ |
492 | struct drm_amdgpu_gem_op { | |
675da0dd | 493 | /** GEM object handle */ |
2ce9dde0 | 494 | __u32 handle; |
675da0dd | 495 | /** AMDGPU_GEM_OP_* */ |
2ce9dde0 | 496 | __u32 op; |
675da0dd | 497 | /** Input or return value */ |
2ce9dde0 | 498 | __u64 value; |
81629cba AD |
499 | }; |
500 | ||
81629cba AD |
501 | #define AMDGPU_VA_OP_MAP 1 |
502 | #define AMDGPU_VA_OP_UNMAP 2 | |
dc54d3d1 | 503 | #define AMDGPU_VA_OP_CLEAR 3 |
80f95c57 | 504 | #define AMDGPU_VA_OP_REPLACE 4 |
81629cba | 505 | |
fc220f65 CK |
506 | /* Delay the page table update till the next CS */ |
507 | #define AMDGPU_VM_DELAY_UPDATE (1 << 0) | |
508 | ||
81629cba AD |
509 | /* Mapping flags */ |
510 | /* readable mapping */ | |
511 | #define AMDGPU_VM_PAGE_READABLE (1 << 1) | |
512 | /* writable mapping */ | |
513 | #define AMDGPU_VM_PAGE_WRITEABLE (1 << 2) | |
514 | /* executable mapping, new for VI */ | |
515 | #define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3) | |
b85891bd JZ |
516 | /* partially resident texture */ |
517 | #define AMDGPU_VM_PAGE_PRT (1 << 4) | |
66e02bc3 AX |
518 | /* MTYPE flags use bit 5 to 8 */ |
519 | #define AMDGPU_VM_MTYPE_MASK (0xf << 5) | |
520 | /* Default MTYPE. Pre-AI must use this. Recommended for newer ASICs. */ | |
521 | #define AMDGPU_VM_MTYPE_DEFAULT (0 << 5) | |
130c8893 | 522 | /* Use Non Coherent MTYPE instead of default MTYPE */ |
66e02bc3 | 523 | #define AMDGPU_VM_MTYPE_NC (1 << 5) |
130c8893 | 524 | /* Use Write Combine MTYPE instead of default MTYPE */ |
66e02bc3 | 525 | #define AMDGPU_VM_MTYPE_WC (2 << 5) |
130c8893 | 526 | /* Use Cache Coherent MTYPE instead of default MTYPE */ |
66e02bc3 | 527 | #define AMDGPU_VM_MTYPE_CC (3 << 5) |
130c8893 | 528 | /* Use UnCached MTYPE instead of default MTYPE */ |
66e02bc3 | 529 | #define AMDGPU_VM_MTYPE_UC (4 << 5) |
130c8893 | 530 | /* Use Read Write MTYPE instead of default MTYPE */ |
484deaed | 531 | #define AMDGPU_VM_MTYPE_RW (5 << 5) |
81629cba | 532 | |
34b5f6a6 | 533 | struct drm_amdgpu_gem_va { |
675da0dd | 534 | /** GEM object handle */ |
2ce9dde0 MR |
535 | __u32 handle; |
536 | __u32 _pad; | |
675da0dd | 537 | /** AMDGPU_VA_OP_* */ |
2ce9dde0 | 538 | __u32 operation; |
675da0dd | 539 | /** AMDGPU_VM_PAGE_* */ |
2ce9dde0 | 540 | __u32 flags; |
675da0dd | 541 | /** va address to assign . Must be correctly aligned.*/ |
2ce9dde0 | 542 | __u64 va_address; |
675da0dd | 543 | /** Specify offset inside of BO to assign. Must be correctly aligned.*/ |
2ce9dde0 | 544 | __u64 offset_in_bo; |
675da0dd | 545 | /** Specify mapping size. Must be correctly aligned. */ |
2ce9dde0 | 546 | __u64 map_size; |
81629cba AD |
547 | }; |
548 | ||
81629cba AD |
549 | #define AMDGPU_HW_IP_GFX 0 |
550 | #define AMDGPU_HW_IP_COMPUTE 1 | |
551 | #define AMDGPU_HW_IP_DMA 2 | |
552 | #define AMDGPU_HW_IP_UVD 3 | |
553 | #define AMDGPU_HW_IP_VCE 4 | |
a50798b6 | 554 | #define AMDGPU_HW_IP_UVD_ENC 5 |
66e236f1 | 555 | #define AMDGPU_HW_IP_VCN_DEC 6 |
fcfc5a90 | 556 | #define AMDGPU_HW_IP_VCN_ENC 7 |
81d35014 BZ |
557 | #define AMDGPU_HW_IP_VCN_JPEG 8 |
558 | #define AMDGPU_HW_IP_NUM 9 | |
81629cba AD |
559 | |
560 | #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1 | |
561 | ||
562 | #define AMDGPU_CHUNK_ID_IB 0x01 | |
563 | #define AMDGPU_CHUNK_ID_FENCE 0x02 | |
2b48d323 | 564 | #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03 |
660e8558 DA |
565 | #define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04 |
566 | #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 | |
964d0fbf | 567 | #define AMDGPU_CHUNK_ID_BO_HANDLES 0x06 |
67dd1a36 | 568 | #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07 |
2624dd15 CZ |
569 | #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08 |
570 | #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09 | |
675da0dd | 571 | |
81629cba | 572 | struct drm_amdgpu_cs_chunk { |
2ce9dde0 MR |
573 | __u32 chunk_id; |
574 | __u32 length_dw; | |
575 | __u64 chunk_data; | |
81629cba AD |
576 | }; |
577 | ||
578 | struct drm_amdgpu_cs_in { | |
579 | /** Rendering context id */ | |
2ce9dde0 | 580 | __u32 ctx_id; |
81629cba | 581 | /** Handle of resource list associated with CS */ |
2ce9dde0 MR |
582 | __u32 bo_list_handle; |
583 | __u32 num_chunks; | |
e90c2b21 | 584 | __u32 flags; |
2ce9dde0 MR |
585 | /** this points to __u64 * which point to cs chunks */ |
586 | __u64 chunks; | |
81629cba AD |
587 | }; |
588 | ||
589 | struct drm_amdgpu_cs_out { | |
2ce9dde0 | 590 | __u64 handle; |
81629cba AD |
591 | }; |
592 | ||
593 | union drm_amdgpu_cs { | |
675da0dd CK |
594 | struct drm_amdgpu_cs_in in; |
595 | struct drm_amdgpu_cs_out out; | |
81629cba AD |
596 | }; |
597 | ||
598 | /* Specify flags to be used for IB */ | |
599 | ||
600 | /* This IB should be submitted to CE */ | |
601 | #define AMDGPU_IB_FLAG_CE (1<<0) | |
602 | ||
ed834af2 | 603 | /* Preamble flag, which means the IB could be dropped if no context switch */ |
cab6d57c | 604 | #define AMDGPU_IB_FLAG_PREAMBLE (1<<1) |
aa2bdb24 | 605 | |
71aec257 ML |
606 | /* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */ |
607 | #define AMDGPU_IB_FLAG_PREEMPT (1<<2) | |
608 | ||
d240cd9e MO |
609 | /* The IB fence should do the L2 writeback but not invalidate any shader |
610 | * caches (L2/vL1/sL1/I$). */ | |
611 | #define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3) | |
612 | ||
41cca166 MO |
613 | /* Set GDS_COMPUTE_MAX_WAVE_ID = DEFAULT before PACKET3_INDIRECT_BUFFER. |
614 | * This will reset wave ID counters for the IB. | |
615 | */ | |
616 | #define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4) | |
617 | ||
0bb5d5b0 LT |
618 | /* Flag the IB as secure (TMZ) |
619 | */ | |
620 | #define AMDGPU_IB_FLAGS_SECURE (1 << 5) | |
621 | ||
43c8546b AG |
622 | /* Tell KMD to flush and invalidate caches |
623 | */ | |
624 | #define AMDGPU_IB_FLAG_EMIT_MEM_SYNC (1 << 6) | |
625 | ||
81629cba | 626 | struct drm_amdgpu_cs_chunk_ib { |
2ce9dde0 | 627 | __u32 _pad; |
675da0dd | 628 | /** AMDGPU_IB_FLAG_* */ |
2ce9dde0 | 629 | __u32 flags; |
675da0dd | 630 | /** Virtual address to begin IB execution */ |
2ce9dde0 | 631 | __u64 va_start; |
675da0dd | 632 | /** Size of submission */ |
2ce9dde0 | 633 | __u32 ib_bytes; |
675da0dd | 634 | /** HW IP to submit to */ |
2ce9dde0 | 635 | __u32 ip_type; |
675da0dd | 636 | /** HW IP index of the same type to submit to */ |
2ce9dde0 | 637 | __u32 ip_instance; |
675da0dd | 638 | /** Ring index to submit to */ |
2ce9dde0 | 639 | __u32 ring; |
81629cba AD |
640 | }; |
641 | ||
2b48d323 | 642 | struct drm_amdgpu_cs_chunk_dep { |
2ce9dde0 MR |
643 | __u32 ip_type; |
644 | __u32 ip_instance; | |
645 | __u32 ring; | |
646 | __u32 ctx_id; | |
647 | __u64 handle; | |
2b48d323 CK |
648 | }; |
649 | ||
81629cba | 650 | struct drm_amdgpu_cs_chunk_fence { |
2ce9dde0 MR |
651 | __u32 handle; |
652 | __u32 offset; | |
81629cba AD |
653 | }; |
654 | ||
660e8558 DA |
655 | struct drm_amdgpu_cs_chunk_sem { |
656 | __u32 handle; | |
657 | }; | |
658 | ||
2624dd15 CZ |
659 | struct drm_amdgpu_cs_chunk_syncobj { |
660 | __u32 handle; | |
661 | __u32 flags; | |
662 | __u64 point; | |
663 | }; | |
664 | ||
7ca24cf2 MO |
665 | #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 0 |
666 | #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 1 | |
667 | #define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2 | |
668 | ||
669 | union drm_amdgpu_fence_to_handle { | |
670 | struct { | |
671 | struct drm_amdgpu_fence fence; | |
672 | __u32 what; | |
56e0349f | 673 | __u32 pad; |
7ca24cf2 MO |
674 | } in; |
675 | struct { | |
676 | __u32 handle; | |
677 | } out; | |
678 | }; | |
679 | ||
81629cba AD |
680 | struct drm_amdgpu_cs_chunk_data { |
681 | union { | |
682 | struct drm_amdgpu_cs_chunk_ib ib_data; | |
683 | struct drm_amdgpu_cs_chunk_fence fence_data; | |
684 | }; | |
685 | }; | |
686 | ||
c45dd3bd | 687 | /* |
81629cba AD |
688 | * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU |
689 | * | |
690 | */ | |
691 | #define AMDGPU_IDS_FLAGS_FUSION 0x1 | |
aafcafa0 | 692 | #define AMDGPU_IDS_FLAGS_PREEMPTION 0x2 |
16c642ec | 693 | #define AMDGPU_IDS_FLAGS_TMZ 0x4 |
81629cba AD |
694 | |
695 | /* indicate if acceleration can be working */ | |
696 | #define AMDGPU_INFO_ACCEL_WORKING 0x00 | |
697 | /* get the crtc_id from the mode object id? */ | |
698 | #define AMDGPU_INFO_CRTC_FROM_ID 0x01 | |
699 | /* query hw IP info */ | |
700 | #define AMDGPU_INFO_HW_IP_INFO 0x02 | |
701 | /* query hw IP instance count for the specified type */ | |
702 | #define AMDGPU_INFO_HW_IP_COUNT 0x03 | |
703 | /* timestamp for GL_ARB_timer_query */ | |
704 | #define AMDGPU_INFO_TIMESTAMP 0x05 | |
705 | /* Query the firmware version */ | |
706 | #define AMDGPU_INFO_FW_VERSION 0x0e | |
707 | /* Subquery id: Query VCE firmware version */ | |
708 | #define AMDGPU_INFO_FW_VCE 0x1 | |
709 | /* Subquery id: Query UVD firmware version */ | |
710 | #define AMDGPU_INFO_FW_UVD 0x2 | |
711 | /* Subquery id: Query GMC firmware version */ | |
712 | #define AMDGPU_INFO_FW_GMC 0x03 | |
713 | /* Subquery id: Query GFX ME firmware version */ | |
714 | #define AMDGPU_INFO_FW_GFX_ME 0x04 | |
715 | /* Subquery id: Query GFX PFP firmware version */ | |
716 | #define AMDGPU_INFO_FW_GFX_PFP 0x05 | |
717 | /* Subquery id: Query GFX CE firmware version */ | |
718 | #define AMDGPU_INFO_FW_GFX_CE 0x06 | |
719 | /* Subquery id: Query GFX RLC firmware version */ | |
720 | #define AMDGPU_INFO_FW_GFX_RLC 0x07 | |
721 | /* Subquery id: Query GFX MEC firmware version */ | |
722 | #define AMDGPU_INFO_FW_GFX_MEC 0x08 | |
723 | /* Subquery id: Query SMC firmware version */ | |
724 | #define AMDGPU_INFO_FW_SMC 0x0a | |
725 | /* Subquery id: Query SDMA firmware version */ | |
726 | #define AMDGPU_INFO_FW_SDMA 0x0b | |
6a7ed07e HR |
727 | /* Subquery id: Query PSP SOS firmware version */ |
728 | #define AMDGPU_INFO_FW_SOS 0x0c | |
729 | /* Subquery id: Query PSP ASD firmware version */ | |
730 | #define AMDGPU_INFO_FW_ASD 0x0d | |
3ac952b1 AD |
731 | /* Subquery id: Query VCN firmware version */ |
732 | #define AMDGPU_INFO_FW_VCN 0x0e | |
621a6318 HR |
733 | /* Subquery id: Query GFX RLC SRLC firmware version */ |
734 | #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f | |
735 | /* Subquery id: Query GFX RLC SRLG firmware version */ | |
736 | #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10 | |
737 | /* Subquery id: Query GFX RLC SRLS firmware version */ | |
738 | #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11 | |
4d11b4b2 DF |
739 | /* Subquery id: Query DMCU firmware version */ |
740 | #define AMDGPU_INFO_FW_DMCU 0x12 | |
9b9ca62d | 741 | #define AMDGPU_INFO_FW_TA 0x13 |
976e51a7 NK |
742 | /* Subquery id: Query DMCUB firmware version */ |
743 | #define AMDGPU_INFO_FW_DMCUB 0x14 | |
6fbcb00c HR |
744 | /* Subquery id: Query TOC firmware version */ |
745 | #define AMDGPU_INFO_FW_TOC 0x15 | |
c4381d0e BZ |
746 | /* Subquery id: Query CAP firmware version */ |
747 | #define AMDGPU_INFO_FW_CAP 0x16 | |
976e51a7 | 748 | |
81629cba AD |
749 | /* number of bytes moved for TTM migration */ |
750 | #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f | |
751 | /* the used VRAM size */ | |
752 | #define AMDGPU_INFO_VRAM_USAGE 0x10 | |
753 | /* the used GTT size */ | |
754 | #define AMDGPU_INFO_GTT_USAGE 0x11 | |
755 | /* Information about GDS, etc. resource configuration */ | |
756 | #define AMDGPU_INFO_GDS_CONFIG 0x13 | |
757 | /* Query information about VRAM and GTT domains */ | |
758 | #define AMDGPU_INFO_VRAM_GTT 0x14 | |
759 | /* Query information about register in MMR address space*/ | |
760 | #define AMDGPU_INFO_READ_MMR_REG 0x15 | |
761 | /* Query information about device: rev id, family, etc. */ | |
762 | #define AMDGPU_INFO_DEV_INFO 0x16 | |
763 | /* visible vram usage */ | |
764 | #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17 | |
83a59b63 MO |
765 | /* number of TTM buffer evictions */ |
766 | #define AMDGPU_INFO_NUM_EVICTIONS 0x18 | |
e0adf6c8 JZ |
767 | /* Query memory about VRAM and GTT domains */ |
768 | #define AMDGPU_INFO_MEMORY 0x19 | |
bbe87974 AD |
769 | /* Query vce clock table */ |
770 | #define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A | |
40ee5888 EQ |
771 | /* Query vbios related information */ |
772 | #define AMDGPU_INFO_VBIOS 0x1B | |
773 | /* Subquery id: Query vbios size */ | |
774 | #define AMDGPU_INFO_VBIOS_SIZE 0x1 | |
775 | /* Subquery id: Query vbios image */ | |
776 | #define AMDGPU_INFO_VBIOS_IMAGE 0x2 | |
29b4c589 JG |
777 | /* Subquery id: Query vbios info */ |
778 | #define AMDGPU_INFO_VBIOS_INFO 0x3 | |
44879b62 AN |
779 | /* Query UVD handles */ |
780 | #define AMDGPU_INFO_NUM_HANDLES 0x1C | |
5ebbac4b AD |
781 | /* Query sensor related information */ |
782 | #define AMDGPU_INFO_SENSOR 0x1D | |
783 | /* Subquery id: Query GPU shader clock */ | |
784 | #define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1 | |
785 | /* Subquery id: Query GPU memory clock */ | |
786 | #define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2 | |
787 | /* Subquery id: Query GPU temperature */ | |
788 | #define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3 | |
789 | /* Subquery id: Query GPU load */ | |
790 | #define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4 | |
791 | /* Subquery id: Query average GPU power */ | |
792 | #define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x5 | |
793 | /* Subquery id: Query northbridge voltage */ | |
794 | #define AMDGPU_INFO_SENSOR_VDDNB 0x6 | |
795 | /* Subquery id: Query graphics voltage */ | |
796 | #define AMDGPU_INFO_SENSOR_VDDGFX 0x7 | |
60bbade2 RZ |
797 | /* Subquery id: Query GPU stable pstate shader clock */ |
798 | #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK 0x8 | |
799 | /* Subquery id: Query GPU stable pstate memory clock */ | |
800 | #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK 0x9 | |
68e2c5ff MO |
801 | /* Number of VRAM page faults on CPU access. */ |
802 | #define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E | |
1f7251b7 | 803 | #define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F |
5cb77114 | 804 | /* query ras mask of enabled features*/ |
805 | #define AMDGPU_INFO_RAS_ENABLED_FEATURES 0x20 | |
5cb77114 | 806 | /* RAS MASK: UMC (VRAM) */ |
807 | #define AMDGPU_INFO_RAS_ENABLED_UMC (1 << 0) | |
808 | /* RAS MASK: SDMA */ | |
809 | #define AMDGPU_INFO_RAS_ENABLED_SDMA (1 << 1) | |
810 | /* RAS MASK: GFX */ | |
811 | #define AMDGPU_INFO_RAS_ENABLED_GFX (1 << 2) | |
812 | /* RAS MASK: MMHUB */ | |
813 | #define AMDGPU_INFO_RAS_ENABLED_MMHUB (1 << 3) | |
814 | /* RAS MASK: ATHUB */ | |
815 | #define AMDGPU_INFO_RAS_ENABLED_ATHUB (1 << 4) | |
816 | /* RAS MASK: PCIE */ | |
817 | #define AMDGPU_INFO_RAS_ENABLED_PCIE (1 << 5) | |
818 | /* RAS MASK: HDP */ | |
819 | #define AMDGPU_INFO_RAS_ENABLED_HDP (1 << 6) | |
820 | /* RAS MASK: XGMI */ | |
821 | #define AMDGPU_INFO_RAS_ENABLED_XGMI (1 << 7) | |
822 | /* RAS MASK: DF */ | |
823 | #define AMDGPU_INFO_RAS_ENABLED_DF (1 << 8) | |
824 | /* RAS MASK: SMN */ | |
825 | #define AMDGPU_INFO_RAS_ENABLED_SMN (1 << 9) | |
826 | /* RAS MASK: SEM */ | |
827 | #define AMDGPU_INFO_RAS_ENABLED_SEM (1 << 10) | |
828 | /* RAS MASK: MP0 */ | |
829 | #define AMDGPU_INFO_RAS_ENABLED_MP0 (1 << 11) | |
830 | /* RAS MASK: MP1 */ | |
831 | #define AMDGPU_INFO_RAS_ENABLED_MP1 (1 << 12) | |
832 | /* RAS MASK: FUSE */ | |
833 | #define AMDGPU_INFO_RAS_ENABLED_FUSE (1 << 13) | |
72f4c9d5 AD |
834 | /* query video encode/decode caps */ |
835 | #define AMDGPU_INFO_VIDEO_CAPS 0x21 | |
836 | /* Subquery id: Decode */ | |
837 | #define AMDGPU_INFO_VIDEO_CAPS_DECODE 0 | |
838 | /* Subquery id: Encode */ | |
839 | #define AMDGPU_INFO_VIDEO_CAPS_ENCODE 1 | |
81629cba AD |
840 | |
841 | #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0 | |
842 | #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff | |
843 | #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8 | |
844 | #define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff | |
845 | ||
000cab9a HR |
846 | struct drm_amdgpu_query_fw { |
847 | /** AMDGPU_INFO_FW_* */ | |
848 | __u32 fw_type; | |
849 | /** | |
850 | * Index of the IP if there are more IPs of | |
851 | * the same type. | |
852 | */ | |
853 | __u32 ip_instance; | |
854 | /** | |
855 | * Index of the engine. Whether this is used depends | |
856 | * on the firmware type. (e.g. MEC, SDMA) | |
857 | */ | |
858 | __u32 index; | |
859 | __u32 _pad; | |
860 | }; | |
861 | ||
81629cba AD |
862 | /* Input structure for the INFO ioctl */ |
863 | struct drm_amdgpu_info { | |
864 | /* Where the return value will be stored */ | |
2ce9dde0 | 865 | __u64 return_pointer; |
81629cba AD |
866 | /* The size of the return value. Just like "size" in "snprintf", |
867 | * it limits how many bytes the kernel can write. */ | |
2ce9dde0 | 868 | __u32 return_size; |
81629cba | 869 | /* The query request id. */ |
2ce9dde0 | 870 | __u32 query; |
81629cba AD |
871 | |
872 | union { | |
873 | struct { | |
2ce9dde0 MR |
874 | __u32 id; |
875 | __u32 _pad; | |
81629cba AD |
876 | } mode_crtc; |
877 | ||
878 | struct { | |
879 | /** AMDGPU_HW_IP_* */ | |
2ce9dde0 | 880 | __u32 type; |
81629cba | 881 | /** |
675da0dd CK |
882 | * Index of the IP if there are more IPs of the same |
883 | * type. Ignored by AMDGPU_INFO_HW_IP_COUNT. | |
81629cba | 884 | */ |
2ce9dde0 | 885 | __u32 ip_instance; |
81629cba AD |
886 | } query_hw_ip; |
887 | ||
888 | struct { | |
2ce9dde0 | 889 | __u32 dword_offset; |
675da0dd | 890 | /** number of registers to read */ |
2ce9dde0 MR |
891 | __u32 count; |
892 | __u32 instance; | |
675da0dd | 893 | /** For future use, no flags defined so far */ |
2ce9dde0 | 894 | __u32 flags; |
81629cba AD |
895 | } read_mmr_reg; |
896 | ||
000cab9a | 897 | struct drm_amdgpu_query_fw query_fw; |
40ee5888 EQ |
898 | |
899 | struct { | |
900 | __u32 type; | |
901 | __u32 offset; | |
902 | } vbios_info; | |
5ebbac4b AD |
903 | |
904 | struct { | |
905 | __u32 type; | |
906 | } sensor_info; | |
f35e9bdb AD |
907 | |
908 | struct { | |
909 | __u32 type; | |
910 | } video_cap; | |
81629cba AD |
911 | }; |
912 | }; | |
913 | ||
914 | struct drm_amdgpu_info_gds { | |
915 | /** GDS GFX partition size */ | |
2ce9dde0 | 916 | __u32 gds_gfx_partition_size; |
81629cba | 917 | /** GDS compute partition size */ |
2ce9dde0 | 918 | __u32 compute_partition_size; |
81629cba | 919 | /** total GDS memory size */ |
2ce9dde0 | 920 | __u32 gds_total_size; |
81629cba | 921 | /** GWS size per GFX partition */ |
2ce9dde0 | 922 | __u32 gws_per_gfx_partition; |
81629cba | 923 | /** GSW size per compute partition */ |
2ce9dde0 | 924 | __u32 gws_per_compute_partition; |
81629cba | 925 | /** OA size per GFX partition */ |
2ce9dde0 | 926 | __u32 oa_per_gfx_partition; |
81629cba | 927 | /** OA size per compute partition */ |
2ce9dde0 MR |
928 | __u32 oa_per_compute_partition; |
929 | __u32 _pad; | |
81629cba AD |
930 | }; |
931 | ||
932 | struct drm_amdgpu_info_vram_gtt { | |
2ce9dde0 MR |
933 | __u64 vram_size; |
934 | __u64 vram_cpu_accessible_size; | |
935 | __u64 gtt_size; | |
81629cba AD |
936 | }; |
937 | ||
e0adf6c8 JZ |
938 | struct drm_amdgpu_heap_info { |
939 | /** max. physical memory */ | |
940 | __u64 total_heap_size; | |
941 | ||
942 | /** Theoretical max. available memory in the given heap */ | |
943 | __u64 usable_heap_size; | |
944 | ||
945 | /** | |
946 | * Number of bytes allocated in the heap. This includes all processes | |
947 | * and private allocations in the kernel. It changes when new buffers | |
948 | * are allocated, freed, and moved. It cannot be larger than | |
949 | * heap_size. | |
950 | */ | |
951 | __u64 heap_usage; | |
952 | ||
953 | /** | |
954 | * Theoretical possible max. size of buffer which | |
955 | * could be allocated in the given heap | |
956 | */ | |
957 | __u64 max_allocation; | |
9f6163e7 JZ |
958 | }; |
959 | ||
e0adf6c8 JZ |
960 | struct drm_amdgpu_memory_info { |
961 | struct drm_amdgpu_heap_info vram; | |
962 | struct drm_amdgpu_heap_info cpu_accessible_vram; | |
963 | struct drm_amdgpu_heap_info gtt; | |
cfa32556 JZ |
964 | }; |
965 | ||
81629cba | 966 | struct drm_amdgpu_info_firmware { |
2ce9dde0 MR |
967 | __u32 ver; |
968 | __u32 feature; | |
81629cba AD |
969 | }; |
970 | ||
29b4c589 JG |
971 | struct drm_amdgpu_info_vbios { |
972 | __u8 name[64]; | |
973 | __u8 vbios_pn[64]; | |
974 | __u32 version; | |
975 | __u32 pad; | |
976 | __u8 vbios_ver_str[32]; | |
977 | __u8 date[32]; | |
978 | }; | |
979 | ||
81c59f54 KW |
980 | #define AMDGPU_VRAM_TYPE_UNKNOWN 0 |
981 | #define AMDGPU_VRAM_TYPE_GDDR1 1 | |
982 | #define AMDGPU_VRAM_TYPE_DDR2 2 | |
983 | #define AMDGPU_VRAM_TYPE_GDDR3 3 | |
984 | #define AMDGPU_VRAM_TYPE_GDDR4 4 | |
985 | #define AMDGPU_VRAM_TYPE_GDDR5 5 | |
986 | #define AMDGPU_VRAM_TYPE_HBM 6 | |
987 | #define AMDGPU_VRAM_TYPE_DDR3 7 | |
1e09b053 | 988 | #define AMDGPU_VRAM_TYPE_DDR4 8 |
d67383e6 | 989 | #define AMDGPU_VRAM_TYPE_GDDR6 9 |
1e483203 | 990 | #define AMDGPU_VRAM_TYPE_DDR5 10 |
81c59f54 | 991 | |
81629cba AD |
992 | struct drm_amdgpu_info_device { |
993 | /** PCI Device ID */ | |
2ce9dde0 | 994 | __u32 device_id; |
81629cba | 995 | /** Internal chip revision: A0, A1, etc.) */ |
2ce9dde0 MR |
996 | __u32 chip_rev; |
997 | __u32 external_rev; | |
81629cba | 998 | /** Revision id in PCI Config space */ |
2ce9dde0 MR |
999 | __u32 pci_rev; |
1000 | __u32 family; | |
1001 | __u32 num_shader_engines; | |
1002 | __u32 num_shader_arrays_per_engine; | |
675da0dd | 1003 | /* in KHz */ |
2ce9dde0 MR |
1004 | __u32 gpu_counter_freq; |
1005 | __u64 max_engine_clock; | |
1006 | __u64 max_memory_clock; | |
81629cba | 1007 | /* cu information */ |
2ce9dde0 | 1008 | __u32 cu_active_number; |
dbfe85ea | 1009 | /* NOTE: cu_ao_mask is INVALID, DON'T use it */ |
2ce9dde0 MR |
1010 | __u32 cu_ao_mask; |
1011 | __u32 cu_bitmap[4][4]; | |
81629cba | 1012 | /** Render backend pipe mask. One render backend is CB+DB. */ |
2ce9dde0 MR |
1013 | __u32 enabled_rb_pipes_mask; |
1014 | __u32 num_rb_pipes; | |
1015 | __u32 num_hw_gfx_contexts; | |
1016 | __u32 _pad; | |
1017 | __u64 ids_flags; | |
81629cba | 1018 | /** Starting virtual address for UMDs. */ |
2ce9dde0 | 1019 | __u64 virtual_address_offset; |
02b70c8c | 1020 | /** The maximum virtual address */ |
2ce9dde0 | 1021 | __u64 virtual_address_max; |
81629cba | 1022 | /** Required alignment of virtual addresses. */ |
2ce9dde0 | 1023 | __u32 virtual_address_alignment; |
81629cba | 1024 | /** Page table entry - fragment size */ |
2ce9dde0 MR |
1025 | __u32 pte_fragment_size; |
1026 | __u32 gart_page_size; | |
a101a899 | 1027 | /** constant engine ram size*/ |
2ce9dde0 | 1028 | __u32 ce_ram_size; |
cab6d57c | 1029 | /** video memory type info*/ |
2ce9dde0 | 1030 | __u32 vram_type; |
81c59f54 | 1031 | /** video memory bit width*/ |
2ce9dde0 | 1032 | __u32 vram_bit_width; |
fa92754e | 1033 | /* vce harvesting instance */ |
2ce9dde0 | 1034 | __u32 vce_harvest_config; |
df6e2c4a JZ |
1035 | /* gfx double offchip LDS buffers */ |
1036 | __u32 gc_double_offchip_lds_buf; | |
bce23e00 AD |
1037 | /* NGG Primitive Buffer */ |
1038 | __u64 prim_buf_gpu_addr; | |
1039 | /* NGG Position Buffer */ | |
1040 | __u64 pos_buf_gpu_addr; | |
1041 | /* NGG Control Sideband */ | |
1042 | __u64 cntl_sb_buf_gpu_addr; | |
1043 | /* NGG Parameter Cache */ | |
1044 | __u64 param_buf_gpu_addr; | |
408bfe7c JZ |
1045 | __u32 prim_buf_size; |
1046 | __u32 pos_buf_size; | |
1047 | __u32 cntl_sb_buf_size; | |
1048 | __u32 param_buf_size; | |
1049 | /* wavefront size*/ | |
1050 | __u32 wave_front_size; | |
1051 | /* shader visible vgprs*/ | |
1052 | __u32 num_shader_visible_vgprs; | |
1053 | /* CU per shader array*/ | |
1054 | __u32 num_cu_per_sh; | |
1055 | /* number of tcc blocks*/ | |
1056 | __u32 num_tcc_blocks; | |
1057 | /* gs vgt table depth*/ | |
1058 | __u32 gs_vgt_table_depth; | |
1059 | /* gs primitive buffer depth*/ | |
1060 | __u32 gs_prim_buffer_depth; | |
1061 | /* max gs wavefront per vgt*/ | |
1062 | __u32 max_gs_waves_per_vgt; | |
1063 | __u32 _pad1; | |
dbfe85ea FC |
1064 | /* always on cu bitmap */ |
1065 | __u32 cu_ao_bitmap[4][4]; | |
5b565e0e CK |
1066 | /** Starting high virtual address for UMDs. */ |
1067 | __u64 high_va_offset; | |
1068 | /** The maximum high virtual address */ | |
1069 | __u64 high_va_max; | |
22e96fa6 HZ |
1070 | /* gfx10 pa_sc_tile_steering_override */ |
1071 | __u32 pa_sc_tile_steering_override; | |
cf21e76a MO |
1072 | /* disabled TCCs */ |
1073 | __u64 tcc_disabled_mask; | |
81629cba AD |
1074 | }; |
1075 | ||
1076 | struct drm_amdgpu_info_hw_ip { | |
1077 | /** Version of h/w IP */ | |
2ce9dde0 MR |
1078 | __u32 hw_ip_version_major; |
1079 | __u32 hw_ip_version_minor; | |
81629cba | 1080 | /** Capabilities */ |
2ce9dde0 | 1081 | __u64 capabilities_flags; |
71062f43 | 1082 | /** command buffer address start alignment*/ |
2ce9dde0 | 1083 | __u32 ib_start_alignment; |
71062f43 | 1084 | /** command buffer size alignment*/ |
2ce9dde0 | 1085 | __u32 ib_size_alignment; |
81629cba | 1086 | /** Bitmask of available rings. Bit 0 means ring 0, etc. */ |
2ce9dde0 MR |
1087 | __u32 available_rings; |
1088 | __u32 _pad; | |
81629cba AD |
1089 | }; |
1090 | ||
44879b62 AN |
1091 | struct drm_amdgpu_info_num_handles { |
1092 | /** Max handles as supported by firmware for UVD */ | |
1093 | __u32 uvd_max_handles; | |
1094 | /** Handles currently in use for UVD */ | |
1095 | __u32 uvd_used_handles; | |
1096 | }; | |
1097 | ||
bbe87974 AD |
1098 | #define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6 |
1099 | ||
1100 | struct drm_amdgpu_info_vce_clock_table_entry { | |
1101 | /** System clock */ | |
1102 | __u32 sclk; | |
1103 | /** Memory clock */ | |
1104 | __u32 mclk; | |
1105 | /** VCE clock */ | |
1106 | __u32 eclk; | |
1107 | __u32 pad; | |
1108 | }; | |
1109 | ||
1110 | struct drm_amdgpu_info_vce_clock_table { | |
1111 | struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES]; | |
1112 | __u32 num_valid_entries; | |
1113 | __u32 pad; | |
1114 | }; | |
1115 | ||
f35e9bdb AD |
1116 | /* query video encode/decode caps */ |
1117 | #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 0 | |
1118 | #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 1 | |
1119 | #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 2 | |
1120 | #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC 3 | |
1121 | #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC 4 | |
1122 | #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG 5 | |
1123 | #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9 6 | |
1124 | #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1 7 | |
1125 | #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT 8 | |
1126 | ||
1127 | struct drm_amdgpu_info_video_codec_info { | |
1128 | __u32 valid; | |
1129 | __u32 max_width; | |
1130 | __u32 max_height; | |
1131 | __u32 max_pixels_per_frame; | |
1132 | __u32 max_level; | |
1133 | __u32 pad; | |
1134 | }; | |
1135 | ||
1136 | struct drm_amdgpu_info_video_caps { | |
1137 | struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT]; | |
1138 | }; | |
1139 | ||
81629cba AD |
1140 | /* |
1141 | * Supported GPU families | |
1142 | */ | |
1143 | #define AMDGPU_FAMILY_UNKNOWN 0 | |
295d0daf | 1144 | #define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */ |
81629cba AD |
1145 | #define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */ |
1146 | #define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */ | |
1147 | #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */ | |
39bb0c92 | 1148 | #define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */ |
a8f1f1ce | 1149 | #define AMDGPU_FAMILY_AI 141 /* Vega10 */ |
2ca8a5d2 | 1150 | #define AMDGPU_FAMILY_RV 142 /* Raven */ |
107c34bc | 1151 | #define AMDGPU_FAMILY_NV 143 /* Navi10 */ |
f7b2cdb2 | 1152 | #define AMDGPU_FAMILY_VGH 144 /* Van Gogh */ |
90a187d2 | 1153 | #define AMDGPU_FAMILY_YC 146 /* Yellow Carp */ |
a65dbf7c | 1154 | #define AMDGPU_FAMILY_GC_10_3_7 151 /* GC 10.3.7 */ |
81629cba | 1155 | |
cfa7152f EV |
1156 | #if defined(__cplusplus) |
1157 | } | |
1158 | #endif | |
1159 | ||
81629cba | 1160 | #endif |