blob: baa2e44abd4b4201db9ab6c8d8effa6362c59156 [file] [log] [blame]
Christopher Ferris05d08e92016-02-04 13:16:38 -08001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef __AMDGPU_DRM_H__
20#define __AMDGPU_DRM_H__
21#include "drm.h"
Christopher Ferris106b3a82016-08-24 12:15:38 -070022#ifdef __cplusplus
Christopher Ferris48fe0ae2019-01-10 15:59:33 -080023extern "C" {
Christopher Ferris106b3a82016-08-24 12:15:38 -070024#endif
25#define DRM_AMDGPU_GEM_CREATE 0x00
Christopher Ferris05d08e92016-02-04 13:16:38 -080026#define DRM_AMDGPU_GEM_MMAP 0x01
27#define DRM_AMDGPU_CTX 0x02
28#define DRM_AMDGPU_BO_LIST 0x03
29#define DRM_AMDGPU_CS 0x04
Christopher Ferris05d08e92016-02-04 13:16:38 -080030#define DRM_AMDGPU_INFO 0x05
31#define DRM_AMDGPU_GEM_METADATA 0x06
32#define DRM_AMDGPU_GEM_WAIT_IDLE 0x07
33#define DRM_AMDGPU_GEM_VA 0x08
Christopher Ferris05d08e92016-02-04 13:16:38 -080034#define DRM_AMDGPU_WAIT_CS 0x09
35#define DRM_AMDGPU_GEM_OP 0x10
36#define DRM_AMDGPU_GEM_USERPTR 0x11
Christopher Ferris48af7cb2017-02-21 12:35:09 -080037#define DRM_AMDGPU_WAIT_FENCES 0x12
Christopher Ferris1308ad32017-11-14 17:32:13 -080038#define DRM_AMDGPU_VM 0x13
Christopher Ferris934ec942018-01-31 15:29:16 -080039#define DRM_AMDGPU_FENCE_TO_HANDLE 0x14
40#define DRM_AMDGPU_SCHED 0x15
Christopher Ferris05d08e92016-02-04 13:16:38 -080041#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
Christopher Ferris05d08e92016-02-04 13:16:38 -080042#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080043#define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
Christopher Ferris05d08e92016-02-04 13:16:38 -080044#define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
45#define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
Christopher Ferris05d08e92016-02-04 13:16:38 -080046#define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080047#define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
Christopher Ferris05d08e92016-02-04 13:16:38 -080048#define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
49#define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
Christopher Ferris05d08e92016-02-04 13:16:38 -080050#define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080051#define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
Christopher Ferris05d08e92016-02-04 13:16:38 -080052#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080053#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)
Christopher Ferris1308ad32017-11-14 17:32:13 -080054#define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
Christopher Ferris934ec942018-01-31 15:29:16 -080055#define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
56#define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
Christopher Ferris05d08e92016-02-04 13:16:38 -080057#define AMDGPU_GEM_DOMAIN_CPU 0x1
Christopher Ferris05d08e92016-02-04 13:16:38 -080058#define AMDGPU_GEM_DOMAIN_GTT 0x2
59#define AMDGPU_GEM_DOMAIN_VRAM 0x4
60#define AMDGPU_GEM_DOMAIN_GDS 0x8
61#define AMDGPU_GEM_DOMAIN_GWS 0x10
Christopher Ferris05d08e92016-02-04 13:16:38 -080062#define AMDGPU_GEM_DOMAIN_OA 0x20
Christopher Ferris9ce28842018-10-25 12:11:39 -070063#define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | AMDGPU_GEM_DOMAIN_GTT | AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GDS | AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA)
Christopher Ferris05d08e92016-02-04 13:16:38 -080064#define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
65#define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)
66#define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)
Christopher Ferris6a9755d2017-01-13 14:09:31 -080067#define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3)
68#define AMDGPU_GEM_CREATE_SHADOW (1 << 4)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080069#define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5)
Christopher Ferris934ec942018-01-31 15:29:16 -080070#define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6)
71#define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7)
Christopher Ferris9ce28842018-10-25 12:11:39 -070072#define AMDGPU_GEM_CREATE_MQD_GFX9 (1 << 8)
Christopher Ferris05d08e92016-02-04 13:16:38 -080073struct drm_amdgpu_gem_create_in {
Christopher Ferris106b3a82016-08-24 12:15:38 -070074 __u64 bo_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -070075 __u64 alignment;
76 __u64 domains;
77 __u64 domain_flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -080078};
79struct drm_amdgpu_gem_create_out {
Christopher Ferris106b3a82016-08-24 12:15:38 -070080 __u32 handle;
81 __u32 _pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -080082};
83union drm_amdgpu_gem_create {
84 struct drm_amdgpu_gem_create_in in;
Christopher Ferris05d08e92016-02-04 13:16:38 -080085 struct drm_amdgpu_gem_create_out out;
86};
87#define AMDGPU_BO_LIST_OP_CREATE 0
88#define AMDGPU_BO_LIST_OP_DESTROY 1
Christopher Ferris05d08e92016-02-04 13:16:38 -080089#define AMDGPU_BO_LIST_OP_UPDATE 2
90struct drm_amdgpu_bo_list_in {
Christopher Ferris106b3a82016-08-24 12:15:38 -070091 __u32 operation;
92 __u32 list_handle;
93 __u32 bo_number;
94 __u32 bo_info_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -070095 __u64 bo_info_ptr;
Christopher Ferris05d08e92016-02-04 13:16:38 -080096};
Christopher Ferris05d08e92016-02-04 13:16:38 -080097struct drm_amdgpu_bo_list_entry {
Christopher Ferris106b3a82016-08-24 12:15:38 -070098 __u32 bo_handle;
Christopher Ferris106b3a82016-08-24 12:15:38 -070099 __u32 bo_priority;
100};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800101struct drm_amdgpu_bo_list_out {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700102 __u32 list_handle;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700103 __u32 _pad;
104};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800105union drm_amdgpu_bo_list {
106 struct drm_amdgpu_bo_list_in in;
107 struct drm_amdgpu_bo_list_out out;
108};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800109#define AMDGPU_CTX_OP_ALLOC_CTX 1
110#define AMDGPU_CTX_OP_FREE_CTX 2
111#define AMDGPU_CTX_OP_QUERY_STATE 3
Christopher Ferris76a1d452018-06-27 14:12:29 -0700112#define AMDGPU_CTX_OP_QUERY_STATE2 4
Christopher Ferris05d08e92016-02-04 13:16:38 -0800113#define AMDGPU_CTX_NO_RESET 0
Christopher Ferris05d08e92016-02-04 13:16:38 -0800114#define AMDGPU_CTX_GUILTY_RESET 1
115#define AMDGPU_CTX_INNOCENT_RESET 2
116#define AMDGPU_CTX_UNKNOWN_RESET 3
Christopher Ferris76a1d452018-06-27 14:12:29 -0700117#define AMDGPU_CTX_QUERY2_FLAGS_RESET (1 << 0)
118#define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1 << 1)
119#define AMDGPU_CTX_QUERY2_FLAGS_GUILTY (1 << 2)
Christopher Ferris934ec942018-01-31 15:29:16 -0800120#define AMDGPU_CTX_PRIORITY_UNSET - 2048
121#define AMDGPU_CTX_PRIORITY_VERY_LOW - 1023
122#define AMDGPU_CTX_PRIORITY_LOW - 512
123#define AMDGPU_CTX_PRIORITY_NORMAL 0
124#define AMDGPU_CTX_PRIORITY_HIGH 512
125#define AMDGPU_CTX_PRIORITY_VERY_HIGH 1023
Christopher Ferris05d08e92016-02-04 13:16:38 -0800126struct drm_amdgpu_ctx_in {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700127 __u32 op;
128 __u32 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700129 __u32 ctx_id;
Christopher Ferris934ec942018-01-31 15:29:16 -0800130 __s32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800131};
132union drm_amdgpu_ctx_out {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700133 struct {
134 __u32 ctx_id;
135 __u32 _pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800136 } alloc;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700137 struct {
138 __u64 flags;
139 __u32 hangs;
140 __u32 reset_status;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800141 } state;
142};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800143union drm_amdgpu_ctx {
144 struct drm_amdgpu_ctx_in in;
145 union drm_amdgpu_ctx_out out;
146};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800147#define AMDGPU_VM_OP_RESERVE_VMID 1
148#define AMDGPU_VM_OP_UNRESERVE_VMID 2
149struct drm_amdgpu_vm_in {
150 __u32 op;
151 __u32 flags;
152};
153struct drm_amdgpu_vm_out {
154 __u64 flags;
155};
156union drm_amdgpu_vm {
157 struct drm_amdgpu_vm_in in;
158 struct drm_amdgpu_vm_out out;
159};
Christopher Ferris934ec942018-01-31 15:29:16 -0800160#define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE 1
161struct drm_amdgpu_sched_in {
162 __u32 op;
163 __u32 fd;
164 __s32 priority;
165 __u32 flags;
166};
167union drm_amdgpu_sched {
168 struct drm_amdgpu_sched_in in;
169};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800170#define AMDGPU_GEM_USERPTR_READONLY (1 << 0)
171#define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)
172#define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)
173#define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800174struct drm_amdgpu_gem_userptr {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700175 __u64 addr;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700176 __u64 size;
177 __u32 flags;
178 __u32 handle;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800179};
180#define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
181#define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
Christopher Ferris05d08e92016-02-04 13:16:38 -0800182#define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4
183#define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f
184#define AMDGPU_TILING_TILE_SPLIT_SHIFT 9
185#define AMDGPU_TILING_TILE_SPLIT_MASK 0x7
Christopher Ferris05d08e92016-02-04 13:16:38 -0800186#define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12
187#define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7
188#define AMDGPU_TILING_BANK_WIDTH_SHIFT 15
189#define AMDGPU_TILING_BANK_WIDTH_MASK 0x3
Christopher Ferris05d08e92016-02-04 13:16:38 -0800190#define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17
191#define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3
192#define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19
193#define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3
Christopher Ferris05d08e92016-02-04 13:16:38 -0800194#define AMDGPU_TILING_NUM_BANKS_SHIFT 21
195#define AMDGPU_TILING_NUM_BANKS_MASK 0x3
Christopher Ferris525ce912017-07-26 13:12:53 -0700196#define AMDGPU_TILING_SWIZZLE_MODE_SHIFT 0
197#define AMDGPU_TILING_SWIZZLE_MODE_MASK 0x1f
Christopher Ferrisd842e432019-03-07 10:21:59 -0800198#define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT 5
199#define AMDGPU_TILING_DCC_OFFSET_256B_MASK 0xFFFFFF
200#define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT 29
201#define AMDGPU_TILING_DCC_PITCH_MAX_MASK 0x3FFF
202#define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT 43
203#define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK 0x1
Christopher Ferris525ce912017-07-26 13:12:53 -0700204#define AMDGPU_TILING_SET(field,value) (((__u64) (value) & AMDGPU_TILING_ ##field ##_MASK) << AMDGPU_TILING_ ##field ##_SHIFT)
205#define AMDGPU_TILING_GET(value,field) (((__u64) (value) >> AMDGPU_TILING_ ##field ##_SHIFT) & AMDGPU_TILING_ ##field ##_MASK)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800206#define AMDGPU_GEM_METADATA_OP_SET_METADATA 1
207#define AMDGPU_GEM_METADATA_OP_GET_METADATA 2
208struct drm_amdgpu_gem_metadata {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700209 __u32 handle;
210 __u32 op;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800211 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700212 __u64 flags;
213 __u64 tiling_info;
214 __u32 data_size_bytes;
215 __u32 data[64];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800216 } data;
217};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800218struct drm_amdgpu_gem_mmap_in {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700219 __u32 handle;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700220 __u32 _pad;
221};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800222struct drm_amdgpu_gem_mmap_out {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700223 __u64 addr_ptr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800224};
225union drm_amdgpu_gem_mmap {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800226 struct drm_amdgpu_gem_mmap_in in;
227 struct drm_amdgpu_gem_mmap_out out;
228};
229struct drm_amdgpu_gem_wait_idle_in {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700230 __u32 handle;
231 __u32 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700232 __u64 timeout;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800233};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800234struct drm_amdgpu_gem_wait_idle_out {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700235 __u32 status;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700236 __u32 domain;
237};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800238union drm_amdgpu_gem_wait_idle {
239 struct drm_amdgpu_gem_wait_idle_in in;
240 struct drm_amdgpu_gem_wait_idle_out out;
241};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800242struct drm_amdgpu_wait_cs_in {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700243 __u64 handle;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700244 __u64 timeout;
245 __u32 ip_type;
246 __u32 ip_instance;
247 __u32 ring;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700248 __u32 ctx_id;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800249};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800250struct drm_amdgpu_wait_cs_out {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700251 __u64 status;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800252};
253union drm_amdgpu_wait_cs {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800254 struct drm_amdgpu_wait_cs_in in;
255 struct drm_amdgpu_wait_cs_out out;
256};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800257struct drm_amdgpu_fence {
258 __u32 ctx_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800259 __u32 ip_type;
260 __u32 ip_instance;
261 __u32 ring;
262 __u64 seq_no;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800263};
264struct drm_amdgpu_wait_fences_in {
265 __u64 fences;
266 __u32 fence_count;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800267 __u32 wait_all;
268 __u64 timeout_ns;
269};
270struct drm_amdgpu_wait_fences_out {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800271 __u32 status;
272 __u32 first_signaled;
273};
274union drm_amdgpu_wait_fences {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800275 struct drm_amdgpu_wait_fences_in in;
276 struct drm_amdgpu_wait_fences_out out;
277};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800278#define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0
Christopher Ferris05d08e92016-02-04 13:16:38 -0800279#define AMDGPU_GEM_OP_SET_PLACEMENT 1
280struct drm_amdgpu_gem_op {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700281 __u32 handle;
282 __u32 op;
283 __u64 value;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800284};
285#define AMDGPU_VA_OP_MAP 1
286#define AMDGPU_VA_OP_UNMAP 2
Christopher Ferris525ce912017-07-26 13:12:53 -0700287#define AMDGPU_VA_OP_CLEAR 3
288#define AMDGPU_VA_OP_REPLACE 4
Christopher Ferris05d08e92016-02-04 13:16:38 -0800289#define AMDGPU_VM_DELAY_UPDATE (1 << 0)
290#define AMDGPU_VM_PAGE_READABLE (1 << 1)
291#define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
292#define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
Christopher Ferris525ce912017-07-26 13:12:53 -0700293#define AMDGPU_VM_PAGE_PRT (1 << 4)
294#define AMDGPU_VM_MTYPE_MASK (0xf << 5)
295#define AMDGPU_VM_MTYPE_DEFAULT (0 << 5)
296#define AMDGPU_VM_MTYPE_NC (1 << 5)
297#define AMDGPU_VM_MTYPE_WC (2 << 5)
298#define AMDGPU_VM_MTYPE_CC (3 << 5)
299#define AMDGPU_VM_MTYPE_UC (4 << 5)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800300struct drm_amdgpu_gem_va {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700301 __u32 handle;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700302 __u32 _pad;
303 __u32 operation;
304 __u32 flags;
305 __u64 va_address;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700306 __u64 offset_in_bo;
307 __u64 map_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800308};
309#define AMDGPU_HW_IP_GFX 0
310#define AMDGPU_HW_IP_COMPUTE 1
311#define AMDGPU_HW_IP_DMA 2
Christopher Ferris05d08e92016-02-04 13:16:38 -0800312#define AMDGPU_HW_IP_UVD 3
313#define AMDGPU_HW_IP_VCE 4
Christopher Ferris525ce912017-07-26 13:12:53 -0700314#define AMDGPU_HW_IP_UVD_ENC 5
Christopher Ferris1308ad32017-11-14 17:32:13 -0800315#define AMDGPU_HW_IP_VCN_DEC 6
316#define AMDGPU_HW_IP_VCN_ENC 7
Christopher Ferris9ce28842018-10-25 12:11:39 -0700317#define AMDGPU_HW_IP_VCN_JPEG 8
318#define AMDGPU_HW_IP_NUM 9
Christopher Ferris05d08e92016-02-04 13:16:38 -0800319#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800320#define AMDGPU_CHUNK_ID_IB 0x01
321#define AMDGPU_CHUNK_ID_FENCE 0x02
322#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
Christopher Ferris1308ad32017-11-14 17:32:13 -0800323#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04
324#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05
Christopher Ferris9ce28842018-10-25 12:11:39 -0700325#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06
Christopher Ferris05d08e92016-02-04 13:16:38 -0800326struct drm_amdgpu_cs_chunk {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700327 __u32 chunk_id;
328 __u32 length_dw;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700329 __u64 chunk_data;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800330};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800331struct drm_amdgpu_cs_in {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700332 __u32 ctx_id;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700333 __u32 bo_list_handle;
334 __u32 num_chunks;
335 __u32 _pad;
336 __u64 chunks;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800337};
338struct drm_amdgpu_cs_out {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700339 __u64 handle;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800340};
341union drm_amdgpu_cs {
342 struct drm_amdgpu_cs_in in;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800343 struct drm_amdgpu_cs_out out;
344};
345#define AMDGPU_IB_FLAG_CE (1 << 0)
346#define AMDGPU_IB_FLAG_PREAMBLE (1 << 1)
Christopher Ferris525ce912017-07-26 13:12:53 -0700347#define AMDGPU_IB_FLAG_PREEMPT (1 << 2)
Christopher Ferris9ce28842018-10-25 12:11:39 -0700348#define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800349struct drm_amdgpu_cs_chunk_ib {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700350 __u32 _pad;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700351 __u32 flags;
352 __u64 va_start;
353 __u32 ib_bytes;
354 __u32 ip_type;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700355 __u32 ip_instance;
356 __u32 ring;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800357};
358struct drm_amdgpu_cs_chunk_dep {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700359 __u32 ip_type;
360 __u32 ip_instance;
361 __u32 ring;
362 __u32 ctx_id;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700363 __u64 handle;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800364};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800365struct drm_amdgpu_cs_chunk_fence {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700366 __u32 handle;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700367 __u32 offset;
368};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800369struct drm_amdgpu_cs_chunk_sem {
370 __u32 handle;
371};
Christopher Ferris934ec942018-01-31 15:29:16 -0800372#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 0
373#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 1
374#define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2
375union drm_amdgpu_fence_to_handle {
376 struct {
377 struct drm_amdgpu_fence fence;
378 __u32 what;
379 __u32 pad;
380 } in;
381 struct {
382 __u32 handle;
383 } out;
384};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800385struct drm_amdgpu_cs_chunk_data {
386 union {
387 struct drm_amdgpu_cs_chunk_ib ib_data;
388 struct drm_amdgpu_cs_chunk_fence fence_data;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800389 };
390};
391#define AMDGPU_IDS_FLAGS_FUSION 0x1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800392#define AMDGPU_IDS_FLAGS_PREEMPTION 0x2
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800393#define AMDGPU_INFO_ACCEL_WORKING 0x00
Christopher Ferris05d08e92016-02-04 13:16:38 -0800394#define AMDGPU_INFO_CRTC_FROM_ID 0x01
395#define AMDGPU_INFO_HW_IP_INFO 0x02
396#define AMDGPU_INFO_HW_IP_COUNT 0x03
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800397#define AMDGPU_INFO_TIMESTAMP 0x05
Christopher Ferris05d08e92016-02-04 13:16:38 -0800398#define AMDGPU_INFO_FW_VERSION 0x0e
399#define AMDGPU_INFO_FW_VCE 0x1
400#define AMDGPU_INFO_FW_UVD 0x2
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800401#define AMDGPU_INFO_FW_GMC 0x03
Christopher Ferris05d08e92016-02-04 13:16:38 -0800402#define AMDGPU_INFO_FW_GFX_ME 0x04
403#define AMDGPU_INFO_FW_GFX_PFP 0x05
404#define AMDGPU_INFO_FW_GFX_CE 0x06
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800405#define AMDGPU_INFO_FW_GFX_RLC 0x07
Christopher Ferris05d08e92016-02-04 13:16:38 -0800406#define AMDGPU_INFO_FW_GFX_MEC 0x08
407#define AMDGPU_INFO_FW_SMC 0x0a
408#define AMDGPU_INFO_FW_SDMA 0x0b
Christopher Ferris525ce912017-07-26 13:12:53 -0700409#define AMDGPU_INFO_FW_SOS 0x0c
410#define AMDGPU_INFO_FW_ASD 0x0d
Christopher Ferris76a1d452018-06-27 14:12:29 -0700411#define AMDGPU_INFO_FW_VCN 0x0e
Christopher Ferris9ce28842018-10-25 12:11:39 -0700412#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f
413#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10
414#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11
Christopher Ferris86a48372019-01-10 14:14:59 -0800415#define AMDGPU_INFO_FW_DMCU 0x12
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800416#define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
Christopher Ferris05d08e92016-02-04 13:16:38 -0800417#define AMDGPU_INFO_VRAM_USAGE 0x10
418#define AMDGPU_INFO_GTT_USAGE 0x11
419#define AMDGPU_INFO_GDS_CONFIG 0x13
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800420#define AMDGPU_INFO_VRAM_GTT 0x14
Christopher Ferris05d08e92016-02-04 13:16:38 -0800421#define AMDGPU_INFO_READ_MMR_REG 0x15
422#define AMDGPU_INFO_DEV_INFO 0x16
423#define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800424#define AMDGPU_INFO_NUM_EVICTIONS 0x18
425#define AMDGPU_INFO_MEMORY 0x19
426#define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A
427#define AMDGPU_INFO_VBIOS 0x1B
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800428#define AMDGPU_INFO_VBIOS_SIZE 0x1
429#define AMDGPU_INFO_VBIOS_IMAGE 0x2
Christopher Ferris525ce912017-07-26 13:12:53 -0700430#define AMDGPU_INFO_NUM_HANDLES 0x1C
431#define AMDGPU_INFO_SENSOR 0x1D
432#define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1
433#define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2
434#define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3
435#define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4
436#define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x5
437#define AMDGPU_INFO_SENSOR_VDDNB 0x6
438#define AMDGPU_INFO_SENSOR_VDDGFX 0x7
Christopher Ferris76a1d452018-06-27 14:12:29 -0700439#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK 0x8
440#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK 0x9
Christopher Ferris1308ad32017-11-14 17:32:13 -0800441#define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E
Christopher Ferris934ec942018-01-31 15:29:16 -0800442#define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F
Christopher Ferris05d08e92016-02-04 13:16:38 -0800443#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
Christopher Ferris05d08e92016-02-04 13:16:38 -0800444#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
445#define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
446#define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
Christopher Ferris49f525c2016-12-12 14:55:36 -0800447struct drm_amdgpu_query_fw {
448 __u32 fw_type;
449 __u32 ip_instance;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800450 __u32 index;
451 __u32 _pad;
452};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800453struct drm_amdgpu_info {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700454 __u64 return_pointer;
455 __u32 return_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700456 __u32 query;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800457 union {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800458 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700459 __u32 id;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700460 __u32 _pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800461 } mode_crtc;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800462 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700463 __u32 type;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700464 __u32 ip_instance;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800465 } query_hw_ip;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800466 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700467 __u32 dword_offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700468 __u32 count;
469 __u32 instance;
470 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800471 } read_mmr_reg;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800472 struct drm_amdgpu_query_fw query_fw;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800473 struct {
474 __u32 type;
475 __u32 offset;
476 } vbios_info;
Christopher Ferris525ce912017-07-26 13:12:53 -0700477 struct {
478 __u32 type;
479 } sensor_info;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800480 };
Christopher Ferris49f525c2016-12-12 14:55:36 -0800481};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800482struct drm_amdgpu_info_gds {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700483 __u32 gds_gfx_partition_size;
484 __u32 compute_partition_size;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800485 __u32 gds_total_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700486 __u32 gws_per_gfx_partition;
487 __u32 gws_per_compute_partition;
488 __u32 oa_per_gfx_partition;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800489 __u32 oa_per_compute_partition;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700490 __u32 _pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800491};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800492struct drm_amdgpu_info_vram_gtt {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800493 __u64 vram_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700494 __u64 vram_cpu_accessible_size;
495 __u64 gtt_size;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800496};
497struct drm_amdgpu_heap_info {
498 __u64 total_heap_size;
499 __u64 usable_heap_size;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800500 __u64 heap_usage;
501 __u64 max_allocation;
502};
503struct drm_amdgpu_memory_info {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800504 struct drm_amdgpu_heap_info vram;
505 struct drm_amdgpu_heap_info cpu_accessible_vram;
506 struct drm_amdgpu_heap_info gtt;
507};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800508struct drm_amdgpu_info_firmware {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700509 __u32 ver;
510 __u32 feature;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800511};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800512#define AMDGPU_VRAM_TYPE_UNKNOWN 0
Christopher Ferris05d08e92016-02-04 13:16:38 -0800513#define AMDGPU_VRAM_TYPE_GDDR1 1
514#define AMDGPU_VRAM_TYPE_DDR2 2
Christopher Ferris05d08e92016-02-04 13:16:38 -0800515#define AMDGPU_VRAM_TYPE_GDDR3 3
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800516#define AMDGPU_VRAM_TYPE_GDDR4 4
Christopher Ferris05d08e92016-02-04 13:16:38 -0800517#define AMDGPU_VRAM_TYPE_GDDR5 5
518#define AMDGPU_VRAM_TYPE_HBM 6
Christopher Ferris05d08e92016-02-04 13:16:38 -0800519#define AMDGPU_VRAM_TYPE_DDR3 7
Christopher Ferris76a1d452018-06-27 14:12:29 -0700520#define AMDGPU_VRAM_TYPE_DDR4 8
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800521struct drm_amdgpu_info_device {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700522 __u32 device_id;
523 __u32 chip_rev;
524 __u32 external_rev;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800525 __u32 pci_rev;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700526 __u32 family;
527 __u32 num_shader_engines;
528 __u32 num_shader_arrays_per_engine;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800529 __u32 gpu_counter_freq;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700530 __u64 max_engine_clock;
531 __u64 max_memory_clock;
532 __u32 cu_active_number;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800533 __u32 cu_ao_mask;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700534 __u32 cu_bitmap[4][4];
535 __u32 enabled_rb_pipes_mask;
536 __u32 num_rb_pipes;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800537 __u32 num_hw_gfx_contexts;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700538 __u32 _pad;
539 __u64 ids_flags;
540 __u64 virtual_address_offset;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800541 __u64 virtual_address_max;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700542 __u32 virtual_address_alignment;
543 __u32 pte_fragment_size;
544 __u32 gart_page_size;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800545 __u32 ce_ram_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700546 __u32 vram_type;
547 __u32 vram_bit_width;
548 __u32 vce_harvest_config;
Christopher Ferris525ce912017-07-26 13:12:53 -0700549 __u32 gc_double_offchip_lds_buf;
550 __u64 prim_buf_gpu_addr;
551 __u64 pos_buf_gpu_addr;
552 __u64 cntl_sb_buf_gpu_addr;
553 __u64 param_buf_gpu_addr;
554 __u32 prim_buf_size;
555 __u32 pos_buf_size;
556 __u32 cntl_sb_buf_size;
557 __u32 param_buf_size;
558 __u32 wave_front_size;
559 __u32 num_shader_visible_vgprs;
560 __u32 num_cu_per_sh;
561 __u32 num_tcc_blocks;
562 __u32 gs_vgt_table_depth;
563 __u32 gs_prim_buffer_depth;
564 __u32 max_gs_waves_per_vgt;
565 __u32 _pad1;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800566 __u32 cu_ao_bitmap[4][4];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700567 __u64 high_va_offset;
568 __u64 high_va_max;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800569};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800570struct drm_amdgpu_info_hw_ip {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700571 __u32 hw_ip_version_major;
572 __u32 hw_ip_version_minor;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800573 __u64 capabilities_flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700574 __u32 ib_start_alignment;
575 __u32 ib_size_alignment;
576 __u32 available_rings;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800577 __u32 _pad;
578};
Christopher Ferris525ce912017-07-26 13:12:53 -0700579struct drm_amdgpu_info_num_handles {
580 __u32 uvd_max_handles;
581 __u32 uvd_used_handles;
582};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800583#define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6
584struct drm_amdgpu_info_vce_clock_table_entry {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800585 __u32 sclk;
586 __u32 mclk;
587 __u32 eclk;
588 __u32 pad;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800589};
590struct drm_amdgpu_info_vce_clock_table {
591 struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
592 __u32 num_valid_entries;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800593 __u32 pad;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800594};
595#define AMDGPU_FAMILY_UNKNOWN 0
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800596#define AMDGPU_FAMILY_SI 110
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800597#define AMDGPU_FAMILY_CI 120
Christopher Ferris49f525c2016-12-12 14:55:36 -0800598#define AMDGPU_FAMILY_KV 125
Christopher Ferris05d08e92016-02-04 13:16:38 -0800599#define AMDGPU_FAMILY_VI 130
600#define AMDGPU_FAMILY_CZ 135
Christopher Ferris525ce912017-07-26 13:12:53 -0700601#define AMDGPU_FAMILY_AI 141
Christopher Ferris1308ad32017-11-14 17:32:13 -0800602#define AMDGPU_FAMILY_RV 142
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800603#ifdef __cplusplus
Christopher Ferris48fe0ae2019-01-10 15:59:33 -0800604}
Christopher Ferris05d08e92016-02-04 13:16:38 -0800605#endif
Christopher Ferris49f525c2016-12-12 14:55:36 -0800606#endif