1bf215546Sopenharmony_ci/* amdgpu_drm.h -- Public header for the amdgpu driver -*- linux-c -*-
2bf215546Sopenharmony_ci *
3bf215546Sopenharmony_ci * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
4bf215546Sopenharmony_ci * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
5bf215546Sopenharmony_ci * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
6bf215546Sopenharmony_ci * Copyright 2014 Advanced Micro Devices, Inc.
7bf215546Sopenharmony_ci *
8bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
9bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
10bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
11bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
13bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
16bf215546Sopenharmony_ci * all copies or substantial portions of the Software.
17bf215546Sopenharmony_ci *
18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21bf215546Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
22bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci * Authors:
27bf215546Sopenharmony_ci *    Kevin E. Martin <martin@valinux.com>
28bf215546Sopenharmony_ci *    Gareth Hughes <gareth@valinux.com>
29bf215546Sopenharmony_ci *    Keith Whitwell <keith@tungstengraphics.com>
30bf215546Sopenharmony_ci */
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_ci#ifndef __AMDGPU_DRM_H__
33bf215546Sopenharmony_ci#define __AMDGPU_DRM_H__
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_ci#include "drm.h"
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_ci#if defined(__cplusplus)
38bf215546Sopenharmony_ciextern "C" {
39bf215546Sopenharmony_ci#endif
40bf215546Sopenharmony_ci
41bf215546Sopenharmony_ci#define DRM_AMDGPU_GEM_CREATE		0x00
42bf215546Sopenharmony_ci#define DRM_AMDGPU_GEM_MMAP		0x01
43bf215546Sopenharmony_ci#define DRM_AMDGPU_CTX			0x02
44bf215546Sopenharmony_ci#define DRM_AMDGPU_BO_LIST		0x03
45bf215546Sopenharmony_ci#define DRM_AMDGPU_CS			0x04
46bf215546Sopenharmony_ci#define DRM_AMDGPU_INFO			0x05
47bf215546Sopenharmony_ci#define DRM_AMDGPU_GEM_METADATA		0x06
48bf215546Sopenharmony_ci#define DRM_AMDGPU_GEM_WAIT_IDLE	0x07
49bf215546Sopenharmony_ci#define DRM_AMDGPU_GEM_VA		0x08
50bf215546Sopenharmony_ci#define DRM_AMDGPU_WAIT_CS		0x09
51bf215546Sopenharmony_ci#define DRM_AMDGPU_GEM_OP		0x10
52bf215546Sopenharmony_ci#define DRM_AMDGPU_GEM_USERPTR		0x11
53bf215546Sopenharmony_ci#define DRM_AMDGPU_WAIT_FENCES		0x12
54bf215546Sopenharmony_ci#define DRM_AMDGPU_VM			0x13
55bf215546Sopenharmony_ci#define DRM_AMDGPU_FENCE_TO_HANDLE	0x14
56bf215546Sopenharmony_ci#define DRM_AMDGPU_SCHED		0x15
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_GEM_CREATE	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
59bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_GEM_MMAP	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
60bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_CTX		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
61bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_BO_LIST	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
62bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_CS		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
63bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_INFO		DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
64bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_GEM_METADATA	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
65bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
66bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_GEM_VA		DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
67bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_WAIT_CS	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
68bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_GEM_OP		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
69bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_GEM_USERPTR	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
70bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_WAIT_FENCES	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)
71bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_VM		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
72bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
73bf215546Sopenharmony_ci#define DRM_IOCTL_AMDGPU_SCHED		DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci/**
76bf215546Sopenharmony_ci * DOC: memory domains
77bf215546Sopenharmony_ci *
78bf215546Sopenharmony_ci * %AMDGPU_GEM_DOMAIN_CPU	System memory that is not GPU accessible.
79bf215546Sopenharmony_ci * Memory in this pool could be swapped out to disk if there is pressure.
80bf215546Sopenharmony_ci *
81bf215546Sopenharmony_ci * %AMDGPU_GEM_DOMAIN_GTT	GPU accessible system memory, mapped into the
82bf215546Sopenharmony_ci * GPU's virtual address space via gart. Gart memory linearizes non-contiguous
83bf215546Sopenharmony_ci * pages of system memory, allows GPU access system memory in a linearized
84bf215546Sopenharmony_ci * fashion.
85bf215546Sopenharmony_ci *
86bf215546Sopenharmony_ci * %AMDGPU_GEM_DOMAIN_VRAM	Local video memory. For APUs, it is memory
87bf215546Sopenharmony_ci * carved out by the BIOS.
88bf215546Sopenharmony_ci *
89bf215546Sopenharmony_ci * %AMDGPU_GEM_DOMAIN_GDS	Global on-chip data storage used to share data
90bf215546Sopenharmony_ci * across shader threads.
91bf215546Sopenharmony_ci *
92bf215546Sopenharmony_ci * %AMDGPU_GEM_DOMAIN_GWS	Global wave sync, used to synchronize the
93bf215546Sopenharmony_ci * execution of all the waves on a device.
94bf215546Sopenharmony_ci *
95bf215546Sopenharmony_ci * %AMDGPU_GEM_DOMAIN_OA	Ordered append, used by 3D or Compute engines
96bf215546Sopenharmony_ci * for appending data.
97bf215546Sopenharmony_ci */
98bf215546Sopenharmony_ci#define AMDGPU_GEM_DOMAIN_CPU		0x1
99bf215546Sopenharmony_ci#define AMDGPU_GEM_DOMAIN_GTT		0x2
100bf215546Sopenharmony_ci#define AMDGPU_GEM_DOMAIN_VRAM		0x4
101bf215546Sopenharmony_ci#define AMDGPU_GEM_DOMAIN_GDS		0x8
102bf215546Sopenharmony_ci#define AMDGPU_GEM_DOMAIN_GWS		0x10
103bf215546Sopenharmony_ci#define AMDGPU_GEM_DOMAIN_OA		0x20
104bf215546Sopenharmony_ci#define AMDGPU_GEM_DOMAIN_MASK		(AMDGPU_GEM_DOMAIN_CPU | \
105bf215546Sopenharmony_ci					 AMDGPU_GEM_DOMAIN_GTT | \
106bf215546Sopenharmony_ci					 AMDGPU_GEM_DOMAIN_VRAM | \
107bf215546Sopenharmony_ci					 AMDGPU_GEM_DOMAIN_GDS | \
108bf215546Sopenharmony_ci					 AMDGPU_GEM_DOMAIN_GWS | \
109bf215546Sopenharmony_ci					 AMDGPU_GEM_DOMAIN_OA)
110bf215546Sopenharmony_ci
111bf215546Sopenharmony_ci/* Flag that CPU access will be required for the case of VRAM domain */
112bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED	(1 << 0)
113bf215546Sopenharmony_ci/* Flag that CPU access will not work, this VRAM domain is invisible */
114bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_NO_CPU_ACCESS		(1 << 1)
115bf215546Sopenharmony_ci/* Flag that USWC attributes should be used for GTT */
116bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_CPU_GTT_USWC		(1 << 2)
117bf215546Sopenharmony_ci/* Flag that the memory should be in VRAM and cleared */
118bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_VRAM_CLEARED		(1 << 3)
119bf215546Sopenharmony_ci/* Flag that allocating the BO should use linear VRAM */
120bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS	(1 << 5)
121bf215546Sopenharmony_ci/* Flag that BO is always valid in this VM */
122bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID	(1 << 6)
123bf215546Sopenharmony_ci/* Flag that BO sharing will be explicitly synchronized */
124bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_EXPLICIT_SYNC		(1 << 7)
125bf215546Sopenharmony_ci/* Flag that indicates allocating MQD gart on GFX9, where the mtype
126bf215546Sopenharmony_ci * for the second page onward should be set to NC. It should never
127bf215546Sopenharmony_ci * be used by user space applications.
128bf215546Sopenharmony_ci */
129bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_CP_MQD_GFX9		(1 << 8)
130bf215546Sopenharmony_ci/* Flag that BO may contain sensitive data that must be wiped before
131bf215546Sopenharmony_ci * releasing the memory
132bf215546Sopenharmony_ci */
133bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE	(1 << 9)
134bf215546Sopenharmony_ci/* Flag that BO will be encrypted and that the TMZ bit should be
135bf215546Sopenharmony_ci * set in the PTEs when mapping this buffer via GPUVM or
136bf215546Sopenharmony_ci * accessing it with various hw blocks
137bf215546Sopenharmony_ci */
138bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_ENCRYPTED		(1 << 10)
139bf215546Sopenharmony_ci/* Flag that BO will be used only in preemptible context, which does
140bf215546Sopenharmony_ci * not require GTT memory accounting
141bf215546Sopenharmony_ci */
142bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_PREEMPTIBLE		(1 << 11)
143bf215546Sopenharmony_ci/* Flag that BO can be discarded under memory pressure without keeping the
144bf215546Sopenharmony_ci * content.
145bf215546Sopenharmony_ci */
146bf215546Sopenharmony_ci#define AMDGPU_GEM_CREATE_DISCARDABLE		(1 << 12)
147bf215546Sopenharmony_ci
148bf215546Sopenharmony_cistruct drm_amdgpu_gem_create_in  {
149bf215546Sopenharmony_ci	/** the requested memory size */
150bf215546Sopenharmony_ci	__u64 bo_size;
151bf215546Sopenharmony_ci	/** physical start_addr alignment in bytes for some HW requirements */
152bf215546Sopenharmony_ci	__u64 alignment;
153bf215546Sopenharmony_ci	/** the requested memory domains */
154bf215546Sopenharmony_ci	__u64 domains;
155bf215546Sopenharmony_ci	/** allocation flags */
156bf215546Sopenharmony_ci	__u64 domain_flags;
157bf215546Sopenharmony_ci};
158bf215546Sopenharmony_ci
159bf215546Sopenharmony_cistruct drm_amdgpu_gem_create_out  {
160bf215546Sopenharmony_ci	/** returned GEM object handle */
161bf215546Sopenharmony_ci	__u32 handle;
162bf215546Sopenharmony_ci	__u32 _pad;
163bf215546Sopenharmony_ci};
164bf215546Sopenharmony_ci
165bf215546Sopenharmony_ciunion drm_amdgpu_gem_create {
166bf215546Sopenharmony_ci	struct drm_amdgpu_gem_create_in		in;
167bf215546Sopenharmony_ci	struct drm_amdgpu_gem_create_out	out;
168bf215546Sopenharmony_ci};
169bf215546Sopenharmony_ci
170bf215546Sopenharmony_ci/** Opcode to create new residency list.  */
171bf215546Sopenharmony_ci#define AMDGPU_BO_LIST_OP_CREATE	0
172bf215546Sopenharmony_ci/** Opcode to destroy previously created residency list */
173bf215546Sopenharmony_ci#define AMDGPU_BO_LIST_OP_DESTROY	1
174bf215546Sopenharmony_ci/** Opcode to update resource information in the list */
175bf215546Sopenharmony_ci#define AMDGPU_BO_LIST_OP_UPDATE	2
176bf215546Sopenharmony_ci
177bf215546Sopenharmony_cistruct drm_amdgpu_bo_list_in {
178bf215546Sopenharmony_ci	/** Type of operation */
179bf215546Sopenharmony_ci	__u32 operation;
180bf215546Sopenharmony_ci	/** Handle of list or 0 if we want to create one */
181bf215546Sopenharmony_ci	__u32 list_handle;
182bf215546Sopenharmony_ci	/** Number of BOs in list  */
183bf215546Sopenharmony_ci	__u32 bo_number;
184bf215546Sopenharmony_ci	/** Size of each element describing BO */
185bf215546Sopenharmony_ci	__u32 bo_info_size;
186bf215546Sopenharmony_ci	/** Pointer to array describing BOs */
187bf215546Sopenharmony_ci	__u64 bo_info_ptr;
188bf215546Sopenharmony_ci};
189bf215546Sopenharmony_ci
190bf215546Sopenharmony_cistruct drm_amdgpu_bo_list_entry {
191bf215546Sopenharmony_ci	/** Handle of BO */
192bf215546Sopenharmony_ci	__u32 bo_handle;
193bf215546Sopenharmony_ci	/** New (if specified) BO priority to be used during migration */
194bf215546Sopenharmony_ci	__u32 bo_priority;
195bf215546Sopenharmony_ci};
196bf215546Sopenharmony_ci
197bf215546Sopenharmony_cistruct drm_amdgpu_bo_list_out {
198bf215546Sopenharmony_ci	/** Handle of resource list  */
199bf215546Sopenharmony_ci	__u32 list_handle;
200bf215546Sopenharmony_ci	__u32 _pad;
201bf215546Sopenharmony_ci};
202bf215546Sopenharmony_ci
203bf215546Sopenharmony_ciunion drm_amdgpu_bo_list {
204bf215546Sopenharmony_ci	struct drm_amdgpu_bo_list_in in;
205bf215546Sopenharmony_ci	struct drm_amdgpu_bo_list_out out;
206bf215546Sopenharmony_ci};
207bf215546Sopenharmony_ci
208bf215546Sopenharmony_ci/* context related */
209bf215546Sopenharmony_ci#define AMDGPU_CTX_OP_ALLOC_CTX	1
210bf215546Sopenharmony_ci#define AMDGPU_CTX_OP_FREE_CTX	2
211bf215546Sopenharmony_ci#define AMDGPU_CTX_OP_QUERY_STATE	3
212bf215546Sopenharmony_ci#define AMDGPU_CTX_OP_QUERY_STATE2	4
213bf215546Sopenharmony_ci#define AMDGPU_CTX_OP_GET_STABLE_PSTATE	5
214bf215546Sopenharmony_ci#define AMDGPU_CTX_OP_SET_STABLE_PSTATE	6
215bf215546Sopenharmony_ci
216bf215546Sopenharmony_ci/* GPU reset status */
217bf215546Sopenharmony_ci#define AMDGPU_CTX_NO_RESET		0
218bf215546Sopenharmony_ci/* this the context caused it */
219bf215546Sopenharmony_ci#define AMDGPU_CTX_GUILTY_RESET		1
220bf215546Sopenharmony_ci/* some other context caused it */
221bf215546Sopenharmony_ci#define AMDGPU_CTX_INNOCENT_RESET	2
222bf215546Sopenharmony_ci/* unknown cause */
223bf215546Sopenharmony_ci#define AMDGPU_CTX_UNKNOWN_RESET	3
224bf215546Sopenharmony_ci
225bf215546Sopenharmony_ci/* indicate gpu reset occured after ctx created */
226bf215546Sopenharmony_ci#define AMDGPU_CTX_QUERY2_FLAGS_RESET    (1<<0)
227bf215546Sopenharmony_ci/* indicate vram lost occured after ctx created */
228bf215546Sopenharmony_ci#define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)
229bf215546Sopenharmony_ci/* indicate some job from this context once cause gpu hang */
230bf215546Sopenharmony_ci#define AMDGPU_CTX_QUERY2_FLAGS_GUILTY   (1<<2)
231bf215546Sopenharmony_ci/* indicate some errors are detected by RAS */
232bf215546Sopenharmony_ci#define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE   (1<<3)
233bf215546Sopenharmony_ci#define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE   (1<<4)
234bf215546Sopenharmony_ci
235bf215546Sopenharmony_ci/* Context priority level */
236bf215546Sopenharmony_ci#define AMDGPU_CTX_PRIORITY_UNSET       -2048
237bf215546Sopenharmony_ci#define AMDGPU_CTX_PRIORITY_VERY_LOW    -1023
238bf215546Sopenharmony_ci#define AMDGPU_CTX_PRIORITY_LOW         -512
239bf215546Sopenharmony_ci#define AMDGPU_CTX_PRIORITY_NORMAL      0
240bf215546Sopenharmony_ci/*
241bf215546Sopenharmony_ci * When used in struct drm_amdgpu_ctx_in, a priority above NORMAL requires
242bf215546Sopenharmony_ci * CAP_SYS_NICE or DRM_MASTER
243bf215546Sopenharmony_ci*/
244bf215546Sopenharmony_ci#define AMDGPU_CTX_PRIORITY_HIGH        512
245bf215546Sopenharmony_ci#define AMDGPU_CTX_PRIORITY_VERY_HIGH   1023
246bf215546Sopenharmony_ci
247bf215546Sopenharmony_ci/* select a stable profiling pstate for perfmon tools */
248bf215546Sopenharmony_ci#define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK  0xf
249bf215546Sopenharmony_ci#define AMDGPU_CTX_STABLE_PSTATE_NONE  0
250bf215546Sopenharmony_ci#define AMDGPU_CTX_STABLE_PSTATE_STANDARD  1
251bf215546Sopenharmony_ci#define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK  2
252bf215546Sopenharmony_ci#define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK  3
253bf215546Sopenharmony_ci#define AMDGPU_CTX_STABLE_PSTATE_PEAK  4
254bf215546Sopenharmony_ci
255bf215546Sopenharmony_cistruct drm_amdgpu_ctx_in {
256bf215546Sopenharmony_ci	/** AMDGPU_CTX_OP_* */
257bf215546Sopenharmony_ci	__u32	op;
258bf215546Sopenharmony_ci	/** Flags */
259bf215546Sopenharmony_ci	__u32	flags;
260bf215546Sopenharmony_ci	__u32	ctx_id;
261bf215546Sopenharmony_ci	/** AMDGPU_CTX_PRIORITY_* */
262bf215546Sopenharmony_ci	__s32	priority;
263bf215546Sopenharmony_ci};
264bf215546Sopenharmony_ci
265bf215546Sopenharmony_ciunion drm_amdgpu_ctx_out {
266bf215546Sopenharmony_ci		struct {
267bf215546Sopenharmony_ci			__u32	ctx_id;
268bf215546Sopenharmony_ci			__u32	_pad;
269bf215546Sopenharmony_ci		} alloc;
270bf215546Sopenharmony_ci
271bf215546Sopenharmony_ci		struct {
272bf215546Sopenharmony_ci			/** For future use, no flags defined so far */
273bf215546Sopenharmony_ci			__u64	flags;
274bf215546Sopenharmony_ci			/** Number of resets caused by this context so far. */
275bf215546Sopenharmony_ci			__u32	hangs;
276bf215546Sopenharmony_ci			/** Reset status since the last call of the ioctl. */
277bf215546Sopenharmony_ci			__u32	reset_status;
278bf215546Sopenharmony_ci		} state;
279bf215546Sopenharmony_ci
280bf215546Sopenharmony_ci		struct {
281bf215546Sopenharmony_ci			__u32	flags;
282bf215546Sopenharmony_ci			__u32	_pad;
283bf215546Sopenharmony_ci		} pstate;
284bf215546Sopenharmony_ci};
285bf215546Sopenharmony_ci
286bf215546Sopenharmony_ciunion drm_amdgpu_ctx {
287bf215546Sopenharmony_ci	struct drm_amdgpu_ctx_in in;
288bf215546Sopenharmony_ci	union drm_amdgpu_ctx_out out;
289bf215546Sopenharmony_ci};
290bf215546Sopenharmony_ci
291bf215546Sopenharmony_ci/* vm ioctl */
292bf215546Sopenharmony_ci#define AMDGPU_VM_OP_RESERVE_VMID	1
293bf215546Sopenharmony_ci#define AMDGPU_VM_OP_UNRESERVE_VMID	2
294bf215546Sopenharmony_ci
295bf215546Sopenharmony_cistruct drm_amdgpu_vm_in {
296bf215546Sopenharmony_ci	/** AMDGPU_VM_OP_* */
297bf215546Sopenharmony_ci	__u32	op;
298bf215546Sopenharmony_ci	__u32	flags;
299bf215546Sopenharmony_ci};
300bf215546Sopenharmony_ci
301bf215546Sopenharmony_cistruct drm_amdgpu_vm_out {
302bf215546Sopenharmony_ci	/** For future use, no flags defined so far */
303bf215546Sopenharmony_ci	__u64	flags;
304bf215546Sopenharmony_ci};
305bf215546Sopenharmony_ci
306bf215546Sopenharmony_ciunion drm_amdgpu_vm {
307bf215546Sopenharmony_ci	struct drm_amdgpu_vm_in in;
308bf215546Sopenharmony_ci	struct drm_amdgpu_vm_out out;
309bf215546Sopenharmony_ci};
310bf215546Sopenharmony_ci
311bf215546Sopenharmony_ci/* sched ioctl */
312bf215546Sopenharmony_ci#define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE	1
313bf215546Sopenharmony_ci#define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE	2
314bf215546Sopenharmony_ci
315bf215546Sopenharmony_cistruct drm_amdgpu_sched_in {
316bf215546Sopenharmony_ci	/* AMDGPU_SCHED_OP_* */
317bf215546Sopenharmony_ci	__u32	op;
318bf215546Sopenharmony_ci	__u32	fd;
319bf215546Sopenharmony_ci	/** AMDGPU_CTX_PRIORITY_* */
320bf215546Sopenharmony_ci	__s32	priority;
321bf215546Sopenharmony_ci	__u32   ctx_id;
322bf215546Sopenharmony_ci};
323bf215546Sopenharmony_ci
324bf215546Sopenharmony_ciunion drm_amdgpu_sched {
325bf215546Sopenharmony_ci	struct drm_amdgpu_sched_in in;
326bf215546Sopenharmony_ci};
327bf215546Sopenharmony_ci
328bf215546Sopenharmony_ci/*
329bf215546Sopenharmony_ci * This is not a reliable API and you should expect it to fail for any
330bf215546Sopenharmony_ci * number of reasons and have fallback path that do not use userptr to
331bf215546Sopenharmony_ci * perform any operation.
332bf215546Sopenharmony_ci */
333bf215546Sopenharmony_ci#define AMDGPU_GEM_USERPTR_READONLY	(1 << 0)
334bf215546Sopenharmony_ci#define AMDGPU_GEM_USERPTR_ANONONLY	(1 << 1)
335bf215546Sopenharmony_ci#define AMDGPU_GEM_USERPTR_VALIDATE	(1 << 2)
336bf215546Sopenharmony_ci#define AMDGPU_GEM_USERPTR_REGISTER	(1 << 3)
337bf215546Sopenharmony_ci
338bf215546Sopenharmony_cistruct drm_amdgpu_gem_userptr {
339bf215546Sopenharmony_ci	__u64		addr;
340bf215546Sopenharmony_ci	__u64		size;
341bf215546Sopenharmony_ci	/* AMDGPU_GEM_USERPTR_* */
342bf215546Sopenharmony_ci	__u32		flags;
343bf215546Sopenharmony_ci	/* Resulting GEM handle */
344bf215546Sopenharmony_ci	__u32		handle;
345bf215546Sopenharmony_ci};
346bf215546Sopenharmony_ci
347bf215546Sopenharmony_ci/* SI-CI-VI: */
348bf215546Sopenharmony_ci/* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
349bf215546Sopenharmony_ci#define AMDGPU_TILING_ARRAY_MODE_SHIFT			0
350bf215546Sopenharmony_ci#define AMDGPU_TILING_ARRAY_MODE_MASK			0xf
351bf215546Sopenharmony_ci#define AMDGPU_TILING_PIPE_CONFIG_SHIFT			4
352bf215546Sopenharmony_ci#define AMDGPU_TILING_PIPE_CONFIG_MASK			0x1f
353bf215546Sopenharmony_ci#define AMDGPU_TILING_TILE_SPLIT_SHIFT			9
354bf215546Sopenharmony_ci#define AMDGPU_TILING_TILE_SPLIT_MASK			0x7
355bf215546Sopenharmony_ci#define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT		12
356bf215546Sopenharmony_ci#define AMDGPU_TILING_MICRO_TILE_MODE_MASK		0x7
357bf215546Sopenharmony_ci#define AMDGPU_TILING_BANK_WIDTH_SHIFT			15
358bf215546Sopenharmony_ci#define AMDGPU_TILING_BANK_WIDTH_MASK			0x3
359bf215546Sopenharmony_ci#define AMDGPU_TILING_BANK_HEIGHT_SHIFT			17
360bf215546Sopenharmony_ci#define AMDGPU_TILING_BANK_HEIGHT_MASK			0x3
361bf215546Sopenharmony_ci#define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT		19
362bf215546Sopenharmony_ci#define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK		0x3
363bf215546Sopenharmony_ci#define AMDGPU_TILING_NUM_BANKS_SHIFT			21
364bf215546Sopenharmony_ci#define AMDGPU_TILING_NUM_BANKS_MASK			0x3
365bf215546Sopenharmony_ci
366bf215546Sopenharmony_ci/* GFX9 and later: */
367bf215546Sopenharmony_ci#define AMDGPU_TILING_SWIZZLE_MODE_SHIFT		0
368bf215546Sopenharmony_ci#define AMDGPU_TILING_SWIZZLE_MODE_MASK			0x1f
369bf215546Sopenharmony_ci#define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT		5
370bf215546Sopenharmony_ci#define AMDGPU_TILING_DCC_OFFSET_256B_MASK		0xFFFFFF
371bf215546Sopenharmony_ci#define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT		29
372bf215546Sopenharmony_ci#define AMDGPU_TILING_DCC_PITCH_MAX_MASK		0x3FFF
373bf215546Sopenharmony_ci#define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT		43
374bf215546Sopenharmony_ci#define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK		0x1
375bf215546Sopenharmony_ci#define AMDGPU_TILING_DCC_INDEPENDENT_128B_SHIFT	44
376bf215546Sopenharmony_ci#define AMDGPU_TILING_DCC_INDEPENDENT_128B_MASK		0x1
377bf215546Sopenharmony_ci#define AMDGPU_TILING_SCANOUT_SHIFT			63
378bf215546Sopenharmony_ci#define AMDGPU_TILING_SCANOUT_MASK			0x1
379bf215546Sopenharmony_ci
380bf215546Sopenharmony_ci/* Set/Get helpers for tiling flags. */
381bf215546Sopenharmony_ci#define AMDGPU_TILING_SET(field, value) \
382bf215546Sopenharmony_ci	(((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
383bf215546Sopenharmony_ci#define AMDGPU_TILING_GET(value, field) \
384bf215546Sopenharmony_ci	(((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
385bf215546Sopenharmony_ci
386bf215546Sopenharmony_ci#define AMDGPU_GEM_METADATA_OP_SET_METADATA                  1
387bf215546Sopenharmony_ci#define AMDGPU_GEM_METADATA_OP_GET_METADATA                  2
388bf215546Sopenharmony_ci
389bf215546Sopenharmony_ci/** The same structure is shared for input/output */
390bf215546Sopenharmony_cistruct drm_amdgpu_gem_metadata {
391bf215546Sopenharmony_ci	/** GEM Object handle */
392bf215546Sopenharmony_ci	__u32	handle;
393bf215546Sopenharmony_ci	/** Do we want get or set metadata */
394bf215546Sopenharmony_ci	__u32	op;
395bf215546Sopenharmony_ci	struct {
396bf215546Sopenharmony_ci		/** For future use, no flags defined so far */
397bf215546Sopenharmony_ci		__u64	flags;
398bf215546Sopenharmony_ci		/** family specific tiling info */
399bf215546Sopenharmony_ci		__u64	tiling_info;
400bf215546Sopenharmony_ci		__u32	data_size_bytes;
401bf215546Sopenharmony_ci		__u32	data[64];
402bf215546Sopenharmony_ci	} data;
403bf215546Sopenharmony_ci};
404bf215546Sopenharmony_ci
405bf215546Sopenharmony_cistruct drm_amdgpu_gem_mmap_in {
406bf215546Sopenharmony_ci	/** the GEM object handle */
407bf215546Sopenharmony_ci	__u32 handle;
408bf215546Sopenharmony_ci	__u32 _pad;
409bf215546Sopenharmony_ci};
410bf215546Sopenharmony_ci
411bf215546Sopenharmony_cistruct drm_amdgpu_gem_mmap_out {
412bf215546Sopenharmony_ci	/** mmap offset from the vma offset manager */
413bf215546Sopenharmony_ci	__u64 addr_ptr;
414bf215546Sopenharmony_ci};
415bf215546Sopenharmony_ci
416bf215546Sopenharmony_ciunion drm_amdgpu_gem_mmap {
417bf215546Sopenharmony_ci	struct drm_amdgpu_gem_mmap_in   in;
418bf215546Sopenharmony_ci	struct drm_amdgpu_gem_mmap_out out;
419bf215546Sopenharmony_ci};
420bf215546Sopenharmony_ci
421bf215546Sopenharmony_cistruct drm_amdgpu_gem_wait_idle_in {
422bf215546Sopenharmony_ci	/** GEM object handle */
423bf215546Sopenharmony_ci	__u32 handle;
424bf215546Sopenharmony_ci	/** For future use, no flags defined so far */
425bf215546Sopenharmony_ci	__u32 flags;
426bf215546Sopenharmony_ci	/** Absolute timeout to wait */
427bf215546Sopenharmony_ci	__u64 timeout;
428bf215546Sopenharmony_ci};
429bf215546Sopenharmony_ci
430bf215546Sopenharmony_cistruct drm_amdgpu_gem_wait_idle_out {
431bf215546Sopenharmony_ci	/** BO status:  0 - BO is idle, 1 - BO is busy */
432bf215546Sopenharmony_ci	__u32 status;
433bf215546Sopenharmony_ci	/** Returned current memory domain */
434bf215546Sopenharmony_ci	__u32 domain;
435bf215546Sopenharmony_ci};
436bf215546Sopenharmony_ci
437bf215546Sopenharmony_ciunion drm_amdgpu_gem_wait_idle {
438bf215546Sopenharmony_ci	struct drm_amdgpu_gem_wait_idle_in  in;
439bf215546Sopenharmony_ci	struct drm_amdgpu_gem_wait_idle_out out;
440bf215546Sopenharmony_ci};
441bf215546Sopenharmony_ci
442bf215546Sopenharmony_cistruct drm_amdgpu_wait_cs_in {
443bf215546Sopenharmony_ci	/* Command submission handle
444bf215546Sopenharmony_ci         * handle equals 0 means none to wait for
445bf215546Sopenharmony_ci         * handle equals ~0ull means wait for the latest sequence number
446bf215546Sopenharmony_ci         */
447bf215546Sopenharmony_ci	__u64 handle;
448bf215546Sopenharmony_ci	/** Absolute timeout to wait */
449bf215546Sopenharmony_ci	__u64 timeout;
450bf215546Sopenharmony_ci	__u32 ip_type;
451bf215546Sopenharmony_ci	__u32 ip_instance;
452bf215546Sopenharmony_ci	__u32 ring;
453bf215546Sopenharmony_ci	__u32 ctx_id;
454bf215546Sopenharmony_ci};
455bf215546Sopenharmony_ci
456bf215546Sopenharmony_cistruct drm_amdgpu_wait_cs_out {
457bf215546Sopenharmony_ci	/** CS status:  0 - CS completed, 1 - CS still busy */
458bf215546Sopenharmony_ci	__u64 status;
459bf215546Sopenharmony_ci};
460bf215546Sopenharmony_ci
461bf215546Sopenharmony_ciunion drm_amdgpu_wait_cs {
462bf215546Sopenharmony_ci	struct drm_amdgpu_wait_cs_in in;
463bf215546Sopenharmony_ci	struct drm_amdgpu_wait_cs_out out;
464bf215546Sopenharmony_ci};
465bf215546Sopenharmony_ci
466bf215546Sopenharmony_cistruct drm_amdgpu_fence {
467bf215546Sopenharmony_ci	__u32 ctx_id;
468bf215546Sopenharmony_ci	__u32 ip_type;
469bf215546Sopenharmony_ci	__u32 ip_instance;
470bf215546Sopenharmony_ci	__u32 ring;
471bf215546Sopenharmony_ci	__u64 seq_no;
472bf215546Sopenharmony_ci};
473bf215546Sopenharmony_ci
474bf215546Sopenharmony_cistruct drm_amdgpu_wait_fences_in {
475bf215546Sopenharmony_ci	/** This points to uint64_t * which points to fences */
476bf215546Sopenharmony_ci	__u64 fences;
477bf215546Sopenharmony_ci	__u32 fence_count;
478bf215546Sopenharmony_ci	__u32 wait_all;
479bf215546Sopenharmony_ci	__u64 timeout_ns;
480bf215546Sopenharmony_ci};
481bf215546Sopenharmony_ci
482bf215546Sopenharmony_cistruct drm_amdgpu_wait_fences_out {
483bf215546Sopenharmony_ci	__u32 status;
484bf215546Sopenharmony_ci	__u32 first_signaled;
485bf215546Sopenharmony_ci};
486bf215546Sopenharmony_ci
487bf215546Sopenharmony_ciunion drm_amdgpu_wait_fences {
488bf215546Sopenharmony_ci	struct drm_amdgpu_wait_fences_in in;
489bf215546Sopenharmony_ci	struct drm_amdgpu_wait_fences_out out;
490bf215546Sopenharmony_ci};
491bf215546Sopenharmony_ci
492bf215546Sopenharmony_ci#define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO	0
493bf215546Sopenharmony_ci#define AMDGPU_GEM_OP_SET_PLACEMENT		1
494bf215546Sopenharmony_ci
495bf215546Sopenharmony_ci/* Sets or returns a value associated with a buffer. */
496bf215546Sopenharmony_cistruct drm_amdgpu_gem_op {
497bf215546Sopenharmony_ci	/** GEM object handle */
498bf215546Sopenharmony_ci	__u32	handle;
499bf215546Sopenharmony_ci	/** AMDGPU_GEM_OP_* */
500bf215546Sopenharmony_ci	__u32	op;
501bf215546Sopenharmony_ci	/** Input or return value */
502bf215546Sopenharmony_ci	__u64	value;
503bf215546Sopenharmony_ci};
504bf215546Sopenharmony_ci
505bf215546Sopenharmony_ci#define AMDGPU_VA_OP_MAP			1
506bf215546Sopenharmony_ci#define AMDGPU_VA_OP_UNMAP			2
507bf215546Sopenharmony_ci#define AMDGPU_VA_OP_CLEAR			3
508bf215546Sopenharmony_ci#define AMDGPU_VA_OP_REPLACE			4
509bf215546Sopenharmony_ci
510bf215546Sopenharmony_ci/* Delay the page table update till the next CS */
511bf215546Sopenharmony_ci#define AMDGPU_VM_DELAY_UPDATE		(1 << 0)
512bf215546Sopenharmony_ci
513bf215546Sopenharmony_ci/* Mapping flags */
514bf215546Sopenharmony_ci/* readable mapping */
515bf215546Sopenharmony_ci#define AMDGPU_VM_PAGE_READABLE		(1 << 1)
516bf215546Sopenharmony_ci/* writable mapping */
517bf215546Sopenharmony_ci#define AMDGPU_VM_PAGE_WRITEABLE	(1 << 2)
518bf215546Sopenharmony_ci/* executable mapping, new for VI */
519bf215546Sopenharmony_ci#define AMDGPU_VM_PAGE_EXECUTABLE	(1 << 3)
520bf215546Sopenharmony_ci/* partially resident texture */
521bf215546Sopenharmony_ci#define AMDGPU_VM_PAGE_PRT		(1 << 4)
522bf215546Sopenharmony_ci/* MTYPE flags use bit 5 to 8 */
523bf215546Sopenharmony_ci#define AMDGPU_VM_MTYPE_MASK		(0xf << 5)
524bf215546Sopenharmony_ci/* Default MTYPE. Pre-AI must use this.  Recommended for newer ASICs. */
525bf215546Sopenharmony_ci#define AMDGPU_VM_MTYPE_DEFAULT		(0 << 5)
526bf215546Sopenharmony_ci/* Use Non Coherent MTYPE instead of default MTYPE */
527bf215546Sopenharmony_ci#define AMDGPU_VM_MTYPE_NC		(1 << 5)
528bf215546Sopenharmony_ci/* Use Write Combine MTYPE instead of default MTYPE */
529bf215546Sopenharmony_ci#define AMDGPU_VM_MTYPE_WC		(2 << 5)
530bf215546Sopenharmony_ci/* Use Cache Coherent MTYPE instead of default MTYPE */
531bf215546Sopenharmony_ci#define AMDGPU_VM_MTYPE_CC		(3 << 5)
532bf215546Sopenharmony_ci/* Use UnCached MTYPE instead of default MTYPE */
533bf215546Sopenharmony_ci#define AMDGPU_VM_MTYPE_UC		(4 << 5)
534bf215546Sopenharmony_ci/* Use Read Write MTYPE instead of default MTYPE */
535bf215546Sopenharmony_ci#define AMDGPU_VM_MTYPE_RW		(5 << 5)
536bf215546Sopenharmony_ci/* don't allocate MALL */
537bf215546Sopenharmony_ci#define AMDGPU_VM_PAGE_NOALLOC		(1 << 9)
538bf215546Sopenharmony_ci
539bf215546Sopenharmony_cistruct drm_amdgpu_gem_va {
540bf215546Sopenharmony_ci	/** GEM object handle */
541bf215546Sopenharmony_ci	__u32 handle;
542bf215546Sopenharmony_ci	__u32 _pad;
543bf215546Sopenharmony_ci	/** AMDGPU_VA_OP_* */
544bf215546Sopenharmony_ci	__u32 operation;
545bf215546Sopenharmony_ci	/** AMDGPU_VM_PAGE_* */
546bf215546Sopenharmony_ci	__u32 flags;
547bf215546Sopenharmony_ci	/** va address to assign . Must be correctly aligned.*/
548bf215546Sopenharmony_ci	__u64 va_address;
549bf215546Sopenharmony_ci	/** Specify offset inside of BO to assign. Must be correctly aligned.*/
550bf215546Sopenharmony_ci	__u64 offset_in_bo;
551bf215546Sopenharmony_ci	/** Specify mapping size. Must be correctly aligned. */
552bf215546Sopenharmony_ci	__u64 map_size;
553bf215546Sopenharmony_ci};
554bf215546Sopenharmony_ci
555bf215546Sopenharmony_ci#define AMDGPU_HW_IP_GFX          0
556bf215546Sopenharmony_ci#define AMDGPU_HW_IP_COMPUTE      1
557bf215546Sopenharmony_ci#define AMDGPU_HW_IP_DMA          2
558bf215546Sopenharmony_ci#define AMDGPU_HW_IP_UVD          3
559bf215546Sopenharmony_ci#define AMDGPU_HW_IP_VCE          4
560bf215546Sopenharmony_ci#define AMDGPU_HW_IP_UVD_ENC      5
561bf215546Sopenharmony_ci#define AMDGPU_HW_IP_VCN_DEC      6
562bf215546Sopenharmony_ci#define AMDGPU_HW_IP_VCN_ENC      7
563bf215546Sopenharmony_ci#define AMDGPU_HW_IP_VCN_JPEG     8
564bf215546Sopenharmony_ci#define AMDGPU_HW_IP_NUM          9
565bf215546Sopenharmony_ci
566bf215546Sopenharmony_ci#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
567bf215546Sopenharmony_ci
568bf215546Sopenharmony_ci#define AMDGPU_CHUNK_ID_IB		0x01
569bf215546Sopenharmony_ci#define AMDGPU_CHUNK_ID_FENCE		0x02
570bf215546Sopenharmony_ci#define AMDGPU_CHUNK_ID_DEPENDENCIES	0x03
571bf215546Sopenharmony_ci#define AMDGPU_CHUNK_ID_SYNCOBJ_IN      0x04
572bf215546Sopenharmony_ci#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT     0x05
573bf215546Sopenharmony_ci#define AMDGPU_CHUNK_ID_BO_HANDLES      0x06
574bf215546Sopenharmony_ci#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES	0x07
575bf215546Sopenharmony_ci#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
576bf215546Sopenharmony_ci#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
577bf215546Sopenharmony_ci
578bf215546Sopenharmony_cistruct drm_amdgpu_cs_chunk {
579bf215546Sopenharmony_ci	__u32		chunk_id;
580bf215546Sopenharmony_ci	__u32		length_dw;
581bf215546Sopenharmony_ci	__u64		chunk_data;
582bf215546Sopenharmony_ci};
583bf215546Sopenharmony_ci
584bf215546Sopenharmony_cistruct drm_amdgpu_cs_in {
585bf215546Sopenharmony_ci	/** Rendering context id */
586bf215546Sopenharmony_ci	__u32		ctx_id;
587bf215546Sopenharmony_ci	/**  Handle of resource list associated with CS */
588bf215546Sopenharmony_ci	__u32		bo_list_handle;
589bf215546Sopenharmony_ci	__u32		num_chunks;
590bf215546Sopenharmony_ci	__u32		flags;
591bf215546Sopenharmony_ci	/** this points to __u64 * which point to cs chunks */
592bf215546Sopenharmony_ci	__u64		chunks;
593bf215546Sopenharmony_ci};
594bf215546Sopenharmony_ci
595bf215546Sopenharmony_cistruct drm_amdgpu_cs_out {
596bf215546Sopenharmony_ci	__u64 handle;
597bf215546Sopenharmony_ci};
598bf215546Sopenharmony_ci
599bf215546Sopenharmony_ciunion drm_amdgpu_cs {
600bf215546Sopenharmony_ci	struct drm_amdgpu_cs_in in;
601bf215546Sopenharmony_ci	struct drm_amdgpu_cs_out out;
602bf215546Sopenharmony_ci};
603bf215546Sopenharmony_ci
604bf215546Sopenharmony_ci/* Specify flags to be used for IB */
605bf215546Sopenharmony_ci
606bf215546Sopenharmony_ci/* This IB should be submitted to CE */
607bf215546Sopenharmony_ci#define AMDGPU_IB_FLAG_CE	(1<<0)
608bf215546Sopenharmony_ci
609bf215546Sopenharmony_ci/* Preamble flag, which means the IB could be dropped if no context switch */
610bf215546Sopenharmony_ci#define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
611bf215546Sopenharmony_ci
612bf215546Sopenharmony_ci/* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */
613bf215546Sopenharmony_ci#define AMDGPU_IB_FLAG_PREEMPT (1<<2)
614bf215546Sopenharmony_ci
615bf215546Sopenharmony_ci/* The IB fence should do the L2 writeback but not invalidate any shader
616bf215546Sopenharmony_ci * caches (L2/vL1/sL1/I$). */
617bf215546Sopenharmony_ci#define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3)
618bf215546Sopenharmony_ci
619bf215546Sopenharmony_ci/* Set GDS_COMPUTE_MAX_WAVE_ID = DEFAULT before PACKET3_INDIRECT_BUFFER.
620bf215546Sopenharmony_ci * This will reset wave ID counters for the IB.
621bf215546Sopenharmony_ci */
622bf215546Sopenharmony_ci#define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4)
623bf215546Sopenharmony_ci
624bf215546Sopenharmony_ci/* Flag the IB as secure (TMZ)
625bf215546Sopenharmony_ci */
626bf215546Sopenharmony_ci#define AMDGPU_IB_FLAGS_SECURE  (1 << 5)
627bf215546Sopenharmony_ci
628bf215546Sopenharmony_ci/* Tell KMD to flush and invalidate caches
629bf215546Sopenharmony_ci */
630bf215546Sopenharmony_ci#define AMDGPU_IB_FLAG_EMIT_MEM_SYNC  (1 << 6)
631bf215546Sopenharmony_ci
632bf215546Sopenharmony_cistruct drm_amdgpu_cs_chunk_ib {
633bf215546Sopenharmony_ci	__u32 _pad;
634bf215546Sopenharmony_ci	/** AMDGPU_IB_FLAG_* */
635bf215546Sopenharmony_ci	__u32 flags;
636bf215546Sopenharmony_ci	/** Virtual address to begin IB execution */
637bf215546Sopenharmony_ci	__u64 va_start;
638bf215546Sopenharmony_ci	/** Size of submission */
639bf215546Sopenharmony_ci	__u32 ib_bytes;
640bf215546Sopenharmony_ci	/** HW IP to submit to */
641bf215546Sopenharmony_ci	__u32 ip_type;
642bf215546Sopenharmony_ci	/** HW IP index of the same type to submit to  */
643bf215546Sopenharmony_ci	__u32 ip_instance;
644bf215546Sopenharmony_ci	/** Ring index to submit to */
645bf215546Sopenharmony_ci	__u32 ring;
646bf215546Sopenharmony_ci};
647bf215546Sopenharmony_ci
648bf215546Sopenharmony_cistruct drm_amdgpu_cs_chunk_dep {
649bf215546Sopenharmony_ci	__u32 ip_type;
650bf215546Sopenharmony_ci	__u32 ip_instance;
651bf215546Sopenharmony_ci	__u32 ring;
652bf215546Sopenharmony_ci	__u32 ctx_id;
653bf215546Sopenharmony_ci	__u64 handle;
654bf215546Sopenharmony_ci};
655bf215546Sopenharmony_ci
656bf215546Sopenharmony_cistruct drm_amdgpu_cs_chunk_fence {
657bf215546Sopenharmony_ci	__u32 handle;
658bf215546Sopenharmony_ci	__u32 offset;
659bf215546Sopenharmony_ci};
660bf215546Sopenharmony_ci
661bf215546Sopenharmony_cistruct drm_amdgpu_cs_chunk_sem {
662bf215546Sopenharmony_ci	__u32 handle;
663bf215546Sopenharmony_ci};
664bf215546Sopenharmony_ci
665bf215546Sopenharmony_cistruct drm_amdgpu_cs_chunk_syncobj {
666bf215546Sopenharmony_ci       __u32 handle;
667bf215546Sopenharmony_ci       __u32 flags;
668bf215546Sopenharmony_ci       __u64 point;
669bf215546Sopenharmony_ci};
670bf215546Sopenharmony_ci
671bf215546Sopenharmony_ci#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ	0
672bf215546Sopenharmony_ci#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD	1
673bf215546Sopenharmony_ci#define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD	2
674bf215546Sopenharmony_ci
675bf215546Sopenharmony_ciunion drm_amdgpu_fence_to_handle {
676bf215546Sopenharmony_ci	struct {
677bf215546Sopenharmony_ci		struct drm_amdgpu_fence fence;
678bf215546Sopenharmony_ci		__u32 what;
679bf215546Sopenharmony_ci		__u32 pad;
680bf215546Sopenharmony_ci	} in;
681bf215546Sopenharmony_ci	struct {
682bf215546Sopenharmony_ci		__u32 handle;
683bf215546Sopenharmony_ci	} out;
684bf215546Sopenharmony_ci};
685bf215546Sopenharmony_ci
686bf215546Sopenharmony_cistruct drm_amdgpu_cs_chunk_data {
687bf215546Sopenharmony_ci	union {
688bf215546Sopenharmony_ci		struct drm_amdgpu_cs_chunk_ib		ib_data;
689bf215546Sopenharmony_ci		struct drm_amdgpu_cs_chunk_fence	fence_data;
690bf215546Sopenharmony_ci	};
691bf215546Sopenharmony_ci};
692bf215546Sopenharmony_ci
693bf215546Sopenharmony_ci/*
694bf215546Sopenharmony_ci *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
695bf215546Sopenharmony_ci *
696bf215546Sopenharmony_ci */
697bf215546Sopenharmony_ci#define AMDGPU_IDS_FLAGS_FUSION         0x1
698bf215546Sopenharmony_ci#define AMDGPU_IDS_FLAGS_PREEMPTION     0x2
699bf215546Sopenharmony_ci#define AMDGPU_IDS_FLAGS_TMZ            0x4
700bf215546Sopenharmony_ci
701bf215546Sopenharmony_ci/* indicate if acceleration can be working */
702bf215546Sopenharmony_ci#define AMDGPU_INFO_ACCEL_WORKING		0x00
703bf215546Sopenharmony_ci/* get the crtc_id from the mode object id? */
704bf215546Sopenharmony_ci#define AMDGPU_INFO_CRTC_FROM_ID		0x01
705bf215546Sopenharmony_ci/* query hw IP info */
706bf215546Sopenharmony_ci#define AMDGPU_INFO_HW_IP_INFO			0x02
707bf215546Sopenharmony_ci/* query hw IP instance count for the specified type */
708bf215546Sopenharmony_ci#define AMDGPU_INFO_HW_IP_COUNT			0x03
709bf215546Sopenharmony_ci/* timestamp for GL_ARB_timer_query */
710bf215546Sopenharmony_ci#define AMDGPU_INFO_TIMESTAMP			0x05
711bf215546Sopenharmony_ci/* Query the firmware version */
712bf215546Sopenharmony_ci#define AMDGPU_INFO_FW_VERSION			0x0e
713bf215546Sopenharmony_ci	/* Subquery id: Query VCE firmware version */
714bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_VCE		0x1
715bf215546Sopenharmony_ci	/* Subquery id: Query UVD firmware version */
716bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_UVD		0x2
717bf215546Sopenharmony_ci	/* Subquery id: Query GMC firmware version */
718bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_GMC		0x03
719bf215546Sopenharmony_ci	/* Subquery id: Query GFX ME firmware version */
720bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_GFX_ME		0x04
721bf215546Sopenharmony_ci	/* Subquery id: Query GFX PFP firmware version */
722bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_GFX_PFP		0x05
723bf215546Sopenharmony_ci	/* Subquery id: Query GFX CE firmware version */
724bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_GFX_CE		0x06
725bf215546Sopenharmony_ci	/* Subquery id: Query GFX RLC firmware version */
726bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_GFX_RLC		0x07
727bf215546Sopenharmony_ci	/* Subquery id: Query GFX MEC firmware version */
728bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_GFX_MEC		0x08
729bf215546Sopenharmony_ci	/* Subquery id: Query SMC firmware version */
730bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_SMC		0x0a
731bf215546Sopenharmony_ci	/* Subquery id: Query SDMA firmware version */
732bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_SDMA		0x0b
733bf215546Sopenharmony_ci	/* Subquery id: Query PSP SOS firmware version */
734bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_SOS		0x0c
735bf215546Sopenharmony_ci	/* Subquery id: Query PSP ASD firmware version */
736bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_ASD		0x0d
737bf215546Sopenharmony_ci	/* Subquery id: Query VCN firmware version */
738bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_VCN		0x0e
739bf215546Sopenharmony_ci	/* Subquery id: Query GFX RLC SRLC firmware version */
740bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f
741bf215546Sopenharmony_ci	/* Subquery id: Query GFX RLC SRLG firmware version */
742bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10
743bf215546Sopenharmony_ci	/* Subquery id: Query GFX RLC SRLS firmware version */
744bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11
745bf215546Sopenharmony_ci	/* Subquery id: Query DMCU firmware version */
746bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_DMCU		0x12
747bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_TA		0x13
748bf215546Sopenharmony_ci	/* Subquery id: Query DMCUB firmware version */
749bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_DMCUB		0x14
750bf215546Sopenharmony_ci	/* Subquery id: Query TOC firmware version */
751bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_TOC		0x15
752bf215546Sopenharmony_ci	/* Subquery id: Query CAP firmware version */
753bf215546Sopenharmony_ci	#define AMDGPU_INFO_FW_CAP		0x16
754bf215546Sopenharmony_ci
755bf215546Sopenharmony_ci/* number of bytes moved for TTM migration */
756bf215546Sopenharmony_ci#define AMDGPU_INFO_NUM_BYTES_MOVED		0x0f
757bf215546Sopenharmony_ci/* the used VRAM size */
758bf215546Sopenharmony_ci#define AMDGPU_INFO_VRAM_USAGE			0x10
759bf215546Sopenharmony_ci/* the used GTT size */
760bf215546Sopenharmony_ci#define AMDGPU_INFO_GTT_USAGE			0x11
761bf215546Sopenharmony_ci/* Information about GDS, etc. resource configuration */
762bf215546Sopenharmony_ci#define AMDGPU_INFO_GDS_CONFIG			0x13
763bf215546Sopenharmony_ci/* Query information about VRAM and GTT domains */
764bf215546Sopenharmony_ci#define AMDGPU_INFO_VRAM_GTT			0x14
765bf215546Sopenharmony_ci/* Query information about register in MMR address space*/
766bf215546Sopenharmony_ci#define AMDGPU_INFO_READ_MMR_REG		0x15
767bf215546Sopenharmony_ci/* Query information about device: rev id, family, etc. */
768bf215546Sopenharmony_ci#define AMDGPU_INFO_DEV_INFO			0x16
769bf215546Sopenharmony_ci/* visible vram usage */
770bf215546Sopenharmony_ci#define AMDGPU_INFO_VIS_VRAM_USAGE		0x17
771bf215546Sopenharmony_ci/* number of TTM buffer evictions */
772bf215546Sopenharmony_ci#define AMDGPU_INFO_NUM_EVICTIONS		0x18
773bf215546Sopenharmony_ci/* Query memory about VRAM and GTT domains */
774bf215546Sopenharmony_ci#define AMDGPU_INFO_MEMORY			0x19
775bf215546Sopenharmony_ci/* Query vce clock table */
776bf215546Sopenharmony_ci#define AMDGPU_INFO_VCE_CLOCK_TABLE		0x1A
777bf215546Sopenharmony_ci/* Query vbios related information */
778bf215546Sopenharmony_ci#define AMDGPU_INFO_VBIOS			0x1B
779bf215546Sopenharmony_ci	/* Subquery id: Query vbios size */
780bf215546Sopenharmony_ci	#define AMDGPU_INFO_VBIOS_SIZE		0x1
781bf215546Sopenharmony_ci	/* Subquery id: Query vbios image */
782bf215546Sopenharmony_ci	#define AMDGPU_INFO_VBIOS_IMAGE		0x2
783bf215546Sopenharmony_ci	/* Subquery id: Query vbios info */
784bf215546Sopenharmony_ci	#define AMDGPU_INFO_VBIOS_INFO		0x3
785bf215546Sopenharmony_ci/* Query UVD handles */
786bf215546Sopenharmony_ci#define AMDGPU_INFO_NUM_HANDLES			0x1C
787bf215546Sopenharmony_ci/* Query sensor related information */
788bf215546Sopenharmony_ci#define AMDGPU_INFO_SENSOR			0x1D
789bf215546Sopenharmony_ci	/* Subquery id: Query GPU shader clock */
790bf215546Sopenharmony_ci	#define AMDGPU_INFO_SENSOR_GFX_SCLK		0x1
791bf215546Sopenharmony_ci	/* Subquery id: Query GPU memory clock */
792bf215546Sopenharmony_ci	#define AMDGPU_INFO_SENSOR_GFX_MCLK		0x2
793bf215546Sopenharmony_ci	/* Subquery id: Query GPU temperature */
794bf215546Sopenharmony_ci	#define AMDGPU_INFO_SENSOR_GPU_TEMP		0x3
795bf215546Sopenharmony_ci	/* Subquery id: Query GPU load */
796bf215546Sopenharmony_ci	#define AMDGPU_INFO_SENSOR_GPU_LOAD		0x4
797bf215546Sopenharmony_ci	/* Subquery id: Query average GPU power	*/
798bf215546Sopenharmony_ci	#define AMDGPU_INFO_SENSOR_GPU_AVG_POWER	0x5
799bf215546Sopenharmony_ci	/* Subquery id: Query northbridge voltage */
800bf215546Sopenharmony_ci	#define AMDGPU_INFO_SENSOR_VDDNB		0x6
801bf215546Sopenharmony_ci	/* Subquery id: Query graphics voltage */
802bf215546Sopenharmony_ci	#define AMDGPU_INFO_SENSOR_VDDGFX		0x7
803bf215546Sopenharmony_ci	/* Subquery id: Query GPU stable pstate shader clock */
804bf215546Sopenharmony_ci	#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK		0x8
805bf215546Sopenharmony_ci	/* Subquery id: Query GPU stable pstate memory clock */
806bf215546Sopenharmony_ci	#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK		0x9
807bf215546Sopenharmony_ci/* Number of VRAM page faults on CPU access. */
808bf215546Sopenharmony_ci#define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS	0x1E
809bf215546Sopenharmony_ci#define AMDGPU_INFO_VRAM_LOST_COUNTER		0x1F
810bf215546Sopenharmony_ci/* query ras mask of enabled features*/
811bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_FEATURES	0x20
812bf215546Sopenharmony_ci/* RAS MASK: UMC (VRAM) */
813bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_UMC			(1 << 0)
814bf215546Sopenharmony_ci/* RAS MASK: SDMA */
815bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_SDMA			(1 << 1)
816bf215546Sopenharmony_ci/* RAS MASK: GFX */
817bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_GFX			(1 << 2)
818bf215546Sopenharmony_ci/* RAS MASK: MMHUB */
819bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_MMHUB			(1 << 3)
820bf215546Sopenharmony_ci/* RAS MASK: ATHUB */
821bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_ATHUB			(1 << 4)
822bf215546Sopenharmony_ci/* RAS MASK: PCIE */
823bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_PCIE			(1 << 5)
824bf215546Sopenharmony_ci/* RAS MASK: HDP */
825bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_HDP			(1 << 6)
826bf215546Sopenharmony_ci/* RAS MASK: XGMI */
827bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_XGMI			(1 << 7)
828bf215546Sopenharmony_ci/* RAS MASK: DF */
829bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_DF			(1 << 8)
830bf215546Sopenharmony_ci/* RAS MASK: SMN */
831bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_SMN			(1 << 9)
832bf215546Sopenharmony_ci/* RAS MASK: SEM */
833bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_SEM			(1 << 10)
834bf215546Sopenharmony_ci/* RAS MASK: MP0 */
835bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_MP0			(1 << 11)
836bf215546Sopenharmony_ci/* RAS MASK: MP1 */
837bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_MP1			(1 << 12)
838bf215546Sopenharmony_ci/* RAS MASK: FUSE */
839bf215546Sopenharmony_ci#define AMDGPU_INFO_RAS_ENABLED_FUSE			(1 << 13)
840bf215546Sopenharmony_ci/* query video encode/decode caps */
841bf215546Sopenharmony_ci#define AMDGPU_INFO_VIDEO_CAPS			0x21
842bf215546Sopenharmony_ci	/* Subquery id: Decode */
843bf215546Sopenharmony_ci	#define AMDGPU_INFO_VIDEO_CAPS_DECODE		0
844bf215546Sopenharmony_ci	/* Subquery id: Encode */
845bf215546Sopenharmony_ci	#define AMDGPU_INFO_VIDEO_CAPS_ENCODE		1
846bf215546Sopenharmony_ci
847bf215546Sopenharmony_ci#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT	0
848bf215546Sopenharmony_ci#define AMDGPU_INFO_MMR_SE_INDEX_MASK	0xff
849bf215546Sopenharmony_ci#define AMDGPU_INFO_MMR_SH_INDEX_SHIFT	8
850bf215546Sopenharmony_ci#define AMDGPU_INFO_MMR_SH_INDEX_MASK	0xff
851bf215546Sopenharmony_ci
852bf215546Sopenharmony_cistruct drm_amdgpu_query_fw {
853bf215546Sopenharmony_ci	/** AMDGPU_INFO_FW_* */
854bf215546Sopenharmony_ci	__u32 fw_type;
855bf215546Sopenharmony_ci	/**
856bf215546Sopenharmony_ci	 * Index of the IP if there are more IPs of
857bf215546Sopenharmony_ci	 * the same type.
858bf215546Sopenharmony_ci	 */
859bf215546Sopenharmony_ci	__u32 ip_instance;
860bf215546Sopenharmony_ci	/**
861bf215546Sopenharmony_ci	 * Index of the engine. Whether this is used depends
862bf215546Sopenharmony_ci	 * on the firmware type. (e.g. MEC, SDMA)
863bf215546Sopenharmony_ci	 */
864bf215546Sopenharmony_ci	__u32 index;
865bf215546Sopenharmony_ci	__u32 _pad;
866bf215546Sopenharmony_ci};
867bf215546Sopenharmony_ci
868bf215546Sopenharmony_ci/* Input structure for the INFO ioctl */
869bf215546Sopenharmony_cistruct drm_amdgpu_info {
870bf215546Sopenharmony_ci	/* Where the return value will be stored */
871bf215546Sopenharmony_ci	__u64 return_pointer;
872bf215546Sopenharmony_ci	/* The size of the return value. Just like "size" in "snprintf",
873bf215546Sopenharmony_ci	 * it limits how many bytes the kernel can write. */
874bf215546Sopenharmony_ci	__u32 return_size;
875bf215546Sopenharmony_ci	/* The query request id. */
876bf215546Sopenharmony_ci	__u32 query;
877bf215546Sopenharmony_ci
878bf215546Sopenharmony_ci	union {
879bf215546Sopenharmony_ci		struct {
880bf215546Sopenharmony_ci			__u32 id;
881bf215546Sopenharmony_ci			__u32 _pad;
882bf215546Sopenharmony_ci		} mode_crtc;
883bf215546Sopenharmony_ci
884bf215546Sopenharmony_ci		struct {
885bf215546Sopenharmony_ci			/** AMDGPU_HW_IP_* */
886bf215546Sopenharmony_ci			__u32 type;
887bf215546Sopenharmony_ci			/**
888bf215546Sopenharmony_ci			 * Index of the IP if there are more IPs of the same
889bf215546Sopenharmony_ci			 * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
890bf215546Sopenharmony_ci			 */
891bf215546Sopenharmony_ci			__u32 ip_instance;
892bf215546Sopenharmony_ci		} query_hw_ip;
893bf215546Sopenharmony_ci
894bf215546Sopenharmony_ci		struct {
895bf215546Sopenharmony_ci			__u32 dword_offset;
896bf215546Sopenharmony_ci			/** number of registers to read */
897bf215546Sopenharmony_ci			__u32 count;
898bf215546Sopenharmony_ci			__u32 instance;
899bf215546Sopenharmony_ci			/** For future use, no flags defined so far */
900bf215546Sopenharmony_ci			__u32 flags;
901bf215546Sopenharmony_ci		} read_mmr_reg;
902bf215546Sopenharmony_ci
903bf215546Sopenharmony_ci		struct drm_amdgpu_query_fw query_fw;
904bf215546Sopenharmony_ci
905bf215546Sopenharmony_ci		struct {
906bf215546Sopenharmony_ci			__u32 type;
907bf215546Sopenharmony_ci			__u32 offset;
908bf215546Sopenharmony_ci		} vbios_info;
909bf215546Sopenharmony_ci
910bf215546Sopenharmony_ci		struct {
911bf215546Sopenharmony_ci			__u32 type;
912bf215546Sopenharmony_ci		} sensor_info;
913bf215546Sopenharmony_ci
914bf215546Sopenharmony_ci		struct {
915bf215546Sopenharmony_ci			__u32 type;
916bf215546Sopenharmony_ci		} video_cap;
917bf215546Sopenharmony_ci	};
918bf215546Sopenharmony_ci};
919bf215546Sopenharmony_ci
920bf215546Sopenharmony_cistruct drm_amdgpu_info_gds {
921bf215546Sopenharmony_ci	/** GDS GFX partition size */
922bf215546Sopenharmony_ci	__u32 gds_gfx_partition_size;
923bf215546Sopenharmony_ci	/** GDS compute partition size */
924bf215546Sopenharmony_ci	__u32 compute_partition_size;
925bf215546Sopenharmony_ci	/** total GDS memory size */
926bf215546Sopenharmony_ci	__u32 gds_total_size;
927bf215546Sopenharmony_ci	/** GWS size per GFX partition */
928bf215546Sopenharmony_ci	__u32 gws_per_gfx_partition;
929bf215546Sopenharmony_ci	/** GSW size per compute partition */
930bf215546Sopenharmony_ci	__u32 gws_per_compute_partition;
931bf215546Sopenharmony_ci	/** OA size per GFX partition */
932bf215546Sopenharmony_ci	__u32 oa_per_gfx_partition;
933bf215546Sopenharmony_ci	/** OA size per compute partition */
934bf215546Sopenharmony_ci	__u32 oa_per_compute_partition;
935bf215546Sopenharmony_ci	__u32 _pad;
936bf215546Sopenharmony_ci};
937bf215546Sopenharmony_ci
938bf215546Sopenharmony_cistruct drm_amdgpu_info_vram_gtt {
939bf215546Sopenharmony_ci	__u64 vram_size;
940bf215546Sopenharmony_ci	__u64 vram_cpu_accessible_size;
941bf215546Sopenharmony_ci	__u64 gtt_size;
942bf215546Sopenharmony_ci};
943bf215546Sopenharmony_ci
944bf215546Sopenharmony_cistruct drm_amdgpu_heap_info {
945bf215546Sopenharmony_ci	/** max. physical memory */
946bf215546Sopenharmony_ci	__u64 total_heap_size;
947bf215546Sopenharmony_ci
948bf215546Sopenharmony_ci	/** Theoretical max. available memory in the given heap */
949bf215546Sopenharmony_ci	__u64 usable_heap_size;
950bf215546Sopenharmony_ci
951bf215546Sopenharmony_ci	/**
952bf215546Sopenharmony_ci	 * Number of bytes allocated in the heap. This includes all processes
953bf215546Sopenharmony_ci	 * and private allocations in the kernel. It changes when new buffers
954bf215546Sopenharmony_ci	 * are allocated, freed, and moved. It cannot be larger than
955bf215546Sopenharmony_ci	 * heap_size.
956bf215546Sopenharmony_ci	 */
957bf215546Sopenharmony_ci	__u64 heap_usage;
958bf215546Sopenharmony_ci
959bf215546Sopenharmony_ci	/**
960bf215546Sopenharmony_ci	 * Theoretical possible max. size of buffer which
961bf215546Sopenharmony_ci	 * could be allocated in the given heap
962bf215546Sopenharmony_ci	 */
963bf215546Sopenharmony_ci	__u64 max_allocation;
964bf215546Sopenharmony_ci};
965bf215546Sopenharmony_ci
966bf215546Sopenharmony_cistruct drm_amdgpu_memory_info {
967bf215546Sopenharmony_ci	struct drm_amdgpu_heap_info vram;
968bf215546Sopenharmony_ci	struct drm_amdgpu_heap_info cpu_accessible_vram;
969bf215546Sopenharmony_ci	struct drm_amdgpu_heap_info gtt;
970bf215546Sopenharmony_ci};
971bf215546Sopenharmony_ci
972bf215546Sopenharmony_cistruct drm_amdgpu_info_firmware {
973bf215546Sopenharmony_ci	__u32 ver;
974bf215546Sopenharmony_ci	__u32 feature;
975bf215546Sopenharmony_ci};
976bf215546Sopenharmony_ci
977bf215546Sopenharmony_cistruct drm_amdgpu_info_vbios {
978bf215546Sopenharmony_ci	__u8 name[64];
979bf215546Sopenharmony_ci	__u8 vbios_pn[64];
980bf215546Sopenharmony_ci	__u32 version;
981bf215546Sopenharmony_ci	__u32 pad;
982bf215546Sopenharmony_ci	__u8 vbios_ver_str[32];
983bf215546Sopenharmony_ci	__u8 date[32];
984bf215546Sopenharmony_ci};
985bf215546Sopenharmony_ci
986bf215546Sopenharmony_ci#define AMDGPU_VRAM_TYPE_UNKNOWN 0
987bf215546Sopenharmony_ci#define AMDGPU_VRAM_TYPE_GDDR1 1
988bf215546Sopenharmony_ci#define AMDGPU_VRAM_TYPE_DDR2  2
989bf215546Sopenharmony_ci#define AMDGPU_VRAM_TYPE_GDDR3 3
990bf215546Sopenharmony_ci#define AMDGPU_VRAM_TYPE_GDDR4 4
991bf215546Sopenharmony_ci#define AMDGPU_VRAM_TYPE_GDDR5 5
992bf215546Sopenharmony_ci#define AMDGPU_VRAM_TYPE_HBM   6
993bf215546Sopenharmony_ci#define AMDGPU_VRAM_TYPE_DDR3  7
994bf215546Sopenharmony_ci#define AMDGPU_VRAM_TYPE_DDR4  8
995bf215546Sopenharmony_ci#define AMDGPU_VRAM_TYPE_GDDR6 9
996bf215546Sopenharmony_ci#define AMDGPU_VRAM_TYPE_DDR5  10
997bf215546Sopenharmony_ci
998bf215546Sopenharmony_cistruct drm_amdgpu_info_device {
999bf215546Sopenharmony_ci	/** PCI Device ID */
1000bf215546Sopenharmony_ci	__u32 device_id;
1001bf215546Sopenharmony_ci	/** Internal chip revision: A0, A1, etc.) */
1002bf215546Sopenharmony_ci	__u32 chip_rev;
1003bf215546Sopenharmony_ci	__u32 external_rev;
1004bf215546Sopenharmony_ci	/** Revision id in PCI Config space */
1005bf215546Sopenharmony_ci	__u32 pci_rev;
1006bf215546Sopenharmony_ci	__u32 family;
1007bf215546Sopenharmony_ci	__u32 num_shader_engines;
1008bf215546Sopenharmony_ci	__u32 num_shader_arrays_per_engine;
1009bf215546Sopenharmony_ci	/* in KHz */
1010bf215546Sopenharmony_ci	__u32 gpu_counter_freq;
1011bf215546Sopenharmony_ci	__u64 max_engine_clock;
1012bf215546Sopenharmony_ci	__u64 max_memory_clock;
1013bf215546Sopenharmony_ci	/* cu information */
1014bf215546Sopenharmony_ci	__u32 cu_active_number;
1015bf215546Sopenharmony_ci	/* NOTE: cu_ao_mask is INVALID, DON'T use it */
1016bf215546Sopenharmony_ci	__u32 cu_ao_mask;
1017bf215546Sopenharmony_ci	__u32 cu_bitmap[4][4];
1018bf215546Sopenharmony_ci	/** Render backend pipe mask. One render backend is CB+DB. */
1019bf215546Sopenharmony_ci	__u32 enabled_rb_pipes_mask;
1020bf215546Sopenharmony_ci	__u32 num_rb_pipes;
1021bf215546Sopenharmony_ci	__u32 num_hw_gfx_contexts;
1022bf215546Sopenharmony_ci	__u32 _pad;
1023bf215546Sopenharmony_ci	__u64 ids_flags;
1024bf215546Sopenharmony_ci	/** Starting virtual address for UMDs. */
1025bf215546Sopenharmony_ci	__u64 virtual_address_offset;
1026bf215546Sopenharmony_ci	/** The maximum virtual address */
1027bf215546Sopenharmony_ci	__u64 virtual_address_max;
1028bf215546Sopenharmony_ci	/** Required alignment of virtual addresses. */
1029bf215546Sopenharmony_ci	__u32 virtual_address_alignment;
1030bf215546Sopenharmony_ci	/** Page table entry - fragment size */
1031bf215546Sopenharmony_ci	__u32 pte_fragment_size;
1032bf215546Sopenharmony_ci	__u32 gart_page_size;
1033bf215546Sopenharmony_ci	/** constant engine ram size*/
1034bf215546Sopenharmony_ci	__u32 ce_ram_size;
1035bf215546Sopenharmony_ci	/** video memory type info*/
1036bf215546Sopenharmony_ci	__u32 vram_type;
1037bf215546Sopenharmony_ci	/** video memory bit width*/
1038bf215546Sopenharmony_ci	__u32 vram_bit_width;
1039bf215546Sopenharmony_ci	/* vce harvesting instance */
1040bf215546Sopenharmony_ci	__u32 vce_harvest_config;
1041bf215546Sopenharmony_ci	/* gfx double offchip LDS buffers */
1042bf215546Sopenharmony_ci	__u32 gc_double_offchip_lds_buf;
1043bf215546Sopenharmony_ci	/* NGG Primitive Buffer */
1044bf215546Sopenharmony_ci	__u64 prim_buf_gpu_addr;
1045bf215546Sopenharmony_ci	/* NGG Position Buffer */
1046bf215546Sopenharmony_ci	__u64 pos_buf_gpu_addr;
1047bf215546Sopenharmony_ci	/* NGG Control Sideband */
1048bf215546Sopenharmony_ci	__u64 cntl_sb_buf_gpu_addr;
1049bf215546Sopenharmony_ci	/* NGG Parameter Cache */
1050bf215546Sopenharmony_ci	__u64 param_buf_gpu_addr;
1051bf215546Sopenharmony_ci	__u32 prim_buf_size;
1052bf215546Sopenharmony_ci	__u32 pos_buf_size;
1053bf215546Sopenharmony_ci	__u32 cntl_sb_buf_size;
1054bf215546Sopenharmony_ci	__u32 param_buf_size;
1055bf215546Sopenharmony_ci	/* wavefront size*/
1056bf215546Sopenharmony_ci	__u32 wave_front_size;
1057bf215546Sopenharmony_ci	/* shader visible vgprs*/
1058bf215546Sopenharmony_ci	__u32 num_shader_visible_vgprs;
1059bf215546Sopenharmony_ci	/* CU per shader array*/
1060bf215546Sopenharmony_ci	__u32 num_cu_per_sh;
1061bf215546Sopenharmony_ci	/* number of tcc blocks*/
1062bf215546Sopenharmony_ci	__u32 num_tcc_blocks;
1063bf215546Sopenharmony_ci	/* gs vgt table depth*/
1064bf215546Sopenharmony_ci	__u32 gs_vgt_table_depth;
1065bf215546Sopenharmony_ci	/* gs primitive buffer depth*/
1066bf215546Sopenharmony_ci	__u32 gs_prim_buffer_depth;
1067bf215546Sopenharmony_ci	/* max gs wavefront per vgt*/
1068bf215546Sopenharmony_ci	__u32 max_gs_waves_per_vgt;
1069bf215546Sopenharmony_ci	__u32 _pad1;
1070bf215546Sopenharmony_ci	/* always on cu bitmap */
1071bf215546Sopenharmony_ci	__u32 cu_ao_bitmap[4][4];
1072bf215546Sopenharmony_ci	/** Starting high virtual address for UMDs. */
1073bf215546Sopenharmony_ci	__u64 high_va_offset;
1074bf215546Sopenharmony_ci	/** The maximum high virtual address */
1075bf215546Sopenharmony_ci	__u64 high_va_max;
1076bf215546Sopenharmony_ci	/* gfx10 pa_sc_tile_steering_override */
1077bf215546Sopenharmony_ci	__u32 pa_sc_tile_steering_override;
1078bf215546Sopenharmony_ci	/* disabled TCCs */
1079bf215546Sopenharmony_ci	__u64 tcc_disabled_mask;
1080bf215546Sopenharmony_ci};
1081bf215546Sopenharmony_ci
1082bf215546Sopenharmony_cistruct drm_amdgpu_info_hw_ip {
1083bf215546Sopenharmony_ci	/** Version of h/w IP */
1084bf215546Sopenharmony_ci	__u32  hw_ip_version_major;
1085bf215546Sopenharmony_ci	__u32  hw_ip_version_minor;
1086bf215546Sopenharmony_ci	/** Capabilities */
1087bf215546Sopenharmony_ci	__u64  capabilities_flags;
1088bf215546Sopenharmony_ci	/** command buffer address start alignment*/
1089bf215546Sopenharmony_ci	__u32  ib_start_alignment;
1090bf215546Sopenharmony_ci	/** command buffer size alignment*/
1091bf215546Sopenharmony_ci	__u32  ib_size_alignment;
1092bf215546Sopenharmony_ci	/** Bitmask of available rings. Bit 0 means ring 0, etc. */
1093bf215546Sopenharmony_ci	__u32  available_rings;
1094bf215546Sopenharmony_ci	/** version info: bits 23:16 major, 15:8 minor, 7:0 revision */
1095bf215546Sopenharmony_ci	__u32  ip_discovery_version;
1096bf215546Sopenharmony_ci};
1097bf215546Sopenharmony_ci
1098bf215546Sopenharmony_cistruct drm_amdgpu_info_num_handles {
1099bf215546Sopenharmony_ci	/** Max handles as supported by firmware for UVD */
1100bf215546Sopenharmony_ci	__u32  uvd_max_handles;
1101bf215546Sopenharmony_ci	/** Handles currently in use for UVD */
1102bf215546Sopenharmony_ci	__u32  uvd_used_handles;
1103bf215546Sopenharmony_ci};
1104bf215546Sopenharmony_ci
1105bf215546Sopenharmony_ci#define AMDGPU_VCE_CLOCK_TABLE_ENTRIES		6
1106bf215546Sopenharmony_ci
1107bf215546Sopenharmony_cistruct drm_amdgpu_info_vce_clock_table_entry {
1108bf215546Sopenharmony_ci	/** System clock */
1109bf215546Sopenharmony_ci	__u32 sclk;
1110bf215546Sopenharmony_ci	/** Memory clock */
1111bf215546Sopenharmony_ci	__u32 mclk;
1112bf215546Sopenharmony_ci	/** VCE clock */
1113bf215546Sopenharmony_ci	__u32 eclk;
1114bf215546Sopenharmony_ci	__u32 pad;
1115bf215546Sopenharmony_ci};
1116bf215546Sopenharmony_ci
1117bf215546Sopenharmony_cistruct drm_amdgpu_info_vce_clock_table {
1118bf215546Sopenharmony_ci	struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
1119bf215546Sopenharmony_ci	__u32 num_valid_entries;
1120bf215546Sopenharmony_ci	__u32 pad;
1121bf215546Sopenharmony_ci};
1122bf215546Sopenharmony_ci
1123bf215546Sopenharmony_ci/* query video encode/decode caps */
1124bf215546Sopenharmony_ci#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2			0
1125bf215546Sopenharmony_ci#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4			1
1126bf215546Sopenharmony_ci#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1			2
1127bf215546Sopenharmony_ci#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC		3
1128bf215546Sopenharmony_ci#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC			4
1129bf215546Sopenharmony_ci#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG			5
1130bf215546Sopenharmony_ci#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9			6
1131bf215546Sopenharmony_ci#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1			7
1132bf215546Sopenharmony_ci#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT			8
1133bf215546Sopenharmony_ci
1134bf215546Sopenharmony_cistruct drm_amdgpu_info_video_codec_info {
1135bf215546Sopenharmony_ci	__u32 valid;
1136bf215546Sopenharmony_ci	__u32 max_width;
1137bf215546Sopenharmony_ci	__u32 max_height;
1138bf215546Sopenharmony_ci	__u32 max_pixels_per_frame;
1139bf215546Sopenharmony_ci	__u32 max_level;
1140bf215546Sopenharmony_ci	__u32 pad;
1141bf215546Sopenharmony_ci};
1142bf215546Sopenharmony_ci
1143bf215546Sopenharmony_cistruct drm_amdgpu_info_video_caps {
1144bf215546Sopenharmony_ci	struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT];
1145bf215546Sopenharmony_ci};
1146bf215546Sopenharmony_ci
1147bf215546Sopenharmony_ci/*
1148bf215546Sopenharmony_ci * Supported GPU families
1149bf215546Sopenharmony_ci */
1150bf215546Sopenharmony_ci#define AMDGPU_FAMILY_UNKNOWN			0
1151bf215546Sopenharmony_ci#define AMDGPU_FAMILY_SI			110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */
1152bf215546Sopenharmony_ci#define AMDGPU_FAMILY_CI			120 /* Bonaire, Hawaii */
1153bf215546Sopenharmony_ci#define AMDGPU_FAMILY_KV			125 /* Kaveri, Kabini, Mullins */
1154bf215546Sopenharmony_ci#define AMDGPU_FAMILY_VI			130 /* Iceland, Tonga */
1155bf215546Sopenharmony_ci#define AMDGPU_FAMILY_CZ			135 /* Carrizo, Stoney */
1156bf215546Sopenharmony_ci#define AMDGPU_FAMILY_AI			141 /* Vega10 */
1157bf215546Sopenharmony_ci#define AMDGPU_FAMILY_RV			142 /* Raven */
1158bf215546Sopenharmony_ci#define AMDGPU_FAMILY_NV			143 /* Navi10 */
1159bf215546Sopenharmony_ci#define AMDGPU_FAMILY_VGH			144 /* Van Gogh */
1160bf215546Sopenharmony_ci#define AMDGPU_FAMILY_GC_11_0_0			145 /* GC 11.0.0 */
1161bf215546Sopenharmony_ci#define AMDGPU_FAMILY_YC			146 /* Yellow Carp */
1162bf215546Sopenharmony_ci#define AMDGPU_FAMILY_GC_11_0_1			148 /* GC 11.0.1 */
1163bf215546Sopenharmony_ci#define AMDGPU_FAMILY_GC_10_3_6			149 /* GC 10.3.6 */
1164bf215546Sopenharmony_ci#define AMDGPU_FAMILY_GC_10_3_7			151 /* GC 10.3.7 */
1165bf215546Sopenharmony_ci
1166bf215546Sopenharmony_ci#if defined(__cplusplus)
1167bf215546Sopenharmony_ci}
1168bf215546Sopenharmony_ci#endif
1169bf215546Sopenharmony_ci
1170bf215546Sopenharmony_ci#endif
1171