drm/amdgpu: add PTE defines for MTYPE
[linux-2.6-block.git] / include / uapi / drm / amdgpu_drm.h
CommitLineData
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)
38extern "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
81629cba
AD
54
55#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
56#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
57#define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
58#define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
59#define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
60#define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
61#define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
62#define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
34b5f6a6 63#define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
81629cba
AD
64#define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
65#define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
66#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
eef18a82 67#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)
81629cba
AD
68
69#define AMDGPU_GEM_DOMAIN_CPU 0x1
70#define AMDGPU_GEM_DOMAIN_GTT 0x2
71#define AMDGPU_GEM_DOMAIN_VRAM 0x4
72#define AMDGPU_GEM_DOMAIN_GDS 0x8
73#define AMDGPU_GEM_DOMAIN_GWS 0x10
74#define AMDGPU_GEM_DOMAIN_OA 0x20
75
81629cba
AD
76/* Flag that CPU access will be required for the case of VRAM domain */
77#define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
78/* Flag that CPU access will not work, this VRAM domain is invisible */
79#define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)
81629cba 80/* Flag that USWC attributes should be used for GTT */
88671288 81#define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)
4fea83ff
FC
82/* Flag that the memory should be in VRAM and cleared */
83#define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3)
e7893c4b
CZ
84/* Flag that create shadow bo(GTT) while allocating vram bo */
85#define AMDGPU_GEM_CREATE_SHADOW (1 << 4)
03f48dd5
CK
86/* Flag that allocating the BO should use linear VRAM */
87#define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5)
81629cba 88
81629cba
AD
89struct drm_amdgpu_gem_create_in {
90 /** the requested memory size */
2ce9dde0 91 __u64 bo_size;
81629cba 92 /** physical start_addr alignment in bytes for some HW requirements */
2ce9dde0 93 __u64 alignment;
81629cba 94 /** the requested memory domains */
2ce9dde0 95 __u64 domains;
81629cba 96 /** allocation flags */
2ce9dde0 97 __u64 domain_flags;
81629cba
AD
98};
99
100struct drm_amdgpu_gem_create_out {
101 /** returned GEM object handle */
2ce9dde0
MR
102 __u32 handle;
103 __u32 _pad;
81629cba
AD
104};
105
106union drm_amdgpu_gem_create {
107 struct drm_amdgpu_gem_create_in in;
108 struct drm_amdgpu_gem_create_out out;
109};
110
111/** Opcode to create new residency list. */
112#define AMDGPU_BO_LIST_OP_CREATE 0
113/** Opcode to destroy previously created residency list */
114#define AMDGPU_BO_LIST_OP_DESTROY 1
115/** Opcode to update resource information in the list */
116#define AMDGPU_BO_LIST_OP_UPDATE 2
117
118struct drm_amdgpu_bo_list_in {
119 /** Type of operation */
2ce9dde0 120 __u32 operation;
81629cba 121 /** Handle of list or 0 if we want to create one */
2ce9dde0 122 __u32 list_handle;
81629cba 123 /** Number of BOs in list */
2ce9dde0 124 __u32 bo_number;
81629cba 125 /** Size of each element describing BO */
2ce9dde0 126 __u32 bo_info_size;
81629cba 127 /** Pointer to array describing BOs */
2ce9dde0 128 __u64 bo_info_ptr;
81629cba
AD
129};
130
131struct drm_amdgpu_bo_list_entry {
132 /** Handle of BO */
2ce9dde0 133 __u32 bo_handle;
81629cba 134 /** New (if specified) BO priority to be used during migration */
2ce9dde0 135 __u32 bo_priority;
81629cba
AD
136};
137
138struct drm_amdgpu_bo_list_out {
139 /** Handle of resource list */
2ce9dde0
MR
140 __u32 list_handle;
141 __u32 _pad;
81629cba
AD
142};
143
144union drm_amdgpu_bo_list {
145 struct drm_amdgpu_bo_list_in in;
146 struct drm_amdgpu_bo_list_out out;
147};
148
149/* context related */
150#define AMDGPU_CTX_OP_ALLOC_CTX 1
151#define AMDGPU_CTX_OP_FREE_CTX 2
152#define AMDGPU_CTX_OP_QUERY_STATE 3
153
d94aed5a
MO
154/* GPU reset status */
155#define AMDGPU_CTX_NO_RESET 0
675da0dd
CK
156/* this the context caused it */
157#define AMDGPU_CTX_GUILTY_RESET 1
158/* some other context caused it */
159#define AMDGPU_CTX_INNOCENT_RESET 2
160/* unknown cause */
161#define AMDGPU_CTX_UNKNOWN_RESET 3
d94aed5a 162
81629cba 163struct drm_amdgpu_ctx_in {
675da0dd 164 /** AMDGPU_CTX_OP_* */
2ce9dde0 165 __u32 op;
675da0dd 166 /** For future use, no flags defined so far */
2ce9dde0
MR
167 __u32 flags;
168 __u32 ctx_id;
169 __u32 _pad;
81629cba
AD
170};
171
172union drm_amdgpu_ctx_out {
173 struct {
2ce9dde0
MR
174 __u32 ctx_id;
175 __u32 _pad;
81629cba
AD
176 } alloc;
177
178 struct {
675da0dd 179 /** For future use, no flags defined so far */
2ce9dde0 180 __u64 flags;
d94aed5a 181 /** Number of resets caused by this context so far. */
2ce9dde0 182 __u32 hangs;
d94aed5a 183 /** Reset status since the last call of the ioctl. */
2ce9dde0 184 __u32 reset_status;
81629cba
AD
185 } state;
186};
187
188union drm_amdgpu_ctx {
189 struct drm_amdgpu_ctx_in in;
190 union drm_amdgpu_ctx_out out;
191};
192
193/*
194 * This is not a reliable API and you should expect it to fail for any
195 * number of reasons and have fallback path that do not use userptr to
196 * perform any operation.
197 */
198#define AMDGPU_GEM_USERPTR_READONLY (1 << 0)
199#define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)
200#define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)
201#define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)
202
203struct drm_amdgpu_gem_userptr {
2ce9dde0
MR
204 __u64 addr;
205 __u64 size;
675da0dd 206 /* AMDGPU_GEM_USERPTR_* */
2ce9dde0 207 __u32 flags;
675da0dd 208 /* Resulting GEM handle */
2ce9dde0 209 __u32 handle;
81629cba
AD
210};
211
fbd76d59
MO
212/* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
213#define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
214#define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
215#define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4
216#define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f
217#define AMDGPU_TILING_TILE_SPLIT_SHIFT 9
218#define AMDGPU_TILING_TILE_SPLIT_MASK 0x7
219#define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12
220#define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7
221#define AMDGPU_TILING_BANK_WIDTH_SHIFT 15
222#define AMDGPU_TILING_BANK_WIDTH_MASK 0x3
223#define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17
224#define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3
225#define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19
226#define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3
227#define AMDGPU_TILING_NUM_BANKS_SHIFT 21
228#define AMDGPU_TILING_NUM_BANKS_MASK 0x3
229
230#define AMDGPU_TILING_SET(field, value) \
231 (((value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
232#define AMDGPU_TILING_GET(value, field) \
233 (((value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
81629cba
AD
234
235#define AMDGPU_GEM_METADATA_OP_SET_METADATA 1
236#define AMDGPU_GEM_METADATA_OP_GET_METADATA 2
237
238/** The same structure is shared for input/output */
239struct drm_amdgpu_gem_metadata {
675da0dd 240 /** GEM Object handle */
2ce9dde0 241 __u32 handle;
675da0dd 242 /** Do we want get or set metadata */
2ce9dde0 243 __u32 op;
81629cba 244 struct {
675da0dd 245 /** For future use, no flags defined so far */
2ce9dde0 246 __u64 flags;
675da0dd 247 /** family specific tiling info */
2ce9dde0
MR
248 __u64 tiling_info;
249 __u32 data_size_bytes;
250 __u32 data[64];
81629cba
AD
251 } data;
252};
253
254struct drm_amdgpu_gem_mmap_in {
675da0dd 255 /** the GEM object handle */
2ce9dde0
MR
256 __u32 handle;
257 __u32 _pad;
81629cba
AD
258};
259
260struct drm_amdgpu_gem_mmap_out {
675da0dd 261 /** mmap offset from the vma offset manager */
2ce9dde0 262 __u64 addr_ptr;
81629cba
AD
263};
264
265union drm_amdgpu_gem_mmap {
266 struct drm_amdgpu_gem_mmap_in in;
267 struct drm_amdgpu_gem_mmap_out out;
268};
269
270struct drm_amdgpu_gem_wait_idle_in {
675da0dd 271 /** GEM object handle */
2ce9dde0 272 __u32 handle;
675da0dd 273 /** For future use, no flags defined so far */
2ce9dde0 274 __u32 flags;
675da0dd 275 /** Absolute timeout to wait */
2ce9dde0 276 __u64 timeout;
81629cba
AD
277};
278
279struct drm_amdgpu_gem_wait_idle_out {
675da0dd 280 /** BO status: 0 - BO is idle, 1 - BO is busy */
2ce9dde0 281 __u32 status;
675da0dd 282 /** Returned current memory domain */
2ce9dde0 283 __u32 domain;
81629cba
AD
284};
285
286union drm_amdgpu_gem_wait_idle {
287 struct drm_amdgpu_gem_wait_idle_in in;
288 struct drm_amdgpu_gem_wait_idle_out out;
289};
290
291struct drm_amdgpu_wait_cs_in {
675da0dd 292 /** Command submission handle */
2ce9dde0 293 __u64 handle;
675da0dd 294 /** Absolute timeout to wait */
2ce9dde0
MR
295 __u64 timeout;
296 __u32 ip_type;
297 __u32 ip_instance;
298 __u32 ring;
299 __u32 ctx_id;
81629cba
AD
300};
301
302struct drm_amdgpu_wait_cs_out {
675da0dd 303 /** CS status: 0 - CS completed, 1 - CS still busy */
2ce9dde0 304 __u64 status;
81629cba
AD
305};
306
307union drm_amdgpu_wait_cs {
308 struct drm_amdgpu_wait_cs_in in;
309 struct drm_amdgpu_wait_cs_out out;
310};
311
eef18a82
JZ
312struct drm_amdgpu_fence {
313 __u32 ctx_id;
314 __u32 ip_type;
315 __u32 ip_instance;
316 __u32 ring;
317 __u64 seq_no;
318};
319
320struct drm_amdgpu_wait_fences_in {
321 /** This points to uint64_t * which points to fences */
322 __u64 fences;
323 __u32 fence_count;
324 __u32 wait_all;
325 __u64 timeout_ns;
326};
327
328struct drm_amdgpu_wait_fences_out {
329 __u32 status;
330 __u32 first_signaled;
331};
332
333union drm_amdgpu_wait_fences {
334 struct drm_amdgpu_wait_fences_in in;
335 struct drm_amdgpu_wait_fences_out out;
336};
337
675da0dd
CK
338#define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0
339#define AMDGPU_GEM_OP_SET_PLACEMENT 1
340
81629cba
AD
341/* Sets or returns a value associated with a buffer. */
342struct drm_amdgpu_gem_op {
675da0dd 343 /** GEM object handle */
2ce9dde0 344 __u32 handle;
675da0dd 345 /** AMDGPU_GEM_OP_* */
2ce9dde0 346 __u32 op;
675da0dd 347 /** Input or return value */
2ce9dde0 348 __u64 value;
81629cba
AD
349};
350
81629cba
AD
351#define AMDGPU_VA_OP_MAP 1
352#define AMDGPU_VA_OP_UNMAP 2
dc54d3d1 353#define AMDGPU_VA_OP_CLEAR 3
80f95c57 354#define AMDGPU_VA_OP_REPLACE 4
81629cba 355
fc220f65
CK
356/* Delay the page table update till the next CS */
357#define AMDGPU_VM_DELAY_UPDATE (1 << 0)
358
81629cba
AD
359/* Mapping flags */
360/* readable mapping */
361#define AMDGPU_VM_PAGE_READABLE (1 << 1)
362/* writable mapping */
363#define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
364/* executable mapping, new for VI */
365#define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
b85891bd
JZ
366/* partially resident texture */
367#define AMDGPU_VM_PAGE_PRT (1 << 4)
66e02bc3
AX
368/* MTYPE flags use bit 5 to 8 */
369#define AMDGPU_VM_MTYPE_MASK (0xf << 5)
370/* Default MTYPE. Pre-AI must use this. Recommended for newer ASICs. */
371#define AMDGPU_VM_MTYPE_DEFAULT (0 << 5)
372/* Use NC MTYPE instead of default MTYPE */
373#define AMDGPU_VM_MTYPE_NC (1 << 5)
374/* Use WC MTYPE instead of default MTYPE */
375#define AMDGPU_VM_MTYPE_WC (2 << 5)
376/* Use CC MTYPE instead of default MTYPE */
377#define AMDGPU_VM_MTYPE_CC (3 << 5)
378/* Use UC MTYPE instead of default MTYPE */
379#define AMDGPU_VM_MTYPE_UC (4 << 5)
81629cba 380
34b5f6a6 381struct drm_amdgpu_gem_va {
675da0dd 382 /** GEM object handle */
2ce9dde0
MR
383 __u32 handle;
384 __u32 _pad;
675da0dd 385 /** AMDGPU_VA_OP_* */
2ce9dde0 386 __u32 operation;
675da0dd 387 /** AMDGPU_VM_PAGE_* */
2ce9dde0 388 __u32 flags;
675da0dd 389 /** va address to assign . Must be correctly aligned.*/
2ce9dde0 390 __u64 va_address;
675da0dd 391 /** Specify offset inside of BO to assign. Must be correctly aligned.*/
2ce9dde0 392 __u64 offset_in_bo;
675da0dd 393 /** Specify mapping size. Must be correctly aligned. */
2ce9dde0 394 __u64 map_size;
81629cba
AD
395};
396
81629cba
AD
397#define AMDGPU_HW_IP_GFX 0
398#define AMDGPU_HW_IP_COMPUTE 1
399#define AMDGPU_HW_IP_DMA 2
400#define AMDGPU_HW_IP_UVD 3
401#define AMDGPU_HW_IP_VCE 4
a50798b6
LL
402#define AMDGPU_HW_IP_UVD_ENC 5
403#define AMDGPU_HW_IP_NUM 6
81629cba
AD
404
405#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
406
407#define AMDGPU_CHUNK_ID_IB 0x01
408#define AMDGPU_CHUNK_ID_FENCE 0x02
2b48d323 409#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
675da0dd 410
81629cba 411struct drm_amdgpu_cs_chunk {
2ce9dde0
MR
412 __u32 chunk_id;
413 __u32 length_dw;
414 __u64 chunk_data;
81629cba
AD
415};
416
417struct drm_amdgpu_cs_in {
418 /** Rendering context id */
2ce9dde0 419 __u32 ctx_id;
81629cba 420 /** Handle of resource list associated with CS */
2ce9dde0
MR
421 __u32 bo_list_handle;
422 __u32 num_chunks;
423 __u32 _pad;
424 /** this points to __u64 * which point to cs chunks */
425 __u64 chunks;
81629cba
AD
426};
427
428struct drm_amdgpu_cs_out {
2ce9dde0 429 __u64 handle;
81629cba
AD
430};
431
432union drm_amdgpu_cs {
675da0dd
CK
433 struct drm_amdgpu_cs_in in;
434 struct drm_amdgpu_cs_out out;
81629cba
AD
435};
436
437/* Specify flags to be used for IB */
438
439/* This IB should be submitted to CE */
440#define AMDGPU_IB_FLAG_CE (1<<0)
441
aa2bdb24 442/* CE Preamble */
cab6d57c 443#define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
aa2bdb24 444
81629cba 445struct drm_amdgpu_cs_chunk_ib {
2ce9dde0 446 __u32 _pad;
675da0dd 447 /** AMDGPU_IB_FLAG_* */
2ce9dde0 448 __u32 flags;
675da0dd 449 /** Virtual address to begin IB execution */
2ce9dde0 450 __u64 va_start;
675da0dd 451 /** Size of submission */
2ce9dde0 452 __u32 ib_bytes;
675da0dd 453 /** HW IP to submit to */
2ce9dde0 454 __u32 ip_type;
675da0dd 455 /** HW IP index of the same type to submit to */
2ce9dde0 456 __u32 ip_instance;
675da0dd 457 /** Ring index to submit to */
2ce9dde0 458 __u32 ring;
81629cba
AD
459};
460
2b48d323 461struct drm_amdgpu_cs_chunk_dep {
2ce9dde0
MR
462 __u32 ip_type;
463 __u32 ip_instance;
464 __u32 ring;
465 __u32 ctx_id;
466 __u64 handle;
2b48d323
CK
467};
468
81629cba 469struct drm_amdgpu_cs_chunk_fence {
2ce9dde0
MR
470 __u32 handle;
471 __u32 offset;
81629cba
AD
472};
473
474struct drm_amdgpu_cs_chunk_data {
475 union {
476 struct drm_amdgpu_cs_chunk_ib ib_data;
477 struct drm_amdgpu_cs_chunk_fence fence_data;
478 };
479};
480
481/**
482 * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
483 *
484 */
485#define AMDGPU_IDS_FLAGS_FUSION 0x1
aafcafa0 486#define AMDGPU_IDS_FLAGS_PREEMPTION 0x2
81629cba
AD
487
488/* indicate if acceleration can be working */
489#define AMDGPU_INFO_ACCEL_WORKING 0x00
490/* get the crtc_id from the mode object id? */
491#define AMDGPU_INFO_CRTC_FROM_ID 0x01
492/* query hw IP info */
493#define AMDGPU_INFO_HW_IP_INFO 0x02
494/* query hw IP instance count for the specified type */
495#define AMDGPU_INFO_HW_IP_COUNT 0x03
496/* timestamp for GL_ARB_timer_query */
497#define AMDGPU_INFO_TIMESTAMP 0x05
498/* Query the firmware version */
499#define AMDGPU_INFO_FW_VERSION 0x0e
500 /* Subquery id: Query VCE firmware version */
501 #define AMDGPU_INFO_FW_VCE 0x1
502 /* Subquery id: Query UVD firmware version */
503 #define AMDGPU_INFO_FW_UVD 0x2
504 /* Subquery id: Query GMC firmware version */
505 #define AMDGPU_INFO_FW_GMC 0x03
506 /* Subquery id: Query GFX ME firmware version */
507 #define AMDGPU_INFO_FW_GFX_ME 0x04
508 /* Subquery id: Query GFX PFP firmware version */
509 #define AMDGPU_INFO_FW_GFX_PFP 0x05
510 /* Subquery id: Query GFX CE firmware version */
511 #define AMDGPU_INFO_FW_GFX_CE 0x06
512 /* Subquery id: Query GFX RLC firmware version */
513 #define AMDGPU_INFO_FW_GFX_RLC 0x07
514 /* Subquery id: Query GFX MEC firmware version */
515 #define AMDGPU_INFO_FW_GFX_MEC 0x08
516 /* Subquery id: Query SMC firmware version */
517 #define AMDGPU_INFO_FW_SMC 0x0a
518 /* Subquery id: Query SDMA firmware version */
519 #define AMDGPU_INFO_FW_SDMA 0x0b
520/* number of bytes moved for TTM migration */
521#define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
522/* the used VRAM size */
523#define AMDGPU_INFO_VRAM_USAGE 0x10
524/* the used GTT size */
525#define AMDGPU_INFO_GTT_USAGE 0x11
526/* Information about GDS, etc. resource configuration */
527#define AMDGPU_INFO_GDS_CONFIG 0x13
528/* Query information about VRAM and GTT domains */
529#define AMDGPU_INFO_VRAM_GTT 0x14
530/* Query information about register in MMR address space*/
531#define AMDGPU_INFO_READ_MMR_REG 0x15
532/* Query information about device: rev id, family, etc. */
533#define AMDGPU_INFO_DEV_INFO 0x16
534/* visible vram usage */
535#define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
83a59b63
MO
536/* number of TTM buffer evictions */
537#define AMDGPU_INFO_NUM_EVICTIONS 0x18
e0adf6c8
JZ
538/* Query memory about VRAM and GTT domains */
539#define AMDGPU_INFO_MEMORY 0x19
bbe87974
AD
540/* Query vce clock table */
541#define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A
40ee5888
EQ
542/* Query vbios related information */
543#define AMDGPU_INFO_VBIOS 0x1B
544 /* Subquery id: Query vbios size */
545 #define AMDGPU_INFO_VBIOS_SIZE 0x1
546 /* Subquery id: Query vbios image */
547 #define AMDGPU_INFO_VBIOS_IMAGE 0x2
44879b62
AN
548/* Query UVD handles */
549#define AMDGPU_INFO_NUM_HANDLES 0x1C
5ebbac4b
AD
550/* Query sensor related information */
551#define AMDGPU_INFO_SENSOR 0x1D
552 /* Subquery id: Query GPU shader clock */
553 #define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1
554 /* Subquery id: Query GPU memory clock */
555 #define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2
556 /* Subquery id: Query GPU temperature */
557 #define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3
558 /* Subquery id: Query GPU load */
559 #define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4
560 /* Subquery id: Query average GPU power */
561 #define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x5
562 /* Subquery id: Query northbridge voltage */
563 #define AMDGPU_INFO_SENSOR_VDDNB 0x6
564 /* Subquery id: Query graphics voltage */
565 #define AMDGPU_INFO_SENSOR_VDDGFX 0x7
81629cba
AD
566
567#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
568#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
569#define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
570#define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
571
000cab9a
HR
572struct drm_amdgpu_query_fw {
573 /** AMDGPU_INFO_FW_* */
574 __u32 fw_type;
575 /**
576 * Index of the IP if there are more IPs of
577 * the same type.
578 */
579 __u32 ip_instance;
580 /**
581 * Index of the engine. Whether this is used depends
582 * on the firmware type. (e.g. MEC, SDMA)
583 */
584 __u32 index;
585 __u32 _pad;
586};
587
81629cba
AD
588/* Input structure for the INFO ioctl */
589struct drm_amdgpu_info {
590 /* Where the return value will be stored */
2ce9dde0 591 __u64 return_pointer;
81629cba
AD
592 /* The size of the return value. Just like "size" in "snprintf",
593 * it limits how many bytes the kernel can write. */
2ce9dde0 594 __u32 return_size;
81629cba 595 /* The query request id. */
2ce9dde0 596 __u32 query;
81629cba
AD
597
598 union {
599 struct {
2ce9dde0
MR
600 __u32 id;
601 __u32 _pad;
81629cba
AD
602 } mode_crtc;
603
604 struct {
605 /** AMDGPU_HW_IP_* */
2ce9dde0 606 __u32 type;
81629cba 607 /**
675da0dd
CK
608 * Index of the IP if there are more IPs of the same
609 * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
81629cba 610 */
2ce9dde0 611 __u32 ip_instance;
81629cba
AD
612 } query_hw_ip;
613
614 struct {
2ce9dde0 615 __u32 dword_offset;
675da0dd 616 /** number of registers to read */
2ce9dde0
MR
617 __u32 count;
618 __u32 instance;
675da0dd 619 /** For future use, no flags defined so far */
2ce9dde0 620 __u32 flags;
81629cba
AD
621 } read_mmr_reg;
622
000cab9a 623 struct drm_amdgpu_query_fw query_fw;
40ee5888
EQ
624
625 struct {
626 __u32 type;
627 __u32 offset;
628 } vbios_info;
5ebbac4b
AD
629
630 struct {
631 __u32 type;
632 } sensor_info;
81629cba
AD
633 };
634};
635
636struct drm_amdgpu_info_gds {
637 /** GDS GFX partition size */
2ce9dde0 638 __u32 gds_gfx_partition_size;
81629cba 639 /** GDS compute partition size */
2ce9dde0 640 __u32 compute_partition_size;
81629cba 641 /** total GDS memory size */
2ce9dde0 642 __u32 gds_total_size;
81629cba 643 /** GWS size per GFX partition */
2ce9dde0 644 __u32 gws_per_gfx_partition;
81629cba 645 /** GSW size per compute partition */
2ce9dde0 646 __u32 gws_per_compute_partition;
81629cba 647 /** OA size per GFX partition */
2ce9dde0 648 __u32 oa_per_gfx_partition;
81629cba 649 /** OA size per compute partition */
2ce9dde0
MR
650 __u32 oa_per_compute_partition;
651 __u32 _pad;
81629cba
AD
652};
653
654struct drm_amdgpu_info_vram_gtt {
2ce9dde0
MR
655 __u64 vram_size;
656 __u64 vram_cpu_accessible_size;
657 __u64 gtt_size;
81629cba
AD
658};
659
e0adf6c8
JZ
660struct drm_amdgpu_heap_info {
661 /** max. physical memory */
662 __u64 total_heap_size;
663
664 /** Theoretical max. available memory in the given heap */
665 __u64 usable_heap_size;
666
667 /**
668 * Number of bytes allocated in the heap. This includes all processes
669 * and private allocations in the kernel. It changes when new buffers
670 * are allocated, freed, and moved. It cannot be larger than
671 * heap_size.
672 */
673 __u64 heap_usage;
674
675 /**
676 * Theoretical possible max. size of buffer which
677 * could be allocated in the given heap
678 */
679 __u64 max_allocation;
9f6163e7
JZ
680};
681
e0adf6c8
JZ
682struct drm_amdgpu_memory_info {
683 struct drm_amdgpu_heap_info vram;
684 struct drm_amdgpu_heap_info cpu_accessible_vram;
685 struct drm_amdgpu_heap_info gtt;
cfa32556
JZ
686};
687
81629cba 688struct drm_amdgpu_info_firmware {
2ce9dde0
MR
689 __u32 ver;
690 __u32 feature;
81629cba
AD
691};
692
81c59f54
KW
693#define AMDGPU_VRAM_TYPE_UNKNOWN 0
694#define AMDGPU_VRAM_TYPE_GDDR1 1
695#define AMDGPU_VRAM_TYPE_DDR2 2
696#define AMDGPU_VRAM_TYPE_GDDR3 3
697#define AMDGPU_VRAM_TYPE_GDDR4 4
698#define AMDGPU_VRAM_TYPE_GDDR5 5
699#define AMDGPU_VRAM_TYPE_HBM 6
700#define AMDGPU_VRAM_TYPE_DDR3 7
701
81629cba
AD
702struct drm_amdgpu_info_device {
703 /** PCI Device ID */
2ce9dde0 704 __u32 device_id;
81629cba 705 /** Internal chip revision: A0, A1, etc.) */
2ce9dde0
MR
706 __u32 chip_rev;
707 __u32 external_rev;
81629cba 708 /** Revision id in PCI Config space */
2ce9dde0
MR
709 __u32 pci_rev;
710 __u32 family;
711 __u32 num_shader_engines;
712 __u32 num_shader_arrays_per_engine;
675da0dd 713 /* in KHz */
2ce9dde0
MR
714 __u32 gpu_counter_freq;
715 __u64 max_engine_clock;
716 __u64 max_memory_clock;
81629cba 717 /* cu information */
2ce9dde0
MR
718 __u32 cu_active_number;
719 __u32 cu_ao_mask;
720 __u32 cu_bitmap[4][4];
81629cba 721 /** Render backend pipe mask. One render backend is CB+DB. */
2ce9dde0
MR
722 __u32 enabled_rb_pipes_mask;
723 __u32 num_rb_pipes;
724 __u32 num_hw_gfx_contexts;
725 __u32 _pad;
726 __u64 ids_flags;
81629cba 727 /** Starting virtual address for UMDs. */
2ce9dde0 728 __u64 virtual_address_offset;
02b70c8c 729 /** The maximum virtual address */
2ce9dde0 730 __u64 virtual_address_max;
81629cba 731 /** Required alignment of virtual addresses. */
2ce9dde0 732 __u32 virtual_address_alignment;
81629cba 733 /** Page table entry - fragment size */
2ce9dde0
MR
734 __u32 pte_fragment_size;
735 __u32 gart_page_size;
a101a899 736 /** constant engine ram size*/
2ce9dde0 737 __u32 ce_ram_size;
cab6d57c 738 /** video memory type info*/
2ce9dde0 739 __u32 vram_type;
81c59f54 740 /** video memory bit width*/
2ce9dde0 741 __u32 vram_bit_width;
fa92754e 742 /* vce harvesting instance */
2ce9dde0 743 __u32 vce_harvest_config;
df6e2c4a
JZ
744 /* gfx double offchip LDS buffers */
745 __u32 gc_double_offchip_lds_buf;
81629cba
AD
746};
747
748struct drm_amdgpu_info_hw_ip {
749 /** Version of h/w IP */
2ce9dde0
MR
750 __u32 hw_ip_version_major;
751 __u32 hw_ip_version_minor;
81629cba 752 /** Capabilities */
2ce9dde0 753 __u64 capabilities_flags;
71062f43 754 /** command buffer address start alignment*/
2ce9dde0 755 __u32 ib_start_alignment;
71062f43 756 /** command buffer size alignment*/
2ce9dde0 757 __u32 ib_size_alignment;
81629cba 758 /** Bitmask of available rings. Bit 0 means ring 0, etc. */
2ce9dde0
MR
759 __u32 available_rings;
760 __u32 _pad;
81629cba
AD
761};
762
44879b62
AN
763struct drm_amdgpu_info_num_handles {
764 /** Max handles as supported by firmware for UVD */
765 __u32 uvd_max_handles;
766 /** Handles currently in use for UVD */
767 __u32 uvd_used_handles;
768};
769
bbe87974
AD
770#define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6
771
772struct drm_amdgpu_info_vce_clock_table_entry {
773 /** System clock */
774 __u32 sclk;
775 /** Memory clock */
776 __u32 mclk;
777 /** VCE clock */
778 __u32 eclk;
779 __u32 pad;
780};
781
782struct drm_amdgpu_info_vce_clock_table {
783 struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
784 __u32 num_valid_entries;
785 __u32 pad;
786};
787
81629cba
AD
788/*
789 * Supported GPU families
790 */
791#define AMDGPU_FAMILY_UNKNOWN 0
295d0daf 792#define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */
81629cba
AD
793#define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */
794#define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */
795#define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */
39bb0c92 796#define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */
81629cba 797
cfa7152f
EV
798#if defined(__cplusplus)
799}
800#endif
801
81629cba 802#endif