blob: 453a76af123cbc4287b70ee144351e5848cb3adc [file] [log] [blame]
Alex Deucher81629cb2015-04-20 16:42:01 -04001/* 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
Michel Dänzerb3fcf36a2015-07-22 17:29:01 +090035#include "drm.h"
Alex Deucher81629cb2015-04-20 16:42:01 -040036
37#define DRM_AMDGPU_GEM_CREATE 0x00
38#define DRM_AMDGPU_GEM_MMAP 0x01
39#define DRM_AMDGPU_CTX 0x02
40#define DRM_AMDGPU_BO_LIST 0x03
41#define DRM_AMDGPU_CS 0x04
42#define DRM_AMDGPU_INFO 0x05
43#define DRM_AMDGPU_GEM_METADATA 0x06
44#define DRM_AMDGPU_GEM_WAIT_IDLE 0x07
45#define DRM_AMDGPU_GEM_VA 0x08
46#define DRM_AMDGPU_WAIT_CS 0x09
47#define DRM_AMDGPU_GEM_OP 0x10
48#define DRM_AMDGPU_GEM_USERPTR 0x11
49
50#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
51#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
52#define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
53#define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
54#define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
55#define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
56#define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
57#define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
Christian König34b5f6a2015-06-08 15:03:00 +020058#define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
Alex Deucher81629cb2015-04-20 16:42:01 -040059#define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
60#define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
61#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
62
63#define AMDGPU_GEM_DOMAIN_CPU 0x1
64#define AMDGPU_GEM_DOMAIN_GTT 0x2
65#define AMDGPU_GEM_DOMAIN_VRAM 0x4
66#define AMDGPU_GEM_DOMAIN_GDS 0x8
67#define AMDGPU_GEM_DOMAIN_GWS 0x10
68#define AMDGPU_GEM_DOMAIN_OA 0x20
69
Alex Deucher81629cb2015-04-20 16:42:01 -040070/* Flag that CPU access will be required for the case of VRAM domain */
71#define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
72/* Flag that CPU access will not work, this VRAM domain is invisible */
73#define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)
Alex Deucher81629cb2015-04-20 16:42:01 -040074/* Flag that USWC attributes should be used for GTT */
Jammy Zhou88671282015-05-06 18:44:29 +080075#define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)
Alex Deucher81629cb2015-04-20 16:42:01 -040076
Alex Deucher81629cb2015-04-20 16:42:01 -040077struct drm_amdgpu_gem_create_in {
78 /** the requested memory size */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +010079 __u64 bo_size;
Alex Deucher81629cb2015-04-20 16:42:01 -040080 /** physical start_addr alignment in bytes for some HW requirements */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +010081 __u64 alignment;
Alex Deucher81629cb2015-04-20 16:42:01 -040082 /** the requested memory domains */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +010083 __u64 domains;
Alex Deucher81629cb2015-04-20 16:42:01 -040084 /** allocation flags */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +010085 __u64 domain_flags;
Alex Deucher81629cb2015-04-20 16:42:01 -040086};
87
88struct drm_amdgpu_gem_create_out {
89 /** returned GEM object handle */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +010090 __u32 handle;
91 __u32 _pad;
Alex Deucher81629cb2015-04-20 16:42:01 -040092};
93
94union drm_amdgpu_gem_create {
95 struct drm_amdgpu_gem_create_in in;
96 struct drm_amdgpu_gem_create_out out;
97};
98
99/** Opcode to create new residency list. */
100#define AMDGPU_BO_LIST_OP_CREATE 0
101/** Opcode to destroy previously created residency list */
102#define AMDGPU_BO_LIST_OP_DESTROY 1
103/** Opcode to update resource information in the list */
104#define AMDGPU_BO_LIST_OP_UPDATE 2
105
106struct drm_amdgpu_bo_list_in {
107 /** Type of operation */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100108 __u32 operation;
Alex Deucher81629cb2015-04-20 16:42:01 -0400109 /** Handle of list or 0 if we want to create one */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100110 __u32 list_handle;
Alex Deucher81629cb2015-04-20 16:42:01 -0400111 /** Number of BOs in list */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100112 __u32 bo_number;
Alex Deucher81629cb2015-04-20 16:42:01 -0400113 /** Size of each element describing BO */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100114 __u32 bo_info_size;
Alex Deucher81629cb2015-04-20 16:42:01 -0400115 /** Pointer to array describing BOs */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100116 __u64 bo_info_ptr;
Alex Deucher81629cb2015-04-20 16:42:01 -0400117};
118
119struct drm_amdgpu_bo_list_entry {
120 /** Handle of BO */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100121 __u32 bo_handle;
Alex Deucher81629cb2015-04-20 16:42:01 -0400122 /** New (if specified) BO priority to be used during migration */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100123 __u32 bo_priority;
Alex Deucher81629cb2015-04-20 16:42:01 -0400124};
125
126struct drm_amdgpu_bo_list_out {
127 /** Handle of resource list */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100128 __u32 list_handle;
129 __u32 _pad;
Alex Deucher81629cb2015-04-20 16:42:01 -0400130};
131
132union drm_amdgpu_bo_list {
133 struct drm_amdgpu_bo_list_in in;
134 struct drm_amdgpu_bo_list_out out;
135};
136
137/* context related */
138#define AMDGPU_CTX_OP_ALLOC_CTX 1
139#define AMDGPU_CTX_OP_FREE_CTX 2
140#define AMDGPU_CTX_OP_QUERY_STATE 3
141
Marek Olšákd94aed52015-05-05 21:13:49 +0200142/* GPU reset status */
143#define AMDGPU_CTX_NO_RESET 0
Christian König675da0d2015-06-09 15:54:37 +0200144/* this the context caused it */
145#define AMDGPU_CTX_GUILTY_RESET 1
146/* some other context caused it */
147#define AMDGPU_CTX_INNOCENT_RESET 2
148/* unknown cause */
149#define AMDGPU_CTX_UNKNOWN_RESET 3
Marek Olšákd94aed52015-05-05 21:13:49 +0200150
Alex Deucher81629cb2015-04-20 16:42:01 -0400151struct drm_amdgpu_ctx_in {
Christian König675da0d2015-06-09 15:54:37 +0200152 /** AMDGPU_CTX_OP_* */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100153 __u32 op;
Christian König675da0d2015-06-09 15:54:37 +0200154 /** For future use, no flags defined so far */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100155 __u32 flags;
156 __u32 ctx_id;
157 __u32 _pad;
Alex Deucher81629cb2015-04-20 16:42:01 -0400158};
159
160union drm_amdgpu_ctx_out {
161 struct {
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100162 __u32 ctx_id;
163 __u32 _pad;
Alex Deucher81629cb2015-04-20 16:42:01 -0400164 } alloc;
165
166 struct {
Christian König675da0d2015-06-09 15:54:37 +0200167 /** For future use, no flags defined so far */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100168 __u64 flags;
Marek Olšákd94aed52015-05-05 21:13:49 +0200169 /** Number of resets caused by this context so far. */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100170 __u32 hangs;
Marek Olšákd94aed52015-05-05 21:13:49 +0200171 /** Reset status since the last call of the ioctl. */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100172 __u32 reset_status;
Alex Deucher81629cb2015-04-20 16:42:01 -0400173 } state;
174};
175
176union drm_amdgpu_ctx {
177 struct drm_amdgpu_ctx_in in;
178 union drm_amdgpu_ctx_out out;
179};
180
181/*
182 * This is not a reliable API and you should expect it to fail for any
183 * number of reasons and have fallback path that do not use userptr to
184 * perform any operation.
185 */
186#define AMDGPU_GEM_USERPTR_READONLY (1 << 0)
187#define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)
188#define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)
189#define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)
190
191struct drm_amdgpu_gem_userptr {
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100192 __u64 addr;
193 __u64 size;
Christian König675da0d2015-06-09 15:54:37 +0200194 /* AMDGPU_GEM_USERPTR_* */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100195 __u32 flags;
Christian König675da0d2015-06-09 15:54:37 +0200196 /* Resulting GEM handle */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100197 __u32 handle;
Alex Deucher81629cb2015-04-20 16:42:01 -0400198};
199
Marek Olšákfbd76d52015-05-14 23:48:26 +0200200/* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
201#define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
202#define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
203#define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4
204#define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f
205#define AMDGPU_TILING_TILE_SPLIT_SHIFT 9
206#define AMDGPU_TILING_TILE_SPLIT_MASK 0x7
207#define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12
208#define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7
209#define AMDGPU_TILING_BANK_WIDTH_SHIFT 15
210#define AMDGPU_TILING_BANK_WIDTH_MASK 0x3
211#define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17
212#define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3
213#define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19
214#define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3
215#define AMDGPU_TILING_NUM_BANKS_SHIFT 21
216#define AMDGPU_TILING_NUM_BANKS_MASK 0x3
217
218#define AMDGPU_TILING_SET(field, value) \
219 (((value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
220#define AMDGPU_TILING_GET(value, field) \
221 (((value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
Alex Deucher81629cb2015-04-20 16:42:01 -0400222
223#define AMDGPU_GEM_METADATA_OP_SET_METADATA 1
224#define AMDGPU_GEM_METADATA_OP_GET_METADATA 2
225
226/** The same structure is shared for input/output */
227struct drm_amdgpu_gem_metadata {
Christian König675da0d2015-06-09 15:54:37 +0200228 /** GEM Object handle */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100229 __u32 handle;
Christian König675da0d2015-06-09 15:54:37 +0200230 /** Do we want get or set metadata */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100231 __u32 op;
Alex Deucher81629cb2015-04-20 16:42:01 -0400232 struct {
Christian König675da0d2015-06-09 15:54:37 +0200233 /** For future use, no flags defined so far */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100234 __u64 flags;
Christian König675da0d2015-06-09 15:54:37 +0200235 /** family specific tiling info */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100236 __u64 tiling_info;
237 __u32 data_size_bytes;
238 __u32 data[64];
Alex Deucher81629cb2015-04-20 16:42:01 -0400239 } data;
240};
241
242struct drm_amdgpu_gem_mmap_in {
Christian König675da0d2015-06-09 15:54:37 +0200243 /** the GEM object handle */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100244 __u32 handle;
245 __u32 _pad;
Alex Deucher81629cb2015-04-20 16:42:01 -0400246};
247
248struct drm_amdgpu_gem_mmap_out {
Christian König675da0d2015-06-09 15:54:37 +0200249 /** mmap offset from the vma offset manager */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100250 __u64 addr_ptr;
Alex Deucher81629cb2015-04-20 16:42:01 -0400251};
252
253union drm_amdgpu_gem_mmap {
254 struct drm_amdgpu_gem_mmap_in in;
255 struct drm_amdgpu_gem_mmap_out out;
256};
257
258struct drm_amdgpu_gem_wait_idle_in {
Christian König675da0d2015-06-09 15:54:37 +0200259 /** GEM object handle */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100260 __u32 handle;
Christian König675da0d2015-06-09 15:54:37 +0200261 /** For future use, no flags defined so far */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100262 __u32 flags;
Christian König675da0d2015-06-09 15:54:37 +0200263 /** Absolute timeout to wait */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100264 __u64 timeout;
Alex Deucher81629cb2015-04-20 16:42:01 -0400265};
266
267struct drm_amdgpu_gem_wait_idle_out {
Christian König675da0d2015-06-09 15:54:37 +0200268 /** BO status: 0 - BO is idle, 1 - BO is busy */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100269 __u32 status;
Christian König675da0d2015-06-09 15:54:37 +0200270 /** Returned current memory domain */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100271 __u32 domain;
Alex Deucher81629cb2015-04-20 16:42:01 -0400272};
273
274union drm_amdgpu_gem_wait_idle {
275 struct drm_amdgpu_gem_wait_idle_in in;
276 struct drm_amdgpu_gem_wait_idle_out out;
277};
278
279struct drm_amdgpu_wait_cs_in {
Christian König675da0d2015-06-09 15:54:37 +0200280 /** Command submission handle */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100281 __u64 handle;
Christian König675da0d2015-06-09 15:54:37 +0200282 /** Absolute timeout to wait */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100283 __u64 timeout;
284 __u32 ip_type;
285 __u32 ip_instance;
286 __u32 ring;
287 __u32 ctx_id;
Alex Deucher81629cb2015-04-20 16:42:01 -0400288};
289
290struct drm_amdgpu_wait_cs_out {
Christian König675da0d2015-06-09 15:54:37 +0200291 /** CS status: 0 - CS completed, 1 - CS still busy */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100292 __u64 status;
Alex Deucher81629cb2015-04-20 16:42:01 -0400293};
294
295union drm_amdgpu_wait_cs {
296 struct drm_amdgpu_wait_cs_in in;
297 struct drm_amdgpu_wait_cs_out out;
298};
299
Marek Olšákd8f65a22015-05-27 14:30:38 +0200300#define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0
301#define AMDGPU_GEM_OP_SET_PLACEMENT 1
Alex Deucher81629cb2015-04-20 16:42:01 -0400302
Christian König675da0d2015-06-09 15:54:37 +0200303/* Sets or returns a value associated with a buffer. */
304struct drm_amdgpu_gem_op {
305 /** GEM object handle */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100306 __u32 handle;
Christian König675da0d2015-06-09 15:54:37 +0200307 /** AMDGPU_GEM_OP_* */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100308 __u32 op;
Christian König675da0d2015-06-09 15:54:37 +0200309 /** Input or return value */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100310 __u64 value;
Christian König675da0d2015-06-09 15:54:37 +0200311};
312
Alex Deucher81629cb2015-04-20 16:42:01 -0400313#define AMDGPU_VA_OP_MAP 1
314#define AMDGPU_VA_OP_UNMAP 2
315
Christian Königfc220f62015-06-29 17:12:20 +0200316/* Delay the page table update till the next CS */
317#define AMDGPU_VM_DELAY_UPDATE (1 << 0)
318
Alex Deucher81629cb2015-04-20 16:42:01 -0400319/* Mapping flags */
320/* readable mapping */
321#define AMDGPU_VM_PAGE_READABLE (1 << 1)
322/* writable mapping */
323#define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
324/* executable mapping, new for VI */
325#define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
326
Christian König34b5f6a2015-06-08 15:03:00 +0200327struct drm_amdgpu_gem_va {
Christian König675da0d2015-06-09 15:54:37 +0200328 /** GEM object handle */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100329 __u32 handle;
330 __u32 _pad;
Christian König675da0d2015-06-09 15:54:37 +0200331 /** AMDGPU_VA_OP_* */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100332 __u32 operation;
Christian König675da0d2015-06-09 15:54:37 +0200333 /** AMDGPU_VM_PAGE_* */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100334 __u32 flags;
Christian König675da0d2015-06-09 15:54:37 +0200335 /** va address to assign . Must be correctly aligned.*/
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100336 __u64 va_address;
Christian König675da0d2015-06-09 15:54:37 +0200337 /** Specify offset inside of BO to assign. Must be correctly aligned.*/
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100338 __u64 offset_in_bo;
Christian König675da0d2015-06-09 15:54:37 +0200339 /** Specify mapping size. Must be correctly aligned. */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100340 __u64 map_size;
Alex Deucher81629cb2015-04-20 16:42:01 -0400341};
342
Alex Deucher81629cb2015-04-20 16:42:01 -0400343#define AMDGPU_HW_IP_GFX 0
344#define AMDGPU_HW_IP_COMPUTE 1
345#define AMDGPU_HW_IP_DMA 2
346#define AMDGPU_HW_IP_UVD 3
347#define AMDGPU_HW_IP_VCE 4
348#define AMDGPU_HW_IP_NUM 5
349
350#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
351
352#define AMDGPU_CHUNK_ID_IB 0x01
353#define AMDGPU_CHUNK_ID_FENCE 0x02
Christian König2b48d322015-06-19 17:31:29 +0200354#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
Christian König675da0d2015-06-09 15:54:37 +0200355
Alex Deucher81629cb2015-04-20 16:42:01 -0400356struct drm_amdgpu_cs_chunk {
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100357 __u32 chunk_id;
358 __u32 length_dw;
359 __u64 chunk_data;
Alex Deucher81629cb2015-04-20 16:42:01 -0400360};
361
362struct drm_amdgpu_cs_in {
363 /** Rendering context id */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100364 __u32 ctx_id;
Alex Deucher81629cb2015-04-20 16:42:01 -0400365 /** Handle of resource list associated with CS */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100366 __u32 bo_list_handle;
367 __u32 num_chunks;
368 __u32 _pad;
369 /** this points to __u64 * which point to cs chunks */
370 __u64 chunks;
Alex Deucher81629cb2015-04-20 16:42:01 -0400371};
372
373struct drm_amdgpu_cs_out {
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100374 __u64 handle;
Alex Deucher81629cb2015-04-20 16:42:01 -0400375};
376
377union drm_amdgpu_cs {
Christian König675da0d2015-06-09 15:54:37 +0200378 struct drm_amdgpu_cs_in in;
379 struct drm_amdgpu_cs_out out;
Alex Deucher81629cb2015-04-20 16:42:01 -0400380};
381
382/* Specify flags to be used for IB */
383
384/* This IB should be submitted to CE */
385#define AMDGPU_IB_FLAG_CE (1<<0)
386
Jammy Zhouaa2bdb242015-05-11 23:49:34 +0800387/* CE Preamble */
Jammy Zhoucab6d572015-06-06 04:49:22 +0800388#define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
Jammy Zhouaa2bdb242015-05-11 23:49:34 +0800389
Alex Deucher81629cb2015-04-20 16:42:01 -0400390struct drm_amdgpu_cs_chunk_ib {
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100391 __u32 _pad;
Christian König675da0d2015-06-09 15:54:37 +0200392 /** AMDGPU_IB_FLAG_* */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100393 __u32 flags;
Christian König675da0d2015-06-09 15:54:37 +0200394 /** Virtual address to begin IB execution */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100395 __u64 va_start;
Christian König675da0d2015-06-09 15:54:37 +0200396 /** Size of submission */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100397 __u32 ib_bytes;
Christian König675da0d2015-06-09 15:54:37 +0200398 /** HW IP to submit to */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100399 __u32 ip_type;
Christian König675da0d2015-06-09 15:54:37 +0200400 /** HW IP index of the same type to submit to */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100401 __u32 ip_instance;
Christian König675da0d2015-06-09 15:54:37 +0200402 /** Ring index to submit to */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100403 __u32 ring;
Alex Deucher81629cb2015-04-20 16:42:01 -0400404};
405
Christian König2b48d322015-06-19 17:31:29 +0200406struct drm_amdgpu_cs_chunk_dep {
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100407 __u32 ip_type;
408 __u32 ip_instance;
409 __u32 ring;
410 __u32 ctx_id;
411 __u64 handle;
Christian König2b48d322015-06-19 17:31:29 +0200412};
413
Alex Deucher81629cb2015-04-20 16:42:01 -0400414struct drm_amdgpu_cs_chunk_fence {
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100415 __u32 handle;
416 __u32 offset;
Alex Deucher81629cb2015-04-20 16:42:01 -0400417};
418
419struct drm_amdgpu_cs_chunk_data {
420 union {
421 struct drm_amdgpu_cs_chunk_ib ib_data;
422 struct drm_amdgpu_cs_chunk_fence fence_data;
423 };
424};
425
426/**
427 * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
428 *
429 */
430#define AMDGPU_IDS_FLAGS_FUSION 0x1
431
432/* indicate if acceleration can be working */
433#define AMDGPU_INFO_ACCEL_WORKING 0x00
434/* get the crtc_id from the mode object id? */
435#define AMDGPU_INFO_CRTC_FROM_ID 0x01
436/* query hw IP info */
437#define AMDGPU_INFO_HW_IP_INFO 0x02
438/* query hw IP instance count for the specified type */
439#define AMDGPU_INFO_HW_IP_COUNT 0x03
440/* timestamp for GL_ARB_timer_query */
441#define AMDGPU_INFO_TIMESTAMP 0x05
442/* Query the firmware version */
443#define AMDGPU_INFO_FW_VERSION 0x0e
444 /* Subquery id: Query VCE firmware version */
445 #define AMDGPU_INFO_FW_VCE 0x1
446 /* Subquery id: Query UVD firmware version */
447 #define AMDGPU_INFO_FW_UVD 0x2
448 /* Subquery id: Query GMC firmware version */
449 #define AMDGPU_INFO_FW_GMC 0x03
450 /* Subquery id: Query GFX ME firmware version */
451 #define AMDGPU_INFO_FW_GFX_ME 0x04
452 /* Subquery id: Query GFX PFP firmware version */
453 #define AMDGPU_INFO_FW_GFX_PFP 0x05
454 /* Subquery id: Query GFX CE firmware version */
455 #define AMDGPU_INFO_FW_GFX_CE 0x06
456 /* Subquery id: Query GFX RLC firmware version */
457 #define AMDGPU_INFO_FW_GFX_RLC 0x07
458 /* Subquery id: Query GFX MEC firmware version */
459 #define AMDGPU_INFO_FW_GFX_MEC 0x08
460 /* Subquery id: Query SMC firmware version */
461 #define AMDGPU_INFO_FW_SMC 0x0a
462 /* Subquery id: Query SDMA firmware version */
463 #define AMDGPU_INFO_FW_SDMA 0x0b
464/* number of bytes moved for TTM migration */
465#define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
466/* the used VRAM size */
467#define AMDGPU_INFO_VRAM_USAGE 0x10
468/* the used GTT size */
469#define AMDGPU_INFO_GTT_USAGE 0x11
470/* Information about GDS, etc. resource configuration */
471#define AMDGPU_INFO_GDS_CONFIG 0x13
472/* Query information about VRAM and GTT domains */
473#define AMDGPU_INFO_VRAM_GTT 0x14
474/* Query information about register in MMR address space*/
475#define AMDGPU_INFO_READ_MMR_REG 0x15
476/* Query information about device: rev id, family, etc. */
477#define AMDGPU_INFO_DEV_INFO 0x16
478/* visible vram usage */
479#define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
480
481#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
482#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
483#define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
484#define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
485
486/* Input structure for the INFO ioctl */
487struct drm_amdgpu_info {
488 /* Where the return value will be stored */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100489 __u64 return_pointer;
Alex Deucher81629cb2015-04-20 16:42:01 -0400490 /* The size of the return value. Just like "size" in "snprintf",
491 * it limits how many bytes the kernel can write. */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100492 __u32 return_size;
Alex Deucher81629cb2015-04-20 16:42:01 -0400493 /* The query request id. */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100494 __u32 query;
Alex Deucher81629cb2015-04-20 16:42:01 -0400495
496 union {
497 struct {
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100498 __u32 id;
499 __u32 _pad;
Alex Deucher81629cb2015-04-20 16:42:01 -0400500 } mode_crtc;
501
502 struct {
503 /** AMDGPU_HW_IP_* */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100504 __u32 type;
Alex Deucher81629cb2015-04-20 16:42:01 -0400505 /**
Christian König675da0d2015-06-09 15:54:37 +0200506 * Index of the IP if there are more IPs of the same
507 * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
Alex Deucher81629cb2015-04-20 16:42:01 -0400508 */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100509 __u32 ip_instance;
Alex Deucher81629cb2015-04-20 16:42:01 -0400510 } query_hw_ip;
511
512 struct {
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100513 __u32 dword_offset;
Christian König675da0d2015-06-09 15:54:37 +0200514 /** number of registers to read */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100515 __u32 count;
516 __u32 instance;
Christian König675da0d2015-06-09 15:54:37 +0200517 /** For future use, no flags defined so far */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100518 __u32 flags;
Alex Deucher81629cb2015-04-20 16:42:01 -0400519 } read_mmr_reg;
520
521 struct {
522 /** AMDGPU_INFO_FW_* */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100523 __u32 fw_type;
Christian König675da0d2015-06-09 15:54:37 +0200524 /**
525 * Index of the IP if there are more IPs of
526 * the same type.
527 */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100528 __u32 ip_instance;
Alex Deucher81629cb2015-04-20 16:42:01 -0400529 /**
530 * Index of the engine. Whether this is used depends
531 * on the firmware type. (e.g. MEC, SDMA)
532 */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100533 __u32 index;
534 __u32 _pad;
Alex Deucher81629cb2015-04-20 16:42:01 -0400535 } query_fw;
536 };
537};
538
539struct drm_amdgpu_info_gds {
540 /** GDS GFX partition size */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100541 __u32 gds_gfx_partition_size;
Alex Deucher81629cb2015-04-20 16:42:01 -0400542 /** GDS compute partition size */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100543 __u32 compute_partition_size;
Alex Deucher81629cb2015-04-20 16:42:01 -0400544 /** total GDS memory size */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100545 __u32 gds_total_size;
Alex Deucher81629cb2015-04-20 16:42:01 -0400546 /** GWS size per GFX partition */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100547 __u32 gws_per_gfx_partition;
Alex Deucher81629cb2015-04-20 16:42:01 -0400548 /** GSW size per compute partition */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100549 __u32 gws_per_compute_partition;
Alex Deucher81629cb2015-04-20 16:42:01 -0400550 /** OA size per GFX partition */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100551 __u32 oa_per_gfx_partition;
Alex Deucher81629cb2015-04-20 16:42:01 -0400552 /** OA size per compute partition */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100553 __u32 oa_per_compute_partition;
554 __u32 _pad;
Alex Deucher81629cb2015-04-20 16:42:01 -0400555};
556
557struct drm_amdgpu_info_vram_gtt {
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100558 __u64 vram_size;
559 __u64 vram_cpu_accessible_size;
560 __u64 gtt_size;
Alex Deucher81629cb2015-04-20 16:42:01 -0400561};
562
563struct drm_amdgpu_info_firmware {
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100564 __u32 ver;
565 __u32 feature;
Alex Deucher81629cb2015-04-20 16:42:01 -0400566};
567
Ken Wang81c59f52015-06-03 21:02:01 +0800568#define AMDGPU_VRAM_TYPE_UNKNOWN 0
569#define AMDGPU_VRAM_TYPE_GDDR1 1
570#define AMDGPU_VRAM_TYPE_DDR2 2
571#define AMDGPU_VRAM_TYPE_GDDR3 3
572#define AMDGPU_VRAM_TYPE_GDDR4 4
573#define AMDGPU_VRAM_TYPE_GDDR5 5
574#define AMDGPU_VRAM_TYPE_HBM 6
575#define AMDGPU_VRAM_TYPE_DDR3 7
576
Alex Deucher81629cb2015-04-20 16:42:01 -0400577struct drm_amdgpu_info_device {
578 /** PCI Device ID */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100579 __u32 device_id;
Alex Deucher81629cb2015-04-20 16:42:01 -0400580 /** Internal chip revision: A0, A1, etc.) */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100581 __u32 chip_rev;
582 __u32 external_rev;
Alex Deucher81629cb2015-04-20 16:42:01 -0400583 /** Revision id in PCI Config space */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100584 __u32 pci_rev;
585 __u32 family;
586 __u32 num_shader_engines;
587 __u32 num_shader_arrays_per_engine;
Christian König675da0d2015-06-09 15:54:37 +0200588 /* in KHz */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100589 __u32 gpu_counter_freq;
590 __u64 max_engine_clock;
591 __u64 max_memory_clock;
Alex Deucher81629cb2015-04-20 16:42:01 -0400592 /* cu information */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100593 __u32 cu_active_number;
594 __u32 cu_ao_mask;
595 __u32 cu_bitmap[4][4];
Alex Deucher81629cb2015-04-20 16:42:01 -0400596 /** Render backend pipe mask. One render backend is CB+DB. */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100597 __u32 enabled_rb_pipes_mask;
598 __u32 num_rb_pipes;
599 __u32 num_hw_gfx_contexts;
600 __u32 _pad;
601 __u64 ids_flags;
Alex Deucher81629cb2015-04-20 16:42:01 -0400602 /** Starting virtual address for UMDs. */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100603 __u64 virtual_address_offset;
Jammy Zhou02b70c82015-05-12 22:46:45 +0800604 /** The maximum virtual address */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100605 __u64 virtual_address_max;
Alex Deucher81629cb2015-04-20 16:42:01 -0400606 /** Required alignment of virtual addresses. */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100607 __u32 virtual_address_alignment;
Alex Deucher81629cb2015-04-20 16:42:01 -0400608 /** Page table entry - fragment size */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100609 __u32 pte_fragment_size;
610 __u32 gart_page_size;
Ken Wanga101a892015-06-03 17:47:54 +0800611 /** constant engine ram size*/
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100612 __u32 ce_ram_size;
Jammy Zhoucab6d572015-06-06 04:49:22 +0800613 /** video memory type info*/
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100614 __u32 vram_type;
Ken Wang81c59f52015-06-03 21:02:01 +0800615 /** video memory bit width*/
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100616 __u32 vram_bit_width;
Leo Liufa927542015-07-13 12:46:23 -0400617 /* vce harvesting instance */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100618 __u32 vce_harvest_config;
Alex Deucher81629cb2015-04-20 16:42:01 -0400619};
620
621struct drm_amdgpu_info_hw_ip {
622 /** Version of h/w IP */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100623 __u32 hw_ip_version_major;
624 __u32 hw_ip_version_minor;
Alex Deucher81629cb2015-04-20 16:42:01 -0400625 /** Capabilities */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100626 __u64 capabilities_flags;
Ken Wang71062f42015-06-04 21:26:57 +0800627 /** command buffer address start alignment*/
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100628 __u32 ib_start_alignment;
Ken Wang71062f42015-06-04 21:26:57 +0800629 /** command buffer size alignment*/
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100630 __u32 ib_size_alignment;
Alex Deucher81629cb2015-04-20 16:42:01 -0400631 /** Bitmask of available rings. Bit 0 means ring 0, etc. */
Mikko Rapeli2ce9dde2015-12-02 23:44:33 +0100632 __u32 available_rings;
633 __u32 _pad;
Alex Deucher81629cb2015-04-20 16:42:01 -0400634};
635
636/*
637 * Supported GPU families
638 */
639#define AMDGPU_FAMILY_UNKNOWN 0
640#define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */
641#define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */
642#define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */
Samuel Li39bb0c92015-10-08 16:31:43 -0400643#define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */
Alex Deucher81629cb2015-04-20 16:42:01 -0400644
645#endif