/* 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 0x1556#define DRM_AMDGPU_USERQ 0x1657#define DRM_AMDGPU_USERQ_SIGNAL 0x1758#define DRM_AMDGPU_USERQ_WAIT 0x1859#define DRM_AMDGPU_GEM_LIST_HANDLES 0x196061#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)62#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)63#define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)64#define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)65#define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)66#define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)67#define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)68#define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)69#define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)70#define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)71#define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)72#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)73#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)74#define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)75#define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)76#define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)77#define DRM_IOCTL_AMDGPU_USERQ DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ, union drm_amdgpu_userq)78#define DRM_IOCTL_AMDGPU_USERQ_SIGNAL DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_SIGNAL, struct drm_amdgpu_userq_signal)79#define DRM_IOCTL_AMDGPU_USERQ_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_WAIT, struct drm_amdgpu_userq_wait)80#define DRM_IOCTL_AMDGPU_GEM_LIST_HANDLES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_LIST_HANDLES, struct drm_amdgpu_gem_list_handles)8182/**83* DOC: memory domains84*85* %AMDGPU_GEM_DOMAIN_CPU System memory that is not GPU accessible.86* Memory in this pool could be swapped out to disk if there is pressure.87*88* %AMDGPU_GEM_DOMAIN_GTT GPU accessible system memory, mapped into the89* GPU's virtual address space via gart. Gart memory linearizes non-contiguous90* pages of system memory, allows GPU access system memory in a linearized91* fashion.92*93* %AMDGPU_GEM_DOMAIN_VRAM Local video memory. For APUs, it is memory94* carved out by the BIOS.95*96* %AMDGPU_GEM_DOMAIN_GDS Global on-chip data storage used to share data97* across shader threads.98*99* %AMDGPU_GEM_DOMAIN_GWS Global wave sync, used to synchronize the100* execution of all the waves on a device.101*102* %AMDGPU_GEM_DOMAIN_OA Ordered append, used by 3D or Compute engines103* for appending data.104*105* %AMDGPU_GEM_DOMAIN_DOORBELL Doorbell. It is an MMIO region for106* signalling user mode queues.107*108* %AMDGPU_GEM_DOMAIN_MMIO_REMAP MMIO remap page (special mapping for HDP flushing).109*/110#define AMDGPU_GEM_DOMAIN_CPU 0x1111#define AMDGPU_GEM_DOMAIN_GTT 0x2112#define AMDGPU_GEM_DOMAIN_VRAM 0x4113#define AMDGPU_GEM_DOMAIN_GDS 0x8114#define AMDGPU_GEM_DOMAIN_GWS 0x10115#define AMDGPU_GEM_DOMAIN_OA 0x20116#define AMDGPU_GEM_DOMAIN_DOORBELL 0x40117#define AMDGPU_GEM_DOMAIN_MMIO_REMAP 0x80118#define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \119AMDGPU_GEM_DOMAIN_GTT | \120AMDGPU_GEM_DOMAIN_VRAM | \121AMDGPU_GEM_DOMAIN_GDS | \122AMDGPU_GEM_DOMAIN_GWS | \123AMDGPU_GEM_DOMAIN_OA | \124AMDGPU_GEM_DOMAIN_DOORBELL | \125AMDGPU_GEM_DOMAIN_MMIO_REMAP)126127/* Flag that CPU access will be required for the case of VRAM domain */128#define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)129/* Flag that CPU access will not work, this VRAM domain is invisible */130#define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)131/* Flag that USWC attributes should be used for GTT */132#define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)133/* Flag that the memory should be in VRAM and cleared */134#define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3)135/* Flag that allocating the BO should use linear VRAM */136#define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5)137/* Flag that BO is always valid in this VM */138#define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6)139/* Flag that BO sharing will be explicitly synchronized */140#define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7)141/* Flag that indicates allocating MQD gart on GFX9, where the mtype142* for the second page onward should be set to NC. It should never143* be used by user space applications.144*/145#define AMDGPU_GEM_CREATE_CP_MQD_GFX9 (1 << 8)146/* Flag that BO may contain sensitive data that must be wiped before147* releasing the memory148*/149#define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE (1 << 9)150/* Flag that BO will be encrypted and that the TMZ bit should be151* set in the PTEs when mapping this buffer via GPUVM or152* accessing it with various hw blocks153*/154#define AMDGPU_GEM_CREATE_ENCRYPTED (1 << 10)155/* Flag that BO will be used only in preemptible context, which does156* not require GTT memory accounting157*/158#define AMDGPU_GEM_CREATE_PREEMPTIBLE (1 << 11)159/* Flag that BO can be discarded under memory pressure without keeping the160* content.161*/162#define AMDGPU_GEM_CREATE_DISCARDABLE (1 << 12)163/* Flag that BO is shared coherently between multiple devices or CPU threads.164* May depend on GPU instructions to flush caches to system scope explicitly.165*166* This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and167* may override the MTYPE selected in AMDGPU_VA_OP_MAP.168*/169#define AMDGPU_GEM_CREATE_COHERENT (1 << 13)170/* Flag that BO should not be cached by GPU. Coherent without having to flush171* GPU caches explicitly172*173* This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and174* may override the MTYPE selected in AMDGPU_VA_OP_MAP.175*/176#define AMDGPU_GEM_CREATE_UNCACHED (1 << 14)177/* Flag that BO should be coherent across devices when using device-level178* atomics. May depend on GPU instructions to flush caches to device scope179* explicitly, promoting them to system scope automatically.180*181* This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and182* may override the MTYPE selected in AMDGPU_VA_OP_MAP.183*/184#define AMDGPU_GEM_CREATE_EXT_COHERENT (1 << 15)185/* Set PTE.D and recompress during GTT->VRAM moves according to TILING flags. */186#define AMDGPU_GEM_CREATE_GFX12_DCC (1 << 16)187188struct drm_amdgpu_gem_create_in {189/** the requested memory size */190__u64 bo_size;191/** physical start_addr alignment in bytes for some HW requirements */192__u64 alignment;193/** the requested memory domains */194__u64 domains;195/** allocation flags */196__u64 domain_flags;197};198199struct drm_amdgpu_gem_create_out {200/** returned GEM object handle */201__u32 handle;202__u32 _pad;203};204205union drm_amdgpu_gem_create {206struct drm_amdgpu_gem_create_in in;207struct drm_amdgpu_gem_create_out out;208};209210/** Opcode to create new residency list. */211#define AMDGPU_BO_LIST_OP_CREATE 0212/** Opcode to destroy previously created residency list */213#define AMDGPU_BO_LIST_OP_DESTROY 1214/** Opcode to update resource information in the list */215#define AMDGPU_BO_LIST_OP_UPDATE 2216217struct drm_amdgpu_bo_list_in {218/** Type of operation */219__u32 operation;220/** Handle of list or 0 if we want to create one */221__u32 list_handle;222/** Number of BOs in list */223__u32 bo_number;224/** Size of each element describing BO */225__u32 bo_info_size;226/** Pointer to array describing BOs */227__u64 bo_info_ptr;228};229230struct drm_amdgpu_bo_list_entry {231/** Handle of BO */232__u32 bo_handle;233/** New (if specified) BO priority to be used during migration */234__u32 bo_priority;235};236237struct drm_amdgpu_bo_list_out {238/** Handle of resource list */239__u32 list_handle;240__u32 _pad;241};242243union drm_amdgpu_bo_list {244struct drm_amdgpu_bo_list_in in;245struct drm_amdgpu_bo_list_out out;246};247248/* context related */249#define AMDGPU_CTX_OP_ALLOC_CTX 1250#define AMDGPU_CTX_OP_FREE_CTX 2251#define AMDGPU_CTX_OP_QUERY_STATE 3252#define AMDGPU_CTX_OP_QUERY_STATE2 4253#define AMDGPU_CTX_OP_GET_STABLE_PSTATE 5254#define AMDGPU_CTX_OP_SET_STABLE_PSTATE 6255256/* GPU reset status */257#define AMDGPU_CTX_NO_RESET 0258/* this the context caused it */259#define AMDGPU_CTX_GUILTY_RESET 1260/* some other context caused it */261#define AMDGPU_CTX_INNOCENT_RESET 2262/* unknown cause */263#define AMDGPU_CTX_UNKNOWN_RESET 3264265/* indicate gpu reset occurred after ctx created */266#define AMDGPU_CTX_QUERY2_FLAGS_RESET (1<<0)267/* indicate vram lost occurred after ctx created */268#define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)269/* indicate some job from this context once cause gpu hang */270#define AMDGPU_CTX_QUERY2_FLAGS_GUILTY (1<<2)271/* indicate some errors are detected by RAS */272#define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE (1<<3)273#define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE (1<<4)274/* indicate that the reset hasn't completed yet */275#define AMDGPU_CTX_QUERY2_FLAGS_RESET_IN_PROGRESS (1<<5)276277/* Context priority level */278#define AMDGPU_CTX_PRIORITY_UNSET -2048279#define AMDGPU_CTX_PRIORITY_VERY_LOW -1023280#define AMDGPU_CTX_PRIORITY_LOW -512281#define AMDGPU_CTX_PRIORITY_NORMAL 0282/*283* When used in struct drm_amdgpu_ctx_in, a priority above NORMAL requires284* CAP_SYS_NICE or DRM_MASTER285*/286#define AMDGPU_CTX_PRIORITY_HIGH 512287#define AMDGPU_CTX_PRIORITY_VERY_HIGH 1023288289/* select a stable profiling pstate for perfmon tools */290#define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK 0xf291#define AMDGPU_CTX_STABLE_PSTATE_NONE 0292#define AMDGPU_CTX_STABLE_PSTATE_STANDARD 1293#define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK 2294#define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK 3295#define AMDGPU_CTX_STABLE_PSTATE_PEAK 4296297struct drm_amdgpu_ctx_in {298/** AMDGPU_CTX_OP_* */299__u32 op;300/** Flags */301__u32 flags;302__u32 ctx_id;303/** AMDGPU_CTX_PRIORITY_* */304__s32 priority;305};306307union drm_amdgpu_ctx_out {308struct {309__u32 ctx_id;310__u32 _pad;311} alloc;312313struct {314/** For future use, no flags defined so far */315__u64 flags;316/** Number of resets caused by this context so far. */317__u32 hangs;318/** Reset status since the last call of the ioctl. */319__u32 reset_status;320} state;321322struct {323__u32 flags;324__u32 _pad;325} pstate;326};327328union drm_amdgpu_ctx {329struct drm_amdgpu_ctx_in in;330union drm_amdgpu_ctx_out out;331};332333/* user queue IOCTL operations */334#define AMDGPU_USERQ_OP_CREATE 1335#define AMDGPU_USERQ_OP_FREE 2336337/* queue priority levels */338/* low < normal low < normal high < high */339#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_MASK 0x3340#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_SHIFT 0341#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_NORMAL_LOW 0342#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_LOW 1343#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_NORMAL_HIGH 2344#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH 3 /* admin only */345/* for queues that need access to protected content */346#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE (1 << 2)347348/*349* This structure is a container to pass input configuration350* info for all supported userqueue related operations.351* For operation AMDGPU_USERQ_OP_CREATE: user is expected352* to set all fields, excep the parameter 'queue_id'.353* For operation AMDGPU_USERQ_OP_FREE: the only input parameter expected354* to be set is 'queue_id', eveything else is ignored.355*/356struct drm_amdgpu_userq_in {357/** AMDGPU_USERQ_OP_* */358__u32 op;359/** Queue id passed for operation USERQ_OP_FREE */360__u32 queue_id;361/** the target GPU engine to execute workload (AMDGPU_HW_IP_*) */362__u32 ip_type;363/**364* @doorbell_handle: the handle of doorbell GEM object365* associated with this userqueue client.366*/367__u32 doorbell_handle;368/**369* @doorbell_offset: 32-bit offset of the doorbell in the doorbell bo.370* Kernel will generate absolute doorbell offset using doorbell_handle371* and doorbell_offset in the doorbell bo.372*/373__u32 doorbell_offset;374/**375* @flags: flags used for queue parameters376*/377__u32 flags;378/**379* @queue_va: Virtual address of the GPU memory which holds the queue380* object. The queue holds the workload packets.381*/382__u64 queue_va;383/**384* @queue_size: Size of the queue in bytes, this needs to be 256-byte385* aligned.386*/387__u64 queue_size;388/**389* @rptr_va : Virtual address of the GPU memory which holds the ring RPTR.390* This object must be at least 8 byte in size and aligned to 8-byte offset.391*/392__u64 rptr_va;393/**394* @wptr_va : Virtual address of the GPU memory which holds the ring WPTR.395* This object must be at least 8 byte in size and aligned to 8-byte offset.396*397* Queue, RPTR and WPTR can come from the same object, as long as the size398* and alignment related requirements are met.399*/400__u64 wptr_va;401/**402* @mqd: MQD (memory queue descriptor) is a set of parameters which allow403* the GPU to uniquely define and identify a usermode queue.404*405* MQD data can be of different size for different GPU IP/engine and406* their respective versions/revisions, so this points to a __u64 *407* which holds IP specific MQD of this usermode queue.408*/409__u64 mqd;410/**411* @size: size of MQD data in bytes, it must match the MQD structure412* size of the respective engine/revision defined in UAPI for ex, for413* gfx11 workloads, size = sizeof(drm_amdgpu_userq_mqd_gfx11).414*/415__u64 mqd_size;416};417418/* The structure to carry output of userqueue ops */419struct drm_amdgpu_userq_out {420/**421* For operation AMDGPU_USERQ_OP_CREATE: This field contains a unique422* queue ID to represent the newly created userqueue in the system, otherwise423* it should be ignored.424*/425__u32 queue_id;426__u32 _pad;427};428429union drm_amdgpu_userq {430struct drm_amdgpu_userq_in in;431struct drm_amdgpu_userq_out out;432};433434/* GFX V11 IP specific MQD parameters */435struct drm_amdgpu_userq_mqd_gfx11 {436/**437* @shadow_va: Virtual address of the GPU memory to hold the shadow buffer.438* Use AMDGPU_INFO_IOCTL to find the exact size of the object.439*/440__u64 shadow_va;441/**442* @csa_va: Virtual address of the GPU memory to hold the CSA buffer.443* Use AMDGPU_INFO_IOCTL to find the exact size of the object.444*/445__u64 csa_va;446};447448/* GFX V11 SDMA IP specific MQD parameters */449struct drm_amdgpu_userq_mqd_sdma_gfx11 {450/**451* @csa_va: Virtual address of the GPU memory to hold the CSA buffer.452* This must be a from a separate GPU object, and use AMDGPU_INFO IOCTL453* to get the size.454*/455__u64 csa_va;456};457458/* GFX V11 Compute IP specific MQD parameters */459struct drm_amdgpu_userq_mqd_compute_gfx11 {460/**461* @eop_va: Virtual address of the GPU memory to hold the EOP buffer.462* This must be a from a separate GPU object, and use AMDGPU_INFO IOCTL463* to get the size.464*/465__u64 eop_va;466};467468/* userq signal/wait ioctl */469struct drm_amdgpu_userq_signal {470/**471* @queue_id: Queue handle used by the userq fence creation function472* to retrieve the WPTR.473*/474__u32 queue_id;475__u32 pad;476/**477* @syncobj_handles: The list of syncobj handles submitted by the user queue478* job to be signaled.479*/480__u64 syncobj_handles;481/**482* @num_syncobj_handles: A count that represents the number of syncobj handles in483* @syncobj_handles.484*/485__u64 num_syncobj_handles;486/**487* @bo_read_handles: The list of BO handles that the submitted user queue job488* is using for read only. This will update BO fences in the kernel.489*/490__u64 bo_read_handles;491/**492* @bo_write_handles: The list of BO handles that the submitted user queue job493* is using for write only. This will update BO fences in the kernel.494*/495__u64 bo_write_handles;496/**497* @num_bo_read_handles: A count that represents the number of read BO handles in498* @bo_read_handles.499*/500__u32 num_bo_read_handles;501/**502* @num_bo_write_handles: A count that represents the number of write BO handles in503* @bo_write_handles.504*/505__u32 num_bo_write_handles;506};507508struct drm_amdgpu_userq_fence_info {509/**510* @va: A gpu address allocated for each queue which stores the511* read pointer (RPTR) value.512*/513__u64 va;514/**515* @value: A 64 bit value represents the write pointer (WPTR) of the516* queue commands which compared with the RPTR value to signal the517* fences.518*/519__u64 value;520};521522struct drm_amdgpu_userq_wait {523/**524* @waitq_id: Queue handle used by the userq wait IOCTL to retrieve the525* wait queue and maintain the fence driver references in it.526*/527__u32 waitq_id;528__u32 pad;529/**530* @syncobj_handles: The list of syncobj handles submitted by the user queue531* job to get the va/value pairs.532*/533__u64 syncobj_handles;534/**535* @syncobj_timeline_handles: The list of timeline syncobj handles submitted by536* the user queue job to get the va/value pairs at given @syncobj_timeline_points.537*/538__u64 syncobj_timeline_handles;539/**540* @syncobj_timeline_points: The list of timeline syncobj points submitted by the541* user queue job for the corresponding @syncobj_timeline_handles.542*/543__u64 syncobj_timeline_points;544/**545* @bo_read_handles: The list of read BO handles submitted by the user queue546* job to get the va/value pairs.547*/548__u64 bo_read_handles;549/**550* @bo_write_handles: The list of write BO handles submitted by the user queue551* job to get the va/value pairs.552*/553__u64 bo_write_handles;554/**555* @num_syncobj_timeline_handles: A count that represents the number of timeline556* syncobj handles in @syncobj_timeline_handles.557*/558__u16 num_syncobj_timeline_handles;559/**560* @num_fences: This field can be used both as input and output. As input it defines561* the maximum number of fences that can be returned and as output it will specify562* how many fences were actually returned from the ioctl.563*/564__u16 num_fences;565/**566* @num_syncobj_handles: A count that represents the number of syncobj handles in567* @syncobj_handles.568*/569__u32 num_syncobj_handles;570/**571* @num_bo_read_handles: A count that represents the number of read BO handles in572* @bo_read_handles.573*/574__u32 num_bo_read_handles;575/**576* @num_bo_write_handles: A count that represents the number of write BO handles in577* @bo_write_handles.578*/579__u32 num_bo_write_handles;580/**581* @out_fences: The field is a return value from the ioctl containing the list of582* address/value pairs to wait for.583*/584__u64 out_fences;585};586587/* vm ioctl */588#define AMDGPU_VM_OP_RESERVE_VMID 1589#define AMDGPU_VM_OP_UNRESERVE_VMID 2590591struct drm_amdgpu_vm_in {592/** AMDGPU_VM_OP_* */593__u32 op;594__u32 flags;595};596597struct drm_amdgpu_vm_out {598/** For future use, no flags defined so far */599__u64 flags;600};601602union drm_amdgpu_vm {603struct drm_amdgpu_vm_in in;604struct drm_amdgpu_vm_out out;605};606607/* sched ioctl */608#define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE 1609#define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE 2610611struct drm_amdgpu_sched_in {612/* AMDGPU_SCHED_OP_* */613__u32 op;614__u32 fd;615/** AMDGPU_CTX_PRIORITY_* */616__s32 priority;617__u32 ctx_id;618};619620union drm_amdgpu_sched {621struct drm_amdgpu_sched_in in;622};623624/*625* This is not a reliable API and you should expect it to fail for any626* number of reasons and have fallback path that do not use userptr to627* perform any operation.628*/629#define AMDGPU_GEM_USERPTR_READONLY (1 << 0)630#define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)631#define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)632#define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)633634struct drm_amdgpu_gem_userptr {635__u64 addr;636__u64 size;637/* AMDGPU_GEM_USERPTR_* */638__u32 flags;639/* Resulting GEM handle */640__u32 handle;641};642643/* SI-CI-VI: */644/* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */645#define AMDGPU_TILING_ARRAY_MODE_SHIFT 0646#define AMDGPU_TILING_ARRAY_MODE_MASK 0xf647#define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4648#define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f649#define AMDGPU_TILING_TILE_SPLIT_SHIFT 9650#define AMDGPU_TILING_TILE_SPLIT_MASK 0x7651#define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12652#define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7653#define AMDGPU_TILING_BANK_WIDTH_SHIFT 15654#define AMDGPU_TILING_BANK_WIDTH_MASK 0x3655#define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17656#define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3657#define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19658#define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3659#define AMDGPU_TILING_NUM_BANKS_SHIFT 21660#define AMDGPU_TILING_NUM_BANKS_MASK 0x3661662/* GFX9 - GFX11: */663#define AMDGPU_TILING_SWIZZLE_MODE_SHIFT 0664#define AMDGPU_TILING_SWIZZLE_MODE_MASK 0x1f665#define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT 5666#define AMDGPU_TILING_DCC_OFFSET_256B_MASK 0xFFFFFF667#define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT 29668#define AMDGPU_TILING_DCC_PITCH_MAX_MASK 0x3FFF669#define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT 43670#define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK 0x1671#define AMDGPU_TILING_DCC_INDEPENDENT_128B_SHIFT 44672#define AMDGPU_TILING_DCC_INDEPENDENT_128B_MASK 0x1673#define AMDGPU_TILING_SCANOUT_SHIFT 63674#define AMDGPU_TILING_SCANOUT_MASK 0x1675676/* GFX12 and later: */677#define AMDGPU_TILING_GFX12_SWIZZLE_MODE_SHIFT 0678#define AMDGPU_TILING_GFX12_SWIZZLE_MODE_MASK 0x7679/* These are DCC recompression settings for memory management: */680#define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_SHIFT 3681#define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_MASK 0x3 /* 0:64B, 1:128B, 2:256B */682#define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_SHIFT 5683#define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_MASK 0x7 /* CB_COLOR0_INFO.NUMBER_TYPE */684#define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_SHIFT 8685#define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_MASK 0x3f /* [0:4]:CB_COLOR0_INFO.FORMAT, [5]:MM */686/* When clearing the buffer or moving it from VRAM to GTT, don't compress and set DCC metadata687* to uncompressed. Set when parts of an allocation bypass DCC and read raw data. */688#define AMDGPU_TILING_GFX12_DCC_WRITE_COMPRESS_DISABLE_SHIFT 14689#define AMDGPU_TILING_GFX12_DCC_WRITE_COMPRESS_DISABLE_MASK 0x1690/* bit gap */691#define AMDGPU_TILING_GFX12_SCANOUT_SHIFT 63692#define AMDGPU_TILING_GFX12_SCANOUT_MASK 0x1693694/* Set/Get helpers for tiling flags. */695#define AMDGPU_TILING_SET(field, value) \696(((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)697#define AMDGPU_TILING_GET(value, field) \698(((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)699700#define AMDGPU_GEM_METADATA_OP_SET_METADATA 1701#define AMDGPU_GEM_METADATA_OP_GET_METADATA 2702703/** The same structure is shared for input/output */704struct drm_amdgpu_gem_metadata {705/** GEM Object handle */706__u32 handle;707/** Do we want get or set metadata */708__u32 op;709struct {710/** For future use, no flags defined so far */711__u64 flags;712/** family specific tiling info */713__u64 tiling_info;714__u32 data_size_bytes;715__u32 data[64];716} data;717};718719struct drm_amdgpu_gem_mmap_in {720/** the GEM object handle */721__u32 handle;722__u32 _pad;723};724725struct drm_amdgpu_gem_mmap_out {726/** mmap offset from the vma offset manager */727__u64 addr_ptr;728};729730union drm_amdgpu_gem_mmap {731struct drm_amdgpu_gem_mmap_in in;732struct drm_amdgpu_gem_mmap_out out;733};734735struct drm_amdgpu_gem_wait_idle_in {736/** GEM object handle */737__u32 handle;738/** For future use, no flags defined so far */739__u32 flags;740/** Absolute timeout to wait */741__u64 timeout;742};743744struct drm_amdgpu_gem_wait_idle_out {745/** BO status: 0 - BO is idle, 1 - BO is busy */746__u32 status;747/** Returned current memory domain */748__u32 domain;749};750751union drm_amdgpu_gem_wait_idle {752struct drm_amdgpu_gem_wait_idle_in in;753struct drm_amdgpu_gem_wait_idle_out out;754};755756struct drm_amdgpu_wait_cs_in {757/* Command submission handle758* handle equals 0 means none to wait for759* handle equals ~0ull means wait for the latest sequence number760*/761__u64 handle;762/** Absolute timeout to wait */763__u64 timeout;764__u32 ip_type;765__u32 ip_instance;766__u32 ring;767__u32 ctx_id;768};769770struct drm_amdgpu_wait_cs_out {771/** CS status: 0 - CS completed, 1 - CS still busy */772__u64 status;773};774775union drm_amdgpu_wait_cs {776struct drm_amdgpu_wait_cs_in in;777struct drm_amdgpu_wait_cs_out out;778};779780struct drm_amdgpu_fence {781__u32 ctx_id;782__u32 ip_type;783__u32 ip_instance;784__u32 ring;785__u64 seq_no;786};787788struct drm_amdgpu_wait_fences_in {789/** This points to uint64_t * which points to fences */790__u64 fences;791__u32 fence_count;792__u32 wait_all;793__u64 timeout_ns;794};795796struct drm_amdgpu_wait_fences_out {797__u32 status;798__u32 first_signaled;799};800801union drm_amdgpu_wait_fences {802struct drm_amdgpu_wait_fences_in in;803struct drm_amdgpu_wait_fences_out out;804};805806#define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0807#define AMDGPU_GEM_OP_SET_PLACEMENT 1808#define AMDGPU_GEM_OP_GET_MAPPING_INFO 2809810struct drm_amdgpu_gem_vm_entry {811/* Start of mapping (in bytes) */812__u64 addr;813814/* Size of mapping (in bytes) */815__u64 size;816817/* Mapping offset */818__u64 offset;819820/* flags needed to recreate mapping */821__u64 flags;822};823824/* Sets or returns a value associated with a buffer. */825struct drm_amdgpu_gem_op {826/** GEM object handle */827__u32 handle;828/** AMDGPU_GEM_OP_* */829__u32 op;830/** Input or return value. For MAPPING_INFO op: pointer to array of struct drm_amdgpu_gem_vm_entry */831__u64 value;832/** For MAPPING_INFO op: number of mappings (in/out) */833__u32 num_entries;834835__u32 padding;836};837838#define AMDGPU_GEM_LIST_HANDLES_FLAG_IS_IMPORT (1 << 0)839840struct drm_amdgpu_gem_list_handles {841/* User pointer to array of drm_amdgpu_gem_bo_info_entry */842__u64 entries;843844/* Size of entries buffer / Number of handles in process (if larger than size of buffer, must retry) */845__u32 num_entries;846847__u32 padding;848};849850struct drm_amdgpu_gem_list_handles_entry {851/* gem handle of buffer object */852__u32 gem_handle;853854/* Currently just one flag: IS_IMPORT */855__u32 flags;856857/* Size of bo */858__u64 size;859860/* Preferred domains for GEM_CREATE */861__u64 preferred_domains;862863/* GEM_CREATE flags for re-creation of buffer */864__u64 alloc_flags;865866/* physical start_addr alignment in bytes for some HW requirements */867__u64 alignment;868};869870#define AMDGPU_VA_OP_MAP 1871#define AMDGPU_VA_OP_UNMAP 2872#define AMDGPU_VA_OP_CLEAR 3873#define AMDGPU_VA_OP_REPLACE 4874875/* Delay the page table update till the next CS */876#define AMDGPU_VM_DELAY_UPDATE (1 << 0)877878/* Mapping flags */879/* readable mapping */880#define AMDGPU_VM_PAGE_READABLE (1 << 1)881/* writable mapping */882#define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)883/* executable mapping, new for VI */884#define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)885/* partially resident texture */886#define AMDGPU_VM_PAGE_PRT (1 << 4)887/* MTYPE flags use bit 5 to 8 */888#define AMDGPU_VM_MTYPE_MASK (0xf << 5)889/* Default MTYPE. Pre-AI must use this. Recommended for newer ASICs. */890#define AMDGPU_VM_MTYPE_DEFAULT (0 << 5)891/* Use Non Coherent MTYPE instead of default MTYPE */892#define AMDGPU_VM_MTYPE_NC (1 << 5)893/* Use Write Combine MTYPE instead of default MTYPE */894#define AMDGPU_VM_MTYPE_WC (2 << 5)895/* Use Cache Coherent MTYPE instead of default MTYPE */896#define AMDGPU_VM_MTYPE_CC (3 << 5)897/* Use UnCached MTYPE instead of default MTYPE */898#define AMDGPU_VM_MTYPE_UC (4 << 5)899/* Use Read Write MTYPE instead of default MTYPE */900#define AMDGPU_VM_MTYPE_RW (5 << 5)901/* don't allocate MALL */902#define AMDGPU_VM_PAGE_NOALLOC (1 << 9)903904struct drm_amdgpu_gem_va {905/** GEM object handle */906__u32 handle;907__u32 _pad;908/** AMDGPU_VA_OP_* */909__u32 operation;910/** AMDGPU_VM_PAGE_* */911__u32 flags;912/** va address to assign . Must be correctly aligned.*/913__u64 va_address;914/** Specify offset inside of BO to assign. Must be correctly aligned.*/915__u64 offset_in_bo;916/** Specify mapping size. Must be correctly aligned. */917__u64 map_size;918/**919* vm_timeline_point is a sequence number used to add new timeline point.920*/921__u64 vm_timeline_point;922/**923* The vm page table update fence is installed in given vm_timeline_syncobj_out924* at vm_timeline_point.925*/926__u32 vm_timeline_syncobj_out;927/** the number of syncobj handles in @input_fence_syncobj_handles */928__u32 num_syncobj_handles;929/** Array of sync object handle to wait for given input fences */930__u64 input_fence_syncobj_handles;931};932933#define AMDGPU_HW_IP_GFX 0934#define AMDGPU_HW_IP_COMPUTE 1935#define AMDGPU_HW_IP_DMA 2936#define AMDGPU_HW_IP_UVD 3937#define AMDGPU_HW_IP_VCE 4938#define AMDGPU_HW_IP_UVD_ENC 5939#define AMDGPU_HW_IP_VCN_DEC 6940/*941* From VCN4, AMDGPU_HW_IP_VCN_ENC is re-used to support942* both encoding and decoding jobs.943*/944#define AMDGPU_HW_IP_VCN_ENC 7945#define AMDGPU_HW_IP_VCN_JPEG 8946#define AMDGPU_HW_IP_VPE 9947#define AMDGPU_HW_IP_NUM 10948949#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1950951#define AMDGPU_CHUNK_ID_IB 0x01952#define AMDGPU_CHUNK_ID_FENCE 0x02953#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03954#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04955#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05956#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06957#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07958#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08959#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09960#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW 0x0a961962struct drm_amdgpu_cs_chunk {963__u32 chunk_id;964__u32 length_dw;965__u64 chunk_data;966};967968struct drm_amdgpu_cs_in {969/** Rendering context id */970__u32 ctx_id;971/** Handle of resource list associated with CS */972__u32 bo_list_handle;973__u32 num_chunks;974__u32 flags;975/** this points to __u64 * which point to cs chunks */976__u64 chunks;977};978979struct drm_amdgpu_cs_out {980__u64 handle;981};982983union drm_amdgpu_cs {984struct drm_amdgpu_cs_in in;985struct drm_amdgpu_cs_out out;986};987988/* Specify flags to be used for IB */989990/* This IB should be submitted to CE */991#define AMDGPU_IB_FLAG_CE (1<<0)992993/* Preamble flag, which means the IB could be dropped if no context switch */994#define AMDGPU_IB_FLAG_PREAMBLE (1<<1)995996/* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */997#define AMDGPU_IB_FLAG_PREEMPT (1<<2)998999/* The IB fence should do the L2 writeback but not invalidate any shader1000* caches (L2/vL1/sL1/I$). */1001#define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3)10021003/* Set GDS_COMPUTE_MAX_WAVE_ID = DEFAULT before PACKET3_INDIRECT_BUFFER.1004* This will reset wave ID counters for the IB.1005*/1006#define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4)10071008/* Flag the IB as secure (TMZ)1009*/1010#define AMDGPU_IB_FLAGS_SECURE (1 << 5)10111012/* Tell KMD to flush and invalidate caches1013*/1014#define AMDGPU_IB_FLAG_EMIT_MEM_SYNC (1 << 6)10151016struct drm_amdgpu_cs_chunk_ib {1017__u32 _pad;1018/** AMDGPU_IB_FLAG_* */1019__u32 flags;1020/** Virtual address to begin IB execution */1021__u64 va_start;1022/** Size of submission */1023__u32 ib_bytes;1024/** HW IP to submit to */1025__u32 ip_type;1026/** HW IP index of the same type to submit to */1027__u32 ip_instance;1028/** Ring index to submit to */1029__u32 ring;1030};10311032struct drm_amdgpu_cs_chunk_dep {1033__u32 ip_type;1034__u32 ip_instance;1035__u32 ring;1036__u32 ctx_id;1037__u64 handle;1038};10391040struct drm_amdgpu_cs_chunk_fence {1041__u32 handle;1042__u32 offset;1043};10441045struct drm_amdgpu_cs_chunk_sem {1046__u32 handle;1047};10481049struct drm_amdgpu_cs_chunk_syncobj {1050__u32 handle;1051__u32 flags;1052__u64 point;1053};10541055#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 01056#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 11057#define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 210581059union drm_amdgpu_fence_to_handle {1060struct {1061struct drm_amdgpu_fence fence;1062__u32 what;1063__u32 pad;1064} in;1065struct {1066__u32 handle;1067} out;1068};10691070struct drm_amdgpu_cs_chunk_data {1071union {1072struct drm_amdgpu_cs_chunk_ib ib_data;1073struct drm_amdgpu_cs_chunk_fence fence_data;1074};1075};10761077#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW 0x110781079struct drm_amdgpu_cs_chunk_cp_gfx_shadow {1080__u64 shadow_va;1081__u64 csa_va;1082__u64 gds_va;1083__u64 flags;1084};10851086/*1087* Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU1088*1089*/1090#define AMDGPU_IDS_FLAGS_FUSION 0x011091#define AMDGPU_IDS_FLAGS_PREEMPTION 0x021092#define AMDGPU_IDS_FLAGS_TMZ 0x041093#define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x081094#define AMDGPU_IDS_FLAGS_GANG_SUBMIT 0x1010951096/*1097* Query h/w info: Flag identifying VF/PF/PT mode1098*1099*/1100#define AMDGPU_IDS_FLAGS_MODE_MASK 0x3001101#define AMDGPU_IDS_FLAGS_MODE_SHIFT 0x81102#define AMDGPU_IDS_FLAGS_MODE_PF 0x01103#define AMDGPU_IDS_FLAGS_MODE_VF 0x11104#define AMDGPU_IDS_FLAGS_MODE_PT 0x211051106/* indicate if acceleration can be working */1107#define AMDGPU_INFO_ACCEL_WORKING 0x001108/* get the crtc_id from the mode object id? */1109#define AMDGPU_INFO_CRTC_FROM_ID 0x011110/* query hw IP info */1111#define AMDGPU_INFO_HW_IP_INFO 0x021112/* query hw IP instance count for the specified type */1113#define AMDGPU_INFO_HW_IP_COUNT 0x031114/* timestamp for GL_ARB_timer_query */1115#define AMDGPU_INFO_TIMESTAMP 0x051116/* Query the firmware version */1117#define AMDGPU_INFO_FW_VERSION 0x0e1118/* Subquery id: Query VCE firmware version */1119#define AMDGPU_INFO_FW_VCE 0x11120/* Subquery id: Query UVD firmware version */1121#define AMDGPU_INFO_FW_UVD 0x21122/* Subquery id: Query GMC firmware version */1123#define AMDGPU_INFO_FW_GMC 0x031124/* Subquery id: Query GFX ME firmware version */1125#define AMDGPU_INFO_FW_GFX_ME 0x041126/* Subquery id: Query GFX PFP firmware version */1127#define AMDGPU_INFO_FW_GFX_PFP 0x051128/* Subquery id: Query GFX CE firmware version */1129#define AMDGPU_INFO_FW_GFX_CE 0x061130/* Subquery id: Query GFX RLC firmware version */1131#define AMDGPU_INFO_FW_GFX_RLC 0x071132/* Subquery id: Query GFX MEC firmware version */1133#define AMDGPU_INFO_FW_GFX_MEC 0x081134/* Subquery id: Query SMC firmware version */1135#define AMDGPU_INFO_FW_SMC 0x0a1136/* Subquery id: Query SDMA firmware version */1137#define AMDGPU_INFO_FW_SDMA 0x0b1138/* Subquery id: Query PSP SOS firmware version */1139#define AMDGPU_INFO_FW_SOS 0x0c1140/* Subquery id: Query PSP ASD firmware version */1141#define AMDGPU_INFO_FW_ASD 0x0d1142/* Subquery id: Query VCN firmware version */1143#define AMDGPU_INFO_FW_VCN 0x0e1144/* Subquery id: Query GFX RLC SRLC firmware version */1145#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f1146/* Subquery id: Query GFX RLC SRLG firmware version */1147#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x101148/* Subquery id: Query GFX RLC SRLS firmware version */1149#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x111150/* Subquery id: Query DMCU firmware version */1151#define AMDGPU_INFO_FW_DMCU 0x121152#define AMDGPU_INFO_FW_TA 0x131153/* Subquery id: Query DMCUB firmware version */1154#define AMDGPU_INFO_FW_DMCUB 0x141155/* Subquery id: Query TOC firmware version */1156#define AMDGPU_INFO_FW_TOC 0x151157/* Subquery id: Query CAP firmware version */1158#define AMDGPU_INFO_FW_CAP 0x161159/* Subquery id: Query GFX RLCP firmware version */1160#define AMDGPU_INFO_FW_GFX_RLCP 0x171161/* Subquery id: Query GFX RLCV firmware version */1162#define AMDGPU_INFO_FW_GFX_RLCV 0x181163/* Subquery id: Query MES_KIQ firmware version */1164#define AMDGPU_INFO_FW_MES_KIQ 0x191165/* Subquery id: Query MES firmware version */1166#define AMDGPU_INFO_FW_MES 0x1a1167/* Subquery id: Query IMU firmware version */1168#define AMDGPU_INFO_FW_IMU 0x1b1169/* Subquery id: Query VPE firmware version */1170#define AMDGPU_INFO_FW_VPE 0x1c11711172/* number of bytes moved for TTM migration */1173#define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f1174/* the used VRAM size */1175#define AMDGPU_INFO_VRAM_USAGE 0x101176/* the used GTT size */1177#define AMDGPU_INFO_GTT_USAGE 0x111178/* Information about GDS, etc. resource configuration */1179#define AMDGPU_INFO_GDS_CONFIG 0x131180/* Query information about VRAM and GTT domains */1181#define AMDGPU_INFO_VRAM_GTT 0x141182/* Query information about register in MMR address space*/1183#define AMDGPU_INFO_READ_MMR_REG 0x151184/* Query information about device: rev id, family, etc. */1185#define AMDGPU_INFO_DEV_INFO 0x161186/* visible vram usage */1187#define AMDGPU_INFO_VIS_VRAM_USAGE 0x171188/* number of TTM buffer evictions */1189#define AMDGPU_INFO_NUM_EVICTIONS 0x181190/* Query memory about VRAM and GTT domains */1191#define AMDGPU_INFO_MEMORY 0x191192/* Query vce clock table */1193#define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A1194/* Query vbios related information */1195#define AMDGPU_INFO_VBIOS 0x1B1196/* Subquery id: Query vbios size */1197#define AMDGPU_INFO_VBIOS_SIZE 0x11198/* Subquery id: Query vbios image */1199#define AMDGPU_INFO_VBIOS_IMAGE 0x21200/* Subquery id: Query vbios info */1201#define AMDGPU_INFO_VBIOS_INFO 0x31202/* Query UVD handles */1203#define AMDGPU_INFO_NUM_HANDLES 0x1C1204/* Query sensor related information */1205#define AMDGPU_INFO_SENSOR 0x1D1206/* Subquery id: Query GPU shader clock */1207#define AMDGPU_INFO_SENSOR_GFX_SCLK 0x11208/* Subquery id: Query GPU memory clock */1209#define AMDGPU_INFO_SENSOR_GFX_MCLK 0x21210/* Subquery id: Query GPU temperature */1211#define AMDGPU_INFO_SENSOR_GPU_TEMP 0x31212/* Subquery id: Query GPU load */1213#define AMDGPU_INFO_SENSOR_GPU_LOAD 0x41214/* Subquery id: Query average GPU power */1215#define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x51216/* Subquery id: Query northbridge voltage */1217#define AMDGPU_INFO_SENSOR_VDDNB 0x61218/* Subquery id: Query graphics voltage */1219#define AMDGPU_INFO_SENSOR_VDDGFX 0x71220/* Subquery id: Query GPU stable pstate shader clock */1221#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK 0x81222/* Subquery id: Query GPU stable pstate memory clock */1223#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK 0x91224/* Subquery id: Query GPU peak pstate shader clock */1225#define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_SCLK 0xa1226/* Subquery id: Query GPU peak pstate memory clock */1227#define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_MCLK 0xb1228/* Subquery id: Query input GPU power */1229#define AMDGPU_INFO_SENSOR_GPU_INPUT_POWER 0xc1230/* Number of VRAM page faults on CPU access. */1231#define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E1232#define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F1233/* query ras mask of enabled features*/1234#define AMDGPU_INFO_RAS_ENABLED_FEATURES 0x201235/* RAS MASK: UMC (VRAM) */1236#define AMDGPU_INFO_RAS_ENABLED_UMC (1 << 0)1237/* RAS MASK: SDMA */1238#define AMDGPU_INFO_RAS_ENABLED_SDMA (1 << 1)1239/* RAS MASK: GFX */1240#define AMDGPU_INFO_RAS_ENABLED_GFX (1 << 2)1241/* RAS MASK: MMHUB */1242#define AMDGPU_INFO_RAS_ENABLED_MMHUB (1 << 3)1243/* RAS MASK: ATHUB */1244#define AMDGPU_INFO_RAS_ENABLED_ATHUB (1 << 4)1245/* RAS MASK: PCIE */1246#define AMDGPU_INFO_RAS_ENABLED_PCIE (1 << 5)1247/* RAS MASK: HDP */1248#define AMDGPU_INFO_RAS_ENABLED_HDP (1 << 6)1249/* RAS MASK: XGMI */1250#define AMDGPU_INFO_RAS_ENABLED_XGMI (1 << 7)1251/* RAS MASK: DF */1252#define AMDGPU_INFO_RAS_ENABLED_DF (1 << 8)1253/* RAS MASK: SMN */1254#define AMDGPU_INFO_RAS_ENABLED_SMN (1 << 9)1255/* RAS MASK: SEM */1256#define AMDGPU_INFO_RAS_ENABLED_SEM (1 << 10)1257/* RAS MASK: MP0 */1258#define AMDGPU_INFO_RAS_ENABLED_MP0 (1 << 11)1259/* RAS MASK: MP1 */1260#define AMDGPU_INFO_RAS_ENABLED_MP1 (1 << 12)1261/* RAS MASK: FUSE */1262#define AMDGPU_INFO_RAS_ENABLED_FUSE (1 << 13)1263/* query video encode/decode caps */1264#define AMDGPU_INFO_VIDEO_CAPS 0x211265/* Subquery id: Decode */1266#define AMDGPU_INFO_VIDEO_CAPS_DECODE 01267/* Subquery id: Encode */1268#define AMDGPU_INFO_VIDEO_CAPS_ENCODE 11269/* Query the max number of IBs per gang per submission */1270#define AMDGPU_INFO_MAX_IBS 0x221271/* query last page fault info */1272#define AMDGPU_INFO_GPUVM_FAULT 0x231273/* query FW object size and alignment */1274#define AMDGPU_INFO_UQ_FW_AREAS 0x2412751276#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 01277#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff1278#define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 81279#define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff12801281struct drm_amdgpu_query_fw {1282/** AMDGPU_INFO_FW_* */1283__u32 fw_type;1284/**1285* Index of the IP if there are more IPs of1286* the same type.1287*/1288__u32 ip_instance;1289/**1290* Index of the engine. Whether this is used depends1291* on the firmware type. (e.g. MEC, SDMA)1292*/1293__u32 index;1294__u32 _pad;1295};12961297/* Input structure for the INFO ioctl */1298struct drm_amdgpu_info {1299/* Where the return value will be stored */1300__u64 return_pointer;1301/* The size of the return value. Just like "size" in "snprintf",1302* it limits how many bytes the kernel can write. */1303__u32 return_size;1304/* The query request id. */1305__u32 query;13061307union {1308struct {1309__u32 id;1310__u32 _pad;1311} mode_crtc;13121313struct {1314/** AMDGPU_HW_IP_* */1315__u32 type;1316/**1317* Index of the IP if there are more IPs of the same1318* type. Ignored by AMDGPU_INFO_HW_IP_COUNT.1319*/1320__u32 ip_instance;1321} query_hw_ip;13221323struct {1324__u32 dword_offset;1325/** number of registers to read */1326__u32 count;1327__u32 instance;1328/** For future use, no flags defined so far */1329__u32 flags;1330} read_mmr_reg;13311332struct drm_amdgpu_query_fw query_fw;13331334struct {1335__u32 type;1336__u32 offset;1337} vbios_info;13381339struct {1340__u32 type;1341} sensor_info;13421343struct {1344__u32 type;1345} video_cap;1346};1347};13481349struct drm_amdgpu_info_gds {1350/** GDS GFX partition size */1351__u32 gds_gfx_partition_size;1352/** GDS compute partition size */1353__u32 compute_partition_size;1354/** total GDS memory size */1355__u32 gds_total_size;1356/** GWS size per GFX partition */1357__u32 gws_per_gfx_partition;1358/** GSW size per compute partition */1359__u32 gws_per_compute_partition;1360/** OA size per GFX partition */1361__u32 oa_per_gfx_partition;1362/** OA size per compute partition */1363__u32 oa_per_compute_partition;1364__u32 _pad;1365};13661367struct drm_amdgpu_info_vram_gtt {1368__u64 vram_size;1369__u64 vram_cpu_accessible_size;1370__u64 gtt_size;1371};13721373struct drm_amdgpu_heap_info {1374/** max. physical memory */1375__u64 total_heap_size;13761377/** Theoretical max. available memory in the given heap */1378__u64 usable_heap_size;13791380/**1381* Number of bytes allocated in the heap. This includes all processes1382* and private allocations in the kernel. It changes when new buffers1383* are allocated, freed, and moved. It cannot be larger than1384* heap_size.1385*/1386__u64 heap_usage;13871388/**1389* Theoretical possible max. size of buffer which1390* could be allocated in the given heap1391*/1392__u64 max_allocation;1393};13941395struct drm_amdgpu_memory_info {1396struct drm_amdgpu_heap_info vram;1397struct drm_amdgpu_heap_info cpu_accessible_vram;1398struct drm_amdgpu_heap_info gtt;1399};14001401struct drm_amdgpu_info_firmware {1402__u32 ver;1403__u32 feature;1404};14051406struct drm_amdgpu_info_vbios {1407__u8 name[64];1408__u8 vbios_pn[64];1409__u32 version;1410__u32 pad;1411__u8 vbios_ver_str[32];1412__u8 date[32];1413};14141415#define AMDGPU_VRAM_TYPE_UNKNOWN 01416#define AMDGPU_VRAM_TYPE_GDDR1 11417#define AMDGPU_VRAM_TYPE_DDR2 21418#define AMDGPU_VRAM_TYPE_GDDR3 31419#define AMDGPU_VRAM_TYPE_GDDR4 41420#define AMDGPU_VRAM_TYPE_GDDR5 51421#define AMDGPU_VRAM_TYPE_HBM 61422#define AMDGPU_VRAM_TYPE_DDR3 71423#define AMDGPU_VRAM_TYPE_DDR4 81424#define AMDGPU_VRAM_TYPE_GDDR6 91425#define AMDGPU_VRAM_TYPE_DDR5 101426#define AMDGPU_VRAM_TYPE_LPDDR4 111427#define AMDGPU_VRAM_TYPE_LPDDR5 121428#define AMDGPU_VRAM_TYPE_HBM3E 1314291430struct drm_amdgpu_info_device {1431/** PCI Device ID */1432__u32 device_id;1433/** Internal chip revision: A0, A1, etc.) */1434__u32 chip_rev;1435__u32 external_rev;1436/** Revision id in PCI Config space */1437__u32 pci_rev;1438__u32 family;1439__u32 num_shader_engines;1440__u32 num_shader_arrays_per_engine;1441/* in KHz */1442__u32 gpu_counter_freq;1443__u64 max_engine_clock;1444__u64 max_memory_clock;1445/* cu information */1446__u32 cu_active_number;1447/* NOTE: cu_ao_mask is INVALID, DON'T use it */1448__u32 cu_ao_mask;1449__u32 cu_bitmap[4][4];1450/** Render backend pipe mask. One render backend is CB+DB. */1451__u32 enabled_rb_pipes_mask;1452__u32 num_rb_pipes;1453__u32 num_hw_gfx_contexts;1454/* PCIe version (the smaller of the GPU and the CPU/motherboard) */1455__u32 pcie_gen;1456__u64 ids_flags;1457/** Starting virtual address for UMDs. */1458__u64 virtual_address_offset;1459/** The maximum virtual address */1460__u64 virtual_address_max;1461/** Required alignment of virtual addresses. */1462__u32 virtual_address_alignment;1463/** Page table entry - fragment size */1464__u32 pte_fragment_size;1465__u32 gart_page_size;1466/** constant engine ram size*/1467__u32 ce_ram_size;1468/** video memory type info*/1469__u32 vram_type;1470/** video memory bit width*/1471__u32 vram_bit_width;1472/* vce harvesting instance */1473__u32 vce_harvest_config;1474/* gfx double offchip LDS buffers */1475__u32 gc_double_offchip_lds_buf;1476/* NGG Primitive Buffer */1477__u64 prim_buf_gpu_addr;1478/* NGG Position Buffer */1479__u64 pos_buf_gpu_addr;1480/* NGG Control Sideband */1481__u64 cntl_sb_buf_gpu_addr;1482/* NGG Parameter Cache */1483__u64 param_buf_gpu_addr;1484__u32 prim_buf_size;1485__u32 pos_buf_size;1486__u32 cntl_sb_buf_size;1487__u32 param_buf_size;1488/* wavefront size*/1489__u32 wave_front_size;1490/* shader visible vgprs*/1491__u32 num_shader_visible_vgprs;1492/* CU per shader array*/1493__u32 num_cu_per_sh;1494/* number of tcc blocks*/1495__u32 num_tcc_blocks;1496/* gs vgt table depth*/1497__u32 gs_vgt_table_depth;1498/* gs primitive buffer depth*/1499__u32 gs_prim_buffer_depth;1500/* max gs wavefront per vgt*/1501__u32 max_gs_waves_per_vgt;1502/* PCIe number of lanes (the smaller of the GPU and the CPU/motherboard) */1503__u32 pcie_num_lanes;1504/* always on cu bitmap */1505__u32 cu_ao_bitmap[4][4];1506/** Starting high virtual address for UMDs. */1507__u64 high_va_offset;1508/** The maximum high virtual address */1509__u64 high_va_max;1510/* gfx10 pa_sc_tile_steering_override */1511__u32 pa_sc_tile_steering_override;1512/* disabled TCCs */1513__u64 tcc_disabled_mask;1514__u64 min_engine_clock;1515__u64 min_memory_clock;1516/* The following fields are only set on gfx11+, older chips set 0. */1517__u32 tcp_cache_size; /* AKA GL0, VMEM cache */1518__u32 num_sqc_per_wgp;1519__u32 sqc_data_cache_size; /* AKA SMEM cache */1520__u32 sqc_inst_cache_size;1521__u32 gl1c_cache_size;1522__u32 gl2c_cache_size;1523__u64 mall_size; /* AKA infinity cache */1524/* high 32 bits of the rb pipes mask */1525__u32 enabled_rb_pipes_mask_hi;1526/* shadow area size for gfx11 */1527__u32 shadow_size;1528/* shadow area base virtual alignment for gfx11 */1529__u32 shadow_alignment;1530/* context save area size for gfx11 */1531__u32 csa_size;1532/* context save area base virtual alignment for gfx11 */1533__u32 csa_alignment;1534/* Userq IP mask (1 << AMDGPU_HW_IP_*) */1535__u32 userq_ip_mask;1536__u32 pad;1537};15381539struct drm_amdgpu_info_hw_ip {1540/** Version of h/w IP */1541__u32 hw_ip_version_major;1542__u32 hw_ip_version_minor;1543/** Capabilities */1544__u64 capabilities_flags;1545/** command buffer address start alignment*/1546__u32 ib_start_alignment;1547/** command buffer size alignment*/1548__u32 ib_size_alignment;1549/** Bitmask of available rings. Bit 0 means ring 0, etc. */1550__u32 available_rings;1551/** version info: bits 23:16 major, 15:8 minor, 7:0 revision */1552__u32 ip_discovery_version;1553/* Userq available slots */1554__u32 userq_num_slots;1555};15561557/* GFX metadata BO sizes and alignment info (in bytes) */1558struct drm_amdgpu_info_uq_fw_areas_gfx {1559/* shadow area size */1560__u32 shadow_size;1561/* shadow area base virtual mem alignment */1562__u32 shadow_alignment;1563/* context save area size */1564__u32 csa_size;1565/* context save area base virtual mem alignment */1566__u32 csa_alignment;1567};15681569/* IP specific fw related information used in the1570* subquery AMDGPU_INFO_UQ_FW_AREAS1571*/1572struct drm_amdgpu_info_uq_fw_areas {1573union {1574struct drm_amdgpu_info_uq_fw_areas_gfx gfx;1575};1576};15771578struct drm_amdgpu_info_num_handles {1579/** Max handles as supported by firmware for UVD */1580__u32 uvd_max_handles;1581/** Handles currently in use for UVD */1582__u32 uvd_used_handles;1583};15841585#define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 615861587struct drm_amdgpu_info_vce_clock_table_entry {1588/** System clock */1589__u32 sclk;1590/** Memory clock */1591__u32 mclk;1592/** VCE clock */1593__u32 eclk;1594__u32 pad;1595};15961597struct drm_amdgpu_info_vce_clock_table {1598struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];1599__u32 num_valid_entries;1600__u32 pad;1601};16021603/* query video encode/decode caps */1604#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 01605#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 11606#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 21607#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC 31608#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC 41609#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG 51610#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9 61611#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1 71612#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT 816131614struct drm_amdgpu_info_video_codec_info {1615__u32 valid;1616__u32 max_width;1617__u32 max_height;1618__u32 max_pixels_per_frame;1619__u32 max_level;1620__u32 pad;1621};16221623struct drm_amdgpu_info_video_caps {1624struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT];1625};16261627#define AMDGPU_VMHUB_TYPE_MASK 0xff1628#define AMDGPU_VMHUB_TYPE_SHIFT 01629#define AMDGPU_VMHUB_TYPE_GFX 01630#define AMDGPU_VMHUB_TYPE_MM0 11631#define AMDGPU_VMHUB_TYPE_MM1 21632#define AMDGPU_VMHUB_IDX_MASK 0xff001633#define AMDGPU_VMHUB_IDX_SHIFT 816341635struct drm_amdgpu_info_gpuvm_fault {1636__u64 addr;1637__u32 status;1638__u32 vmhub;1639};16401641struct drm_amdgpu_info_uq_metadata_gfx {1642/* shadow area size for gfx11 */1643__u32 shadow_size;1644/* shadow area base virtual alignment for gfx11 */1645__u32 shadow_alignment;1646/* context save area size for gfx11 */1647__u32 csa_size;1648/* context save area base virtual alignment for gfx11 */1649__u32 csa_alignment;1650};16511652struct drm_amdgpu_info_uq_metadata {1653union {1654struct drm_amdgpu_info_uq_metadata_gfx gfx;1655};1656};16571658/*1659* Supported GPU families1660*/1661#define AMDGPU_FAMILY_UNKNOWN 01662#define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */1663#define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */1664#define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */1665#define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */1666#define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */1667#define AMDGPU_FAMILY_AI 141 /* Vega10 */1668#define AMDGPU_FAMILY_RV 142 /* Raven */1669#define AMDGPU_FAMILY_NV 143 /* Navi10 */1670#define AMDGPU_FAMILY_VGH 144 /* Van Gogh */1671#define AMDGPU_FAMILY_GC_11_0_0 145 /* GC 11.0.0 */1672#define AMDGPU_FAMILY_YC 146 /* Yellow Carp */1673#define AMDGPU_FAMILY_GC_11_0_1 148 /* GC 11.0.1 */1674#define AMDGPU_FAMILY_GC_10_3_6 149 /* GC 10.3.6 */1675#define AMDGPU_FAMILY_GC_10_3_7 151 /* GC 10.3.7 */1676#define AMDGPU_FAMILY_GC_11_5_0 150 /* GC 11.5.0 */1677#define AMDGPU_FAMILY_GC_12_0_0 152 /* GC 12.0.0 */16781679/* FIXME wrong namespace! */1680struct drm_color_ctm_3x4 {1681/*1682* Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude1683* (not two's complement!) format.1684*/1685__u64 matrix[12];1686};16871688#if defined(__cplusplus)1689}1690#endif16911692#endif169316941695