13f012e29Smrg/* amdgpu_drm.h -- Public header for the amdgpu driver -*- linux-c -*-
23f012e29Smrg *
33f012e29Smrg * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
43f012e29Smrg * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
53f012e29Smrg * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
63f012e29Smrg * Copyright 2014 Advanced Micro Devices, Inc.
73f012e29Smrg *
83f012e29Smrg * Permission is hereby granted, free of charge, to any person obtaining a
93f012e29Smrg * copy of this software and associated documentation files (the "Software"),
103f012e29Smrg * to deal in the Software without restriction, including without limitation
113f012e29Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
123f012e29Smrg * and/or sell copies of the Software, and to permit persons to whom the
133f012e29Smrg * Software is furnished to do so, subject to the following conditions:
143f012e29Smrg *
153f012e29Smrg * The above copyright notice and this permission notice shall be included in
163f012e29Smrg * all copies or substantial portions of the Software.
173f012e29Smrg *
183f012e29Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
193f012e29Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
203f012e29Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
213f012e29Smrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
223f012e29Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
233f012e29Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
243f012e29Smrg * OTHER DEALINGS IN THE SOFTWARE.
253f012e29Smrg *
263f012e29Smrg * Authors:
273f012e29Smrg *    Kevin E. Martin <martin@valinux.com>
283f012e29Smrg *    Gareth Hughes <gareth@valinux.com>
293f012e29Smrg *    Keith Whitwell <keith@tungstengraphics.com>
303f012e29Smrg */
313f012e29Smrg
323f012e29Smrg#ifndef __AMDGPU_DRM_H__
333f012e29Smrg#define __AMDGPU_DRM_H__
343f012e29Smrg
353f012e29Smrg#include "drm.h"
363f012e29Smrg
37037b3c26Smrg#if defined(__cplusplus)
38037b3c26Smrgextern "C" {
39037b3c26Smrg#endif
40037b3c26Smrg
413f012e29Smrg#define DRM_AMDGPU_GEM_CREATE		0x00
423f012e29Smrg#define DRM_AMDGPU_GEM_MMAP		0x01
433f012e29Smrg#define DRM_AMDGPU_CTX			0x02
443f012e29Smrg#define DRM_AMDGPU_BO_LIST		0x03
453f012e29Smrg#define DRM_AMDGPU_CS			0x04
463f012e29Smrg#define DRM_AMDGPU_INFO			0x05
473f012e29Smrg#define DRM_AMDGPU_GEM_METADATA		0x06
483f012e29Smrg#define DRM_AMDGPU_GEM_WAIT_IDLE	0x07
493f012e29Smrg#define DRM_AMDGPU_GEM_VA		0x08
503f012e29Smrg#define DRM_AMDGPU_WAIT_CS		0x09
513f012e29Smrg#define DRM_AMDGPU_GEM_OP		0x10
523f012e29Smrg#define DRM_AMDGPU_GEM_USERPTR		0x11
53d8807b2fSmrg#define DRM_AMDGPU_WAIT_FENCES		0x12
54d8807b2fSmrg#define DRM_AMDGPU_VM			0x13
5500a23bdaSmrg#define DRM_AMDGPU_FENCE_TO_HANDLE	0x14
5600a23bdaSmrg#define DRM_AMDGPU_SCHED		0x15
573f012e29Smrg
583f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_CREATE	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
593f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_MMAP	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
603f012e29Smrg#define DRM_IOCTL_AMDGPU_CTX		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
613f012e29Smrg#define DRM_IOCTL_AMDGPU_BO_LIST	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
623f012e29Smrg#define DRM_IOCTL_AMDGPU_CS		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
633f012e29Smrg#define DRM_IOCTL_AMDGPU_INFO		DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
643f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_METADATA	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
653f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
663f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_VA		DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
673f012e29Smrg#define DRM_IOCTL_AMDGPU_WAIT_CS	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
683f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_OP		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
693f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_USERPTR	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
70d8807b2fSmrg#define DRM_IOCTL_AMDGPU_WAIT_FENCES	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)
71d8807b2fSmrg#define DRM_IOCTL_AMDGPU_VM		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
7200a23bdaSmrg#define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
7300a23bdaSmrg#define DRM_IOCTL_AMDGPU_SCHED		DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
743f012e29Smrg
757cdc0497Smrg/**
767cdc0497Smrg * DOC: memory domains
777cdc0497Smrg *
787cdc0497Smrg * %AMDGPU_GEM_DOMAIN_CPU	System memory that is not GPU accessible.
797cdc0497Smrg * Memory in this pool could be swapped out to disk if there is pressure.
807cdc0497Smrg *
817cdc0497Smrg * %AMDGPU_GEM_DOMAIN_GTT	GPU accessible system memory, mapped into the
827cdc0497Smrg * GPU's virtual address space via gart. Gart memory linearizes non-contiguous
830ed5401bSmrg * pages of system memory, allows GPU access system memory in a linearized
847cdc0497Smrg * fashion.
857cdc0497Smrg *
867cdc0497Smrg * %AMDGPU_GEM_DOMAIN_VRAM	Local video memory. For APUs, it is memory
877cdc0497Smrg * carved out by the BIOS.
887cdc0497Smrg *
897cdc0497Smrg * %AMDGPU_GEM_DOMAIN_GDS	Global on-chip data storage used to share data
907cdc0497Smrg * across shader threads.
917cdc0497Smrg *
927cdc0497Smrg * %AMDGPU_GEM_DOMAIN_GWS	Global wave sync, used to synchronize the
937cdc0497Smrg * execution of all the waves on a device.
947cdc0497Smrg *
957cdc0497Smrg * %AMDGPU_GEM_DOMAIN_OA	Ordered append, used by 3D or Compute engines
967cdc0497Smrg * for appending data.
97bbff01ceSmrg *
98bbff01ceSmrg * %AMDGPU_GEM_DOMAIN_DOORBELL	Doorbell. It is an MMIO region for
99bbff01ceSmrg * signalling user mode queues.
1007cdc0497Smrg */
1013f012e29Smrg#define AMDGPU_GEM_DOMAIN_CPU		0x1
1023f012e29Smrg#define AMDGPU_GEM_DOMAIN_GTT		0x2
1033f012e29Smrg#define AMDGPU_GEM_DOMAIN_VRAM		0x4
1043f012e29Smrg#define AMDGPU_GEM_DOMAIN_GDS		0x8
1053f012e29Smrg#define AMDGPU_GEM_DOMAIN_GWS		0x10
1063f012e29Smrg#define AMDGPU_GEM_DOMAIN_OA		0x20
107bbff01ceSmrg#define AMDGPU_GEM_DOMAIN_DOORBELL	0x40
1087cdc0497Smrg#define AMDGPU_GEM_DOMAIN_MASK		(AMDGPU_GEM_DOMAIN_CPU | \
1097cdc0497Smrg					 AMDGPU_GEM_DOMAIN_GTT | \
1107cdc0497Smrg					 AMDGPU_GEM_DOMAIN_VRAM | \
1117cdc0497Smrg					 AMDGPU_GEM_DOMAIN_GDS | \
1127cdc0497Smrg					 AMDGPU_GEM_DOMAIN_GWS | \
113bbff01ceSmrg					 AMDGPU_GEM_DOMAIN_OA | \
114bbff01ceSmrg					 AMDGPU_GEM_DOMAIN_DOORBELL)
1153f012e29Smrg
1163f012e29Smrg/* Flag that CPU access will be required for the case of VRAM domain */
1173f012e29Smrg#define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED	(1 << 0)
1183f012e29Smrg/* Flag that CPU access will not work, this VRAM domain is invisible */
1193f012e29Smrg#define AMDGPU_GEM_CREATE_NO_CPU_ACCESS		(1 << 1)
1203f012e29Smrg/* Flag that USWC attributes should be used for GTT */
1213f012e29Smrg#define AMDGPU_GEM_CREATE_CPU_GTT_USWC		(1 << 2)
122037b3c26Smrg/* Flag that the memory should be in VRAM and cleared */
123037b3c26Smrg#define AMDGPU_GEM_CREATE_VRAM_CLEARED		(1 << 3)
124d8807b2fSmrg/* Flag that allocating the BO should use linear VRAM */
125d8807b2fSmrg#define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS	(1 << 5)
12600a23bdaSmrg/* Flag that BO is always valid in this VM */
12700a23bdaSmrg#define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID	(1 << 6)
12800a23bdaSmrg/* Flag that BO sharing will be explicitly synchronized */
12900a23bdaSmrg#define AMDGPU_GEM_CREATE_EXPLICIT_SYNC		(1 << 7)
1307cdc0497Smrg/* Flag that indicates allocating MQD gart on GFX9, where the mtype
13141687f09Smrg * for the second page onward should be set to NC. It should never
13241687f09Smrg * be used by user space applications.
1337cdc0497Smrg */
13441687f09Smrg#define AMDGPU_GEM_CREATE_CP_MQD_GFX9		(1 << 8)
13588f8a8d2Smrg/* Flag that BO may contain sensitive data that must be wiped before
13688f8a8d2Smrg * releasing the memory
13788f8a8d2Smrg */
13888f8a8d2Smrg#define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE	(1 << 9)
13941687f09Smrg/* Flag that BO will be encrypted and that the TMZ bit should be
14041687f09Smrg * set in the PTEs when mapping this buffer via GPUVM or
14141687f09Smrg * accessing it with various hw blocks
14241687f09Smrg */
14341687f09Smrg#define AMDGPU_GEM_CREATE_ENCRYPTED		(1 << 10)
14449ef06a4Smrg/* Flag that BO will be used only in preemptible context, which does
14549ef06a4Smrg * not require GTT memory accounting
14649ef06a4Smrg */
14749ef06a4Smrg#define AMDGPU_GEM_CREATE_PREEMPTIBLE		(1 << 11)
148bbff01ceSmrg/* Flag that BO can be discarded under memory pressure without keeping the
149bbff01ceSmrg * content.
150bbff01ceSmrg */
151bbff01ceSmrg#define AMDGPU_GEM_CREATE_DISCARDABLE		(1 << 12)
152bbff01ceSmrg/* Flag that BO is shared coherently between multiple devices or CPU threads.
153bbff01ceSmrg * May depend on GPU instructions to flush caches to system scope explicitly.
154bbff01ceSmrg *
155bbff01ceSmrg * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
156bbff01ceSmrg * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
157bbff01ceSmrg */
158bbff01ceSmrg#define AMDGPU_GEM_CREATE_COHERENT		(1 << 13)
159bbff01ceSmrg/* Flag that BO should not be cached by GPU. Coherent without having to flush
160bbff01ceSmrg * GPU caches explicitly
161bbff01ceSmrg *
162bbff01ceSmrg * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
163bbff01ceSmrg * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
164bbff01ceSmrg */
165bbff01ceSmrg#define AMDGPU_GEM_CREATE_UNCACHED		(1 << 14)
166bbff01ceSmrg/* Flag that BO should be coherent across devices when using device-level
167bbff01ceSmrg * atomics. May depend on GPU instructions to flush caches to device scope
168bbff01ceSmrg * explicitly, promoting them to system scope automatically.
169bbff01ceSmrg *
170bbff01ceSmrg * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
171bbff01ceSmrg * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
172bbff01ceSmrg */
173bbff01ceSmrg#define AMDGPU_GEM_CREATE_EXT_COHERENT		(1 << 15)
1743f012e29Smrg
1753f012e29Smrgstruct drm_amdgpu_gem_create_in  {
1763f012e29Smrg	/** the requested memory size */
177d8807b2fSmrg	__u64 bo_size;
1783f012e29Smrg	/** physical start_addr alignment in bytes for some HW requirements */
179d8807b2fSmrg	__u64 alignment;
1803f012e29Smrg	/** the requested memory domains */
181d8807b2fSmrg	__u64 domains;
1823f012e29Smrg	/** allocation flags */
183d8807b2fSmrg	__u64 domain_flags;
1843f012e29Smrg};
1853f012e29Smrg
1863f012e29Smrgstruct drm_amdgpu_gem_create_out  {
1873f012e29Smrg	/** returned GEM object handle */
188d8807b2fSmrg	__u32 handle;
189d8807b2fSmrg	__u32 _pad;
1903f012e29Smrg};
1913f012e29Smrg
1923f012e29Smrgunion drm_amdgpu_gem_create {
1933f012e29Smrg	struct drm_amdgpu_gem_create_in		in;
1943f012e29Smrg	struct drm_amdgpu_gem_create_out	out;
1953f012e29Smrg};
1963f012e29Smrg
1973f012e29Smrg/** Opcode to create new residency list.  */
1983f012e29Smrg#define AMDGPU_BO_LIST_OP_CREATE	0
1993f012e29Smrg/** Opcode to destroy previously created residency list */
2003f012e29Smrg#define AMDGPU_BO_LIST_OP_DESTROY	1
2013f012e29Smrg/** Opcode to update resource information in the list */
2023f012e29Smrg#define AMDGPU_BO_LIST_OP_UPDATE	2
2033f012e29Smrg
2043f012e29Smrgstruct drm_amdgpu_bo_list_in {
2053f012e29Smrg	/** Type of operation */
206d8807b2fSmrg	__u32 operation;
2073f012e29Smrg	/** Handle of list or 0 if we want to create one */
208d8807b2fSmrg	__u32 list_handle;
2093f012e29Smrg	/** Number of BOs in list  */
210d8807b2fSmrg	__u32 bo_number;
2113f012e29Smrg	/** Size of each element describing BO */
212d8807b2fSmrg	__u32 bo_info_size;
2133f012e29Smrg	/** Pointer to array describing BOs */
214d8807b2fSmrg	__u64 bo_info_ptr;
2153f012e29Smrg};
2163f012e29Smrg
2173f012e29Smrgstruct drm_amdgpu_bo_list_entry {
2183f012e29Smrg	/** Handle of BO */
219d8807b2fSmrg	__u32 bo_handle;
2203f012e29Smrg	/** New (if specified) BO priority to be used during migration */
221d8807b2fSmrg	__u32 bo_priority;
2223f012e29Smrg};
2233f012e29Smrg
2243f012e29Smrgstruct drm_amdgpu_bo_list_out {
2253f012e29Smrg	/** Handle of resource list  */
226d8807b2fSmrg	__u32 list_handle;
227d8807b2fSmrg	__u32 _pad;
2283f012e29Smrg};
2293f012e29Smrg
2303f012e29Smrgunion drm_amdgpu_bo_list {
2313f012e29Smrg	struct drm_amdgpu_bo_list_in in;
2323f012e29Smrg	struct drm_amdgpu_bo_list_out out;
2333f012e29Smrg};
2343f012e29Smrg
2353f012e29Smrg/* context related */
2363f012e29Smrg#define AMDGPU_CTX_OP_ALLOC_CTX	1
2373f012e29Smrg#define AMDGPU_CTX_OP_FREE_CTX	2
2383f012e29Smrg#define AMDGPU_CTX_OP_QUERY_STATE	3
2397cdc0497Smrg#define AMDGPU_CTX_OP_QUERY_STATE2	4
2400ed5401bSmrg#define AMDGPU_CTX_OP_GET_STABLE_PSTATE	5
2410ed5401bSmrg#define AMDGPU_CTX_OP_SET_STABLE_PSTATE	6
2423f012e29Smrg
2433f012e29Smrg/* GPU reset status */
2443f012e29Smrg#define AMDGPU_CTX_NO_RESET		0
2453f012e29Smrg/* this the context caused it */
2463f012e29Smrg#define AMDGPU_CTX_GUILTY_RESET		1
2473f012e29Smrg/* some other context caused it */
2483f012e29Smrg#define AMDGPU_CTX_INNOCENT_RESET	2
2493f012e29Smrg/* unknown cause */
2503f012e29Smrg#define AMDGPU_CTX_UNKNOWN_RESET	3
2513f012e29Smrg
252bbff01ceSmrg/* indicate gpu reset occurred after ctx created */
2537cdc0497Smrg#define AMDGPU_CTX_QUERY2_FLAGS_RESET    (1<<0)
254bbff01ceSmrg/* indicate vram lost occurred after ctx created */
2557cdc0497Smrg#define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)
2567cdc0497Smrg/* indicate some job from this context once cause gpu hang */
2577cdc0497Smrg#define AMDGPU_CTX_QUERY2_FLAGS_GUILTY   (1<<2)
2585324fb0dSmrg/* indicate some errors are detected by RAS */
2595324fb0dSmrg#define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE   (1<<3)
2605324fb0dSmrg#define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE   (1<<4)
261bbff01ceSmrg/* indicate that the reset hasn't completed yet */
262bbff01ceSmrg#define AMDGPU_CTX_QUERY2_FLAGS_RESET_IN_PROGRESS (1<<5)
2637cdc0497Smrg
26400a23bdaSmrg/* Context priority level */
26500a23bdaSmrg#define AMDGPU_CTX_PRIORITY_UNSET       -2048
26600a23bdaSmrg#define AMDGPU_CTX_PRIORITY_VERY_LOW    -1023
26700a23bdaSmrg#define AMDGPU_CTX_PRIORITY_LOW         -512
26800a23bdaSmrg#define AMDGPU_CTX_PRIORITY_NORMAL      0
26988f8a8d2Smrg/*
27088f8a8d2Smrg * When used in struct drm_amdgpu_ctx_in, a priority above NORMAL requires
27188f8a8d2Smrg * CAP_SYS_NICE or DRM_MASTER
27288f8a8d2Smrg*/
27300a23bdaSmrg#define AMDGPU_CTX_PRIORITY_HIGH        512
27400a23bdaSmrg#define AMDGPU_CTX_PRIORITY_VERY_HIGH   1023
27500a23bdaSmrg
2760ed5401bSmrg/* select a stable profiling pstate for perfmon tools */
2770ed5401bSmrg#define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK  0xf
2780ed5401bSmrg#define AMDGPU_CTX_STABLE_PSTATE_NONE  0
2790ed5401bSmrg#define AMDGPU_CTX_STABLE_PSTATE_STANDARD  1
2800ed5401bSmrg#define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK  2
2810ed5401bSmrg#define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK  3
2820ed5401bSmrg#define AMDGPU_CTX_STABLE_PSTATE_PEAK  4
2830ed5401bSmrg
2843f012e29Smrgstruct drm_amdgpu_ctx_in {
2853f012e29Smrg	/** AMDGPU_CTX_OP_* */
286d8807b2fSmrg	__u32	op;
2870ed5401bSmrg	/** Flags */
288d8807b2fSmrg	__u32	flags;
289d8807b2fSmrg	__u32	ctx_id;
29088f8a8d2Smrg	/** AMDGPU_CTX_PRIORITY_* */
29100a23bdaSmrg	__s32	priority;
2923f012e29Smrg};
2933f012e29Smrg
2943f012e29Smrgunion drm_amdgpu_ctx_out {
2953f012e29Smrg		struct {
296d8807b2fSmrg			__u32	ctx_id;
297d8807b2fSmrg			__u32	_pad;
2983f012e29Smrg		} alloc;
2993f012e29Smrg
3003f012e29Smrg		struct {
3013f012e29Smrg			/** For future use, no flags defined so far */
302d8807b2fSmrg			__u64	flags;
3033f012e29Smrg			/** Number of resets caused by this context so far. */
304d8807b2fSmrg			__u32	hangs;
3053f012e29Smrg			/** Reset status since the last call of the ioctl. */
306d8807b2fSmrg			__u32	reset_status;
3073f012e29Smrg		} state;
3080ed5401bSmrg
3090ed5401bSmrg		struct {
3100ed5401bSmrg			__u32	flags;
3110ed5401bSmrg			__u32	_pad;
3120ed5401bSmrg		} pstate;
3133f012e29Smrg};
3143f012e29Smrg
3153f012e29Smrgunion drm_amdgpu_ctx {
3163f012e29Smrg	struct drm_amdgpu_ctx_in in;
3173f012e29Smrg	union drm_amdgpu_ctx_out out;
3183f012e29Smrg};
3193f012e29Smrg
320d8807b2fSmrg/* vm ioctl */
321d8807b2fSmrg#define AMDGPU_VM_OP_RESERVE_VMID	1
322d8807b2fSmrg#define AMDGPU_VM_OP_UNRESERVE_VMID	2
323d8807b2fSmrg
324d8807b2fSmrgstruct drm_amdgpu_vm_in {
325d8807b2fSmrg	/** AMDGPU_VM_OP_* */
326d8807b2fSmrg	__u32	op;
327d8807b2fSmrg	__u32	flags;
328d8807b2fSmrg};
329d8807b2fSmrg
330d8807b2fSmrgstruct drm_amdgpu_vm_out {
331d8807b2fSmrg	/** For future use, no flags defined so far */
332d8807b2fSmrg	__u64	flags;
333d8807b2fSmrg};
334d8807b2fSmrg
335d8807b2fSmrgunion drm_amdgpu_vm {
336d8807b2fSmrg	struct drm_amdgpu_vm_in in;
337d8807b2fSmrg	struct drm_amdgpu_vm_out out;
338d8807b2fSmrg};
339d8807b2fSmrg
34000a23bdaSmrg/* sched ioctl */
34100a23bdaSmrg#define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE	1
3425324fb0dSmrg#define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE	2
34300a23bdaSmrg
34400a23bdaSmrgstruct drm_amdgpu_sched_in {
34500a23bdaSmrg	/* AMDGPU_SCHED_OP_* */
34600a23bdaSmrg	__u32	op;
34700a23bdaSmrg	__u32	fd;
34888f8a8d2Smrg	/** AMDGPU_CTX_PRIORITY_* */
34900a23bdaSmrg	__s32	priority;
3505324fb0dSmrg	__u32   ctx_id;
35100a23bdaSmrg};
35200a23bdaSmrg
35300a23bdaSmrgunion drm_amdgpu_sched {
35400a23bdaSmrg	struct drm_amdgpu_sched_in in;
35500a23bdaSmrg};
35600a23bdaSmrg
3573f012e29Smrg/*
3583f012e29Smrg * This is not a reliable API and you should expect it to fail for any
3593f012e29Smrg * number of reasons and have fallback path that do not use userptr to
3603f012e29Smrg * perform any operation.
3613f012e29Smrg */
3623f012e29Smrg#define AMDGPU_GEM_USERPTR_READONLY	(1 << 0)
3633f012e29Smrg#define AMDGPU_GEM_USERPTR_ANONONLY	(1 << 1)
3643f012e29Smrg#define AMDGPU_GEM_USERPTR_VALIDATE	(1 << 2)
3653f012e29Smrg#define AMDGPU_GEM_USERPTR_REGISTER	(1 << 3)
3663f012e29Smrg
3673f012e29Smrgstruct drm_amdgpu_gem_userptr {
368d8807b2fSmrg	__u64		addr;
369d8807b2fSmrg	__u64		size;
3703f012e29Smrg	/* AMDGPU_GEM_USERPTR_* */
371d8807b2fSmrg	__u32		flags;
3723f012e29Smrg	/* Resulting GEM handle */
373d8807b2fSmrg	__u32		handle;
3743f012e29Smrg};
3753f012e29Smrg
376d8807b2fSmrg/* SI-CI-VI: */
3773f012e29Smrg/* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
3783f012e29Smrg#define AMDGPU_TILING_ARRAY_MODE_SHIFT			0
3793f012e29Smrg#define AMDGPU_TILING_ARRAY_MODE_MASK			0xf
3803f012e29Smrg#define AMDGPU_TILING_PIPE_CONFIG_SHIFT			4
3813f012e29Smrg#define AMDGPU_TILING_PIPE_CONFIG_MASK			0x1f
3823f012e29Smrg#define AMDGPU_TILING_TILE_SPLIT_SHIFT			9
3833f012e29Smrg#define AMDGPU_TILING_TILE_SPLIT_MASK			0x7
3843f012e29Smrg#define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT		12
3853f012e29Smrg#define AMDGPU_TILING_MICRO_TILE_MODE_MASK		0x7
3863f012e29Smrg#define AMDGPU_TILING_BANK_WIDTH_SHIFT			15
3873f012e29Smrg#define AMDGPU_TILING_BANK_WIDTH_MASK			0x3
3883f012e29Smrg#define AMDGPU_TILING_BANK_HEIGHT_SHIFT			17
3893f012e29Smrg#define AMDGPU_TILING_BANK_HEIGHT_MASK			0x3
3903f012e29Smrg#define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT		19
3913f012e29Smrg#define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK		0x3
3923f012e29Smrg#define AMDGPU_TILING_NUM_BANKS_SHIFT			21
3933f012e29Smrg#define AMDGPU_TILING_NUM_BANKS_MASK			0x3
3943f012e29Smrg
395bbff01ceSmrg/* GFX9 - GFX11: */
396d8807b2fSmrg#define AMDGPU_TILING_SWIZZLE_MODE_SHIFT		0
397d8807b2fSmrg#define AMDGPU_TILING_SWIZZLE_MODE_MASK			0x1f
3986532f28eSmrg#define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT		5
3996532f28eSmrg#define AMDGPU_TILING_DCC_OFFSET_256B_MASK		0xFFFFFF
4006532f28eSmrg#define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT		29
4016532f28eSmrg#define AMDGPU_TILING_DCC_PITCH_MAX_MASK		0x3FFF
4026532f28eSmrg#define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT		43
4036532f28eSmrg#define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK		0x1
40441687f09Smrg#define AMDGPU_TILING_DCC_INDEPENDENT_128B_SHIFT	44
40541687f09Smrg#define AMDGPU_TILING_DCC_INDEPENDENT_128B_MASK		0x1
40641687f09Smrg#define AMDGPU_TILING_SCANOUT_SHIFT			63
40741687f09Smrg#define AMDGPU_TILING_SCANOUT_MASK			0x1
408d8807b2fSmrg
409bbff01ceSmrg/* GFX12 and later: */
410bbff01ceSmrg#define AMDGPU_TILING_GFX12_SWIZZLE_MODE_SHIFT			0
411bbff01ceSmrg#define AMDGPU_TILING_GFX12_SWIZZLE_MODE_MASK			0x7
412bbff01ceSmrg/* These are DCC recompression setting for memory management: */
413bbff01ceSmrg#define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_SHIFT	3
414bbff01ceSmrg#define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_MASK	0x3 /* 0:64B, 1:128B, 2:256B */
415bbff01ceSmrg#define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_SHIFT		5
416bbff01ceSmrg#define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_MASK		0x7 /* CB_COLOR0_INFO.NUMBER_TYPE */
417bbff01ceSmrg#define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_SHIFT		8
418bbff01ceSmrg#define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_MASK		0x3f /* [0:4]:CB_COLOR0_INFO.FORMAT, [5]:MM */
419bbff01ceSmrg
420d8807b2fSmrg/* Set/Get helpers for tiling flags. */
4213f012e29Smrg#define AMDGPU_TILING_SET(field, value) \
422d8807b2fSmrg	(((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
4233f012e29Smrg#define AMDGPU_TILING_GET(value, field) \
424d8807b2fSmrg	(((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
4253f012e29Smrg
4263f012e29Smrg#define AMDGPU_GEM_METADATA_OP_SET_METADATA                  1
4273f012e29Smrg#define AMDGPU_GEM_METADATA_OP_GET_METADATA                  2
4283f012e29Smrg
4293f012e29Smrg/** The same structure is shared for input/output */
4303f012e29Smrgstruct drm_amdgpu_gem_metadata {
4313f012e29Smrg	/** GEM Object handle */
432d8807b2fSmrg	__u32	handle;
4333f012e29Smrg	/** Do we want get or set metadata */
434d8807b2fSmrg	__u32	op;
4353f012e29Smrg	struct {
4363f012e29Smrg		/** For future use, no flags defined so far */
437d8807b2fSmrg		__u64	flags;
4383f012e29Smrg		/** family specific tiling info */
439d8807b2fSmrg		__u64	tiling_info;
440d8807b2fSmrg		__u32	data_size_bytes;
441d8807b2fSmrg		__u32	data[64];
4423f012e29Smrg	} data;
4433f012e29Smrg};
4443f012e29Smrg
4453f012e29Smrgstruct drm_amdgpu_gem_mmap_in {
4463f012e29Smrg	/** the GEM object handle */
447d8807b2fSmrg	__u32 handle;
448d8807b2fSmrg	__u32 _pad;
4493f012e29Smrg};
4503f012e29Smrg
4513f012e29Smrgstruct drm_amdgpu_gem_mmap_out {
4523f012e29Smrg	/** mmap offset from the vma offset manager */
453d8807b2fSmrg	__u64 addr_ptr;
4543f012e29Smrg};
4553f012e29Smrg
4563f012e29Smrgunion drm_amdgpu_gem_mmap {
4573f012e29Smrg	struct drm_amdgpu_gem_mmap_in   in;
4583f012e29Smrg	struct drm_amdgpu_gem_mmap_out out;
4593f012e29Smrg};
4603f012e29Smrg
4613f012e29Smrgstruct drm_amdgpu_gem_wait_idle_in {
4623f012e29Smrg	/** GEM object handle */
463d8807b2fSmrg	__u32 handle;
4643f012e29Smrg	/** For future use, no flags defined so far */
465d8807b2fSmrg	__u32 flags;
4663f012e29Smrg	/** Absolute timeout to wait */
467d8807b2fSmrg	__u64 timeout;
4683f012e29Smrg};
4693f012e29Smrg
4703f012e29Smrgstruct drm_amdgpu_gem_wait_idle_out {
4713f012e29Smrg	/** BO status:  0 - BO is idle, 1 - BO is busy */
472d8807b2fSmrg	__u32 status;
4733f012e29Smrg	/** Returned current memory domain */
474d8807b2fSmrg	__u32 domain;
4753f012e29Smrg};
4763f012e29Smrg
4773f012e29Smrgunion drm_amdgpu_gem_wait_idle {
4783f012e29Smrg	struct drm_amdgpu_gem_wait_idle_in  in;
4793f012e29Smrg	struct drm_amdgpu_gem_wait_idle_out out;
4803f012e29Smrg};
4813f012e29Smrg
4823f012e29Smrgstruct drm_amdgpu_wait_cs_in {
483d8807b2fSmrg	/* Command submission handle
484d8807b2fSmrg         * handle equals 0 means none to wait for
485d8807b2fSmrg         * handle equals ~0ull means wait for the latest sequence number
486d8807b2fSmrg         */
487d8807b2fSmrg	__u64 handle;
4883f012e29Smrg	/** Absolute timeout to wait */
489d8807b2fSmrg	__u64 timeout;
490d8807b2fSmrg	__u32 ip_type;
491d8807b2fSmrg	__u32 ip_instance;
492d8807b2fSmrg	__u32 ring;
493d8807b2fSmrg	__u32 ctx_id;
4943f012e29Smrg};
4953f012e29Smrg
4963f012e29Smrgstruct drm_amdgpu_wait_cs_out {
4973f012e29Smrg	/** CS status:  0 - CS completed, 1 - CS still busy */
498d8807b2fSmrg	__u64 status;
4993f012e29Smrg};
5003f012e29Smrg
5013f012e29Smrgunion drm_amdgpu_wait_cs {
5023f012e29Smrg	struct drm_amdgpu_wait_cs_in in;
5033f012e29Smrg	struct drm_amdgpu_wait_cs_out out;
5043f012e29Smrg};
5053f012e29Smrg
506d8807b2fSmrgstruct drm_amdgpu_fence {
507d8807b2fSmrg	__u32 ctx_id;
508d8807b2fSmrg	__u32 ip_type;
509d8807b2fSmrg	__u32 ip_instance;
510d8807b2fSmrg	__u32 ring;
511d8807b2fSmrg	__u64 seq_no;
512d8807b2fSmrg};
513d8807b2fSmrg
514d8807b2fSmrgstruct drm_amdgpu_wait_fences_in {
515d8807b2fSmrg	/** This points to uint64_t * which points to fences */
516d8807b2fSmrg	__u64 fences;
517d8807b2fSmrg	__u32 fence_count;
518d8807b2fSmrg	__u32 wait_all;
519d8807b2fSmrg	__u64 timeout_ns;
520d8807b2fSmrg};
521d8807b2fSmrg
522d8807b2fSmrgstruct drm_amdgpu_wait_fences_out {
523d8807b2fSmrg	__u32 status;
524d8807b2fSmrg	__u32 first_signaled;
525d8807b2fSmrg};
526d8807b2fSmrg
527d8807b2fSmrgunion drm_amdgpu_wait_fences {
528d8807b2fSmrg	struct drm_amdgpu_wait_fences_in in;
529d8807b2fSmrg	struct drm_amdgpu_wait_fences_out out;
530d8807b2fSmrg};
531d8807b2fSmrg
5323f012e29Smrg#define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO	0
5333f012e29Smrg#define AMDGPU_GEM_OP_SET_PLACEMENT		1
5343f012e29Smrg
5353f012e29Smrg/* Sets or returns a value associated with a buffer. */
5363f012e29Smrgstruct drm_amdgpu_gem_op {
5373f012e29Smrg	/** GEM object handle */
538d8807b2fSmrg	__u32	handle;
5393f012e29Smrg	/** AMDGPU_GEM_OP_* */
540d8807b2fSmrg	__u32	op;
5413f012e29Smrg	/** Input or return value */
542d8807b2fSmrg	__u64	value;
5433f012e29Smrg};
5443f012e29Smrg
5453f012e29Smrg#define AMDGPU_VA_OP_MAP			1
5463f012e29Smrg#define AMDGPU_VA_OP_UNMAP			2
547d8807b2fSmrg#define AMDGPU_VA_OP_CLEAR			3
548d8807b2fSmrg#define AMDGPU_VA_OP_REPLACE			4
5493f012e29Smrg
5503f012e29Smrg/* Delay the page table update till the next CS */
5513f012e29Smrg#define AMDGPU_VM_DELAY_UPDATE		(1 << 0)
5523f012e29Smrg
5533f012e29Smrg/* Mapping flags */
5543f012e29Smrg/* readable mapping */
5553f012e29Smrg#define AMDGPU_VM_PAGE_READABLE		(1 << 1)
5563f012e29Smrg/* writable mapping */
5573f012e29Smrg#define AMDGPU_VM_PAGE_WRITEABLE	(1 << 2)
5583f012e29Smrg/* executable mapping, new for VI */
5593f012e29Smrg#define AMDGPU_VM_PAGE_EXECUTABLE	(1 << 3)
560d8807b2fSmrg/* partially resident texture */
561d8807b2fSmrg#define AMDGPU_VM_PAGE_PRT		(1 << 4)
562d8807b2fSmrg/* MTYPE flags use bit 5 to 8 */
563d8807b2fSmrg#define AMDGPU_VM_MTYPE_MASK		(0xf << 5)
564d8807b2fSmrg/* Default MTYPE. Pre-AI must use this.  Recommended for newer ASICs. */
565d8807b2fSmrg#define AMDGPU_VM_MTYPE_DEFAULT		(0 << 5)
56641687f09Smrg/* Use Non Coherent MTYPE instead of default MTYPE */
567d8807b2fSmrg#define AMDGPU_VM_MTYPE_NC		(1 << 5)
56841687f09Smrg/* Use Write Combine MTYPE instead of default MTYPE */
569d8807b2fSmrg#define AMDGPU_VM_MTYPE_WC		(2 << 5)
57041687f09Smrg/* Use Cache Coherent MTYPE instead of default MTYPE */
571d8807b2fSmrg#define AMDGPU_VM_MTYPE_CC		(3 << 5)
57241687f09Smrg/* Use UnCached MTYPE instead of default MTYPE */
573d8807b2fSmrg#define AMDGPU_VM_MTYPE_UC		(4 << 5)
57441687f09Smrg/* Use Read Write MTYPE instead of default MTYPE */
57541687f09Smrg#define AMDGPU_VM_MTYPE_RW		(5 << 5)
576bbff01ceSmrg/* don't allocate MALL */
577bbff01ceSmrg#define AMDGPU_VM_PAGE_NOALLOC		(1 << 9)
5783f012e29Smrg
5793f012e29Smrgstruct drm_amdgpu_gem_va {
5803f012e29Smrg	/** GEM object handle */
581d8807b2fSmrg	__u32 handle;
582d8807b2fSmrg	__u32 _pad;
5833f012e29Smrg	/** AMDGPU_VA_OP_* */
584d8807b2fSmrg	__u32 operation;
5853f012e29Smrg	/** AMDGPU_VM_PAGE_* */
586d8807b2fSmrg	__u32 flags;
5873f012e29Smrg	/** va address to assign . Must be correctly aligned.*/
588d8807b2fSmrg	__u64 va_address;
5893f012e29Smrg	/** Specify offset inside of BO to assign. Must be correctly aligned.*/
590d8807b2fSmrg	__u64 offset_in_bo;
5913f012e29Smrg	/** Specify mapping size. Must be correctly aligned. */
592d8807b2fSmrg	__u64 map_size;
5933f012e29Smrg};
5943f012e29Smrg
5953f012e29Smrg#define AMDGPU_HW_IP_GFX          0
5963f012e29Smrg#define AMDGPU_HW_IP_COMPUTE      1
5973f012e29Smrg#define AMDGPU_HW_IP_DMA          2
5983f012e29Smrg#define AMDGPU_HW_IP_UVD          3
5993f012e29Smrg#define AMDGPU_HW_IP_VCE          4
600d8807b2fSmrg#define AMDGPU_HW_IP_UVD_ENC      5
601d8807b2fSmrg#define AMDGPU_HW_IP_VCN_DEC      6
602b0ab5608Smrg/*
603b0ab5608Smrg * From VCN4, AMDGPU_HW_IP_VCN_ENC is re-used to support
604b0ab5608Smrg * both encoding and decoding jobs.
605b0ab5608Smrg */
606d8807b2fSmrg#define AMDGPU_HW_IP_VCN_ENC      7
6077cdc0497Smrg#define AMDGPU_HW_IP_VCN_JPEG     8
608bbff01ceSmrg#define AMDGPU_HW_IP_VPE          9
609bbff01ceSmrg#define AMDGPU_HW_IP_NUM          10
6103f012e29Smrg
6113f012e29Smrg#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
6123f012e29Smrg
6133f012e29Smrg#define AMDGPU_CHUNK_ID_IB		0x01
6143f012e29Smrg#define AMDGPU_CHUNK_ID_FENCE		0x02
6153f012e29Smrg#define AMDGPU_CHUNK_ID_DEPENDENCIES	0x03
616d8807b2fSmrg#define AMDGPU_CHUNK_ID_SYNCOBJ_IN      0x04
617d8807b2fSmrg#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT     0x05
6187cdc0497Smrg#define AMDGPU_CHUNK_ID_BO_HANDLES      0x06
6195324fb0dSmrg#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES	0x07
6205324fb0dSmrg#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
6215324fb0dSmrg#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
622bbff01ceSmrg#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
6233f012e29Smrg
6243f012e29Smrgstruct drm_amdgpu_cs_chunk {
625d8807b2fSmrg	__u32		chunk_id;
626d8807b2fSmrg	__u32		length_dw;
627d8807b2fSmrg	__u64		chunk_data;
6283f012e29Smrg};
6293f012e29Smrg
6303f012e29Smrgstruct drm_amdgpu_cs_in {
6313f012e29Smrg	/** Rendering context id */
632d8807b2fSmrg	__u32		ctx_id;
6333f012e29Smrg	/**  Handle of resource list associated with CS */
634d8807b2fSmrg	__u32		bo_list_handle;
635d8807b2fSmrg	__u32		num_chunks;
63641687f09Smrg	__u32		flags;
637d8807b2fSmrg	/** this points to __u64 * which point to cs chunks */
638d8807b2fSmrg	__u64		chunks;
6393f012e29Smrg};
6403f012e29Smrg
6413f012e29Smrgstruct drm_amdgpu_cs_out {
642d8807b2fSmrg	__u64 handle;
6433f012e29Smrg};
6443f012e29Smrg
6453f012e29Smrgunion drm_amdgpu_cs {
6463f012e29Smrg	struct drm_amdgpu_cs_in in;
6473f012e29Smrg	struct drm_amdgpu_cs_out out;
6483f012e29Smrg};
6493f012e29Smrg
6503f012e29Smrg/* Specify flags to be used for IB */
6513f012e29Smrg
6523f012e29Smrg/* This IB should be submitted to CE */
6533f012e29Smrg#define AMDGPU_IB_FLAG_CE	(1<<0)
6543f012e29Smrg
655d8807b2fSmrg/* Preamble flag, which means the IB could be dropped if no context switch */
6563f012e29Smrg#define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
6573f012e29Smrg
658d8807b2fSmrg/* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */
659d8807b2fSmrg#define AMDGPU_IB_FLAG_PREEMPT (1<<2)
660d8807b2fSmrg
6617cdc0497Smrg/* The IB fence should do the L2 writeback but not invalidate any shader
6627cdc0497Smrg * caches (L2/vL1/sL1/I$). */
6637cdc0497Smrg#define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3)
6647cdc0497Smrg
6655324fb0dSmrg/* Set GDS_COMPUTE_MAX_WAVE_ID = DEFAULT before PACKET3_INDIRECT_BUFFER.
6665324fb0dSmrg * This will reset wave ID counters for the IB.
6675324fb0dSmrg */
6685324fb0dSmrg#define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4)
6695324fb0dSmrg
67041687f09Smrg/* Flag the IB as secure (TMZ)
67141687f09Smrg */
67241687f09Smrg#define AMDGPU_IB_FLAGS_SECURE  (1 << 5)
67341687f09Smrg
67441687f09Smrg/* Tell KMD to flush and invalidate caches
67541687f09Smrg */
67641687f09Smrg#define AMDGPU_IB_FLAG_EMIT_MEM_SYNC  (1 << 6)
67741687f09Smrg
6783f012e29Smrgstruct drm_amdgpu_cs_chunk_ib {
679d8807b2fSmrg	__u32 _pad;
6803f012e29Smrg	/** AMDGPU_IB_FLAG_* */
681d8807b2fSmrg	__u32 flags;
6823f012e29Smrg	/** Virtual address to begin IB execution */
683d8807b2fSmrg	__u64 va_start;
6843f012e29Smrg	/** Size of submission */
685d8807b2fSmrg	__u32 ib_bytes;
6863f012e29Smrg	/** HW IP to submit to */
687d8807b2fSmrg	__u32 ip_type;
6883f012e29Smrg	/** HW IP index of the same type to submit to  */
689d8807b2fSmrg	__u32 ip_instance;
6903f012e29Smrg	/** Ring index to submit to */
691d8807b2fSmrg	__u32 ring;
6923f012e29Smrg};
6933f012e29Smrg
6943f012e29Smrgstruct drm_amdgpu_cs_chunk_dep {
695d8807b2fSmrg	__u32 ip_type;
696d8807b2fSmrg	__u32 ip_instance;
697d8807b2fSmrg	__u32 ring;
698d8807b2fSmrg	__u32 ctx_id;
699d8807b2fSmrg	__u64 handle;
7003f012e29Smrg};
7013f012e29Smrg
7023f012e29Smrgstruct drm_amdgpu_cs_chunk_fence {
703d8807b2fSmrg	__u32 handle;
704d8807b2fSmrg	__u32 offset;
705d8807b2fSmrg};
706d8807b2fSmrg
707d8807b2fSmrgstruct drm_amdgpu_cs_chunk_sem {
708d8807b2fSmrg	__u32 handle;
7093f012e29Smrg};
7103f012e29Smrg
7115324fb0dSmrgstruct drm_amdgpu_cs_chunk_syncobj {
71288f8a8d2Smrg       __u32 handle;
71388f8a8d2Smrg       __u32 flags;
71488f8a8d2Smrg       __u64 point;
7155324fb0dSmrg};
7165324fb0dSmrg
71700a23bdaSmrg#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ	0
71800a23bdaSmrg#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD	1
71900a23bdaSmrg#define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD	2
72000a23bdaSmrg
72100a23bdaSmrgunion drm_amdgpu_fence_to_handle {
72200a23bdaSmrg	struct {
72300a23bdaSmrg		struct drm_amdgpu_fence fence;
72400a23bdaSmrg		__u32 what;
72500a23bdaSmrg		__u32 pad;
72600a23bdaSmrg	} in;
72700a23bdaSmrg	struct {
72800a23bdaSmrg		__u32 handle;
72900a23bdaSmrg	} out;
73000a23bdaSmrg};
73100a23bdaSmrg
7323f012e29Smrgstruct drm_amdgpu_cs_chunk_data {
7333f012e29Smrg	union {
7343f012e29Smrg		struct drm_amdgpu_cs_chunk_ib		ib_data;
7353f012e29Smrg		struct drm_amdgpu_cs_chunk_fence	fence_data;
7363f012e29Smrg	};
7373f012e29Smrg};
7383f012e29Smrg
739bbff01ceSmrg#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW         0x1
740bbff01ceSmrg
741bbff01ceSmrgstruct drm_amdgpu_cs_chunk_cp_gfx_shadow {
742bbff01ceSmrg	__u64 shadow_va;
743bbff01ceSmrg	__u64 csa_va;
744bbff01ceSmrg	__u64 gds_va;
745bbff01ceSmrg	__u64 flags;
746bbff01ceSmrg};
747bbff01ceSmrg
74841687f09Smrg/*
7493f012e29Smrg *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
7503f012e29Smrg *
7513f012e29Smrg */
7523f012e29Smrg#define AMDGPU_IDS_FLAGS_FUSION         0x1
753d8807b2fSmrg#define AMDGPU_IDS_FLAGS_PREEMPTION     0x2
75441687f09Smrg#define AMDGPU_IDS_FLAGS_TMZ            0x4
755bbff01ceSmrg#define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x8
756bbff01ceSmrg
757bbff01ceSmrg/*
758bbff01ceSmrg *  Query h/w info: Flag identifying VF/PF/PT mode
759bbff01ceSmrg *
760bbff01ceSmrg */
761bbff01ceSmrg#define AMDGPU_IDS_FLAGS_MODE_MASK      0x300
762bbff01ceSmrg#define AMDGPU_IDS_FLAGS_MODE_SHIFT     0x8
763bbff01ceSmrg#define AMDGPU_IDS_FLAGS_MODE_PF        0x0
764bbff01ceSmrg#define AMDGPU_IDS_FLAGS_MODE_VF        0x1
765bbff01ceSmrg#define AMDGPU_IDS_FLAGS_MODE_PT        0x2
7663f012e29Smrg
7673f012e29Smrg/* indicate if acceleration can be working */
7683f012e29Smrg#define AMDGPU_INFO_ACCEL_WORKING		0x00
7693f012e29Smrg/* get the crtc_id from the mode object id? */
7703f012e29Smrg#define AMDGPU_INFO_CRTC_FROM_ID		0x01
7713f012e29Smrg/* query hw IP info */
7723f012e29Smrg#define AMDGPU_INFO_HW_IP_INFO			0x02
7733f012e29Smrg/* query hw IP instance count for the specified type */
7743f012e29Smrg#define AMDGPU_INFO_HW_IP_COUNT			0x03
7753f012e29Smrg/* timestamp for GL_ARB_timer_query */
7763f012e29Smrg#define AMDGPU_INFO_TIMESTAMP			0x05
7773f012e29Smrg/* Query the firmware version */
7783f012e29Smrg#define AMDGPU_INFO_FW_VERSION			0x0e
7793f012e29Smrg	/* Subquery id: Query VCE firmware version */
7803f012e29Smrg	#define AMDGPU_INFO_FW_VCE		0x1
7813f012e29Smrg	/* Subquery id: Query UVD firmware version */
7823f012e29Smrg	#define AMDGPU_INFO_FW_UVD		0x2
7833f012e29Smrg	/* Subquery id: Query GMC firmware version */
7843f012e29Smrg	#define AMDGPU_INFO_FW_GMC		0x03
7853f012e29Smrg	/* Subquery id: Query GFX ME firmware version */
7863f012e29Smrg	#define AMDGPU_INFO_FW_GFX_ME		0x04
7873f012e29Smrg	/* Subquery id: Query GFX PFP firmware version */
7883f012e29Smrg	#define AMDGPU_INFO_FW_GFX_PFP		0x05
7893f012e29Smrg	/* Subquery id: Query GFX CE firmware version */
7903f012e29Smrg	#define AMDGPU_INFO_FW_GFX_CE		0x06
7913f012e29Smrg	/* Subquery id: Query GFX RLC firmware version */
7923f012e29Smrg	#define AMDGPU_INFO_FW_GFX_RLC		0x07
7933f012e29Smrg	/* Subquery id: Query GFX MEC firmware version */
7943f012e29Smrg	#define AMDGPU_INFO_FW_GFX_MEC		0x08
7953f012e29Smrg	/* Subquery id: Query SMC firmware version */
7963f012e29Smrg	#define AMDGPU_INFO_FW_SMC		0x0a
7973f012e29Smrg	/* Subquery id: Query SDMA firmware version */
7983f012e29Smrg	#define AMDGPU_INFO_FW_SDMA		0x0b
799d8807b2fSmrg	/* Subquery id: Query PSP SOS firmware version */
800d8807b2fSmrg	#define AMDGPU_INFO_FW_SOS		0x0c
801d8807b2fSmrg	/* Subquery id: Query PSP ASD firmware version */
802d8807b2fSmrg	#define AMDGPU_INFO_FW_ASD		0x0d
8037cdc0497Smrg	/* Subquery id: Query VCN firmware version */
8047cdc0497Smrg	#define AMDGPU_INFO_FW_VCN		0x0e
8057cdc0497Smrg	/* Subquery id: Query GFX RLC SRLC firmware version */
8067cdc0497Smrg	#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f
8077cdc0497Smrg	/* Subquery id: Query GFX RLC SRLG firmware version */
8087cdc0497Smrg	#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10
8097cdc0497Smrg	/* Subquery id: Query GFX RLC SRLS firmware version */
8107cdc0497Smrg	#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11
8116532f28eSmrg	/* Subquery id: Query DMCU firmware version */
8126532f28eSmrg	#define AMDGPU_INFO_FW_DMCU		0x12
8135324fb0dSmrg	#define AMDGPU_INFO_FW_TA		0x13
81441687f09Smrg	/* Subquery id: Query DMCUB firmware version */
81541687f09Smrg	#define AMDGPU_INFO_FW_DMCUB		0x14
81641687f09Smrg	/* Subquery id: Query TOC firmware version */
81741687f09Smrg	#define AMDGPU_INFO_FW_TOC		0x15
818bbff01ceSmrg	/* Subquery id: Query CAP firmware version */
819bbff01ceSmrg	#define AMDGPU_INFO_FW_CAP		0x16
820bbff01ceSmrg	/* Subquery id: Query GFX RLCP firmware version */
821bbff01ceSmrg	#define AMDGPU_INFO_FW_GFX_RLCP		0x17
822bbff01ceSmrg	/* Subquery id: Query GFX RLCV firmware version */
823bbff01ceSmrg	#define AMDGPU_INFO_FW_GFX_RLCV		0x18
824bbff01ceSmrg	/* Subquery id: Query MES_KIQ firmware version */
825bbff01ceSmrg	#define AMDGPU_INFO_FW_MES_KIQ		0x19
826bbff01ceSmrg	/* Subquery id: Query MES firmware version */
827bbff01ceSmrg	#define AMDGPU_INFO_FW_MES		0x1a
828bbff01ceSmrg	/* Subquery id: Query IMU firmware version */
829bbff01ceSmrg	#define AMDGPU_INFO_FW_IMU		0x1b
830bbff01ceSmrg	/* Subquery id: Query VPE firmware version */
831bbff01ceSmrg	#define AMDGPU_INFO_FW_VPE		0x1c
83241687f09Smrg
8333f012e29Smrg/* number of bytes moved for TTM migration */
8343f012e29Smrg#define AMDGPU_INFO_NUM_BYTES_MOVED		0x0f
8353f012e29Smrg/* the used VRAM size */
8363f012e29Smrg#define AMDGPU_INFO_VRAM_USAGE			0x10
8373f012e29Smrg/* the used GTT size */
8383f012e29Smrg#define AMDGPU_INFO_GTT_USAGE			0x11
8393f012e29Smrg/* Information about GDS, etc. resource configuration */
8403f012e29Smrg#define AMDGPU_INFO_GDS_CONFIG			0x13
8413f012e29Smrg/* Query information about VRAM and GTT domains */
8423f012e29Smrg#define AMDGPU_INFO_VRAM_GTT			0x14
8433f012e29Smrg/* Query information about register in MMR address space*/
8443f012e29Smrg#define AMDGPU_INFO_READ_MMR_REG		0x15
8453f012e29Smrg/* Query information about device: rev id, family, etc. */
8463f012e29Smrg#define AMDGPU_INFO_DEV_INFO			0x16
8473f012e29Smrg/* visible vram usage */
8483f012e29Smrg#define AMDGPU_INFO_VIS_VRAM_USAGE		0x17
849d8807b2fSmrg/* number of TTM buffer evictions */
850d8807b2fSmrg#define AMDGPU_INFO_NUM_EVICTIONS		0x18
851d8807b2fSmrg/* Query memory about VRAM and GTT domains */
852d8807b2fSmrg#define AMDGPU_INFO_MEMORY			0x19
853d8807b2fSmrg/* Query vce clock table */
854d8807b2fSmrg#define AMDGPU_INFO_VCE_CLOCK_TABLE		0x1A
855d8807b2fSmrg/* Query vbios related information */
856d8807b2fSmrg#define AMDGPU_INFO_VBIOS			0x1B
857d8807b2fSmrg	/* Subquery id: Query vbios size */
858d8807b2fSmrg	#define AMDGPU_INFO_VBIOS_SIZE		0x1
859d8807b2fSmrg	/* Subquery id: Query vbios image */
860d8807b2fSmrg	#define AMDGPU_INFO_VBIOS_IMAGE		0x2
86149ef06a4Smrg	/* Subquery id: Query vbios info */
86249ef06a4Smrg	#define AMDGPU_INFO_VBIOS_INFO		0x3
863d8807b2fSmrg/* Query UVD handles */
864d8807b2fSmrg#define AMDGPU_INFO_NUM_HANDLES			0x1C
865d8807b2fSmrg/* Query sensor related information */
866d8807b2fSmrg#define AMDGPU_INFO_SENSOR			0x1D
867d8807b2fSmrg	/* Subquery id: Query GPU shader clock */
868d8807b2fSmrg	#define AMDGPU_INFO_SENSOR_GFX_SCLK		0x1
869d8807b2fSmrg	/* Subquery id: Query GPU memory clock */
870d8807b2fSmrg	#define AMDGPU_INFO_SENSOR_GFX_MCLK		0x2
871d8807b2fSmrg	/* Subquery id: Query GPU temperature */
872d8807b2fSmrg	#define AMDGPU_INFO_SENSOR_GPU_TEMP		0x3
873d8807b2fSmrg	/* Subquery id: Query GPU load */
874d8807b2fSmrg	#define AMDGPU_INFO_SENSOR_GPU_LOAD		0x4
875d8807b2fSmrg	/* Subquery id: Query average GPU power	*/
876d8807b2fSmrg	#define AMDGPU_INFO_SENSOR_GPU_AVG_POWER	0x5
877d8807b2fSmrg	/* Subquery id: Query northbridge voltage */
878d8807b2fSmrg	#define AMDGPU_INFO_SENSOR_VDDNB		0x6
879d8807b2fSmrg	/* Subquery id: Query graphics voltage */
880d8807b2fSmrg	#define AMDGPU_INFO_SENSOR_VDDGFX		0x7
8817cdc0497Smrg	/* Subquery id: Query GPU stable pstate shader clock */
8827cdc0497Smrg	#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK		0x8
8837cdc0497Smrg	/* Subquery id: Query GPU stable pstate memory clock */
8847cdc0497Smrg	#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK		0x9
885bbff01ceSmrg	/* Subquery id: Query GPU peak pstate shader clock */
886bbff01ceSmrg	#define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_SCLK			0xa
887bbff01ceSmrg	/* Subquery id: Query GPU peak pstate memory clock */
888bbff01ceSmrg	#define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_MCLK			0xb
889bbff01ceSmrg	/* Subquery id: Query input GPU power	*/
890bbff01ceSmrg	#define AMDGPU_INFO_SENSOR_GPU_INPUT_POWER	0xc
891d8807b2fSmrg/* Number of VRAM page faults on CPU access. */
892d8807b2fSmrg#define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS	0x1E
89300a23bdaSmrg#define AMDGPU_INFO_VRAM_LOST_COUNTER		0x1F
8945324fb0dSmrg/* query ras mask of enabled features*/
8955324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_FEATURES	0x20
8965324fb0dSmrg/* RAS MASK: UMC (VRAM) */
8975324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_UMC			(1 << 0)
8985324fb0dSmrg/* RAS MASK: SDMA */
8995324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_SDMA			(1 << 1)
9005324fb0dSmrg/* RAS MASK: GFX */
9015324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_GFX			(1 << 2)
9025324fb0dSmrg/* RAS MASK: MMHUB */
9035324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_MMHUB			(1 << 3)
9045324fb0dSmrg/* RAS MASK: ATHUB */
9055324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_ATHUB			(1 << 4)
9065324fb0dSmrg/* RAS MASK: PCIE */
9075324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_PCIE			(1 << 5)
9085324fb0dSmrg/* RAS MASK: HDP */
9095324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_HDP			(1 << 6)
9105324fb0dSmrg/* RAS MASK: XGMI */
9115324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_XGMI			(1 << 7)
9125324fb0dSmrg/* RAS MASK: DF */
9135324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_DF			(1 << 8)
9145324fb0dSmrg/* RAS MASK: SMN */
9155324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_SMN			(1 << 9)
9165324fb0dSmrg/* RAS MASK: SEM */
9175324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_SEM			(1 << 10)
9185324fb0dSmrg/* RAS MASK: MP0 */
9195324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_MP0			(1 << 11)
9205324fb0dSmrg/* RAS MASK: MP1 */
9215324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_MP1			(1 << 12)
9225324fb0dSmrg/* RAS MASK: FUSE */
9235324fb0dSmrg#define AMDGPU_INFO_RAS_ENABLED_FUSE			(1 << 13)
9240ed5401bSmrg/* query video encode/decode caps */
9250ed5401bSmrg#define AMDGPU_INFO_VIDEO_CAPS			0x21
9260ed5401bSmrg	/* Subquery id: Decode */
9270ed5401bSmrg	#define AMDGPU_INFO_VIDEO_CAPS_DECODE		0
9280ed5401bSmrg	/* Subquery id: Encode */
9290ed5401bSmrg	#define AMDGPU_INFO_VIDEO_CAPS_ENCODE		1
930bbff01ceSmrg/* Query the max number of IBs per gang per submission */
931bbff01ceSmrg#define AMDGPU_INFO_MAX_IBS			0x22
932bbff01ceSmrg/* query last page fault info */
933bbff01ceSmrg#define AMDGPU_INFO_GPUVM_FAULT			0x23
9343f012e29Smrg
9353f012e29Smrg#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT	0
9363f012e29Smrg#define AMDGPU_INFO_MMR_SE_INDEX_MASK	0xff
9373f012e29Smrg#define AMDGPU_INFO_MMR_SH_INDEX_SHIFT	8
9383f012e29Smrg#define AMDGPU_INFO_MMR_SH_INDEX_MASK	0xff
9393f012e29Smrg
940037b3c26Smrgstruct drm_amdgpu_query_fw {
941037b3c26Smrg	/** AMDGPU_INFO_FW_* */
942d8807b2fSmrg	__u32 fw_type;
943037b3c26Smrg	/**
944037b3c26Smrg	 * Index of the IP if there are more IPs of
945037b3c26Smrg	 * the same type.
946037b3c26Smrg	 */
947d8807b2fSmrg	__u32 ip_instance;
948037b3c26Smrg	/**
949037b3c26Smrg	 * Index of the engine. Whether this is used depends
950037b3c26Smrg	 * on the firmware type. (e.g. MEC, SDMA)
951037b3c26Smrg	 */
952d8807b2fSmrg	__u32 index;
953d8807b2fSmrg	__u32 _pad;
954037b3c26Smrg};
955037b3c26Smrg
9563f012e29Smrg/* Input structure for the INFO ioctl */
9573f012e29Smrgstruct drm_amdgpu_info {
9583f012e29Smrg	/* Where the return value will be stored */
959d8807b2fSmrg	__u64 return_pointer;
9603f012e29Smrg	/* The size of the return value. Just like "size" in "snprintf",
9613f012e29Smrg	 * it limits how many bytes the kernel can write. */
962d8807b2fSmrg	__u32 return_size;
9633f012e29Smrg	/* The query request id. */
964d8807b2fSmrg	__u32 query;
9653f012e29Smrg
9663f012e29Smrg	union {
9673f012e29Smrg		struct {
968d8807b2fSmrg			__u32 id;
969d8807b2fSmrg			__u32 _pad;
9703f012e29Smrg		} mode_crtc;
9713f012e29Smrg
9723f012e29Smrg		struct {
9733f012e29Smrg			/** AMDGPU_HW_IP_* */
974d8807b2fSmrg			__u32 type;
9753f012e29Smrg			/**
9763f012e29Smrg			 * Index of the IP if there are more IPs of the same
9773f012e29Smrg			 * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
9783f012e29Smrg			 */
979d8807b2fSmrg			__u32 ip_instance;
9803f012e29Smrg		} query_hw_ip;
9813f012e29Smrg
9823f012e29Smrg		struct {
983d8807b2fSmrg			__u32 dword_offset;
9843f012e29Smrg			/** number of registers to read */
985d8807b2fSmrg			__u32 count;
986d8807b2fSmrg			__u32 instance;
9873f012e29Smrg			/** For future use, no flags defined so far */
988d8807b2fSmrg			__u32 flags;
9893f012e29Smrg		} read_mmr_reg;
9903f012e29Smrg
991037b3c26Smrg		struct drm_amdgpu_query_fw query_fw;
992d8807b2fSmrg
993d8807b2fSmrg		struct {
994d8807b2fSmrg			__u32 type;
995d8807b2fSmrg			__u32 offset;
996d8807b2fSmrg		} vbios_info;
997d8807b2fSmrg
998d8807b2fSmrg		struct {
999d8807b2fSmrg			__u32 type;
1000d8807b2fSmrg		} sensor_info;
100141687f09Smrg
100241687f09Smrg		struct {
100341687f09Smrg			__u32 type;
100441687f09Smrg		} video_cap;
10053f012e29Smrg	};
10063f012e29Smrg};
10073f012e29Smrg
10083f012e29Smrgstruct drm_amdgpu_info_gds {
10093f012e29Smrg	/** GDS GFX partition size */
1010d8807b2fSmrg	__u32 gds_gfx_partition_size;
10113f012e29Smrg	/** GDS compute partition size */
1012d8807b2fSmrg	__u32 compute_partition_size;
10133f012e29Smrg	/** total GDS memory size */
1014d8807b2fSmrg	__u32 gds_total_size;
10153f012e29Smrg	/** GWS size per GFX partition */
1016d8807b2fSmrg	__u32 gws_per_gfx_partition;
10173f012e29Smrg	/** GSW size per compute partition */
1018d8807b2fSmrg	__u32 gws_per_compute_partition;
10193f012e29Smrg	/** OA size per GFX partition */
1020d8807b2fSmrg	__u32 oa_per_gfx_partition;
10213f012e29Smrg	/** OA size per compute partition */
1022d8807b2fSmrg	__u32 oa_per_compute_partition;
1023d8807b2fSmrg	__u32 _pad;
10243f012e29Smrg};
10253f012e29Smrg
10263f012e29Smrgstruct drm_amdgpu_info_vram_gtt {
1027d8807b2fSmrg	__u64 vram_size;
1028d8807b2fSmrg	__u64 vram_cpu_accessible_size;
1029d8807b2fSmrg	__u64 gtt_size;
1030d8807b2fSmrg};
1031d8807b2fSmrg
1032d8807b2fSmrgstruct drm_amdgpu_heap_info {
1033d8807b2fSmrg	/** max. physical memory */
1034d8807b2fSmrg	__u64 total_heap_size;
1035d8807b2fSmrg
1036d8807b2fSmrg	/** Theoretical max. available memory in the given heap */
1037d8807b2fSmrg	__u64 usable_heap_size;
1038d8807b2fSmrg
1039d8807b2fSmrg	/**
1040d8807b2fSmrg	 * Number of bytes allocated in the heap. This includes all processes
1041d8807b2fSmrg	 * and private allocations in the kernel. It changes when new buffers
1042d8807b2fSmrg	 * are allocated, freed, and moved. It cannot be larger than
1043d8807b2fSmrg	 * heap_size.
1044d8807b2fSmrg	 */
1045d8807b2fSmrg	__u64 heap_usage;
1046d8807b2fSmrg
1047d8807b2fSmrg	/**
1048d8807b2fSmrg	 * Theoretical possible max. size of buffer which
1049d8807b2fSmrg	 * could be allocated in the given heap
1050d8807b2fSmrg	 */
1051d8807b2fSmrg	__u64 max_allocation;
1052d8807b2fSmrg};
1053d8807b2fSmrg
1054d8807b2fSmrgstruct drm_amdgpu_memory_info {
1055d8807b2fSmrg	struct drm_amdgpu_heap_info vram;
1056d8807b2fSmrg	struct drm_amdgpu_heap_info cpu_accessible_vram;
1057d8807b2fSmrg	struct drm_amdgpu_heap_info gtt;
10583f012e29Smrg};
10593f012e29Smrg
10603f012e29Smrgstruct drm_amdgpu_info_firmware {
1061d8807b2fSmrg	__u32 ver;
1062d8807b2fSmrg	__u32 feature;
10633f012e29Smrg};
10643f012e29Smrg
106549ef06a4Smrgstruct drm_amdgpu_info_vbios {
106649ef06a4Smrg	__u8 name[64];
106749ef06a4Smrg	__u8 vbios_pn[64];
106849ef06a4Smrg	__u32 version;
106949ef06a4Smrg	__u32 pad;
107049ef06a4Smrg	__u8 vbios_ver_str[32];
107149ef06a4Smrg	__u8 date[32];
107249ef06a4Smrg};
107349ef06a4Smrg
10743f012e29Smrg#define AMDGPU_VRAM_TYPE_UNKNOWN 0
10753f012e29Smrg#define AMDGPU_VRAM_TYPE_GDDR1 1
10763f012e29Smrg#define AMDGPU_VRAM_TYPE_DDR2  2
10773f012e29Smrg#define AMDGPU_VRAM_TYPE_GDDR3 3
10783f012e29Smrg#define AMDGPU_VRAM_TYPE_GDDR4 4
10793f012e29Smrg#define AMDGPU_VRAM_TYPE_GDDR5 5
10803f012e29Smrg#define AMDGPU_VRAM_TYPE_HBM   6
10813f012e29Smrg#define AMDGPU_VRAM_TYPE_DDR3  7
10827cdc0497Smrg#define AMDGPU_VRAM_TYPE_DDR4  8
10835324fb0dSmrg#define AMDGPU_VRAM_TYPE_GDDR6 9
108441687f09Smrg#define AMDGPU_VRAM_TYPE_DDR5  10
1085bbff01ceSmrg#define AMDGPU_VRAM_TYPE_LPDDR4 11
1086bbff01ceSmrg#define AMDGPU_VRAM_TYPE_LPDDR5 12
10873f012e29Smrg
10883f012e29Smrgstruct drm_amdgpu_info_device {
10893f012e29Smrg	/** PCI Device ID */
1090d8807b2fSmrg	__u32 device_id;
10913f012e29Smrg	/** Internal chip revision: A0, A1, etc.) */
1092d8807b2fSmrg	__u32 chip_rev;
1093d8807b2fSmrg	__u32 external_rev;
10943f012e29Smrg	/** Revision id in PCI Config space */
1095d8807b2fSmrg	__u32 pci_rev;
1096d8807b2fSmrg	__u32 family;
1097d8807b2fSmrg	__u32 num_shader_engines;
1098d8807b2fSmrg	__u32 num_shader_arrays_per_engine;
10993f012e29Smrg	/* in KHz */
1100d8807b2fSmrg	__u32 gpu_counter_freq;
1101d8807b2fSmrg	__u64 max_engine_clock;
1102d8807b2fSmrg	__u64 max_memory_clock;
11033f012e29Smrg	/* cu information */
1104d8807b2fSmrg	__u32 cu_active_number;
110500a23bdaSmrg	/* NOTE: cu_ao_mask is INVALID, DON'T use it */
1106d8807b2fSmrg	__u32 cu_ao_mask;
1107d8807b2fSmrg	__u32 cu_bitmap[4][4];
11083f012e29Smrg	/** Render backend pipe mask. One render backend is CB+DB. */
1109d8807b2fSmrg	__u32 enabled_rb_pipes_mask;
1110d8807b2fSmrg	__u32 num_rb_pipes;
1111d8807b2fSmrg	__u32 num_hw_gfx_contexts;
1112bbff01ceSmrg	/* PCIe version (the smaller of the GPU and the CPU/motherboard) */
1113bbff01ceSmrg	__u32 pcie_gen;
1114d8807b2fSmrg	__u64 ids_flags;
11153f012e29Smrg	/** Starting virtual address for UMDs. */
1116d8807b2fSmrg	__u64 virtual_address_offset;
11173f012e29Smrg	/** The maximum virtual address */
1118d8807b2fSmrg	__u64 virtual_address_max;
11193f012e29Smrg	/** Required alignment of virtual addresses. */
1120d8807b2fSmrg	__u32 virtual_address_alignment;
11213f012e29Smrg	/** Page table entry - fragment size */
1122d8807b2fSmrg	__u32 pte_fragment_size;
1123d8807b2fSmrg	__u32 gart_page_size;
11243f012e29Smrg	/** constant engine ram size*/
1125d8807b2fSmrg	__u32 ce_ram_size;
11263f012e29Smrg	/** video memory type info*/
1127d8807b2fSmrg	__u32 vram_type;
11283f012e29Smrg	/** video memory bit width*/
1129d8807b2fSmrg	__u32 vram_bit_width;
11303f012e29Smrg	/* vce harvesting instance */
1131d8807b2fSmrg	__u32 vce_harvest_config;
1132d8807b2fSmrg	/* gfx double offchip LDS buffers */
1133d8807b2fSmrg	__u32 gc_double_offchip_lds_buf;
1134d8807b2fSmrg	/* NGG Primitive Buffer */
1135d8807b2fSmrg	__u64 prim_buf_gpu_addr;
1136d8807b2fSmrg	/* NGG Position Buffer */
1137d8807b2fSmrg	__u64 pos_buf_gpu_addr;
1138d8807b2fSmrg	/* NGG Control Sideband */
1139d8807b2fSmrg	__u64 cntl_sb_buf_gpu_addr;
1140d8807b2fSmrg	/* NGG Parameter Cache */
1141d8807b2fSmrg	__u64 param_buf_gpu_addr;
1142d8807b2fSmrg	__u32 prim_buf_size;
1143d8807b2fSmrg	__u32 pos_buf_size;
1144d8807b2fSmrg	__u32 cntl_sb_buf_size;
1145d8807b2fSmrg	__u32 param_buf_size;
1146d8807b2fSmrg	/* wavefront size*/
1147d8807b2fSmrg	__u32 wave_front_size;
1148d8807b2fSmrg	/* shader visible vgprs*/
1149d8807b2fSmrg	__u32 num_shader_visible_vgprs;
1150d8807b2fSmrg	/* CU per shader array*/
1151d8807b2fSmrg	__u32 num_cu_per_sh;
1152d8807b2fSmrg	/* number of tcc blocks*/
1153d8807b2fSmrg	__u32 num_tcc_blocks;
1154d8807b2fSmrg	/* gs vgt table depth*/
1155d8807b2fSmrg	__u32 gs_vgt_table_depth;
1156d8807b2fSmrg	/* gs primitive buffer depth*/
1157d8807b2fSmrg	__u32 gs_prim_buffer_depth;
1158d8807b2fSmrg	/* max gs wavefront per vgt*/
1159d8807b2fSmrg	__u32 max_gs_waves_per_vgt;
1160bbff01ceSmrg	/* PCIe number of lanes (the smaller of the GPU and the CPU/motherboard) */
1161bbff01ceSmrg	__u32 pcie_num_lanes;
116200a23bdaSmrg	/* always on cu bitmap */
116300a23bdaSmrg	__u32 cu_ao_bitmap[4][4];
116400a23bdaSmrg	/** Starting high virtual address for UMDs. */
116500a23bdaSmrg	__u64 high_va_offset;
116600a23bdaSmrg	/** The maximum high virtual address */
116700a23bdaSmrg	__u64 high_va_max;
11685324fb0dSmrg	/* gfx10 pa_sc_tile_steering_override */
11695324fb0dSmrg	__u32 pa_sc_tile_steering_override;
117088f8a8d2Smrg	/* disabled TCCs */
117188f8a8d2Smrg	__u64 tcc_disabled_mask;
1172bbff01ceSmrg	__u64 min_engine_clock;
1173bbff01ceSmrg	__u64 min_memory_clock;
1174bbff01ceSmrg	/* The following fields are only set on gfx11+, older chips set 0. */
1175bbff01ceSmrg	__u32 tcp_cache_size;       /* AKA GL0, VMEM cache */
1176bbff01ceSmrg	__u32 num_sqc_per_wgp;
1177bbff01ceSmrg	__u32 sqc_data_cache_size;  /* AKA SMEM cache */
1178bbff01ceSmrg	__u32 sqc_inst_cache_size;
1179bbff01ceSmrg	__u32 gl1c_cache_size;
1180bbff01ceSmrg	__u32 gl2c_cache_size;
1181bbff01ceSmrg	__u64 mall_size;            /* AKA infinity cache */
1182bbff01ceSmrg	/* high 32 bits of the rb pipes mask */
1183bbff01ceSmrg	__u32 enabled_rb_pipes_mask_hi;
1184bbff01ceSmrg	/* shadow area size for gfx11 */
1185bbff01ceSmrg	__u32 shadow_size;
1186bbff01ceSmrg	/* shadow area base virtual alignment for gfx11 */
1187bbff01ceSmrg	__u32 shadow_alignment;
1188bbff01ceSmrg	/* context save area size for gfx11 */
1189bbff01ceSmrg	__u32 csa_size;
1190bbff01ceSmrg	/* context save area base virtual alignment for gfx11 */
1191bbff01ceSmrg	__u32 csa_alignment;
11923f012e29Smrg};
11933f012e29Smrg
11943f012e29Smrgstruct drm_amdgpu_info_hw_ip {
11953f012e29Smrg	/** Version of h/w IP */
1196d8807b2fSmrg	__u32  hw_ip_version_major;
1197d8807b2fSmrg	__u32  hw_ip_version_minor;
11983f012e29Smrg	/** Capabilities */
1199d8807b2fSmrg	__u64  capabilities_flags;
12003f012e29Smrg	/** command buffer address start alignment*/
1201d8807b2fSmrg	__u32  ib_start_alignment;
12023f012e29Smrg	/** command buffer size alignment*/
1203d8807b2fSmrg	__u32  ib_size_alignment;
12043f012e29Smrg	/** Bitmask of available rings. Bit 0 means ring 0, etc. */
1205d8807b2fSmrg	__u32  available_rings;
1206bbff01ceSmrg	/** version info: bits 23:16 major, 15:8 minor, 7:0 revision */
1207bbff01ceSmrg	__u32  ip_discovery_version;
1208d8807b2fSmrg};
1209d8807b2fSmrg
1210d8807b2fSmrgstruct drm_amdgpu_info_num_handles {
1211d8807b2fSmrg	/** Max handles as supported by firmware for UVD */
1212d8807b2fSmrg	__u32  uvd_max_handles;
1213d8807b2fSmrg	/** Handles currently in use for UVD */
1214d8807b2fSmrg	__u32  uvd_used_handles;
1215d8807b2fSmrg};
1216d8807b2fSmrg
1217d8807b2fSmrg#define AMDGPU_VCE_CLOCK_TABLE_ENTRIES		6
1218d8807b2fSmrg
1219d8807b2fSmrgstruct drm_amdgpu_info_vce_clock_table_entry {
1220d8807b2fSmrg	/** System clock */
1221d8807b2fSmrg	__u32 sclk;
1222d8807b2fSmrg	/** Memory clock */
1223d8807b2fSmrg	__u32 mclk;
1224d8807b2fSmrg	/** VCE clock */
1225d8807b2fSmrg	__u32 eclk;
1226d8807b2fSmrg	__u32 pad;
1227d8807b2fSmrg};
1228d8807b2fSmrg
1229d8807b2fSmrgstruct drm_amdgpu_info_vce_clock_table {
1230d8807b2fSmrg	struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
1231d8807b2fSmrg	__u32 num_valid_entries;
1232d8807b2fSmrg	__u32 pad;
12333f012e29Smrg};
12343f012e29Smrg
123541687f09Smrg/* query video encode/decode caps */
123641687f09Smrg#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2			0
123741687f09Smrg#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4			1
123841687f09Smrg#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1			2
123941687f09Smrg#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC		3
124041687f09Smrg#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC			4
124141687f09Smrg#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG			5
124241687f09Smrg#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9			6
124341687f09Smrg#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1			7
124441687f09Smrg#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT			8
124541687f09Smrg
124641687f09Smrgstruct drm_amdgpu_info_video_codec_info {
124741687f09Smrg	__u32 valid;
124841687f09Smrg	__u32 max_width;
124941687f09Smrg	__u32 max_height;
125041687f09Smrg	__u32 max_pixels_per_frame;
125141687f09Smrg	__u32 max_level;
125241687f09Smrg	__u32 pad;
125341687f09Smrg};
125441687f09Smrg
125541687f09Smrgstruct drm_amdgpu_info_video_caps {
125641687f09Smrg	struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT];
125741687f09Smrg};
125841687f09Smrg
1259bbff01ceSmrg#define AMDGPU_VMHUB_TYPE_MASK			0xff
1260bbff01ceSmrg#define AMDGPU_VMHUB_TYPE_SHIFT			0
1261bbff01ceSmrg#define AMDGPU_VMHUB_TYPE_GFX			0
1262bbff01ceSmrg#define AMDGPU_VMHUB_TYPE_MM0			1
1263bbff01ceSmrg#define AMDGPU_VMHUB_TYPE_MM1			2
1264bbff01ceSmrg#define AMDGPU_VMHUB_IDX_MASK			0xff00
1265bbff01ceSmrg#define AMDGPU_VMHUB_IDX_SHIFT			8
1266bbff01ceSmrg
1267bbff01ceSmrgstruct drm_amdgpu_info_gpuvm_fault {
1268bbff01ceSmrg	__u64 addr;
1269bbff01ceSmrg	__u32 status;
1270bbff01ceSmrg	__u32 vmhub;
1271bbff01ceSmrg};
1272bbff01ceSmrg
12733f012e29Smrg/*
12743f012e29Smrg * Supported GPU families
12753f012e29Smrg */
12763f012e29Smrg#define AMDGPU_FAMILY_UNKNOWN			0
1277d8807b2fSmrg#define AMDGPU_FAMILY_SI			110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */
12783f012e29Smrg#define AMDGPU_FAMILY_CI			120 /* Bonaire, Hawaii */
12793f012e29Smrg#define AMDGPU_FAMILY_KV			125 /* Kaveri, Kabini, Mullins */
12803f012e29Smrg#define AMDGPU_FAMILY_VI			130 /* Iceland, Tonga */
1281037b3c26Smrg#define AMDGPU_FAMILY_CZ			135 /* Carrizo, Stoney */
1282d8807b2fSmrg#define AMDGPU_FAMILY_AI			141 /* Vega10 */
1283d8807b2fSmrg#define AMDGPU_FAMILY_RV			142 /* Raven */
12845324fb0dSmrg#define AMDGPU_FAMILY_NV			143 /* Navi10 */
128541687f09Smrg#define AMDGPU_FAMILY_VGH			144 /* Van Gogh */
1286bbff01ceSmrg#define AMDGPU_FAMILY_GC_11_0_0			145 /* GC 11.0.0 */
128749ef06a4Smrg#define AMDGPU_FAMILY_YC			146 /* Yellow Carp */
1288bbff01ceSmrg#define AMDGPU_FAMILY_GC_11_0_1			148 /* GC 11.0.1 */
1289bbff01ceSmrg#define AMDGPU_FAMILY_GC_10_3_6			149 /* GC 10.3.6 */
1290bbff01ceSmrg#define AMDGPU_FAMILY_GC_10_3_7			151 /* GC 10.3.7 */
1291bbff01ceSmrg#define AMDGPU_FAMILY_GC_11_5_0			150 /* GC 11.5.0 */
1292bbff01ceSmrg#define AMDGPU_FAMILY_GC_12_0_0			152 /* GC 12.0.0 */
1293037b3c26Smrg
1294037b3c26Smrg#if defined(__cplusplus)
1295037b3c26Smrg}
1296037b3c26Smrg#endif
12973f012e29Smrg
12983f012e29Smrg#endif
1299