blob: 8edf1042036167c55d8b00f16c0b320ac0680a20 [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
35#include <drm/drm.h>
36
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 */
79 uint64_t bo_size;
80 /** physical start_addr alignment in bytes for some HW requirements */
81 uint64_t alignment;
82 /** the requested memory domains */
83 uint64_t domains;
84 /** allocation flags */
85 uint64_t domain_flags;
86};
87
88struct drm_amdgpu_gem_create_out {
89 /** returned GEM object handle */
90 uint32_t handle;
91 uint32_t _pad;
92};
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 */
108 uint32_t operation;
109 /** Handle of list or 0 if we want to create one */
110 uint32_t list_handle;
111 /** Number of BOs in list */
112 uint32_t bo_number;
113 /** Size of each element describing BO */
114 uint32_t bo_info_size;
115 /** Pointer to array describing BOs */
116 uint64_t bo_info_ptr;
117};
118
119struct drm_amdgpu_bo_list_entry {
120 /** Handle of BO */
121 uint32_t bo_handle;
122 /** New (if specified) BO priority to be used during migration */
123 uint32_t bo_priority;
124};
125
126struct drm_amdgpu_bo_list_out {
127 /** Handle of resource list */
128 uint32_t list_handle;
129 uint32_t _pad;
130};
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_* */
Alex Deucher81629cb2015-04-20 16:42:01 -0400153 uint32_t op;
Christian König675da0d2015-06-09 15:54:37 +0200154 /** For future use, no flags defined so far */
Alex Deucher81629cb2015-04-20 16:42:01 -0400155 uint32_t flags;
156 uint32_t ctx_id;
157 uint32_t _pad;
158};
159
160union drm_amdgpu_ctx_out {
161 struct {
162 uint32_t ctx_id;
163 uint32_t _pad;
164 } alloc;
165
166 struct {
Christian König675da0d2015-06-09 15:54:37 +0200167 /** For future use, no flags defined so far */
Alex Deucher81629cb2015-04-20 16:42:01 -0400168 uint64_t flags;
Marek Olšákd94aed52015-05-05 21:13:49 +0200169 /** Number of resets caused by this context so far. */
170 uint32_t hangs;
171 /** Reset status since the last call of the ioctl. */
172 uint32_t 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 {
192 uint64_t addr;
193 uint64_t size;
Christian König675da0d2015-06-09 15:54:37 +0200194 /* AMDGPU_GEM_USERPTR_* */
Alex Deucher81629cb2015-04-20 16:42:01 -0400195 uint32_t flags;
Christian König675da0d2015-06-09 15:54:37 +0200196 /* Resulting GEM handle */
Alex Deucher81629cb2015-04-20 16:42:01 -0400197 uint32_t handle;
198};
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 */
229 uint32_t handle;
230 /** Do we want get or set metadata */
231 uint32_t 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 */
Alex Deucher81629cb2015-04-20 16:42:01 -0400234 uint64_t flags;
Christian König675da0d2015-06-09 15:54:37 +0200235 /** family specific tiling info */
236 uint64_t tiling_info;
Alex Deucher81629cb2015-04-20 16:42:01 -0400237 uint32_t data_size_bytes;
238 uint32_t data[64];
239 } data;
240};
241
242struct drm_amdgpu_gem_mmap_in {
Christian König675da0d2015-06-09 15:54:37 +0200243 /** the GEM object handle */
244 uint32_t handle;
Alex Deucher81629cb2015-04-20 16:42:01 -0400245 uint32_t _pad;
246};
247
248struct drm_amdgpu_gem_mmap_out {
Christian König675da0d2015-06-09 15:54:37 +0200249 /** mmap offset from the vma offset manager */
250 uint64_t 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 */
260 uint32_t handle;
261 /** For future use, no flags defined so far */
Alex Deucher81629cb2015-04-20 16:42:01 -0400262 uint32_t flags;
Christian König675da0d2015-06-09 15:54:37 +0200263 /** Absolute timeout to wait */
264 uint64_t 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 */
269 uint32_t status;
270 /** Returned current memory domain */
271 uint32_t 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 */
Alex Deucher81629cb2015-04-20 16:42:01 -0400281 uint64_t handle;
Christian König675da0d2015-06-09 15:54:37 +0200282 /** Absolute timeout to wait */
Alex Deucher81629cb2015-04-20 16:42:01 -0400283 uint64_t timeout;
284 uint32_t ip_type;
285 uint32_t ip_instance;
286 uint32_t ring;
Jammy Zhou66b3cf22015-05-08 17:29:40 +0800287 uint32_t 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 */
Alex Deucher81629cb2015-04-20 16:42:01 -0400292 uint64_t status;
293};
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 */
306 uint32_t handle;
307 /** AMDGPU_GEM_OP_* */
308 uint32_t op;
309 /** Input or return value */
310 uint64_t value;
311};
312
Alex Deucher81629cb2015-04-20 16:42:01 -0400313#define AMDGPU_VA_OP_MAP 1
314#define AMDGPU_VA_OP_UNMAP 2
315
Alex Deucher81629cb2015-04-20 16:42:01 -0400316/* Mapping flags */
317/* readable mapping */
318#define AMDGPU_VM_PAGE_READABLE (1 << 1)
319/* writable mapping */
320#define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
321/* executable mapping, new for VI */
322#define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
323
Christian König34b5f6a2015-06-08 15:03:00 +0200324struct drm_amdgpu_gem_va {
Christian König675da0d2015-06-09 15:54:37 +0200325 /** GEM object handle */
Alex Deucher81629cb2015-04-20 16:42:01 -0400326 uint32_t handle;
327 uint32_t _pad;
Christian König675da0d2015-06-09 15:54:37 +0200328 /** AMDGPU_VA_OP_* */
Alex Deucher81629cb2015-04-20 16:42:01 -0400329 uint32_t operation;
Christian König675da0d2015-06-09 15:54:37 +0200330 /** AMDGPU_VM_PAGE_* */
Alex Deucher81629cb2015-04-20 16:42:01 -0400331 uint32_t flags;
Christian König675da0d2015-06-09 15:54:37 +0200332 /** va address to assign . Must be correctly aligned.*/
Alex Deucher81629cb2015-04-20 16:42:01 -0400333 uint64_t va_address;
Christian König675da0d2015-06-09 15:54:37 +0200334 /** Specify offset inside of BO to assign. Must be correctly aligned.*/
Alex Deucher81629cb2015-04-20 16:42:01 -0400335 uint64_t offset_in_bo;
Christian König675da0d2015-06-09 15:54:37 +0200336 /** Specify mapping size. Must be correctly aligned. */
Alex Deucher81629cb2015-04-20 16:42:01 -0400337 uint64_t map_size;
338};
339
Alex Deucher81629cb2015-04-20 16:42:01 -0400340#define AMDGPU_HW_IP_GFX 0
341#define AMDGPU_HW_IP_COMPUTE 1
342#define AMDGPU_HW_IP_DMA 2
343#define AMDGPU_HW_IP_UVD 3
344#define AMDGPU_HW_IP_VCE 4
345#define AMDGPU_HW_IP_NUM 5
346
347#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
348
349#define AMDGPU_CHUNK_ID_IB 0x01
350#define AMDGPU_CHUNK_ID_FENCE 0x02
Christian König2b48d322015-06-19 17:31:29 +0200351#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
Christian König675da0d2015-06-09 15:54:37 +0200352
Alex Deucher81629cb2015-04-20 16:42:01 -0400353struct drm_amdgpu_cs_chunk {
354 uint32_t chunk_id;
355 uint32_t length_dw;
356 uint64_t chunk_data;
357};
358
359struct drm_amdgpu_cs_in {
360 /** Rendering context id */
361 uint32_t ctx_id;
362 /** Handle of resource list associated with CS */
363 uint32_t bo_list_handle;
364 uint32_t num_chunks;
365 uint32_t _pad;
Christian König675da0d2015-06-09 15:54:37 +0200366 /** this points to uint64_t * which point to cs chunks */
Alex Deucher81629cb2015-04-20 16:42:01 -0400367 uint64_t chunks;
368};
369
370struct drm_amdgpu_cs_out {
371 uint64_t handle;
372};
373
374union drm_amdgpu_cs {
Christian König675da0d2015-06-09 15:54:37 +0200375 struct drm_amdgpu_cs_in in;
376 struct drm_amdgpu_cs_out out;
Alex Deucher81629cb2015-04-20 16:42:01 -0400377};
378
379/* Specify flags to be used for IB */
380
381/* This IB should be submitted to CE */
382#define AMDGPU_IB_FLAG_CE (1<<0)
383
Jammy Zhouaa2bdb242015-05-11 23:49:34 +0800384/* CE Preamble */
Jammy Zhoucab6d572015-06-06 04:49:22 +0800385#define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
Jammy Zhouaa2bdb242015-05-11 23:49:34 +0800386
Alex Deucher81629cb2015-04-20 16:42:01 -0400387struct drm_amdgpu_cs_chunk_ib {
Marek Olšák3ccec532015-06-02 17:44:49 +0200388 uint32_t _pad;
Christian König675da0d2015-06-09 15:54:37 +0200389 /** AMDGPU_IB_FLAG_* */
390 uint32_t flags;
391 /** Virtual address to begin IB execution */
392 uint64_t va_start;
393 /** Size of submission */
394 uint32_t ib_bytes;
395 /** HW IP to submit to */
396 uint32_t ip_type;
397 /** HW IP index of the same type to submit to */
398 uint32_t ip_instance;
399 /** Ring index to submit to */
400 uint32_t ring;
Alex Deucher81629cb2015-04-20 16:42:01 -0400401};
402
Christian König2b48d322015-06-19 17:31:29 +0200403struct drm_amdgpu_cs_chunk_dep {
404 uint32_t ip_type;
405 uint32_t ip_instance;
406 uint32_t ring;
407 uint32_t ctx_id;
408 uint64_t handle;
409};
410
Alex Deucher81629cb2015-04-20 16:42:01 -0400411struct drm_amdgpu_cs_chunk_fence {
412 uint32_t handle;
413 uint32_t offset;
414};
415
416struct drm_amdgpu_cs_chunk_data {
417 union {
418 struct drm_amdgpu_cs_chunk_ib ib_data;
419 struct drm_amdgpu_cs_chunk_fence fence_data;
420 };
421};
422
423/**
424 * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
425 *
426 */
427#define AMDGPU_IDS_FLAGS_FUSION 0x1
428
429/* indicate if acceleration can be working */
430#define AMDGPU_INFO_ACCEL_WORKING 0x00
431/* get the crtc_id from the mode object id? */
432#define AMDGPU_INFO_CRTC_FROM_ID 0x01
433/* query hw IP info */
434#define AMDGPU_INFO_HW_IP_INFO 0x02
435/* query hw IP instance count for the specified type */
436#define AMDGPU_INFO_HW_IP_COUNT 0x03
437/* timestamp for GL_ARB_timer_query */
438#define AMDGPU_INFO_TIMESTAMP 0x05
439/* Query the firmware version */
440#define AMDGPU_INFO_FW_VERSION 0x0e
441 /* Subquery id: Query VCE firmware version */
442 #define AMDGPU_INFO_FW_VCE 0x1
443 /* Subquery id: Query UVD firmware version */
444 #define AMDGPU_INFO_FW_UVD 0x2
445 /* Subquery id: Query GMC firmware version */
446 #define AMDGPU_INFO_FW_GMC 0x03
447 /* Subquery id: Query GFX ME firmware version */
448 #define AMDGPU_INFO_FW_GFX_ME 0x04
449 /* Subquery id: Query GFX PFP firmware version */
450 #define AMDGPU_INFO_FW_GFX_PFP 0x05
451 /* Subquery id: Query GFX CE firmware version */
452 #define AMDGPU_INFO_FW_GFX_CE 0x06
453 /* Subquery id: Query GFX RLC firmware version */
454 #define AMDGPU_INFO_FW_GFX_RLC 0x07
455 /* Subquery id: Query GFX MEC firmware version */
456 #define AMDGPU_INFO_FW_GFX_MEC 0x08
457 /* Subquery id: Query SMC firmware version */
458 #define AMDGPU_INFO_FW_SMC 0x0a
459 /* Subquery id: Query SDMA firmware version */
460 #define AMDGPU_INFO_FW_SDMA 0x0b
461/* number of bytes moved for TTM migration */
462#define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
463/* the used VRAM size */
464#define AMDGPU_INFO_VRAM_USAGE 0x10
465/* the used GTT size */
466#define AMDGPU_INFO_GTT_USAGE 0x11
467/* Information about GDS, etc. resource configuration */
468#define AMDGPU_INFO_GDS_CONFIG 0x13
469/* Query information about VRAM and GTT domains */
470#define AMDGPU_INFO_VRAM_GTT 0x14
471/* Query information about register in MMR address space*/
472#define AMDGPU_INFO_READ_MMR_REG 0x15
473/* Query information about device: rev id, family, etc. */
474#define AMDGPU_INFO_DEV_INFO 0x16
475/* visible vram usage */
476#define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
477
478#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
479#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
480#define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
481#define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
482
483/* Input structure for the INFO ioctl */
484struct drm_amdgpu_info {
485 /* Where the return value will be stored */
486 uint64_t return_pointer;
487 /* The size of the return value. Just like "size" in "snprintf",
488 * it limits how many bytes the kernel can write. */
489 uint32_t return_size;
490 /* The query request id. */
491 uint32_t query;
492
493 union {
494 struct {
495 uint32_t id;
496 uint32_t _pad;
497 } mode_crtc;
498
499 struct {
500 /** AMDGPU_HW_IP_* */
501 uint32_t type;
502 /**
Christian König675da0d2015-06-09 15:54:37 +0200503 * Index of the IP if there are more IPs of the same
504 * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
Alex Deucher81629cb2015-04-20 16:42:01 -0400505 */
506 uint32_t ip_instance;
507 } query_hw_ip;
508
509 struct {
510 uint32_t dword_offset;
Christian König675da0d2015-06-09 15:54:37 +0200511 /** number of registers to read */
512 uint32_t count;
Alex Deucher81629cb2015-04-20 16:42:01 -0400513 uint32_t instance;
Christian König675da0d2015-06-09 15:54:37 +0200514 /** For future use, no flags defined so far */
Alex Deucher81629cb2015-04-20 16:42:01 -0400515 uint32_t flags;
516 } read_mmr_reg;
517
518 struct {
519 /** AMDGPU_INFO_FW_* */
520 uint32_t fw_type;
Christian König675da0d2015-06-09 15:54:37 +0200521 /**
522 * Index of the IP if there are more IPs of
523 * the same type.
524 */
Alex Deucher81629cb2015-04-20 16:42:01 -0400525 uint32_t ip_instance;
526 /**
527 * Index of the engine. Whether this is used depends
528 * on the firmware type. (e.g. MEC, SDMA)
529 */
530 uint32_t index;
531 uint32_t _pad;
532 } query_fw;
533 };
534};
535
536struct drm_amdgpu_info_gds {
537 /** GDS GFX partition size */
538 uint32_t gds_gfx_partition_size;
539 /** GDS compute partition size */
540 uint32_t compute_partition_size;
541 /** total GDS memory size */
542 uint32_t gds_total_size;
543 /** GWS size per GFX partition */
544 uint32_t gws_per_gfx_partition;
545 /** GSW size per compute partition */
546 uint32_t gws_per_compute_partition;
547 /** OA size per GFX partition */
548 uint32_t oa_per_gfx_partition;
549 /** OA size per compute partition */
550 uint32_t oa_per_compute_partition;
551 uint32_t _pad;
552};
553
554struct drm_amdgpu_info_vram_gtt {
555 uint64_t vram_size;
556 uint64_t vram_cpu_accessible_size;
557 uint64_t gtt_size;
558};
559
560struct drm_amdgpu_info_firmware {
561 uint32_t ver;
562 uint32_t feature;
563};
564
Ken Wang81c59f52015-06-03 21:02:01 +0800565#define AMDGPU_VRAM_TYPE_UNKNOWN 0
566#define AMDGPU_VRAM_TYPE_GDDR1 1
567#define AMDGPU_VRAM_TYPE_DDR2 2
568#define AMDGPU_VRAM_TYPE_GDDR3 3
569#define AMDGPU_VRAM_TYPE_GDDR4 4
570#define AMDGPU_VRAM_TYPE_GDDR5 5
571#define AMDGPU_VRAM_TYPE_HBM 6
572#define AMDGPU_VRAM_TYPE_DDR3 7
573
Alex Deucher81629cb2015-04-20 16:42:01 -0400574struct drm_amdgpu_info_device {
575 /** PCI Device ID */
576 uint32_t device_id;
577 /** Internal chip revision: A0, A1, etc.) */
578 uint32_t chip_rev;
579 uint32_t external_rev;
580 /** Revision id in PCI Config space */
581 uint32_t pci_rev;
582 uint32_t family;
583 uint32_t num_shader_engines;
584 uint32_t num_shader_arrays_per_engine;
Christian König675da0d2015-06-09 15:54:37 +0200585 /* in KHz */
586 uint32_t gpu_counter_freq;
587 uint64_t max_engine_clock;
588 uint64_t max_memory_clock;
Alex Deucher81629cb2015-04-20 16:42:01 -0400589 /* cu information */
590 uint32_t cu_active_number;
591 uint32_t cu_ao_mask;
592 uint32_t cu_bitmap[4][4];
593 /** Render backend pipe mask. One render backend is CB+DB. */
594 uint32_t enabled_rb_pipes_mask;
595 uint32_t num_rb_pipes;
596 uint32_t num_hw_gfx_contexts;
597 uint32_t _pad;
598 uint64_t ids_flags;
599 /** Starting virtual address for UMDs. */
600 uint64_t virtual_address_offset;
Jammy Zhou02b70c82015-05-12 22:46:45 +0800601 /** The maximum virtual address */
602 uint64_t virtual_address_max;
Alex Deucher81629cb2015-04-20 16:42:01 -0400603 /** Required alignment of virtual addresses. */
604 uint32_t virtual_address_alignment;
605 /** Page table entry - fragment size */
606 uint32_t pte_fragment_size;
607 uint32_t gart_page_size;
Ken Wanga101a892015-06-03 17:47:54 +0800608 /** constant engine ram size*/
609 uint32_t ce_ram_size;
Jammy Zhoucab6d572015-06-06 04:49:22 +0800610 /** video memory type info*/
Ken Wang81c59f52015-06-03 21:02:01 +0800611 uint32_t vram_type;
612 /** video memory bit width*/
613 uint32_t vram_bit_width;
Alex Deucher81629cb2015-04-20 16:42:01 -0400614};
615
616struct drm_amdgpu_info_hw_ip {
617 /** Version of h/w IP */
618 uint32_t hw_ip_version_major;
619 uint32_t hw_ip_version_minor;
620 /** Capabilities */
621 uint64_t capabilities_flags;
Ken Wang71062f42015-06-04 21:26:57 +0800622 /** command buffer address start alignment*/
623 uint32_t ib_start_alignment;
624 /** command buffer size alignment*/
625 uint32_t ib_size_alignment;
Alex Deucher81629cb2015-04-20 16:42:01 -0400626 /** Bitmask of available rings. Bit 0 means ring 0, etc. */
627 uint32_t available_rings;
628 uint32_t _pad;
629};
630
631/*
632 * Supported GPU families
633 */
634#define AMDGPU_FAMILY_UNKNOWN 0
635#define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */
636#define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */
637#define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */
638#define AMDGPU_FAMILY_CZ 135 /* Carrizo */
639
640#endif