Path: blob/21.2-virgl/include/drm-uapi/amdgpu_drm.h
4545 views
/* amdgpu_drm.h -- Public header for the amdgpu driver -*- linux-c -*-1*2* Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.3* Copyright 2000 VA Linux Systems, Inc., Fremont, California.4* Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.5* Copyright 2014 Advanced Micro Devices, Inc.6*7* Permission is hereby granted, free of charge, to any person obtaining a8* copy of this software and associated documentation files (the "Software"),9* to deal in the Software without restriction, including without limitation10* the rights to use, copy, modify, merge, publish, distribute, sublicense,11* and/or sell copies of the Software, and to permit persons to whom the12* Software is furnished to do so, subject to the following conditions:13*14* The above copyright notice and this permission notice shall be included in15* all copies or substantial portions of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL20* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR21* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,22* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR23* OTHER DEALINGS IN THE SOFTWARE.24*25* Authors:26* Kevin E. Martin <[email protected]>27* Gareth Hughes <[email protected]>28* Keith Whitwell <[email protected]>29*/3031#ifndef __AMDGPU_DRM_H__32#define __AMDGPU_DRM_H__3334#include "drm.h"3536#if defined(__cplusplus)37extern "C" {38#endif3940#define DRM_AMDGPU_GEM_CREATE 0x0041#define DRM_AMDGPU_GEM_MMAP 0x0142#define DRM_AMDGPU_CTX 0x0243#define DRM_AMDGPU_BO_LIST 0x0344#define DRM_AMDGPU_CS 0x0445#define DRM_AMDGPU_INFO 0x0546#define DRM_AMDGPU_GEM_METADATA 0x0647#define DRM_AMDGPU_GEM_WAIT_IDLE 0x0748#define DRM_AMDGPU_GEM_VA 0x0849#define DRM_AMDGPU_WAIT_CS 0x0950#define DRM_AMDGPU_GEM_OP 0x1051#define DRM_AMDGPU_GEM_USERPTR 0x1152#define DRM_AMDGPU_WAIT_FENCES 0x1253#define DRM_AMDGPU_VM 0x1354#define DRM_AMDGPU_FENCE_TO_HANDLE 0x1455#define DRM_AMDGPU_SCHED 0x155657#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)58#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)59#define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)60#define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)61#define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)62#define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)63#define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)64#define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)65#define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)66#define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)67#define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)68#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)69#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)70#define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)71#define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)72#define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)7374/**75* DOC: memory domains76*77* %AMDGPU_GEM_DOMAIN_CPU System memory that is not GPU accessible.78* Memory in this pool could be swapped out to disk if there is pressure.79*80* %AMDGPU_GEM_DOMAIN_GTT GPU accessible system memory, mapped into the81* GPU's virtual address space via gart. Gart memory linearizes non-contiguous82* pages of system memory, allows GPU access system memory in a linezrized83* fashion.84*85* %AMDGPU_GEM_DOMAIN_VRAM Local video memory. For APUs, it is memory86* carved out by the BIOS.87*88* %AMDGPU_GEM_DOMAIN_GDS Global on-chip data storage used to share data89* across shader threads.90*91* %AMDGPU_GEM_DOMAIN_GWS Global wave sync, used to synchronize the92* execution of all the waves on a device.93*94* %AMDGPU_GEM_DOMAIN_OA Ordered append, used by 3D or Compute engines95* for appending data.96*/97#define AMDGPU_GEM_DOMAIN_CPU 0x198#define AMDGPU_GEM_DOMAIN_GTT 0x299#define AMDGPU_GEM_DOMAIN_VRAM 0x4100#define AMDGPU_GEM_DOMAIN_GDS 0x8101#define AMDGPU_GEM_DOMAIN_GWS 0x10102#define AMDGPU_GEM_DOMAIN_OA 0x20103#define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \104AMDGPU_GEM_DOMAIN_GTT | \105AMDGPU_GEM_DOMAIN_VRAM | \106AMDGPU_GEM_DOMAIN_GDS | \107AMDGPU_GEM_DOMAIN_GWS | \108AMDGPU_GEM_DOMAIN_OA)109110/* Flag that CPU access will be required for the case of VRAM domain */111#define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)112/* Flag that CPU access will not work, this VRAM domain is invisible */113#define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)114/* Flag that USWC attributes should be used for GTT */115#define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)116/* Flag that the memory should be in VRAM and cleared */117#define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3)118/* Flag that allocating the BO should use linear VRAM */119#define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5)120/* Flag that BO is always valid in this VM */121#define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6)122/* Flag that BO sharing will be explicitly synchronized */123#define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7)124/* Flag that indicates allocating MQD gart on GFX9, where the mtype125* for the second page onward should be set to NC. It should never126* be used by user space applications.127*/128#define AMDGPU_GEM_CREATE_CP_MQD_GFX9 (1 << 8)129/* Flag that BO may contain sensitive data that must be wiped before130* releasing the memory131*/132#define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE (1 << 9)133/* Flag that BO will be encrypted and that the TMZ bit should be134* set in the PTEs when mapping this buffer via GPUVM or135* accessing it with various hw blocks136*/137#define AMDGPU_GEM_CREATE_ENCRYPTED (1 << 10)138/* Flag that BO will be used only in preemptible context, which does139* not require GTT memory accounting140*/141#define AMDGPU_GEM_CREATE_PREEMPTIBLE (1 << 11)142143struct drm_amdgpu_gem_create_in {144/** the requested memory size */145__u64 bo_size;146/** physical start_addr alignment in bytes for some HW requirements */147__u64 alignment;148/** the requested memory domains */149__u64 domains;150/** allocation flags */151__u64 domain_flags;152};153154struct drm_amdgpu_gem_create_out {155/** returned GEM object handle */156__u32 handle;157__u32 _pad;158};159160union drm_amdgpu_gem_create {161struct drm_amdgpu_gem_create_in in;162struct drm_amdgpu_gem_create_out out;163};164165/** Opcode to create new residency list. */166#define AMDGPU_BO_LIST_OP_CREATE 0167/** Opcode to destroy previously created residency list */168#define AMDGPU_BO_LIST_OP_DESTROY 1169/** Opcode to update resource information in the list */170#define AMDGPU_BO_LIST_OP_UPDATE 2171172struct drm_amdgpu_bo_list_in {173/** Type of operation */174__u32 operation;175/** Handle of list or 0 if we want to create one */176__u32 list_handle;177/** Number of BOs in list */178__u32 bo_number;179/** Size of each element describing BO */180__u32 bo_info_size;181/** Pointer to array describing BOs */182__u64 bo_info_ptr;183};184185struct drm_amdgpu_bo_list_entry {186/** Handle of BO */187__u32 bo_handle;188/** New (if specified) BO priority to be used during migration */189__u32 bo_priority;190};191192struct drm_amdgpu_bo_list_out {193/** Handle of resource list */194__u32 list_handle;195__u32 _pad;196};197198union drm_amdgpu_bo_list {199struct drm_amdgpu_bo_list_in in;200struct drm_amdgpu_bo_list_out out;201};202203/* context related */204#define AMDGPU_CTX_OP_ALLOC_CTX 1205#define AMDGPU_CTX_OP_FREE_CTX 2206#define AMDGPU_CTX_OP_QUERY_STATE 3207#define AMDGPU_CTX_OP_QUERY_STATE2 4208209/* GPU reset status */210#define AMDGPU_CTX_NO_RESET 0211/* this the context caused it */212#define AMDGPU_CTX_GUILTY_RESET 1213/* some other context caused it */214#define AMDGPU_CTX_INNOCENT_RESET 2215/* unknown cause */216#define AMDGPU_CTX_UNKNOWN_RESET 3217218/* indicate gpu reset occured after ctx created */219#define AMDGPU_CTX_QUERY2_FLAGS_RESET (1<<0)220/* indicate vram lost occured after ctx created */221#define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)222/* indicate some job from this context once cause gpu hang */223#define AMDGPU_CTX_QUERY2_FLAGS_GUILTY (1<<2)224/* indicate some errors are detected by RAS */225#define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE (1<<3)226#define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE (1<<4)227228/* Context priority level */229#define AMDGPU_CTX_PRIORITY_UNSET -2048230#define AMDGPU_CTX_PRIORITY_VERY_LOW -1023231#define AMDGPU_CTX_PRIORITY_LOW -512232#define AMDGPU_CTX_PRIORITY_NORMAL 0233/*234* When used in struct drm_amdgpu_ctx_in, a priority above NORMAL requires235* CAP_SYS_NICE or DRM_MASTER236*/237#define AMDGPU_CTX_PRIORITY_HIGH 512238#define AMDGPU_CTX_PRIORITY_VERY_HIGH 1023239240struct drm_amdgpu_ctx_in {241/** AMDGPU_CTX_OP_* */242__u32 op;243/** For future use, no flags defined so far */244__u32 flags;245__u32 ctx_id;246/** AMDGPU_CTX_PRIORITY_* */247__s32 priority;248};249250union drm_amdgpu_ctx_out {251struct {252__u32 ctx_id;253__u32 _pad;254} alloc;255256struct {257/** For future use, no flags defined so far */258__u64 flags;259/** Number of resets caused by this context so far. */260__u32 hangs;261/** Reset status since the last call of the ioctl. */262__u32 reset_status;263} state;264};265266union drm_amdgpu_ctx {267struct drm_amdgpu_ctx_in in;268union drm_amdgpu_ctx_out out;269};270271/* vm ioctl */272#define AMDGPU_VM_OP_RESERVE_VMID 1273#define AMDGPU_VM_OP_UNRESERVE_VMID 2274275struct drm_amdgpu_vm_in {276/** AMDGPU_VM_OP_* */277__u32 op;278__u32 flags;279};280281struct drm_amdgpu_vm_out {282/** For future use, no flags defined so far */283__u64 flags;284};285286union drm_amdgpu_vm {287struct drm_amdgpu_vm_in in;288struct drm_amdgpu_vm_out out;289};290291/* sched ioctl */292#define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE 1293#define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE 2294295struct drm_amdgpu_sched_in {296/* AMDGPU_SCHED_OP_* */297__u32 op;298__u32 fd;299/** AMDGPU_CTX_PRIORITY_* */300__s32 priority;301__u32 ctx_id;302};303304union drm_amdgpu_sched {305struct drm_amdgpu_sched_in in;306};307308/*309* This is not a reliable API and you should expect it to fail for any310* number of reasons and have fallback path that do not use userptr to311* perform any operation.312*/313#define AMDGPU_GEM_USERPTR_READONLY (1 << 0)314#define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)315#define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)316#define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)317318struct drm_amdgpu_gem_userptr {319__u64 addr;320__u64 size;321/* AMDGPU_GEM_USERPTR_* */322__u32 flags;323/* Resulting GEM handle */324__u32 handle;325};326327/* SI-CI-VI: */328/* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */329#define AMDGPU_TILING_ARRAY_MODE_SHIFT 0330#define AMDGPU_TILING_ARRAY_MODE_MASK 0xf331#define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4332#define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f333#define AMDGPU_TILING_TILE_SPLIT_SHIFT 9334#define AMDGPU_TILING_TILE_SPLIT_MASK 0x7335#define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12336#define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7337#define AMDGPU_TILING_BANK_WIDTH_SHIFT 15338#define AMDGPU_TILING_BANK_WIDTH_MASK 0x3339#define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17340#define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3341#define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19342#define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3343#define AMDGPU_TILING_NUM_BANKS_SHIFT 21344#define AMDGPU_TILING_NUM_BANKS_MASK 0x3345346/* GFX9 and later: */347#define AMDGPU_TILING_SWIZZLE_MODE_SHIFT 0348#define AMDGPU_TILING_SWIZZLE_MODE_MASK 0x1f349#define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT 5350#define AMDGPU_TILING_DCC_OFFSET_256B_MASK 0xFFFFFF351#define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT 29352#define AMDGPU_TILING_DCC_PITCH_MAX_MASK 0x3FFF353#define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT 43354#define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK 0x1355#define AMDGPU_TILING_DCC_INDEPENDENT_128B_SHIFT 44356#define AMDGPU_TILING_DCC_INDEPENDENT_128B_MASK 0x1357#define AMDGPU_TILING_SCANOUT_SHIFT 63358#define AMDGPU_TILING_SCANOUT_MASK 0x1359360/* Set/Get helpers for tiling flags. */361#define AMDGPU_TILING_SET(field, value) \362(((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)363#define AMDGPU_TILING_GET(value, field) \364(((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)365366#define AMDGPU_GEM_METADATA_OP_SET_METADATA 1367#define AMDGPU_GEM_METADATA_OP_GET_METADATA 2368369/** The same structure is shared for input/output */370struct drm_amdgpu_gem_metadata {371/** GEM Object handle */372__u32 handle;373/** Do we want get or set metadata */374__u32 op;375struct {376/** For future use, no flags defined so far */377__u64 flags;378/** family specific tiling info */379__u64 tiling_info;380__u32 data_size_bytes;381__u32 data[64];382} data;383};384385struct drm_amdgpu_gem_mmap_in {386/** the GEM object handle */387__u32 handle;388__u32 _pad;389};390391struct drm_amdgpu_gem_mmap_out {392/** mmap offset from the vma offset manager */393__u64 addr_ptr;394};395396union drm_amdgpu_gem_mmap {397struct drm_amdgpu_gem_mmap_in in;398struct drm_amdgpu_gem_mmap_out out;399};400401struct drm_amdgpu_gem_wait_idle_in {402/** GEM object handle */403__u32 handle;404/** For future use, no flags defined so far */405__u32 flags;406/** Absolute timeout to wait */407__u64 timeout;408};409410struct drm_amdgpu_gem_wait_idle_out {411/** BO status: 0 - BO is idle, 1 - BO is busy */412__u32 status;413/** Returned current memory domain */414__u32 domain;415};416417union drm_amdgpu_gem_wait_idle {418struct drm_amdgpu_gem_wait_idle_in in;419struct drm_amdgpu_gem_wait_idle_out out;420};421422struct drm_amdgpu_wait_cs_in {423/* Command submission handle424* handle equals 0 means none to wait for425* handle equals ~0ull means wait for the latest sequence number426*/427__u64 handle;428/** Absolute timeout to wait */429__u64 timeout;430__u32 ip_type;431__u32 ip_instance;432__u32 ring;433__u32 ctx_id;434};435436struct drm_amdgpu_wait_cs_out {437/** CS status: 0 - CS completed, 1 - CS still busy */438__u64 status;439};440441union drm_amdgpu_wait_cs {442struct drm_amdgpu_wait_cs_in in;443struct drm_amdgpu_wait_cs_out out;444};445446struct drm_amdgpu_fence {447__u32 ctx_id;448__u32 ip_type;449__u32 ip_instance;450__u32 ring;451__u64 seq_no;452};453454struct drm_amdgpu_wait_fences_in {455/** This points to uint64_t * which points to fences */456__u64 fences;457__u32 fence_count;458__u32 wait_all;459__u64 timeout_ns;460};461462struct drm_amdgpu_wait_fences_out {463__u32 status;464__u32 first_signaled;465};466467union drm_amdgpu_wait_fences {468struct drm_amdgpu_wait_fences_in in;469struct drm_amdgpu_wait_fences_out out;470};471472#define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0473#define AMDGPU_GEM_OP_SET_PLACEMENT 1474475/* Sets or returns a value associated with a buffer. */476struct drm_amdgpu_gem_op {477/** GEM object handle */478__u32 handle;479/** AMDGPU_GEM_OP_* */480__u32 op;481/** Input or return value */482__u64 value;483};484485#define AMDGPU_VA_OP_MAP 1486#define AMDGPU_VA_OP_UNMAP 2487#define AMDGPU_VA_OP_CLEAR 3488#define AMDGPU_VA_OP_REPLACE 4489490/* Delay the page table update till the next CS */491#define AMDGPU_VM_DELAY_UPDATE (1 << 0)492493/* Mapping flags */494/* readable mapping */495#define AMDGPU_VM_PAGE_READABLE (1 << 1)496/* writable mapping */497#define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)498/* executable mapping, new for VI */499#define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)500/* partially resident texture */501#define AMDGPU_VM_PAGE_PRT (1 << 4)502/* MTYPE flags use bit 5 to 8 */503#define AMDGPU_VM_MTYPE_MASK (0xf << 5)504/* Default MTYPE. Pre-AI must use this. Recommended for newer ASICs. */505#define AMDGPU_VM_MTYPE_DEFAULT (0 << 5)506/* Use Non Coherent MTYPE instead of default MTYPE */507#define AMDGPU_VM_MTYPE_NC (1 << 5)508/* Use Write Combine MTYPE instead of default MTYPE */509#define AMDGPU_VM_MTYPE_WC (2 << 5)510/* Use Cache Coherent MTYPE instead of default MTYPE */511#define AMDGPU_VM_MTYPE_CC (3 << 5)512/* Use UnCached MTYPE instead of default MTYPE */513#define AMDGPU_VM_MTYPE_UC (4 << 5)514/* Use Read Write MTYPE instead of default MTYPE */515#define AMDGPU_VM_MTYPE_RW (5 << 5)516517struct drm_amdgpu_gem_va {518/** GEM object handle */519__u32 handle;520__u32 _pad;521/** AMDGPU_VA_OP_* */522__u32 operation;523/** AMDGPU_VM_PAGE_* */524__u32 flags;525/** va address to assign . Must be correctly aligned.*/526__u64 va_address;527/** Specify offset inside of BO to assign. Must be correctly aligned.*/528__u64 offset_in_bo;529/** Specify mapping size. Must be correctly aligned. */530__u64 map_size;531};532533#define AMDGPU_HW_IP_GFX 0534#define AMDGPU_HW_IP_COMPUTE 1535#define AMDGPU_HW_IP_DMA 2536#define AMDGPU_HW_IP_UVD 3537#define AMDGPU_HW_IP_VCE 4538#define AMDGPU_HW_IP_UVD_ENC 5539#define AMDGPU_HW_IP_VCN_DEC 6540#define AMDGPU_HW_IP_VCN_ENC 7541#define AMDGPU_HW_IP_VCN_JPEG 8542#define AMDGPU_HW_IP_NUM 9543544#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1545546#define AMDGPU_CHUNK_ID_IB 0x01547#define AMDGPU_CHUNK_ID_FENCE 0x02548#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03549#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04550#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05551#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06552#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07553#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08554#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09555556struct drm_amdgpu_cs_chunk {557__u32 chunk_id;558__u32 length_dw;559__u64 chunk_data;560};561562struct drm_amdgpu_cs_in {563/** Rendering context id */564__u32 ctx_id;565/** Handle of resource list associated with CS */566__u32 bo_list_handle;567__u32 num_chunks;568__u32 flags;569/** this points to __u64 * which point to cs chunks */570__u64 chunks;571};572573struct drm_amdgpu_cs_out {574__u64 handle;575};576577union drm_amdgpu_cs {578struct drm_amdgpu_cs_in in;579struct drm_amdgpu_cs_out out;580};581582/* Specify flags to be used for IB */583584/* This IB should be submitted to CE */585#define AMDGPU_IB_FLAG_CE (1<<0)586587/* Preamble flag, which means the IB could be dropped if no context switch */588#define AMDGPU_IB_FLAG_PREAMBLE (1<<1)589590/* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */591#define AMDGPU_IB_FLAG_PREEMPT (1<<2)592593/* The IB fence should do the L2 writeback but not invalidate any shader594* caches (L2/vL1/sL1/I$). */595#define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3)596597/* Set GDS_COMPUTE_MAX_WAVE_ID = DEFAULT before PACKET3_INDIRECT_BUFFER.598* This will reset wave ID counters for the IB.599*/600#define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4)601602/* Flag the IB as secure (TMZ)603*/604#define AMDGPU_IB_FLAGS_SECURE (1 << 5)605606/* Tell KMD to flush and invalidate caches607*/608#define AMDGPU_IB_FLAG_EMIT_MEM_SYNC (1 << 6)609610struct drm_amdgpu_cs_chunk_ib {611__u32 _pad;612/** AMDGPU_IB_FLAG_* */613__u32 flags;614/** Virtual address to begin IB execution */615__u64 va_start;616/** Size of submission */617__u32 ib_bytes;618/** HW IP to submit to */619__u32 ip_type;620/** HW IP index of the same type to submit to */621__u32 ip_instance;622/** Ring index to submit to */623__u32 ring;624};625626struct drm_amdgpu_cs_chunk_dep {627__u32 ip_type;628__u32 ip_instance;629__u32 ring;630__u32 ctx_id;631__u64 handle;632};633634struct drm_amdgpu_cs_chunk_fence {635__u32 handle;636__u32 offset;637};638639struct drm_amdgpu_cs_chunk_sem {640__u32 handle;641};642643struct drm_amdgpu_cs_chunk_syncobj {644__u32 handle;645__u32 flags;646__u64 point;647};648649#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 0650#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 1651#define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2652653union drm_amdgpu_fence_to_handle {654struct {655struct drm_amdgpu_fence fence;656__u32 what;657__u32 pad;658} in;659struct {660__u32 handle;661} out;662};663664struct drm_amdgpu_cs_chunk_data {665union {666struct drm_amdgpu_cs_chunk_ib ib_data;667struct drm_amdgpu_cs_chunk_fence fence_data;668};669};670671/*672* Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU673*674*/675#define AMDGPU_IDS_FLAGS_FUSION 0x1676#define AMDGPU_IDS_FLAGS_PREEMPTION 0x2677#define AMDGPU_IDS_FLAGS_TMZ 0x4678679/* indicate if acceleration can be working */680#define AMDGPU_INFO_ACCEL_WORKING 0x00681/* get the crtc_id from the mode object id? */682#define AMDGPU_INFO_CRTC_FROM_ID 0x01683/* query hw IP info */684#define AMDGPU_INFO_HW_IP_INFO 0x02685/* query hw IP instance count for the specified type */686#define AMDGPU_INFO_HW_IP_COUNT 0x03687/* timestamp for GL_ARB_timer_query */688#define AMDGPU_INFO_TIMESTAMP 0x05689/* Query the firmware version */690#define AMDGPU_INFO_FW_VERSION 0x0e691/* Subquery id: Query VCE firmware version */692#define AMDGPU_INFO_FW_VCE 0x1693/* Subquery id: Query UVD firmware version */694#define AMDGPU_INFO_FW_UVD 0x2695/* Subquery id: Query GMC firmware version */696#define AMDGPU_INFO_FW_GMC 0x03697/* Subquery id: Query GFX ME firmware version */698#define AMDGPU_INFO_FW_GFX_ME 0x04699/* Subquery id: Query GFX PFP firmware version */700#define AMDGPU_INFO_FW_GFX_PFP 0x05701/* Subquery id: Query GFX CE firmware version */702#define AMDGPU_INFO_FW_GFX_CE 0x06703/* Subquery id: Query GFX RLC firmware version */704#define AMDGPU_INFO_FW_GFX_RLC 0x07705/* Subquery id: Query GFX MEC firmware version */706#define AMDGPU_INFO_FW_GFX_MEC 0x08707/* Subquery id: Query SMC firmware version */708#define AMDGPU_INFO_FW_SMC 0x0a709/* Subquery id: Query SDMA firmware version */710#define AMDGPU_INFO_FW_SDMA 0x0b711/* Subquery id: Query PSP SOS firmware version */712#define AMDGPU_INFO_FW_SOS 0x0c713/* Subquery id: Query PSP ASD firmware version */714#define AMDGPU_INFO_FW_ASD 0x0d715/* Subquery id: Query VCN firmware version */716#define AMDGPU_INFO_FW_VCN 0x0e717/* Subquery id: Query GFX RLC SRLC firmware version */718#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f719/* Subquery id: Query GFX RLC SRLG firmware version */720#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10721/* Subquery id: Query GFX RLC SRLS firmware version */722#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11723/* Subquery id: Query DMCU firmware version */724#define AMDGPU_INFO_FW_DMCU 0x12725#define AMDGPU_INFO_FW_TA 0x13726/* Subquery id: Query DMCUB firmware version */727#define AMDGPU_INFO_FW_DMCUB 0x14728/* Subquery id: Query TOC firmware version */729#define AMDGPU_INFO_FW_TOC 0x15730731/* number of bytes moved for TTM migration */732#define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f733/* the used VRAM size */734#define AMDGPU_INFO_VRAM_USAGE 0x10735/* the used GTT size */736#define AMDGPU_INFO_GTT_USAGE 0x11737/* Information about GDS, etc. resource configuration */738#define AMDGPU_INFO_GDS_CONFIG 0x13739/* Query information about VRAM and GTT domains */740#define AMDGPU_INFO_VRAM_GTT 0x14741/* Query information about register in MMR address space*/742#define AMDGPU_INFO_READ_MMR_REG 0x15743/* Query information about device: rev id, family, etc. */744#define AMDGPU_INFO_DEV_INFO 0x16745/* visible vram usage */746#define AMDGPU_INFO_VIS_VRAM_USAGE 0x17747/* number of TTM buffer evictions */748#define AMDGPU_INFO_NUM_EVICTIONS 0x18749/* Query memory about VRAM and GTT domains */750#define AMDGPU_INFO_MEMORY 0x19751/* Query vce clock table */752#define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A753/* Query vbios related information */754#define AMDGPU_INFO_VBIOS 0x1B755/* Subquery id: Query vbios size */756#define AMDGPU_INFO_VBIOS_SIZE 0x1757/* Subquery id: Query vbios image */758#define AMDGPU_INFO_VBIOS_IMAGE 0x2759/* Subquery id: Query vbios info */760#define AMDGPU_INFO_VBIOS_INFO 0x3761/* Query UVD handles */762#define AMDGPU_INFO_NUM_HANDLES 0x1C763/* Query sensor related information */764#define AMDGPU_INFO_SENSOR 0x1D765/* Subquery id: Query GPU shader clock */766#define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1767/* Subquery id: Query GPU memory clock */768#define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2769/* Subquery id: Query GPU temperature */770#define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3771/* Subquery id: Query GPU load */772#define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4773/* Subquery id: Query average GPU power */774#define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x5775/* Subquery id: Query northbridge voltage */776#define AMDGPU_INFO_SENSOR_VDDNB 0x6777/* Subquery id: Query graphics voltage */778#define AMDGPU_INFO_SENSOR_VDDGFX 0x7779/* Subquery id: Query GPU stable pstate shader clock */780#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK 0x8781/* Subquery id: Query GPU stable pstate memory clock */782#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK 0x9783/* Number of VRAM page faults on CPU access. */784#define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E785#define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F786/* query ras mask of enabled features*/787#define AMDGPU_INFO_RAS_ENABLED_FEATURES 0x20788/* query video encode/decode caps */789#define AMDGPU_INFO_VIDEO_CAPS 0x21790/* Subquery id: Decode */791#define AMDGPU_INFO_VIDEO_CAPS_DECODE 0792/* Subquery id: Encode */793#define AMDGPU_INFO_VIDEO_CAPS_ENCODE 1794795/* RAS MASK: UMC (VRAM) */796#define AMDGPU_INFO_RAS_ENABLED_UMC (1 << 0)797/* RAS MASK: SDMA */798#define AMDGPU_INFO_RAS_ENABLED_SDMA (1 << 1)799/* RAS MASK: GFX */800#define AMDGPU_INFO_RAS_ENABLED_GFX (1 << 2)801/* RAS MASK: MMHUB */802#define AMDGPU_INFO_RAS_ENABLED_MMHUB (1 << 3)803/* RAS MASK: ATHUB */804#define AMDGPU_INFO_RAS_ENABLED_ATHUB (1 << 4)805/* RAS MASK: PCIE */806#define AMDGPU_INFO_RAS_ENABLED_PCIE (1 << 5)807/* RAS MASK: HDP */808#define AMDGPU_INFO_RAS_ENABLED_HDP (1 << 6)809/* RAS MASK: XGMI */810#define AMDGPU_INFO_RAS_ENABLED_XGMI (1 << 7)811/* RAS MASK: DF */812#define AMDGPU_INFO_RAS_ENABLED_DF (1 << 8)813/* RAS MASK: SMN */814#define AMDGPU_INFO_RAS_ENABLED_SMN (1 << 9)815/* RAS MASK: SEM */816#define AMDGPU_INFO_RAS_ENABLED_SEM (1 << 10)817/* RAS MASK: MP0 */818#define AMDGPU_INFO_RAS_ENABLED_MP0 (1 << 11)819/* RAS MASK: MP1 */820#define AMDGPU_INFO_RAS_ENABLED_MP1 (1 << 12)821/* RAS MASK: FUSE */822#define AMDGPU_INFO_RAS_ENABLED_FUSE (1 << 13)823824#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0825#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff826#define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8827#define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff828829struct drm_amdgpu_query_fw {830/** AMDGPU_INFO_FW_* */831__u32 fw_type;832/**833* Index of the IP if there are more IPs of834* the same type.835*/836__u32 ip_instance;837/**838* Index of the engine. Whether this is used depends839* on the firmware type. (e.g. MEC, SDMA)840*/841__u32 index;842__u32 _pad;843};844845/* Input structure for the INFO ioctl */846struct drm_amdgpu_info {847/* Where the return value will be stored */848__u64 return_pointer;849/* The size of the return value. Just like "size" in "snprintf",850* it limits how many bytes the kernel can write. */851__u32 return_size;852/* The query request id. */853__u32 query;854855union {856struct {857__u32 id;858__u32 _pad;859} mode_crtc;860861struct {862/** AMDGPU_HW_IP_* */863__u32 type;864/**865* Index of the IP if there are more IPs of the same866* type. Ignored by AMDGPU_INFO_HW_IP_COUNT.867*/868__u32 ip_instance;869} query_hw_ip;870871struct {872__u32 dword_offset;873/** number of registers to read */874__u32 count;875__u32 instance;876/** For future use, no flags defined so far */877__u32 flags;878} read_mmr_reg;879880struct drm_amdgpu_query_fw query_fw;881882struct {883__u32 type;884__u32 offset;885} vbios_info;886887struct {888__u32 type;889} sensor_info;890891struct {892__u32 type;893} video_cap;894};895};896897struct drm_amdgpu_info_gds {898/** GDS GFX partition size */899__u32 gds_gfx_partition_size;900/** GDS compute partition size */901__u32 compute_partition_size;902/** total GDS memory size */903__u32 gds_total_size;904/** GWS size per GFX partition */905__u32 gws_per_gfx_partition;906/** GSW size per compute partition */907__u32 gws_per_compute_partition;908/** OA size per GFX partition */909__u32 oa_per_gfx_partition;910/** OA size per compute partition */911__u32 oa_per_compute_partition;912__u32 _pad;913};914915struct drm_amdgpu_info_vram_gtt {916__u64 vram_size;917__u64 vram_cpu_accessible_size;918__u64 gtt_size;919};920921struct drm_amdgpu_heap_info {922/** max. physical memory */923__u64 total_heap_size;924925/** Theoretical max. available memory in the given heap */926__u64 usable_heap_size;927928/**929* Number of bytes allocated in the heap. This includes all processes930* and private allocations in the kernel. It changes when new buffers931* are allocated, freed, and moved. It cannot be larger than932* heap_size.933*/934__u64 heap_usage;935936/**937* Theoretical possible max. size of buffer which938* could be allocated in the given heap939*/940__u64 max_allocation;941};942943struct drm_amdgpu_memory_info {944struct drm_amdgpu_heap_info vram;945struct drm_amdgpu_heap_info cpu_accessible_vram;946struct drm_amdgpu_heap_info gtt;947};948949struct drm_amdgpu_info_firmware {950__u32 ver;951__u32 feature;952};953954struct drm_amdgpu_info_vbios {955__u8 name[64];956__u8 vbios_pn[64];957__u32 version;958__u32 pad;959__u8 vbios_ver_str[32];960__u8 date[32];961};962963#define AMDGPU_VRAM_TYPE_UNKNOWN 0964#define AMDGPU_VRAM_TYPE_GDDR1 1965#define AMDGPU_VRAM_TYPE_DDR2 2966#define AMDGPU_VRAM_TYPE_GDDR3 3967#define AMDGPU_VRAM_TYPE_GDDR4 4968#define AMDGPU_VRAM_TYPE_GDDR5 5969#define AMDGPU_VRAM_TYPE_HBM 6970#define AMDGPU_VRAM_TYPE_DDR3 7971#define AMDGPU_VRAM_TYPE_DDR4 8972#define AMDGPU_VRAM_TYPE_GDDR6 9973#define AMDGPU_VRAM_TYPE_DDR5 10974975struct drm_amdgpu_info_device {976/** PCI Device ID */977__u32 device_id;978/** Internal chip revision: A0, A1, etc.) */979__u32 chip_rev;980__u32 external_rev;981/** Revision id in PCI Config space */982__u32 pci_rev;983__u32 family;984__u32 num_shader_engines;985__u32 num_shader_arrays_per_engine;986/* in KHz */987__u32 gpu_counter_freq;988__u64 max_engine_clock;989__u64 max_memory_clock;990/* cu information */991__u32 cu_active_number;992/* NOTE: cu_ao_mask is INVALID, DON'T use it */993__u32 cu_ao_mask;994__u32 cu_bitmap[4][4];995/** Render backend pipe mask. One render backend is CB+DB. */996__u32 enabled_rb_pipes_mask;997__u32 num_rb_pipes;998__u32 num_hw_gfx_contexts;999__u32 _pad;1000__u64 ids_flags;1001/** Starting virtual address for UMDs. */1002__u64 virtual_address_offset;1003/** The maximum virtual address */1004__u64 virtual_address_max;1005/** Required alignment of virtual addresses. */1006__u32 virtual_address_alignment;1007/** Page table entry - fragment size */1008__u32 pte_fragment_size;1009__u32 gart_page_size;1010/** constant engine ram size*/1011__u32 ce_ram_size;1012/** video memory type info*/1013__u32 vram_type;1014/** video memory bit width*/1015__u32 vram_bit_width;1016/* vce harvesting instance */1017__u32 vce_harvest_config;1018/* gfx double offchip LDS buffers */1019__u32 gc_double_offchip_lds_buf;1020/* NGG Primitive Buffer */1021__u64 prim_buf_gpu_addr;1022/* NGG Position Buffer */1023__u64 pos_buf_gpu_addr;1024/* NGG Control Sideband */1025__u64 cntl_sb_buf_gpu_addr;1026/* NGG Parameter Cache */1027__u64 param_buf_gpu_addr;1028__u32 prim_buf_size;1029__u32 pos_buf_size;1030__u32 cntl_sb_buf_size;1031__u32 param_buf_size;1032/* wavefront size*/1033__u32 wave_front_size;1034/* shader visible vgprs*/1035__u32 num_shader_visible_vgprs;1036/* CU per shader array*/1037__u32 num_cu_per_sh;1038/* number of tcc blocks*/1039__u32 num_tcc_blocks;1040/* gs vgt table depth*/1041__u32 gs_vgt_table_depth;1042/* gs primitive buffer depth*/1043__u32 gs_prim_buffer_depth;1044/* max gs wavefront per vgt*/1045__u32 max_gs_waves_per_vgt;1046__u32 _pad1;1047/* always on cu bitmap */1048__u32 cu_ao_bitmap[4][4];1049/** Starting high virtual address for UMDs. */1050__u64 high_va_offset;1051/** The maximum high virtual address */1052__u64 high_va_max;1053/* gfx10 pa_sc_tile_steering_override */1054__u32 pa_sc_tile_steering_override;1055/* disabled TCCs */1056__u64 tcc_disabled_mask;1057};10581059struct drm_amdgpu_info_hw_ip {1060/** Version of h/w IP */1061__u32 hw_ip_version_major;1062__u32 hw_ip_version_minor;1063/** Capabilities */1064__u64 capabilities_flags;1065/** command buffer address start alignment*/1066__u32 ib_start_alignment;1067/** command buffer size alignment*/1068__u32 ib_size_alignment;1069/** Bitmask of available rings. Bit 0 means ring 0, etc. */1070__u32 available_rings;1071__u32 _pad;1072};10731074struct drm_amdgpu_info_num_handles {1075/** Max handles as supported by firmware for UVD */1076__u32 uvd_max_handles;1077/** Handles currently in use for UVD */1078__u32 uvd_used_handles;1079};10801081#define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 610821083struct drm_amdgpu_info_vce_clock_table_entry {1084/** System clock */1085__u32 sclk;1086/** Memory clock */1087__u32 mclk;1088/** VCE clock */1089__u32 eclk;1090__u32 pad;1091};10921093struct drm_amdgpu_info_vce_clock_table {1094struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];1095__u32 num_valid_entries;1096__u32 pad;1097};10981099/* query video encode/decode caps */1100#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 01101#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 11102#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 21103#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC 31104#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC 41105#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG 51106#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9 61107#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1 71108#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT 811091110struct drm_amdgpu_info_video_codec_info {1111__u32 valid;1112__u32 max_width;1113__u32 max_height;1114__u32 max_pixels_per_frame;1115__u32 max_level;1116__u32 pad;1117};11181119struct drm_amdgpu_info_video_caps {1120struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT];1121};11221123/*1124* Supported GPU families1125*/1126#define AMDGPU_FAMILY_UNKNOWN 01127#define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */1128#define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */1129#define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */1130#define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */1131#define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */1132#define AMDGPU_FAMILY_AI 141 /* Vega10 */1133#define AMDGPU_FAMILY_RV 142 /* Raven */1134#define AMDGPU_FAMILY_NV 143 /* Navi10 */1135#define AMDGPU_FAMILY_VGH 144 /* Van Gogh */1136#define AMDGPU_FAMILY_YC 146 /* Yellow Carp */11371138#if defined(__cplusplus)1139}1140#endif11411142#endif114311441145