amdgpu_drm.h revision 037b3c26
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
533f012e29Smrg
543f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_CREATE	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
553f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_MMAP	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
563f012e29Smrg#define DRM_IOCTL_AMDGPU_CTX		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
573f012e29Smrg#define DRM_IOCTL_AMDGPU_BO_LIST	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
583f012e29Smrg#define DRM_IOCTL_AMDGPU_CS		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
593f012e29Smrg#define DRM_IOCTL_AMDGPU_INFO		DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
603f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_METADATA	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
613f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
623f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_VA		DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
633f012e29Smrg#define DRM_IOCTL_AMDGPU_WAIT_CS	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
643f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_OP		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
653f012e29Smrg#define DRM_IOCTL_AMDGPU_GEM_USERPTR	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
663f012e29Smrg
673f012e29Smrg#define AMDGPU_GEM_DOMAIN_CPU		0x1
683f012e29Smrg#define AMDGPU_GEM_DOMAIN_GTT		0x2
693f012e29Smrg#define AMDGPU_GEM_DOMAIN_VRAM		0x4
703f012e29Smrg#define AMDGPU_GEM_DOMAIN_GDS		0x8
713f012e29Smrg#define AMDGPU_GEM_DOMAIN_GWS		0x10
723f012e29Smrg#define AMDGPU_GEM_DOMAIN_OA		0x20
733f012e29Smrg
743f012e29Smrg/* Flag that CPU access will be required for the case of VRAM domain */
753f012e29Smrg#define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED	(1 << 0)
763f012e29Smrg/* Flag that CPU access will not work, this VRAM domain is invisible */
773f012e29Smrg#define AMDGPU_GEM_CREATE_NO_CPU_ACCESS		(1 << 1)
783f012e29Smrg/* Flag that USWC attributes should be used for GTT */
793f012e29Smrg#define AMDGPU_GEM_CREATE_CPU_GTT_USWC		(1 << 2)
80037b3c26Smrg/* Flag that the memory should be in VRAM and cleared */
81037b3c26Smrg#define AMDGPU_GEM_CREATE_VRAM_CLEARED		(1 << 3)
823f012e29Smrg
833f012e29Smrgstruct drm_amdgpu_gem_create_in  {
843f012e29Smrg	/** the requested memory size */
853f012e29Smrg	uint64_t bo_size;
863f012e29Smrg	/** physical start_addr alignment in bytes for some HW requirements */
873f012e29Smrg	uint64_t alignment;
883f012e29Smrg	/** the requested memory domains */
893f012e29Smrg	uint64_t domains;
903f012e29Smrg	/** allocation flags */
913f012e29Smrg	uint64_t domain_flags;
923f012e29Smrg};
933f012e29Smrg
943f012e29Smrgstruct drm_amdgpu_gem_create_out  {
953f012e29Smrg	/** returned GEM object handle */
963f012e29Smrg	uint32_t handle;
973f012e29Smrg	uint32_t _pad;
983f012e29Smrg};
993f012e29Smrg
1003f012e29Smrgunion drm_amdgpu_gem_create {
1013f012e29Smrg	struct drm_amdgpu_gem_create_in		in;
1023f012e29Smrg	struct drm_amdgpu_gem_create_out	out;
1033f012e29Smrg};
1043f012e29Smrg
1053f012e29Smrg/** Opcode to create new residency list.  */
1063f012e29Smrg#define AMDGPU_BO_LIST_OP_CREATE	0
1073f012e29Smrg/** Opcode to destroy previously created residency list */
1083f012e29Smrg#define AMDGPU_BO_LIST_OP_DESTROY	1
1093f012e29Smrg/** Opcode to update resource information in the list */
1103f012e29Smrg#define AMDGPU_BO_LIST_OP_UPDATE	2
1113f012e29Smrg
1123f012e29Smrgstruct drm_amdgpu_bo_list_in {
1133f012e29Smrg	/** Type of operation */
1143f012e29Smrg	uint32_t operation;
1153f012e29Smrg	/** Handle of list or 0 if we want to create one */
1163f012e29Smrg	uint32_t list_handle;
1173f012e29Smrg	/** Number of BOs in list  */
1183f012e29Smrg	uint32_t bo_number;
1193f012e29Smrg	/** Size of each element describing BO */
1203f012e29Smrg	uint32_t bo_info_size;
1213f012e29Smrg	/** Pointer to array describing BOs */
1223f012e29Smrg	uint64_t bo_info_ptr;
1233f012e29Smrg};
1243f012e29Smrg
1253f012e29Smrgstruct drm_amdgpu_bo_list_entry {
1263f012e29Smrg	/** Handle of BO */
1273f012e29Smrg	uint32_t bo_handle;
1283f012e29Smrg	/** New (if specified) BO priority to be used during migration */
1293f012e29Smrg	uint32_t bo_priority;
1303f012e29Smrg};
1313f012e29Smrg
1323f012e29Smrgstruct drm_amdgpu_bo_list_out {
1333f012e29Smrg	/** Handle of resource list  */
1343f012e29Smrg	uint32_t list_handle;
1353f012e29Smrg	uint32_t _pad;
1363f012e29Smrg};
1373f012e29Smrg
1383f012e29Smrgunion drm_amdgpu_bo_list {
1393f012e29Smrg	struct drm_amdgpu_bo_list_in in;
1403f012e29Smrg	struct drm_amdgpu_bo_list_out out;
1413f012e29Smrg};
1423f012e29Smrg
1433f012e29Smrg/* context related */
1443f012e29Smrg#define AMDGPU_CTX_OP_ALLOC_CTX	1
1453f012e29Smrg#define AMDGPU_CTX_OP_FREE_CTX	2
1463f012e29Smrg#define AMDGPU_CTX_OP_QUERY_STATE	3
1473f012e29Smrg
1483f012e29Smrg/* GPU reset status */
1493f012e29Smrg#define AMDGPU_CTX_NO_RESET		0
1503f012e29Smrg/* this the context caused it */
1513f012e29Smrg#define AMDGPU_CTX_GUILTY_RESET		1
1523f012e29Smrg/* some other context caused it */
1533f012e29Smrg#define AMDGPU_CTX_INNOCENT_RESET	2
1543f012e29Smrg/* unknown cause */
1553f012e29Smrg#define AMDGPU_CTX_UNKNOWN_RESET	3
1563f012e29Smrg
1573f012e29Smrgstruct drm_amdgpu_ctx_in {
1583f012e29Smrg	/** AMDGPU_CTX_OP_* */
1593f012e29Smrg	uint32_t	op;
1603f012e29Smrg	/** For future use, no flags defined so far */
1613f012e29Smrg	uint32_t	flags;
1623f012e29Smrg	uint32_t	ctx_id;
1633f012e29Smrg	uint32_t	_pad;
1643f012e29Smrg};
1653f012e29Smrg
1663f012e29Smrgunion drm_amdgpu_ctx_out {
1673f012e29Smrg		struct {
1683f012e29Smrg			uint32_t	ctx_id;
1693f012e29Smrg			uint32_t	_pad;
1703f012e29Smrg		} alloc;
1713f012e29Smrg
1723f012e29Smrg		struct {
1733f012e29Smrg			/** For future use, no flags defined so far */
1743f012e29Smrg			uint64_t	flags;
1753f012e29Smrg			/** Number of resets caused by this context so far. */
1763f012e29Smrg			uint32_t	hangs;
1773f012e29Smrg			/** Reset status since the last call of the ioctl. */
1783f012e29Smrg			uint32_t	reset_status;
1793f012e29Smrg		} state;
1803f012e29Smrg};
1813f012e29Smrg
1823f012e29Smrgunion drm_amdgpu_ctx {
1833f012e29Smrg	struct drm_amdgpu_ctx_in in;
1843f012e29Smrg	union drm_amdgpu_ctx_out out;
1853f012e29Smrg};
1863f012e29Smrg
1873f012e29Smrg/*
1883f012e29Smrg * This is not a reliable API and you should expect it to fail for any
1893f012e29Smrg * number of reasons and have fallback path that do not use userptr to
1903f012e29Smrg * perform any operation.
1913f012e29Smrg */
1923f012e29Smrg#define AMDGPU_GEM_USERPTR_READONLY	(1 << 0)
1933f012e29Smrg#define AMDGPU_GEM_USERPTR_ANONONLY	(1 << 1)
1943f012e29Smrg#define AMDGPU_GEM_USERPTR_VALIDATE	(1 << 2)
1953f012e29Smrg#define AMDGPU_GEM_USERPTR_REGISTER	(1 << 3)
1963f012e29Smrg
1973f012e29Smrgstruct drm_amdgpu_gem_userptr {
1983f012e29Smrg	uint64_t		addr;
1993f012e29Smrg	uint64_t		size;
2003f012e29Smrg	/* AMDGPU_GEM_USERPTR_* */
2013f012e29Smrg	uint32_t		flags;
2023f012e29Smrg	/* Resulting GEM handle */
2033f012e29Smrg	uint32_t		handle;
2043f012e29Smrg};
2053f012e29Smrg
2063f012e29Smrg/* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
2073f012e29Smrg#define AMDGPU_TILING_ARRAY_MODE_SHIFT			0
2083f012e29Smrg#define AMDGPU_TILING_ARRAY_MODE_MASK			0xf
2093f012e29Smrg#define AMDGPU_TILING_PIPE_CONFIG_SHIFT			4
2103f012e29Smrg#define AMDGPU_TILING_PIPE_CONFIG_MASK			0x1f
2113f012e29Smrg#define AMDGPU_TILING_TILE_SPLIT_SHIFT			9
2123f012e29Smrg#define AMDGPU_TILING_TILE_SPLIT_MASK			0x7
2133f012e29Smrg#define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT		12
2143f012e29Smrg#define AMDGPU_TILING_MICRO_TILE_MODE_MASK		0x7
2153f012e29Smrg#define AMDGPU_TILING_BANK_WIDTH_SHIFT			15
2163f012e29Smrg#define AMDGPU_TILING_BANK_WIDTH_MASK			0x3
2173f012e29Smrg#define AMDGPU_TILING_BANK_HEIGHT_SHIFT			17
2183f012e29Smrg#define AMDGPU_TILING_BANK_HEIGHT_MASK			0x3
2193f012e29Smrg#define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT		19
2203f012e29Smrg#define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK		0x3
2213f012e29Smrg#define AMDGPU_TILING_NUM_BANKS_SHIFT			21
2223f012e29Smrg#define AMDGPU_TILING_NUM_BANKS_MASK			0x3
2233f012e29Smrg
2243f012e29Smrg#define AMDGPU_TILING_SET(field, value) \
2253f012e29Smrg	(((value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
2263f012e29Smrg#define AMDGPU_TILING_GET(value, field) \
2273f012e29Smrg	(((value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
2283f012e29Smrg
2293f012e29Smrg#define AMDGPU_GEM_METADATA_OP_SET_METADATA                  1
2303f012e29Smrg#define AMDGPU_GEM_METADATA_OP_GET_METADATA                  2
2313f012e29Smrg
2323f012e29Smrg/** The same structure is shared for input/output */
2333f012e29Smrgstruct drm_amdgpu_gem_metadata {
2343f012e29Smrg	/** GEM Object handle */
2353f012e29Smrg	uint32_t	handle;
2363f012e29Smrg	/** Do we want get or set metadata */
2373f012e29Smrg	uint32_t	op;
2383f012e29Smrg	struct {
2393f012e29Smrg		/** For future use, no flags defined so far */
2403f012e29Smrg		uint64_t	flags;
2413f012e29Smrg		/** family specific tiling info */
2423f012e29Smrg		uint64_t	tiling_info;
2433f012e29Smrg		uint32_t	data_size_bytes;
2443f012e29Smrg		uint32_t	data[64];
2453f012e29Smrg	} data;
2463f012e29Smrg};
2473f012e29Smrg
2483f012e29Smrgstruct drm_amdgpu_gem_mmap_in {
2493f012e29Smrg	/** the GEM object handle */
2503f012e29Smrg	uint32_t handle;
2513f012e29Smrg	uint32_t _pad;
2523f012e29Smrg};
2533f012e29Smrg
2543f012e29Smrgstruct drm_amdgpu_gem_mmap_out {
2553f012e29Smrg	/** mmap offset from the vma offset manager */
2563f012e29Smrg	uint64_t addr_ptr;
2573f012e29Smrg};
2583f012e29Smrg
2593f012e29Smrgunion drm_amdgpu_gem_mmap {
2603f012e29Smrg	struct drm_amdgpu_gem_mmap_in   in;
2613f012e29Smrg	struct drm_amdgpu_gem_mmap_out out;
2623f012e29Smrg};
2633f012e29Smrg
2643f012e29Smrgstruct drm_amdgpu_gem_wait_idle_in {
2653f012e29Smrg	/** GEM object handle */
2663f012e29Smrg	uint32_t handle;
2673f012e29Smrg	/** For future use, no flags defined so far */
2683f012e29Smrg	uint32_t flags;
2693f012e29Smrg	/** Absolute timeout to wait */
2703f012e29Smrg	uint64_t timeout;
2713f012e29Smrg};
2723f012e29Smrg
2733f012e29Smrgstruct drm_amdgpu_gem_wait_idle_out {
2743f012e29Smrg	/** BO status:  0 - BO is idle, 1 - BO is busy */
2753f012e29Smrg	uint32_t status;
2763f012e29Smrg	/** Returned current memory domain */
2773f012e29Smrg	uint32_t domain;
2783f012e29Smrg};
2793f012e29Smrg
2803f012e29Smrgunion drm_amdgpu_gem_wait_idle {
2813f012e29Smrg	struct drm_amdgpu_gem_wait_idle_in  in;
2823f012e29Smrg	struct drm_amdgpu_gem_wait_idle_out out;
2833f012e29Smrg};
2843f012e29Smrg
2853f012e29Smrgstruct drm_amdgpu_wait_cs_in {
2863f012e29Smrg	/** Command submission handle */
2873f012e29Smrg	uint64_t handle;
2883f012e29Smrg	/** Absolute timeout to wait */
2893f012e29Smrg	uint64_t timeout;
2903f012e29Smrg	uint32_t ip_type;
2913f012e29Smrg	uint32_t ip_instance;
2923f012e29Smrg	uint32_t ring;
2933f012e29Smrg	uint32_t ctx_id;
2943f012e29Smrg};
2953f012e29Smrg
2963f012e29Smrgstruct drm_amdgpu_wait_cs_out {
2973f012e29Smrg	/** CS status:  0 - CS completed, 1 - CS still busy */
2983f012e29Smrg	uint64_t status;
2993f012e29Smrg};
3003f012e29Smrg
3013f012e29Smrgunion drm_amdgpu_wait_cs {
3023f012e29Smrg	struct drm_amdgpu_wait_cs_in in;
3033f012e29Smrg	struct drm_amdgpu_wait_cs_out out;
3043f012e29Smrg};
3053f012e29Smrg
3063f012e29Smrg#define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO	0
3073f012e29Smrg#define AMDGPU_GEM_OP_SET_PLACEMENT		1
3083f012e29Smrg
3093f012e29Smrg/* Sets or returns a value associated with a buffer. */
3103f012e29Smrgstruct drm_amdgpu_gem_op {
3113f012e29Smrg	/** GEM object handle */
3123f012e29Smrg	uint32_t	handle;
3133f012e29Smrg	/** AMDGPU_GEM_OP_* */
3143f012e29Smrg	uint32_t	op;
3153f012e29Smrg	/** Input or return value */
3163f012e29Smrg	uint64_t	value;
3173f012e29Smrg};
3183f012e29Smrg
3193f012e29Smrg#define AMDGPU_VA_OP_MAP			1
3203f012e29Smrg#define AMDGPU_VA_OP_UNMAP			2
3213f012e29Smrg
3223f012e29Smrg/* Delay the page table update till the next CS */
3233f012e29Smrg#define AMDGPU_VM_DELAY_UPDATE		(1 << 0)
3243f012e29Smrg
3253f012e29Smrg/* Mapping flags */
3263f012e29Smrg/* readable mapping */
3273f012e29Smrg#define AMDGPU_VM_PAGE_READABLE		(1 << 1)
3283f012e29Smrg/* writable mapping */
3293f012e29Smrg#define AMDGPU_VM_PAGE_WRITEABLE	(1 << 2)
3303f012e29Smrg/* executable mapping, new for VI */
3313f012e29Smrg#define AMDGPU_VM_PAGE_EXECUTABLE	(1 << 3)
3323f012e29Smrg
3333f012e29Smrgstruct drm_amdgpu_gem_va {
3343f012e29Smrg	/** GEM object handle */
3353f012e29Smrg	uint32_t handle;
3363f012e29Smrg	uint32_t _pad;
3373f012e29Smrg	/** AMDGPU_VA_OP_* */
3383f012e29Smrg	uint32_t operation;
3393f012e29Smrg	/** AMDGPU_VM_PAGE_* */
3403f012e29Smrg	uint32_t flags;
3413f012e29Smrg	/** va address to assign . Must be correctly aligned.*/
3423f012e29Smrg	uint64_t va_address;
3433f012e29Smrg	/** Specify offset inside of BO to assign. Must be correctly aligned.*/
3443f012e29Smrg	uint64_t offset_in_bo;
3453f012e29Smrg	/** Specify mapping size. Must be correctly aligned. */
3463f012e29Smrg	uint64_t map_size;
3473f012e29Smrg};
3483f012e29Smrg
3493f012e29Smrg#define AMDGPU_HW_IP_GFX          0
3503f012e29Smrg#define AMDGPU_HW_IP_COMPUTE      1
3513f012e29Smrg#define AMDGPU_HW_IP_DMA          2
3523f012e29Smrg#define AMDGPU_HW_IP_UVD          3
3533f012e29Smrg#define AMDGPU_HW_IP_VCE          4
3543f012e29Smrg#define AMDGPU_HW_IP_NUM          5
3553f012e29Smrg
3563f012e29Smrg#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
3573f012e29Smrg
3583f012e29Smrg#define AMDGPU_CHUNK_ID_IB		0x01
3593f012e29Smrg#define AMDGPU_CHUNK_ID_FENCE		0x02
3603f012e29Smrg#define AMDGPU_CHUNK_ID_DEPENDENCIES	0x03
3613f012e29Smrg
3623f012e29Smrgstruct drm_amdgpu_cs_chunk {
3633f012e29Smrg	uint32_t		chunk_id;
3643f012e29Smrg	uint32_t		length_dw;
3653f012e29Smrg	uint64_t		chunk_data;
3663f012e29Smrg};
3673f012e29Smrg
3683f012e29Smrgstruct drm_amdgpu_cs_in {
3693f012e29Smrg	/** Rendering context id */
3703f012e29Smrg	uint32_t		ctx_id;
3713f012e29Smrg	/**  Handle of resource list associated with CS */
3723f012e29Smrg	uint32_t		bo_list_handle;
3733f012e29Smrg	uint32_t		num_chunks;
3743f012e29Smrg	uint32_t		_pad;
3753f012e29Smrg	/** this points to uint64_t * which point to cs chunks */
3763f012e29Smrg	uint64_t		chunks;
3773f012e29Smrg};
3783f012e29Smrg
3793f012e29Smrgstruct drm_amdgpu_cs_out {
3803f012e29Smrg	uint64_t handle;
3813f012e29Smrg};
3823f012e29Smrg
3833f012e29Smrgunion drm_amdgpu_cs {
3843f012e29Smrg	struct drm_amdgpu_cs_in in;
3853f012e29Smrg	struct drm_amdgpu_cs_out out;
3863f012e29Smrg};
3873f012e29Smrg
3883f012e29Smrg/* Specify flags to be used for IB */
3893f012e29Smrg
3903f012e29Smrg/* This IB should be submitted to CE */
3913f012e29Smrg#define AMDGPU_IB_FLAG_CE	(1<<0)
3923f012e29Smrg
3933f012e29Smrg/* CE Preamble */
3943f012e29Smrg#define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
3953f012e29Smrg
3963f012e29Smrgstruct drm_amdgpu_cs_chunk_ib {
3973f012e29Smrg	uint32_t _pad;
3983f012e29Smrg	/** AMDGPU_IB_FLAG_* */
3993f012e29Smrg	uint32_t flags;
4003f012e29Smrg	/** Virtual address to begin IB execution */
4013f012e29Smrg	uint64_t va_start;
4023f012e29Smrg	/** Size of submission */
4033f012e29Smrg	uint32_t ib_bytes;
4043f012e29Smrg	/** HW IP to submit to */
4053f012e29Smrg	uint32_t ip_type;
4063f012e29Smrg	/** HW IP index of the same type to submit to  */
4073f012e29Smrg	uint32_t ip_instance;
4083f012e29Smrg	/** Ring index to submit to */
4093f012e29Smrg	uint32_t ring;
4103f012e29Smrg};
4113f012e29Smrg
4123f012e29Smrgstruct drm_amdgpu_cs_chunk_dep {
4133f012e29Smrg	uint32_t ip_type;
4143f012e29Smrg	uint32_t ip_instance;
4153f012e29Smrg	uint32_t ring;
4163f012e29Smrg	uint32_t ctx_id;
4173f012e29Smrg	uint64_t handle;
4183f012e29Smrg};
4193f012e29Smrg
4203f012e29Smrgstruct drm_amdgpu_cs_chunk_fence {
4213f012e29Smrg	uint32_t handle;
4223f012e29Smrg	uint32_t offset;
4233f012e29Smrg};
4243f012e29Smrg
4253f012e29Smrgstruct drm_amdgpu_cs_chunk_data {
4263f012e29Smrg	union {
4273f012e29Smrg		struct drm_amdgpu_cs_chunk_ib		ib_data;
4283f012e29Smrg		struct drm_amdgpu_cs_chunk_fence	fence_data;
4293f012e29Smrg	};
4303f012e29Smrg};
4313f012e29Smrg
4323f012e29Smrg/**
4333f012e29Smrg *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
4343f012e29Smrg *
4353f012e29Smrg */
4363f012e29Smrg#define AMDGPU_IDS_FLAGS_FUSION         0x1
4373f012e29Smrg
4383f012e29Smrg/* indicate if acceleration can be working */
4393f012e29Smrg#define AMDGPU_INFO_ACCEL_WORKING		0x00
4403f012e29Smrg/* get the crtc_id from the mode object id? */
4413f012e29Smrg#define AMDGPU_INFO_CRTC_FROM_ID		0x01
4423f012e29Smrg/* query hw IP info */
4433f012e29Smrg#define AMDGPU_INFO_HW_IP_INFO			0x02
4443f012e29Smrg/* query hw IP instance count for the specified type */
4453f012e29Smrg#define AMDGPU_INFO_HW_IP_COUNT			0x03
4463f012e29Smrg/* timestamp for GL_ARB_timer_query */
4473f012e29Smrg#define AMDGPU_INFO_TIMESTAMP			0x05
4483f012e29Smrg/* Query the firmware version */
4493f012e29Smrg#define AMDGPU_INFO_FW_VERSION			0x0e
4503f012e29Smrg	/* Subquery id: Query VCE firmware version */
4513f012e29Smrg	#define AMDGPU_INFO_FW_VCE		0x1
4523f012e29Smrg	/* Subquery id: Query UVD firmware version */
4533f012e29Smrg	#define AMDGPU_INFO_FW_UVD		0x2
4543f012e29Smrg	/* Subquery id: Query GMC firmware version */
4553f012e29Smrg	#define AMDGPU_INFO_FW_GMC		0x03
4563f012e29Smrg	/* Subquery id: Query GFX ME firmware version */
4573f012e29Smrg	#define AMDGPU_INFO_FW_GFX_ME		0x04
4583f012e29Smrg	/* Subquery id: Query GFX PFP firmware version */
4593f012e29Smrg	#define AMDGPU_INFO_FW_GFX_PFP		0x05
4603f012e29Smrg	/* Subquery id: Query GFX CE firmware version */
4613f012e29Smrg	#define AMDGPU_INFO_FW_GFX_CE		0x06
4623f012e29Smrg	/* Subquery id: Query GFX RLC firmware version */
4633f012e29Smrg	#define AMDGPU_INFO_FW_GFX_RLC		0x07
4643f012e29Smrg	/* Subquery id: Query GFX MEC firmware version */
4653f012e29Smrg	#define AMDGPU_INFO_FW_GFX_MEC		0x08
4663f012e29Smrg	/* Subquery id: Query SMC firmware version */
4673f012e29Smrg	#define AMDGPU_INFO_FW_SMC		0x0a
4683f012e29Smrg	/* Subquery id: Query SDMA firmware version */
4693f012e29Smrg	#define AMDGPU_INFO_FW_SDMA		0x0b
4703f012e29Smrg/* number of bytes moved for TTM migration */
4713f012e29Smrg#define AMDGPU_INFO_NUM_BYTES_MOVED		0x0f
4723f012e29Smrg/* the used VRAM size */
4733f012e29Smrg#define AMDGPU_INFO_VRAM_USAGE			0x10
4743f012e29Smrg/* the used GTT size */
4753f012e29Smrg#define AMDGPU_INFO_GTT_USAGE			0x11
4763f012e29Smrg/* Information about GDS, etc. resource configuration */
4773f012e29Smrg#define AMDGPU_INFO_GDS_CONFIG			0x13
4783f012e29Smrg/* Query information about VRAM and GTT domains */
4793f012e29Smrg#define AMDGPU_INFO_VRAM_GTT			0x14
4803f012e29Smrg/* Query information about register in MMR address space*/
4813f012e29Smrg#define AMDGPU_INFO_READ_MMR_REG		0x15
4823f012e29Smrg/* Query information about device: rev id, family, etc. */
4833f012e29Smrg#define AMDGPU_INFO_DEV_INFO			0x16
4843f012e29Smrg/* visible vram usage */
4853f012e29Smrg#define AMDGPU_INFO_VIS_VRAM_USAGE		0x17
4863f012e29Smrg
4873f012e29Smrg#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT	0
4883f012e29Smrg#define AMDGPU_INFO_MMR_SE_INDEX_MASK	0xff
4893f012e29Smrg#define AMDGPU_INFO_MMR_SH_INDEX_SHIFT	8
4903f012e29Smrg#define AMDGPU_INFO_MMR_SH_INDEX_MASK	0xff
4913f012e29Smrg
492037b3c26Smrgstruct drm_amdgpu_query_fw {
493037b3c26Smrg	/** AMDGPU_INFO_FW_* */
494037b3c26Smrg	uint32_t fw_type;
495037b3c26Smrg	/**
496037b3c26Smrg	 * Index of the IP if there are more IPs of
497037b3c26Smrg	 * the same type.
498037b3c26Smrg	 */
499037b3c26Smrg	uint32_t ip_instance;
500037b3c26Smrg	/**
501037b3c26Smrg	 * Index of the engine. Whether this is used depends
502037b3c26Smrg	 * on the firmware type. (e.g. MEC, SDMA)
503037b3c26Smrg	 */
504037b3c26Smrg	uint32_t index;
505037b3c26Smrg	uint32_t _pad;
506037b3c26Smrg};
507037b3c26Smrg
5083f012e29Smrg/* Input structure for the INFO ioctl */
5093f012e29Smrgstruct drm_amdgpu_info {
5103f012e29Smrg	/* Where the return value will be stored */
5113f012e29Smrg	uint64_t return_pointer;
5123f012e29Smrg	/* The size of the return value. Just like "size" in "snprintf",
5133f012e29Smrg	 * it limits how many bytes the kernel can write. */
5143f012e29Smrg	uint32_t return_size;
5153f012e29Smrg	/* The query request id. */
5163f012e29Smrg	uint32_t query;
5173f012e29Smrg
5183f012e29Smrg	union {
5193f012e29Smrg		struct {
5203f012e29Smrg			uint32_t id;
5213f012e29Smrg			uint32_t _pad;
5223f012e29Smrg		} mode_crtc;
5233f012e29Smrg
5243f012e29Smrg		struct {
5253f012e29Smrg			/** AMDGPU_HW_IP_* */
5263f012e29Smrg			uint32_t type;
5273f012e29Smrg			/**
5283f012e29Smrg			 * Index of the IP if there are more IPs of the same
5293f012e29Smrg			 * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
5303f012e29Smrg			 */
5313f012e29Smrg			uint32_t ip_instance;
5323f012e29Smrg		} query_hw_ip;
5333f012e29Smrg
5343f012e29Smrg		struct {
5353f012e29Smrg			uint32_t dword_offset;
5363f012e29Smrg			/** number of registers to read */
5373f012e29Smrg			uint32_t count;
5383f012e29Smrg			uint32_t instance;
5393f012e29Smrg			/** For future use, no flags defined so far */
5403f012e29Smrg			uint32_t flags;
5413f012e29Smrg		} read_mmr_reg;
5423f012e29Smrg
543037b3c26Smrg		struct drm_amdgpu_query_fw query_fw;
5443f012e29Smrg	};
5453f012e29Smrg};
5463f012e29Smrg
5473f012e29Smrgstruct drm_amdgpu_info_gds {
5483f012e29Smrg	/** GDS GFX partition size */
5493f012e29Smrg	uint32_t gds_gfx_partition_size;
5503f012e29Smrg	/** GDS compute partition size */
5513f012e29Smrg	uint32_t compute_partition_size;
5523f012e29Smrg	/** total GDS memory size */
5533f012e29Smrg	uint32_t gds_total_size;
5543f012e29Smrg	/** GWS size per GFX partition */
5553f012e29Smrg	uint32_t gws_per_gfx_partition;
5563f012e29Smrg	/** GSW size per compute partition */
5573f012e29Smrg	uint32_t gws_per_compute_partition;
5583f012e29Smrg	/** OA size per GFX partition */
5593f012e29Smrg	uint32_t oa_per_gfx_partition;
5603f012e29Smrg	/** OA size per compute partition */
5613f012e29Smrg	uint32_t oa_per_compute_partition;
5623f012e29Smrg	uint32_t _pad;
5633f012e29Smrg};
5643f012e29Smrg
5653f012e29Smrgstruct drm_amdgpu_info_vram_gtt {
5663f012e29Smrg	uint64_t vram_size;
5673f012e29Smrg	uint64_t vram_cpu_accessible_size;
5683f012e29Smrg	uint64_t gtt_size;
5693f012e29Smrg};
5703f012e29Smrg
5713f012e29Smrgstruct drm_amdgpu_info_firmware {
5723f012e29Smrg	uint32_t ver;
5733f012e29Smrg	uint32_t feature;
5743f012e29Smrg};
5753f012e29Smrg
5763f012e29Smrg#define AMDGPU_VRAM_TYPE_UNKNOWN 0
5773f012e29Smrg#define AMDGPU_VRAM_TYPE_GDDR1 1
5783f012e29Smrg#define AMDGPU_VRAM_TYPE_DDR2  2
5793f012e29Smrg#define AMDGPU_VRAM_TYPE_GDDR3 3
5803f012e29Smrg#define AMDGPU_VRAM_TYPE_GDDR4 4
5813f012e29Smrg#define AMDGPU_VRAM_TYPE_GDDR5 5
5823f012e29Smrg#define AMDGPU_VRAM_TYPE_HBM   6
5833f012e29Smrg#define AMDGPU_VRAM_TYPE_DDR3  7
5843f012e29Smrg
5853f012e29Smrgstruct drm_amdgpu_info_device {
5863f012e29Smrg	/** PCI Device ID */
5873f012e29Smrg	uint32_t device_id;
5883f012e29Smrg	/** Internal chip revision: A0, A1, etc.) */
5893f012e29Smrg	uint32_t chip_rev;
5903f012e29Smrg	uint32_t external_rev;
5913f012e29Smrg	/** Revision id in PCI Config space */
5923f012e29Smrg	uint32_t pci_rev;
5933f012e29Smrg	uint32_t family;
5943f012e29Smrg	uint32_t num_shader_engines;
5953f012e29Smrg	uint32_t num_shader_arrays_per_engine;
5963f012e29Smrg	/* in KHz */
5973f012e29Smrg	uint32_t gpu_counter_freq;
5983f012e29Smrg	uint64_t max_engine_clock;
5993f012e29Smrg	uint64_t max_memory_clock;
6003f012e29Smrg	/* cu information */
6013f012e29Smrg	uint32_t cu_active_number;
6023f012e29Smrg	uint32_t cu_ao_mask;
6033f012e29Smrg	uint32_t cu_bitmap[4][4];
6043f012e29Smrg	/** Render backend pipe mask. One render backend is CB+DB. */
6053f012e29Smrg	uint32_t enabled_rb_pipes_mask;
6063f012e29Smrg	uint32_t num_rb_pipes;
6073f012e29Smrg	uint32_t num_hw_gfx_contexts;
6083f012e29Smrg	uint32_t _pad;
6093f012e29Smrg	uint64_t ids_flags;
6103f012e29Smrg	/** Starting virtual address for UMDs. */
6113f012e29Smrg	uint64_t virtual_address_offset;
6123f012e29Smrg	/** The maximum virtual address */
6133f012e29Smrg	uint64_t virtual_address_max;
6143f012e29Smrg	/** Required alignment of virtual addresses. */
6153f012e29Smrg	uint32_t virtual_address_alignment;
6163f012e29Smrg	/** Page table entry - fragment size */
6173f012e29Smrg	uint32_t pte_fragment_size;
6183f012e29Smrg	uint32_t gart_page_size;
6193f012e29Smrg	/** constant engine ram size*/
6203f012e29Smrg	uint32_t ce_ram_size;
6213f012e29Smrg	/** video memory type info*/
6223f012e29Smrg	uint32_t vram_type;
6233f012e29Smrg	/** video memory bit width*/
6243f012e29Smrg	uint32_t vram_bit_width;
6253f012e29Smrg	/* vce harvesting instance */
6263f012e29Smrg	uint32_t vce_harvest_config;
6273f012e29Smrg};
6283f012e29Smrg
6293f012e29Smrgstruct drm_amdgpu_info_hw_ip {
6303f012e29Smrg	/** Version of h/w IP */
6313f012e29Smrg	uint32_t  hw_ip_version_major;
6323f012e29Smrg	uint32_t  hw_ip_version_minor;
6333f012e29Smrg	/** Capabilities */
6343f012e29Smrg	uint64_t  capabilities_flags;
6353f012e29Smrg	/** command buffer address start alignment*/
6363f012e29Smrg	uint32_t  ib_start_alignment;
6373f012e29Smrg	/** command buffer size alignment*/
6383f012e29Smrg	uint32_t  ib_size_alignment;
6393f012e29Smrg	/** Bitmask of available rings. Bit 0 means ring 0, etc. */
6403f012e29Smrg	uint32_t  available_rings;
6413f012e29Smrg	uint32_t  _pad;
6423f012e29Smrg};
6433f012e29Smrg
6443f012e29Smrg/*
6453f012e29Smrg * Supported GPU families
6463f012e29Smrg */
6473f012e29Smrg#define AMDGPU_FAMILY_UNKNOWN			0
6483f012e29Smrg#define AMDGPU_FAMILY_CI			120 /* Bonaire, Hawaii */
6493f012e29Smrg#define AMDGPU_FAMILY_KV			125 /* Kaveri, Kabini, Mullins */
6503f012e29Smrg#define AMDGPU_FAMILY_VI			130 /* Iceland, Tonga */
651037b3c26Smrg#define AMDGPU_FAMILY_CZ			135 /* Carrizo, Stoney */
652037b3c26Smrg
653037b3c26Smrg#if defined(__cplusplus)
654037b3c26Smrg}
655037b3c26Smrg#endif
6563f012e29Smrg
6573f012e29Smrg#endif
658