/* 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 0x185960#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)61#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)62#define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)63#define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)64#define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)65#define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)66#define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)67#define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)68#define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)69#define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)70#define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)71#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)72#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)73#define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)74#define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)75#define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)76#define DRM_IOCTL_AMDGPU_USERQ DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ, union drm_amdgpu_userq)77#define DRM_IOCTL_AMDGPU_USERQ_SIGNAL DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_SIGNAL, struct drm_amdgpu_userq_signal)78#define DRM_IOCTL_AMDGPU_USERQ_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_WAIT, struct drm_amdgpu_userq_wait)7980/**81* DOC: memory domains82*83* %AMDGPU_GEM_DOMAIN_CPU System memory that is not GPU accessible.84* Memory in this pool could be swapped out to disk if there is pressure.85*86* %AMDGPU_GEM_DOMAIN_GTT GPU accessible system memory, mapped into the87* GPU's virtual address space via gart. Gart memory linearizes non-contiguous88* pages of system memory, allows GPU access system memory in a linearized89* fashion.90*91* %AMDGPU_GEM_DOMAIN_VRAM Local video memory. For APUs, it is memory92* carved out by the BIOS.93*94* %AMDGPU_GEM_DOMAIN_GDS Global on-chip data storage used to share data95* across shader threads.96*97* %AMDGPU_GEM_DOMAIN_GWS Global wave sync, used to synchronize the98* execution of all the waves on a device.99*100* %AMDGPU_GEM_DOMAIN_OA Ordered append, used by 3D or Compute engines101* for appending data.102*103* %AMDGPU_GEM_DOMAIN_DOORBELL Doorbell. It is an MMIO region for104* signalling user mode queues.105*/106#define AMDGPU_GEM_DOMAIN_CPU 0x1107#define AMDGPU_GEM_DOMAIN_GTT 0x2108#define AMDGPU_GEM_DOMAIN_VRAM 0x4109#define AMDGPU_GEM_DOMAIN_GDS 0x8110#define AMDGPU_GEM_DOMAIN_GWS 0x10111#define AMDGPU_GEM_DOMAIN_OA 0x20112#define AMDGPU_GEM_DOMAIN_DOORBELL 0x40113#define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \114AMDGPU_GEM_DOMAIN_GTT | \115AMDGPU_GEM_DOMAIN_VRAM | \116AMDGPU_GEM_DOMAIN_GDS | \117AMDGPU_GEM_DOMAIN_GWS | \118AMDGPU_GEM_DOMAIN_OA | \119AMDGPU_GEM_DOMAIN_DOORBELL)120121/* Flag that CPU access will be required for the case of VRAM domain */122#define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)123/* Flag that CPU access will not work, this VRAM domain is invisible */124#define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)125/* Flag that USWC attributes should be used for GTT */126#define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)127/* Flag that the memory should be in VRAM and cleared */128#define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3)129/* Flag that allocating the BO should use linear VRAM */130#define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5)131/* Flag that BO is always valid in this VM */132#define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6)133/* Flag that BO sharing will be explicitly synchronized */134#define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7)135/* Flag that indicates allocating MQD gart on GFX9, where the mtype136* for the second page onward should be set to NC. It should never137* be used by user space applications.138*/139#define AMDGPU_GEM_CREATE_CP_MQD_GFX9 (1 << 8)140/* Flag that BO may contain sensitive data that must be wiped before141* releasing the memory142*/143#define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE (1 << 9)144/* Flag that BO will be encrypted and that the TMZ bit should be145* set in the PTEs when mapping this buffer via GPUVM or146* accessing it with various hw blocks147*/148#define AMDGPU_GEM_CREATE_ENCRYPTED (1 << 10)149/* Flag that BO will be used only in preemptible context, which does150* not require GTT memory accounting151*/152#define AMDGPU_GEM_CREATE_PREEMPTIBLE (1 << 11)153/* Flag that BO can be discarded under memory pressure without keeping the154* content.155*/156#define AMDGPU_GEM_CREATE_DISCARDABLE (1 << 12)157/* Flag that BO is shared coherently between multiple devices or CPU threads.158* May depend on GPU instructions to flush caches to system scope explicitly.159*160* This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and161* may override the MTYPE selected in AMDGPU_VA_OP_MAP.162*/163#define AMDGPU_GEM_CREATE_COHERENT (1 << 13)164/* Flag that BO should not be cached by GPU. Coherent without having to flush165* GPU caches explicitly166*167* This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and168* may override the MTYPE selected in AMDGPU_VA_OP_MAP.169*/170#define AMDGPU_GEM_CREATE_UNCACHED (1 << 14)171/* Flag that BO should be coherent across devices when using device-level172* atomics. May depend on GPU instructions to flush caches to device scope173* explicitly, promoting them to system scope automatically.174*175* This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and176* may override the MTYPE selected in AMDGPU_VA_OP_MAP.177*/178#define AMDGPU_GEM_CREATE_EXT_COHERENT (1 << 15)179/* Set PTE.D and recompress during GTT->VRAM moves according to TILING flags. */180#define AMDGPU_GEM_CREATE_GFX12_DCC (1 << 16)181182struct drm_amdgpu_gem_create_in {183/** the requested memory size */184__u64 bo_size;185/** physical start_addr alignment in bytes for some HW requirements */186__u64 alignment;187/** the requested memory domains */188__u64 domains;189/** allocation flags */190__u64 domain_flags;191};192193struct drm_amdgpu_gem_create_out {194/** returned GEM object handle */195__u32 handle;196__u32 _pad;197};198199union drm_amdgpu_gem_create {200struct drm_amdgpu_gem_create_in in;201struct drm_amdgpu_gem_create_out out;202};203204/** Opcode to create new residency list. */205#define AMDGPU_BO_LIST_OP_CREATE 0206/** Opcode to destroy previously created residency list */207#define AMDGPU_BO_LIST_OP_DESTROY 1208/** Opcode to update resource information in the list */209#define AMDGPU_BO_LIST_OP_UPDATE 2210211struct drm_amdgpu_bo_list_in {212/** Type of operation */213__u32 operation;214/** Handle of list or 0 if we want to create one */215__u32 list_handle;216/** Number of BOs in list */217__u32 bo_number;218/** Size of each element describing BO */219__u32 bo_info_size;220/** Pointer to array describing BOs */221__u64 bo_info_ptr;222};223224struct drm_amdgpu_bo_list_entry {225/** Handle of BO */226__u32 bo_handle;227/** New (if specified) BO priority to be used during migration */228__u32 bo_priority;229};230231struct drm_amdgpu_bo_list_out {232/** Handle of resource list */233__u32 list_handle;234__u32 _pad;235};236237union drm_amdgpu_bo_list {238struct drm_amdgpu_bo_list_in in;239struct drm_amdgpu_bo_list_out out;240};241242/* context related */243#define AMDGPU_CTX_OP_ALLOC_CTX 1244#define AMDGPU_CTX_OP_FREE_CTX 2245#define AMDGPU_CTX_OP_QUERY_STATE 3246#define AMDGPU_CTX_OP_QUERY_STATE2 4247#define AMDGPU_CTX_OP_GET_STABLE_PSTATE 5248#define AMDGPU_CTX_OP_SET_STABLE_PSTATE 6249250/* GPU reset status */251#define AMDGPU_CTX_NO_RESET 0252/* this the context caused it */253#define AMDGPU_CTX_GUILTY_RESET 1254/* some other context caused it */255#define AMDGPU_CTX_INNOCENT_RESET 2256/* unknown cause */257#define AMDGPU_CTX_UNKNOWN_RESET 3258259/* indicate gpu reset occurred after ctx created */260#define AMDGPU_CTX_QUERY2_FLAGS_RESET (1<<0)261/* indicate vram lost occurred after ctx created */262#define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)263/* indicate some job from this context once cause gpu hang */264#define AMDGPU_CTX_QUERY2_FLAGS_GUILTY (1<<2)265/* indicate some errors are detected by RAS */266#define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE (1<<3)267#define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE (1<<4)268/* indicate that the reset hasn't completed yet */269#define AMDGPU_CTX_QUERY2_FLAGS_RESET_IN_PROGRESS (1<<5)270271/* Context priority level */272#define AMDGPU_CTX_PRIORITY_UNSET -2048273#define AMDGPU_CTX_PRIORITY_VERY_LOW -1023274#define AMDGPU_CTX_PRIORITY_LOW -512275#define AMDGPU_CTX_PRIORITY_NORMAL 0276/*277* When used in struct drm_amdgpu_ctx_in, a priority above NORMAL requires278* CAP_SYS_NICE or DRM_MASTER279*/280#define AMDGPU_CTX_PRIORITY_HIGH 512281#define AMDGPU_CTX_PRIORITY_VERY_HIGH 1023282283/* select a stable profiling pstate for perfmon tools */284#define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK 0xf285#define AMDGPU_CTX_STABLE_PSTATE_NONE 0286#define AMDGPU_CTX_STABLE_PSTATE_STANDARD 1287#define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK 2288#define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK 3289#define AMDGPU_CTX_STABLE_PSTATE_PEAK 4290291struct drm_amdgpu_ctx_in {292/** AMDGPU_CTX_OP_* */293__u32 op;294/** Flags */295__u32 flags;296__u32 ctx_id;297/** AMDGPU_CTX_PRIORITY_* */298__s32 priority;299};300301union drm_amdgpu_ctx_out {302struct {303__u32 ctx_id;304__u32 _pad;305} alloc;306307struct {308/** For future use, no flags defined so far */309__u64 flags;310/** Number of resets caused by this context so far. */311__u32 hangs;312/** Reset status since the last call of the ioctl. */313__u32 reset_status;314} state;315316struct {317__u32 flags;318__u32 _pad;319} pstate;320};321322union drm_amdgpu_ctx {323struct drm_amdgpu_ctx_in in;324union drm_amdgpu_ctx_out out;325};326327/* user queue IOCTL operations */328#define AMDGPU_USERQ_OP_CREATE 1329#define AMDGPU_USERQ_OP_FREE 2330331/* queue priority levels */332/* low < normal low < normal high < high */333#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_MASK 0x3334#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_SHIFT 0335#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_NORMAL_LOW 0336#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_LOW 1337#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_NORMAL_HIGH 2338#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH 3 /* admin only */339/* for queues that need access to protected content */340#define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE (1 << 2)341342/*343* This structure is a container to pass input configuration344* info for all supported userqueue related operations.345* For operation AMDGPU_USERQ_OP_CREATE: user is expected346* to set all fields, excep the parameter 'queue_id'.347* For operation AMDGPU_USERQ_OP_FREE: the only input parameter expected348* to be set is 'queue_id', eveything else is ignored.349*/350struct drm_amdgpu_userq_in {351/** AMDGPU_USERQ_OP_* */352__u32 op;353/** Queue id passed for operation USERQ_OP_FREE */354__u32 queue_id;355/** the target GPU engine to execute workload (AMDGPU_HW_IP_*) */356__u32 ip_type;357/**358* @doorbell_handle: the handle of doorbell GEM object359* associated with this userqueue client.360*/361__u32 doorbell_handle;362/**363* @doorbell_offset: 32-bit offset of the doorbell in the doorbell bo.364* Kernel will generate absolute doorbell offset using doorbell_handle365* and doorbell_offset in the doorbell bo.366*/367__u32 doorbell_offset;368/**369* @flags: flags used for queue parameters370*/371__u32 flags;372/**373* @queue_va: Virtual address of the GPU memory which holds the queue374* object. The queue holds the workload packets.375*/376__u64 queue_va;377/**378* @queue_size: Size of the queue in bytes, this needs to be 256-byte379* aligned.380*/381__u64 queue_size;382/**383* @rptr_va : Virtual address of the GPU memory which holds the ring RPTR.384* This object must be at least 8 byte in size and aligned to 8-byte offset.385*/386__u64 rptr_va;387/**388* @wptr_va : Virtual address of the GPU memory which holds the ring WPTR.389* This object must be at least 8 byte in size and aligned to 8-byte offset.390*391* Queue, RPTR and WPTR can come from the same object, as long as the size392* and alignment related requirements are met.393*/394__u64 wptr_va;395/**396* @mqd: MQD (memory queue descriptor) is a set of parameters which allow397* the GPU to uniquely define and identify a usermode queue.398*399* MQD data can be of different size for different GPU IP/engine and400* their respective versions/revisions, so this points to a __u64 *401* which holds IP specific MQD of this usermode queue.402*/403__u64 mqd;404/**405* @size: size of MQD data in bytes, it must match the MQD structure406* size of the respective engine/revision defined in UAPI for ex, for407* gfx11 workloads, size = sizeof(drm_amdgpu_userq_mqd_gfx11).408*/409__u64 mqd_size;410};411412/* The structure to carry output of userqueue ops */413struct drm_amdgpu_userq_out {414/**415* For operation AMDGPU_USERQ_OP_CREATE: This field contains a unique416* queue ID to represent the newly created userqueue in the system, otherwise417* it should be ignored.418*/419__u32 queue_id;420__u32 _pad;421};422423union drm_amdgpu_userq {424struct drm_amdgpu_userq_in in;425struct drm_amdgpu_userq_out out;426};427428/* GFX V11 IP specific MQD parameters */429struct drm_amdgpu_userq_mqd_gfx11 {430/**431* @shadow_va: Virtual address of the GPU memory to hold the shadow buffer.432* Use AMDGPU_INFO_IOCTL to find the exact size of the object.433*/434__u64 shadow_va;435/**436* @csa_va: Virtual address of the GPU memory to hold the CSA buffer.437* Use AMDGPU_INFO_IOCTL to find the exact size of the object.438*/439__u64 csa_va;440};441442/* GFX V11 SDMA IP specific MQD parameters */443struct drm_amdgpu_userq_mqd_sdma_gfx11 {444/**445* @csa_va: Virtual address of the GPU memory to hold the CSA buffer.446* This must be a from a separate GPU object, and use AMDGPU_INFO IOCTL447* to get the size.448*/449__u64 csa_va;450};451452/* GFX V11 Compute IP specific MQD parameters */453struct drm_amdgpu_userq_mqd_compute_gfx11 {454/**455* @eop_va: Virtual address of the GPU memory to hold the EOP buffer.456* This must be a from a separate GPU object, and use AMDGPU_INFO IOCTL457* to get the size.458*/459__u64 eop_va;460};461462/* userq signal/wait ioctl */463struct drm_amdgpu_userq_signal {464/**465* @queue_id: Queue handle used by the userq fence creation function466* to retrieve the WPTR.467*/468__u32 queue_id;469__u32 pad;470/**471* @syncobj_handles: The list of syncobj handles submitted by the user queue472* job to be signaled.473*/474__u64 syncobj_handles;475/**476* @num_syncobj_handles: A count that represents the number of syncobj handles in477* @syncobj_handles.478*/479__u64 num_syncobj_handles;480/**481* @bo_read_handles: The list of BO handles that the submitted user queue job482* is using for read only. This will update BO fences in the kernel.483*/484__u64 bo_read_handles;485/**486* @bo_write_handles: The list of BO handles that the submitted user queue job487* is using for write only. This will update BO fences in the kernel.488*/489__u64 bo_write_handles;490/**491* @num_bo_read_handles: A count that represents the number of read BO handles in492* @bo_read_handles.493*/494__u32 num_bo_read_handles;495/**496* @num_bo_write_handles: A count that represents the number of write BO handles in497* @bo_write_handles.498*/499__u32 num_bo_write_handles;500};501502struct drm_amdgpu_userq_fence_info {503/**504* @va: A gpu address allocated for each queue which stores the505* read pointer (RPTR) value.506*/507__u64 va;508/**509* @value: A 64 bit value represents the write pointer (WPTR) of the510* queue commands which compared with the RPTR value to signal the511* fences.512*/513__u64 value;514};515516struct drm_amdgpu_userq_wait {517/**518* @waitq_id: Queue handle used by the userq wait IOCTL to retrieve the519* wait queue and maintain the fence driver references in it.520*/521__u32 waitq_id;522__u32 pad;523/**524* @syncobj_handles: The list of syncobj handles submitted by the user queue525* job to get the va/value pairs.526*/527__u64 syncobj_handles;528/**529* @syncobj_timeline_handles: The list of timeline syncobj handles submitted by530* the user queue job to get the va/value pairs at given @syncobj_timeline_points.531*/532__u64 syncobj_timeline_handles;533/**534* @syncobj_timeline_points: The list of timeline syncobj points submitted by the535* user queue job for the corresponding @syncobj_timeline_handles.536*/537__u64 syncobj_timeline_points;538/**539* @bo_read_handles: The list of read BO handles submitted by the user queue540* job to get the va/value pairs.541*/542__u64 bo_read_handles;543/**544* @bo_write_handles: The list of write BO handles submitted by the user queue545* job to get the va/value pairs.546*/547__u64 bo_write_handles;548/**549* @num_syncobj_timeline_handles: A count that represents the number of timeline550* syncobj handles in @syncobj_timeline_handles.551*/552__u16 num_syncobj_timeline_handles;553/**554* @num_fences: This field can be used both as input and output. As input it defines555* the maximum number of fences that can be returned and as output it will specify556* how many fences were actually returned from the ioctl.557*/558__u16 num_fences;559/**560* @num_syncobj_handles: A count that represents the number of syncobj handles in561* @syncobj_handles.562*/563__u32 num_syncobj_handles;564/**565* @num_bo_read_handles: A count that represents the number of read BO handles in566* @bo_read_handles.567*/568__u32 num_bo_read_handles;569/**570* @num_bo_write_handles: A count that represents the number of write BO handles in571* @bo_write_handles.572*/573__u32 num_bo_write_handles;574/**575* @out_fences: The field is a return value from the ioctl containing the list of576* address/value pairs to wait for.577*/578__u64 out_fences;579};580581/* vm ioctl */582#define AMDGPU_VM_OP_RESERVE_VMID 1583#define AMDGPU_VM_OP_UNRESERVE_VMID 2584585struct drm_amdgpu_vm_in {586/** AMDGPU_VM_OP_* */587__u32 op;588__u32 flags;589};590591struct drm_amdgpu_vm_out {592/** For future use, no flags defined so far */593__u64 flags;594};595596union drm_amdgpu_vm {597struct drm_amdgpu_vm_in in;598struct drm_amdgpu_vm_out out;599};600601/* sched ioctl */602#define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE 1603#define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE 2604605struct drm_amdgpu_sched_in {606/* AMDGPU_SCHED_OP_* */607__u32 op;608__u32 fd;609/** AMDGPU_CTX_PRIORITY_* */610__s32 priority;611__u32 ctx_id;612};613614union drm_amdgpu_sched {615struct drm_amdgpu_sched_in in;616};617618/*619* This is not a reliable API and you should expect it to fail for any620* number of reasons and have fallback path that do not use userptr to621* perform any operation.622*/623#define AMDGPU_GEM_USERPTR_READONLY (1 << 0)624#define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)625#define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)626#define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)627628struct drm_amdgpu_gem_userptr {629__u64 addr;630__u64 size;631/* AMDGPU_GEM_USERPTR_* */632__u32 flags;633/* Resulting GEM handle */634__u32 handle;635};636637/* SI-CI-VI: */638/* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */639#define AMDGPU_TILING_ARRAY_MODE_SHIFT 0640#define AMDGPU_TILING_ARRAY_MODE_MASK 0xf641#define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4642#define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f643#define AMDGPU_TILING_TILE_SPLIT_SHIFT 9644#define AMDGPU_TILING_TILE_SPLIT_MASK 0x7645#define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12646#define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7647#define AMDGPU_TILING_BANK_WIDTH_SHIFT 15648#define AMDGPU_TILING_BANK_WIDTH_MASK 0x3649#define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17650#define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3651#define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19652#define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3653#define AMDGPU_TILING_NUM_BANKS_SHIFT 21654#define AMDGPU_TILING_NUM_BANKS_MASK 0x3655656/* GFX9 - GFX11: */657#define AMDGPU_TILING_SWIZZLE_MODE_SHIFT 0658#define AMDGPU_TILING_SWIZZLE_MODE_MASK 0x1f659#define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT 5660#define AMDGPU_TILING_DCC_OFFSET_256B_MASK 0xFFFFFF661#define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT 29662#define AMDGPU_TILING_DCC_PITCH_MAX_MASK 0x3FFF663#define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT 43664#define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK 0x1665#define AMDGPU_TILING_DCC_INDEPENDENT_128B_SHIFT 44666#define AMDGPU_TILING_DCC_INDEPENDENT_128B_MASK 0x1667#define AMDGPU_TILING_SCANOUT_SHIFT 63668#define AMDGPU_TILING_SCANOUT_MASK 0x1669670/* GFX12 and later: */671#define AMDGPU_TILING_GFX12_SWIZZLE_MODE_SHIFT 0672#define AMDGPU_TILING_GFX12_SWIZZLE_MODE_MASK 0x7673/* These are DCC recompression settings for memory management: */674#define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_SHIFT 3675#define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_MASK 0x3 /* 0:64B, 1:128B, 2:256B */676#define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_SHIFT 5677#define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_MASK 0x7 /* CB_COLOR0_INFO.NUMBER_TYPE */678#define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_SHIFT 8679#define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_MASK 0x3f /* [0:4]:CB_COLOR0_INFO.FORMAT, [5]:MM */680/* When clearing the buffer or moving it from VRAM to GTT, don't compress and set DCC metadata681* to uncompressed. Set when parts of an allocation bypass DCC and read raw data. */682#define AMDGPU_TILING_GFX12_DCC_WRITE_COMPRESS_DISABLE_SHIFT 14683#define AMDGPU_TILING_GFX12_DCC_WRITE_COMPRESS_DISABLE_MASK 0x1684/* bit gap */685#define AMDGPU_TILING_GFX12_SCANOUT_SHIFT 63686#define AMDGPU_TILING_GFX12_SCANOUT_MASK 0x1687688/* Set/Get helpers for tiling flags. */689#define AMDGPU_TILING_SET(field, value) \690(((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)691#define AMDGPU_TILING_GET(value, field) \692(((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)693694#define AMDGPU_GEM_METADATA_OP_SET_METADATA 1695#define AMDGPU_GEM_METADATA_OP_GET_METADATA 2696697/** The same structure is shared for input/output */698struct drm_amdgpu_gem_metadata {699/** GEM Object handle */700__u32 handle;701/** Do we want get or set metadata */702__u32 op;703struct {704/** For future use, no flags defined so far */705__u64 flags;706/** family specific tiling info */707__u64 tiling_info;708__u32 data_size_bytes;709__u32 data[64];710} data;711};712713struct drm_amdgpu_gem_mmap_in {714/** the GEM object handle */715__u32 handle;716__u32 _pad;717};718719struct drm_amdgpu_gem_mmap_out {720/** mmap offset from the vma offset manager */721__u64 addr_ptr;722};723724union drm_amdgpu_gem_mmap {725struct drm_amdgpu_gem_mmap_in in;726struct drm_amdgpu_gem_mmap_out out;727};728729struct drm_amdgpu_gem_wait_idle_in {730/** GEM object handle */731__u32 handle;732/** For future use, no flags defined so far */733__u32 flags;734/** Absolute timeout to wait */735__u64 timeout;736};737738struct drm_amdgpu_gem_wait_idle_out {739/** BO status: 0 - BO is idle, 1 - BO is busy */740__u32 status;741/** Returned current memory domain */742__u32 domain;743};744745union drm_amdgpu_gem_wait_idle {746struct drm_amdgpu_gem_wait_idle_in in;747struct drm_amdgpu_gem_wait_idle_out out;748};749750struct drm_amdgpu_wait_cs_in {751/* Command submission handle752* handle equals 0 means none to wait for753* handle equals ~0ull means wait for the latest sequence number754*/755__u64 handle;756/** Absolute timeout to wait */757__u64 timeout;758__u32 ip_type;759__u32 ip_instance;760__u32 ring;761__u32 ctx_id;762};763764struct drm_amdgpu_wait_cs_out {765/** CS status: 0 - CS completed, 1 - CS still busy */766__u64 status;767};768769union drm_amdgpu_wait_cs {770struct drm_amdgpu_wait_cs_in in;771struct drm_amdgpu_wait_cs_out out;772};773774struct drm_amdgpu_fence {775__u32 ctx_id;776__u32 ip_type;777__u32 ip_instance;778__u32 ring;779__u64 seq_no;780};781782struct drm_amdgpu_wait_fences_in {783/** This points to uint64_t * which points to fences */784__u64 fences;785__u32 fence_count;786__u32 wait_all;787__u64 timeout_ns;788};789790struct drm_amdgpu_wait_fences_out {791__u32 status;792__u32 first_signaled;793};794795union drm_amdgpu_wait_fences {796struct drm_amdgpu_wait_fences_in in;797struct drm_amdgpu_wait_fences_out out;798};799800#define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0801#define AMDGPU_GEM_OP_SET_PLACEMENT 1802803/* Sets or returns a value associated with a buffer. */804struct drm_amdgpu_gem_op {805/** GEM object handle */806__u32 handle;807/** AMDGPU_GEM_OP_* */808__u32 op;809/** Input or return value */810__u64 value;811};812813#define AMDGPU_VA_OP_MAP 1814#define AMDGPU_VA_OP_UNMAP 2815#define AMDGPU_VA_OP_CLEAR 3816#define AMDGPU_VA_OP_REPLACE 4817818/* Delay the page table update till the next CS */819#define AMDGPU_VM_DELAY_UPDATE (1 << 0)820821/* Mapping flags */822/* readable mapping */823#define AMDGPU_VM_PAGE_READABLE (1 << 1)824/* writable mapping */825#define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)826/* executable mapping, new for VI */827#define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)828/* partially resident texture */829#define AMDGPU_VM_PAGE_PRT (1 << 4)830/* MTYPE flags use bit 5 to 8 */831#define AMDGPU_VM_MTYPE_MASK (0xf << 5)832/* Default MTYPE. Pre-AI must use this. Recommended for newer ASICs. */833#define AMDGPU_VM_MTYPE_DEFAULT (0 << 5)834/* Use Non Coherent MTYPE instead of default MTYPE */835#define AMDGPU_VM_MTYPE_NC (1 << 5)836/* Use Write Combine MTYPE instead of default MTYPE */837#define AMDGPU_VM_MTYPE_WC (2 << 5)838/* Use Cache Coherent MTYPE instead of default MTYPE */839#define AMDGPU_VM_MTYPE_CC (3 << 5)840/* Use UnCached MTYPE instead of default MTYPE */841#define AMDGPU_VM_MTYPE_UC (4 << 5)842/* Use Read Write MTYPE instead of default MTYPE */843#define AMDGPU_VM_MTYPE_RW (5 << 5)844/* don't allocate MALL */845#define AMDGPU_VM_PAGE_NOALLOC (1 << 9)846847struct drm_amdgpu_gem_va {848/** GEM object handle */849__u32 handle;850__u32 _pad;851/** AMDGPU_VA_OP_* */852__u32 operation;853/** AMDGPU_VM_PAGE_* */854__u32 flags;855/** va address to assign . Must be correctly aligned.*/856__u64 va_address;857/** Specify offset inside of BO to assign. Must be correctly aligned.*/858__u64 offset_in_bo;859/** Specify mapping size. Must be correctly aligned. */860__u64 map_size;861/**862* vm_timeline_point is a sequence number used to add new timeline point.863*/864__u64 vm_timeline_point;865/**866* The vm page table update fence is installed in given vm_timeline_syncobj_out867* at vm_timeline_point.868*/869__u32 vm_timeline_syncobj_out;870/** the number of syncobj handles in @input_fence_syncobj_handles */871__u32 num_syncobj_handles;872/** Array of sync object handle to wait for given input fences */873__u64 input_fence_syncobj_handles;874};875876#define AMDGPU_HW_IP_GFX 0877#define AMDGPU_HW_IP_COMPUTE 1878#define AMDGPU_HW_IP_DMA 2879#define AMDGPU_HW_IP_UVD 3880#define AMDGPU_HW_IP_VCE 4881#define AMDGPU_HW_IP_UVD_ENC 5882#define AMDGPU_HW_IP_VCN_DEC 6883/*884* From VCN4, AMDGPU_HW_IP_VCN_ENC is re-used to support885* both encoding and decoding jobs.886*/887#define AMDGPU_HW_IP_VCN_ENC 7888#define AMDGPU_HW_IP_VCN_JPEG 8889#define AMDGPU_HW_IP_VPE 9890#define AMDGPU_HW_IP_NUM 10891892#define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1893894#define AMDGPU_CHUNK_ID_IB 0x01895#define AMDGPU_CHUNK_ID_FENCE 0x02896#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03897#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04898#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05899#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06900#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07901#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08902#define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09903#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW 0x0a904905struct drm_amdgpu_cs_chunk {906__u32 chunk_id;907__u32 length_dw;908__u64 chunk_data;909};910911struct drm_amdgpu_cs_in {912/** Rendering context id */913__u32 ctx_id;914/** Handle of resource list associated with CS */915__u32 bo_list_handle;916__u32 num_chunks;917__u32 flags;918/** this points to __u64 * which point to cs chunks */919__u64 chunks;920};921922struct drm_amdgpu_cs_out {923__u64 handle;924};925926union drm_amdgpu_cs {927struct drm_amdgpu_cs_in in;928struct drm_amdgpu_cs_out out;929};930931/* Specify flags to be used for IB */932933/* This IB should be submitted to CE */934#define AMDGPU_IB_FLAG_CE (1<<0)935936/* Preamble flag, which means the IB could be dropped if no context switch */937#define AMDGPU_IB_FLAG_PREAMBLE (1<<1)938939/* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */940#define AMDGPU_IB_FLAG_PREEMPT (1<<2)941942/* The IB fence should do the L2 writeback but not invalidate any shader943* caches (L2/vL1/sL1/I$). */944#define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3)945946/* Set GDS_COMPUTE_MAX_WAVE_ID = DEFAULT before PACKET3_INDIRECT_BUFFER.947* This will reset wave ID counters for the IB.948*/949#define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4)950951/* Flag the IB as secure (TMZ)952*/953#define AMDGPU_IB_FLAGS_SECURE (1 << 5)954955/* Tell KMD to flush and invalidate caches956*/957#define AMDGPU_IB_FLAG_EMIT_MEM_SYNC (1 << 6)958959struct drm_amdgpu_cs_chunk_ib {960__u32 _pad;961/** AMDGPU_IB_FLAG_* */962__u32 flags;963/** Virtual address to begin IB execution */964__u64 va_start;965/** Size of submission */966__u32 ib_bytes;967/** HW IP to submit to */968__u32 ip_type;969/** HW IP index of the same type to submit to */970__u32 ip_instance;971/** Ring index to submit to */972__u32 ring;973};974975struct drm_amdgpu_cs_chunk_dep {976__u32 ip_type;977__u32 ip_instance;978__u32 ring;979__u32 ctx_id;980__u64 handle;981};982983struct drm_amdgpu_cs_chunk_fence {984__u32 handle;985__u32 offset;986};987988struct drm_amdgpu_cs_chunk_sem {989__u32 handle;990};991992struct drm_amdgpu_cs_chunk_syncobj {993__u32 handle;994__u32 flags;995__u64 point;996};997998#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 0999#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 11000#define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 210011002union drm_amdgpu_fence_to_handle {1003struct {1004struct drm_amdgpu_fence fence;1005__u32 what;1006__u32 pad;1007} in;1008struct {1009__u32 handle;1010} out;1011};10121013struct drm_amdgpu_cs_chunk_data {1014union {1015struct drm_amdgpu_cs_chunk_ib ib_data;1016struct drm_amdgpu_cs_chunk_fence fence_data;1017};1018};10191020#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW 0x110211022struct drm_amdgpu_cs_chunk_cp_gfx_shadow {1023__u64 shadow_va;1024__u64 csa_va;1025__u64 gds_va;1026__u64 flags;1027};10281029/*1030* Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU1031*1032*/1033#define AMDGPU_IDS_FLAGS_FUSION 0x11034#define AMDGPU_IDS_FLAGS_PREEMPTION 0x21035#define AMDGPU_IDS_FLAGS_TMZ 0x41036#define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x810371038/*1039* Query h/w info: Flag identifying VF/PF/PT mode1040*1041*/1042#define AMDGPU_IDS_FLAGS_MODE_MASK 0x3001043#define AMDGPU_IDS_FLAGS_MODE_SHIFT 0x81044#define AMDGPU_IDS_FLAGS_MODE_PF 0x01045#define AMDGPU_IDS_FLAGS_MODE_VF 0x11046#define AMDGPU_IDS_FLAGS_MODE_PT 0x210471048/* indicate if acceleration can be working */1049#define AMDGPU_INFO_ACCEL_WORKING 0x001050/* get the crtc_id from the mode object id? */1051#define AMDGPU_INFO_CRTC_FROM_ID 0x011052/* query hw IP info */1053#define AMDGPU_INFO_HW_IP_INFO 0x021054/* query hw IP instance count for the specified type */1055#define AMDGPU_INFO_HW_IP_COUNT 0x031056/* timestamp for GL_ARB_timer_query */1057#define AMDGPU_INFO_TIMESTAMP 0x051058/* Query the firmware version */1059#define AMDGPU_INFO_FW_VERSION 0x0e1060/* Subquery id: Query VCE firmware version */1061#define AMDGPU_INFO_FW_VCE 0x11062/* Subquery id: Query UVD firmware version */1063#define AMDGPU_INFO_FW_UVD 0x21064/* Subquery id: Query GMC firmware version */1065#define AMDGPU_INFO_FW_GMC 0x031066/* Subquery id: Query GFX ME firmware version */1067#define AMDGPU_INFO_FW_GFX_ME 0x041068/* Subquery id: Query GFX PFP firmware version */1069#define AMDGPU_INFO_FW_GFX_PFP 0x051070/* Subquery id: Query GFX CE firmware version */1071#define AMDGPU_INFO_FW_GFX_CE 0x061072/* Subquery id: Query GFX RLC firmware version */1073#define AMDGPU_INFO_FW_GFX_RLC 0x071074/* Subquery id: Query GFX MEC firmware version */1075#define AMDGPU_INFO_FW_GFX_MEC 0x081076/* Subquery id: Query SMC firmware version */1077#define AMDGPU_INFO_FW_SMC 0x0a1078/* Subquery id: Query SDMA firmware version */1079#define AMDGPU_INFO_FW_SDMA 0x0b1080/* Subquery id: Query PSP SOS firmware version */1081#define AMDGPU_INFO_FW_SOS 0x0c1082/* Subquery id: Query PSP ASD firmware version */1083#define AMDGPU_INFO_FW_ASD 0x0d1084/* Subquery id: Query VCN firmware version */1085#define AMDGPU_INFO_FW_VCN 0x0e1086/* Subquery id: Query GFX RLC SRLC firmware version */1087#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f1088/* Subquery id: Query GFX RLC SRLG firmware version */1089#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x101090/* Subquery id: Query GFX RLC SRLS firmware version */1091#define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x111092/* Subquery id: Query DMCU firmware version */1093#define AMDGPU_INFO_FW_DMCU 0x121094#define AMDGPU_INFO_FW_TA 0x131095/* Subquery id: Query DMCUB firmware version */1096#define AMDGPU_INFO_FW_DMCUB 0x141097/* Subquery id: Query TOC firmware version */1098#define AMDGPU_INFO_FW_TOC 0x151099/* Subquery id: Query CAP firmware version */1100#define AMDGPU_INFO_FW_CAP 0x161101/* Subquery id: Query GFX RLCP firmware version */1102#define AMDGPU_INFO_FW_GFX_RLCP 0x171103/* Subquery id: Query GFX RLCV firmware version */1104#define AMDGPU_INFO_FW_GFX_RLCV 0x181105/* Subquery id: Query MES_KIQ firmware version */1106#define AMDGPU_INFO_FW_MES_KIQ 0x191107/* Subquery id: Query MES firmware version */1108#define AMDGPU_INFO_FW_MES 0x1a1109/* Subquery id: Query IMU firmware version */1110#define AMDGPU_INFO_FW_IMU 0x1b1111/* Subquery id: Query VPE firmware version */1112#define AMDGPU_INFO_FW_VPE 0x1c11131114/* number of bytes moved for TTM migration */1115#define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f1116/* the used VRAM size */1117#define AMDGPU_INFO_VRAM_USAGE 0x101118/* the used GTT size */1119#define AMDGPU_INFO_GTT_USAGE 0x111120/* Information about GDS, etc. resource configuration */1121#define AMDGPU_INFO_GDS_CONFIG 0x131122/* Query information about VRAM and GTT domains */1123#define AMDGPU_INFO_VRAM_GTT 0x141124/* Query information about register in MMR address space*/1125#define AMDGPU_INFO_READ_MMR_REG 0x151126/* Query information about device: rev id, family, etc. */1127#define AMDGPU_INFO_DEV_INFO 0x161128/* visible vram usage */1129#define AMDGPU_INFO_VIS_VRAM_USAGE 0x171130/* number of TTM buffer evictions */1131#define AMDGPU_INFO_NUM_EVICTIONS 0x181132/* Query memory about VRAM and GTT domains */1133#define AMDGPU_INFO_MEMORY 0x191134/* Query vce clock table */1135#define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A1136/* Query vbios related information */1137#define AMDGPU_INFO_VBIOS 0x1B1138/* Subquery id: Query vbios size */1139#define AMDGPU_INFO_VBIOS_SIZE 0x11140/* Subquery id: Query vbios image */1141#define AMDGPU_INFO_VBIOS_IMAGE 0x21142/* Subquery id: Query vbios info */1143#define AMDGPU_INFO_VBIOS_INFO 0x31144/* Query UVD handles */1145#define AMDGPU_INFO_NUM_HANDLES 0x1C1146/* Query sensor related information */1147#define AMDGPU_INFO_SENSOR 0x1D1148/* Subquery id: Query GPU shader clock */1149#define AMDGPU_INFO_SENSOR_GFX_SCLK 0x11150/* Subquery id: Query GPU memory clock */1151#define AMDGPU_INFO_SENSOR_GFX_MCLK 0x21152/* Subquery id: Query GPU temperature */1153#define AMDGPU_INFO_SENSOR_GPU_TEMP 0x31154/* Subquery id: Query GPU load */1155#define AMDGPU_INFO_SENSOR_GPU_LOAD 0x41156/* Subquery id: Query average GPU power */1157#define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x51158/* Subquery id: Query northbridge voltage */1159#define AMDGPU_INFO_SENSOR_VDDNB 0x61160/* Subquery id: Query graphics voltage */1161#define AMDGPU_INFO_SENSOR_VDDGFX 0x71162/* Subquery id: Query GPU stable pstate shader clock */1163#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK 0x81164/* Subquery id: Query GPU stable pstate memory clock */1165#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK 0x91166/* Subquery id: Query GPU peak pstate shader clock */1167#define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_SCLK 0xa1168/* Subquery id: Query GPU peak pstate memory clock */1169#define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_MCLK 0xb1170/* Subquery id: Query input GPU power */1171#define AMDGPU_INFO_SENSOR_GPU_INPUT_POWER 0xc1172/* Number of VRAM page faults on CPU access. */1173#define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E1174#define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F1175/* query ras mask of enabled features*/1176#define AMDGPU_INFO_RAS_ENABLED_FEATURES 0x201177/* RAS MASK: UMC (VRAM) */1178#define AMDGPU_INFO_RAS_ENABLED_UMC (1 << 0)1179/* RAS MASK: SDMA */1180#define AMDGPU_INFO_RAS_ENABLED_SDMA (1 << 1)1181/* RAS MASK: GFX */1182#define AMDGPU_INFO_RAS_ENABLED_GFX (1 << 2)1183/* RAS MASK: MMHUB */1184#define AMDGPU_INFO_RAS_ENABLED_MMHUB (1 << 3)1185/* RAS MASK: ATHUB */1186#define AMDGPU_INFO_RAS_ENABLED_ATHUB (1 << 4)1187/* RAS MASK: PCIE */1188#define AMDGPU_INFO_RAS_ENABLED_PCIE (1 << 5)1189/* RAS MASK: HDP */1190#define AMDGPU_INFO_RAS_ENABLED_HDP (1 << 6)1191/* RAS MASK: XGMI */1192#define AMDGPU_INFO_RAS_ENABLED_XGMI (1 << 7)1193/* RAS MASK: DF */1194#define AMDGPU_INFO_RAS_ENABLED_DF (1 << 8)1195/* RAS MASK: SMN */1196#define AMDGPU_INFO_RAS_ENABLED_SMN (1 << 9)1197/* RAS MASK: SEM */1198#define AMDGPU_INFO_RAS_ENABLED_SEM (1 << 10)1199/* RAS MASK: MP0 */1200#define AMDGPU_INFO_RAS_ENABLED_MP0 (1 << 11)1201/* RAS MASK: MP1 */1202#define AMDGPU_INFO_RAS_ENABLED_MP1 (1 << 12)1203/* RAS MASK: FUSE */1204#define AMDGPU_INFO_RAS_ENABLED_FUSE (1 << 13)1205/* query video encode/decode caps */1206#define AMDGPU_INFO_VIDEO_CAPS 0x211207/* Subquery id: Decode */1208#define AMDGPU_INFO_VIDEO_CAPS_DECODE 01209/* Subquery id: Encode */1210#define AMDGPU_INFO_VIDEO_CAPS_ENCODE 11211/* Query the max number of IBs per gang per submission */1212#define AMDGPU_INFO_MAX_IBS 0x221213/* query last page fault info */1214#define AMDGPU_INFO_GPUVM_FAULT 0x231215/* query FW object size and alignment */1216#define AMDGPU_INFO_UQ_FW_AREAS 0x2412171218#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 01219#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff1220#define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 81221#define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff12221223struct drm_amdgpu_query_fw {1224/** AMDGPU_INFO_FW_* */1225__u32 fw_type;1226/**1227* Index of the IP if there are more IPs of1228* the same type.1229*/1230__u32 ip_instance;1231/**1232* Index of the engine. Whether this is used depends1233* on the firmware type. (e.g. MEC, SDMA)1234*/1235__u32 index;1236__u32 _pad;1237};12381239/* Input structure for the INFO ioctl */1240struct drm_amdgpu_info {1241/* Where the return value will be stored */1242__u64 return_pointer;1243/* The size of the return value. Just like "size" in "snprintf",1244* it limits how many bytes the kernel can write. */1245__u32 return_size;1246/* The query request id. */1247__u32 query;12481249union {1250struct {1251__u32 id;1252__u32 _pad;1253} mode_crtc;12541255struct {1256/** AMDGPU_HW_IP_* */1257__u32 type;1258/**1259* Index of the IP if there are more IPs of the same1260* type. Ignored by AMDGPU_INFO_HW_IP_COUNT.1261*/1262__u32 ip_instance;1263} query_hw_ip;12641265struct {1266__u32 dword_offset;1267/** number of registers to read */1268__u32 count;1269__u32 instance;1270/** For future use, no flags defined so far */1271__u32 flags;1272} read_mmr_reg;12731274struct drm_amdgpu_query_fw query_fw;12751276struct {1277__u32 type;1278__u32 offset;1279} vbios_info;12801281struct {1282__u32 type;1283} sensor_info;12841285struct {1286__u32 type;1287} video_cap;1288};1289};12901291struct drm_amdgpu_info_gds {1292/** GDS GFX partition size */1293__u32 gds_gfx_partition_size;1294/** GDS compute partition size */1295__u32 compute_partition_size;1296/** total GDS memory size */1297__u32 gds_total_size;1298/** GWS size per GFX partition */1299__u32 gws_per_gfx_partition;1300/** GSW size per compute partition */1301__u32 gws_per_compute_partition;1302/** OA size per GFX partition */1303__u32 oa_per_gfx_partition;1304/** OA size per compute partition */1305__u32 oa_per_compute_partition;1306__u32 _pad;1307};13081309struct drm_amdgpu_info_vram_gtt {1310__u64 vram_size;1311__u64 vram_cpu_accessible_size;1312__u64 gtt_size;1313};13141315struct drm_amdgpu_heap_info {1316/** max. physical memory */1317__u64 total_heap_size;13181319/** Theoretical max. available memory in the given heap */1320__u64 usable_heap_size;13211322/**1323* Number of bytes allocated in the heap. This includes all processes1324* and private allocations in the kernel. It changes when new buffers1325* are allocated, freed, and moved. It cannot be larger than1326* heap_size.1327*/1328__u64 heap_usage;13291330/**1331* Theoretical possible max. size of buffer which1332* could be allocated in the given heap1333*/1334__u64 max_allocation;1335};13361337struct drm_amdgpu_memory_info {1338struct drm_amdgpu_heap_info vram;1339struct drm_amdgpu_heap_info cpu_accessible_vram;1340struct drm_amdgpu_heap_info gtt;1341};13421343struct drm_amdgpu_info_firmware {1344__u32 ver;1345__u32 feature;1346};13471348struct drm_amdgpu_info_vbios {1349__u8 name[64];1350__u8 vbios_pn[64];1351__u32 version;1352__u32 pad;1353__u8 vbios_ver_str[32];1354__u8 date[32];1355};13561357#define AMDGPU_VRAM_TYPE_UNKNOWN 01358#define AMDGPU_VRAM_TYPE_GDDR1 11359#define AMDGPU_VRAM_TYPE_DDR2 21360#define AMDGPU_VRAM_TYPE_GDDR3 31361#define AMDGPU_VRAM_TYPE_GDDR4 41362#define AMDGPU_VRAM_TYPE_GDDR5 51363#define AMDGPU_VRAM_TYPE_HBM 61364#define AMDGPU_VRAM_TYPE_DDR3 71365#define AMDGPU_VRAM_TYPE_DDR4 81366#define AMDGPU_VRAM_TYPE_GDDR6 91367#define AMDGPU_VRAM_TYPE_DDR5 101368#define AMDGPU_VRAM_TYPE_LPDDR4 111369#define AMDGPU_VRAM_TYPE_LPDDR5 121370#define AMDGPU_VRAM_TYPE_HBM3E 1313711372struct drm_amdgpu_info_device {1373/** PCI Device ID */1374__u32 device_id;1375/** Internal chip revision: A0, A1, etc.) */1376__u32 chip_rev;1377__u32 external_rev;1378/** Revision id in PCI Config space */1379__u32 pci_rev;1380__u32 family;1381__u32 num_shader_engines;1382__u32 num_shader_arrays_per_engine;1383/* in KHz */1384__u32 gpu_counter_freq;1385__u64 max_engine_clock;1386__u64 max_memory_clock;1387/* cu information */1388__u32 cu_active_number;1389/* NOTE: cu_ao_mask is INVALID, DON'T use it */1390__u32 cu_ao_mask;1391__u32 cu_bitmap[4][4];1392/** Render backend pipe mask. One render backend is CB+DB. */1393__u32 enabled_rb_pipes_mask;1394__u32 num_rb_pipes;1395__u32 num_hw_gfx_contexts;1396/* PCIe version (the smaller of the GPU and the CPU/motherboard) */1397__u32 pcie_gen;1398__u64 ids_flags;1399/** Starting virtual address for UMDs. */1400__u64 virtual_address_offset;1401/** The maximum virtual address */1402__u64 virtual_address_max;1403/** Required alignment of virtual addresses. */1404__u32 virtual_address_alignment;1405/** Page table entry - fragment size */1406__u32 pte_fragment_size;1407__u32 gart_page_size;1408/** constant engine ram size*/1409__u32 ce_ram_size;1410/** video memory type info*/1411__u32 vram_type;1412/** video memory bit width*/1413__u32 vram_bit_width;1414/* vce harvesting instance */1415__u32 vce_harvest_config;1416/* gfx double offchip LDS buffers */1417__u32 gc_double_offchip_lds_buf;1418/* NGG Primitive Buffer */1419__u64 prim_buf_gpu_addr;1420/* NGG Position Buffer */1421__u64 pos_buf_gpu_addr;1422/* NGG Control Sideband */1423__u64 cntl_sb_buf_gpu_addr;1424/* NGG Parameter Cache */1425__u64 param_buf_gpu_addr;1426__u32 prim_buf_size;1427__u32 pos_buf_size;1428__u32 cntl_sb_buf_size;1429__u32 param_buf_size;1430/* wavefront size*/1431__u32 wave_front_size;1432/* shader visible vgprs*/1433__u32 num_shader_visible_vgprs;1434/* CU per shader array*/1435__u32 num_cu_per_sh;1436/* number of tcc blocks*/1437__u32 num_tcc_blocks;1438/* gs vgt table depth*/1439__u32 gs_vgt_table_depth;1440/* gs primitive buffer depth*/1441__u32 gs_prim_buffer_depth;1442/* max gs wavefront per vgt*/1443__u32 max_gs_waves_per_vgt;1444/* PCIe number of lanes (the smaller of the GPU and the CPU/motherboard) */1445__u32 pcie_num_lanes;1446/* always on cu bitmap */1447__u32 cu_ao_bitmap[4][4];1448/** Starting high virtual address for UMDs. */1449__u64 high_va_offset;1450/** The maximum high virtual address */1451__u64 high_va_max;1452/* gfx10 pa_sc_tile_steering_override */1453__u32 pa_sc_tile_steering_override;1454/* disabled TCCs */1455__u64 tcc_disabled_mask;1456__u64 min_engine_clock;1457__u64 min_memory_clock;1458/* The following fields are only set on gfx11+, older chips set 0. */1459__u32 tcp_cache_size; /* AKA GL0, VMEM cache */1460__u32 num_sqc_per_wgp;1461__u32 sqc_data_cache_size; /* AKA SMEM cache */1462__u32 sqc_inst_cache_size;1463__u32 gl1c_cache_size;1464__u32 gl2c_cache_size;1465__u64 mall_size; /* AKA infinity cache */1466/* high 32 bits of the rb pipes mask */1467__u32 enabled_rb_pipes_mask_hi;1468/* shadow area size for gfx11 */1469__u32 shadow_size;1470/* shadow area base virtual alignment for gfx11 */1471__u32 shadow_alignment;1472/* context save area size for gfx11 */1473__u32 csa_size;1474/* context save area base virtual alignment for gfx11 */1475__u32 csa_alignment;1476/* Userq IP mask (1 << AMDGPU_HW_IP_*) */1477__u32 userq_ip_mask;1478__u32 pad;1479};14801481struct drm_amdgpu_info_hw_ip {1482/** Version of h/w IP */1483__u32 hw_ip_version_major;1484__u32 hw_ip_version_minor;1485/** Capabilities */1486__u64 capabilities_flags;1487/** command buffer address start alignment*/1488__u32 ib_start_alignment;1489/** command buffer size alignment*/1490__u32 ib_size_alignment;1491/** Bitmask of available rings. Bit 0 means ring 0, etc. */1492__u32 available_rings;1493/** version info: bits 23:16 major, 15:8 minor, 7:0 revision */1494__u32 ip_discovery_version;1495/* Userq available slots */1496__u32 userq_num_slots;1497};14981499/* GFX metadata BO sizes and alignment info (in bytes) */1500struct drm_amdgpu_info_uq_fw_areas_gfx {1501/* shadow area size */1502__u32 shadow_size;1503/* shadow area base virtual mem alignment */1504__u32 shadow_alignment;1505/* context save area size */1506__u32 csa_size;1507/* context save area base virtual mem alignment */1508__u32 csa_alignment;1509};15101511/* IP specific fw related information used in the1512* subquery AMDGPU_INFO_UQ_FW_AREAS1513*/1514struct drm_amdgpu_info_uq_fw_areas {1515union {1516struct drm_amdgpu_info_uq_fw_areas_gfx gfx;1517};1518};15191520struct drm_amdgpu_info_num_handles {1521/** Max handles as supported by firmware for UVD */1522__u32 uvd_max_handles;1523/** Handles currently in use for UVD */1524__u32 uvd_used_handles;1525};15261527#define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 615281529struct drm_amdgpu_info_vce_clock_table_entry {1530/** System clock */1531__u32 sclk;1532/** Memory clock */1533__u32 mclk;1534/** VCE clock */1535__u32 eclk;1536__u32 pad;1537};15381539struct drm_amdgpu_info_vce_clock_table {1540struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];1541__u32 num_valid_entries;1542__u32 pad;1543};15441545/* query video encode/decode caps */1546#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 01547#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 11548#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 21549#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC 31550#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC 41551#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG 51552#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9 61553#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1 71554#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT 815551556struct drm_amdgpu_info_video_codec_info {1557__u32 valid;1558__u32 max_width;1559__u32 max_height;1560__u32 max_pixels_per_frame;1561__u32 max_level;1562__u32 pad;1563};15641565struct drm_amdgpu_info_video_caps {1566struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT];1567};15681569#define AMDGPU_VMHUB_TYPE_MASK 0xff1570#define AMDGPU_VMHUB_TYPE_SHIFT 01571#define AMDGPU_VMHUB_TYPE_GFX 01572#define AMDGPU_VMHUB_TYPE_MM0 11573#define AMDGPU_VMHUB_TYPE_MM1 21574#define AMDGPU_VMHUB_IDX_MASK 0xff001575#define AMDGPU_VMHUB_IDX_SHIFT 815761577struct drm_amdgpu_info_gpuvm_fault {1578__u64 addr;1579__u32 status;1580__u32 vmhub;1581};15821583struct drm_amdgpu_info_uq_metadata_gfx {1584/* shadow area size for gfx11 */1585__u32 shadow_size;1586/* shadow area base virtual alignment for gfx11 */1587__u32 shadow_alignment;1588/* context save area size for gfx11 */1589__u32 csa_size;1590/* context save area base virtual alignment for gfx11 */1591__u32 csa_alignment;1592};15931594struct drm_amdgpu_info_uq_metadata {1595union {1596struct drm_amdgpu_info_uq_metadata_gfx gfx;1597};1598};15991600/*1601* Supported GPU families1602*/1603#define AMDGPU_FAMILY_UNKNOWN 01604#define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */1605#define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */1606#define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */1607#define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */1608#define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */1609#define AMDGPU_FAMILY_AI 141 /* Vega10 */1610#define AMDGPU_FAMILY_RV 142 /* Raven */1611#define AMDGPU_FAMILY_NV 143 /* Navi10 */1612#define AMDGPU_FAMILY_VGH 144 /* Van Gogh */1613#define AMDGPU_FAMILY_GC_11_0_0 145 /* GC 11.0.0 */1614#define AMDGPU_FAMILY_YC 146 /* Yellow Carp */1615#define AMDGPU_FAMILY_GC_11_0_1 148 /* GC 11.0.1 */1616#define AMDGPU_FAMILY_GC_10_3_6 149 /* GC 10.3.6 */1617#define AMDGPU_FAMILY_GC_10_3_7 151 /* GC 10.3.7 */1618#define AMDGPU_FAMILY_GC_11_5_0 150 /* GC 11.5.0 */1619#define AMDGPU_FAMILY_GC_12_0_0 152 /* GC 12.0.0 */16201621/* FIXME wrong namespace! */1622struct drm_color_ctm_3x4 {1623/*1624* Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude1625* (not two's complement!) format.1626*/1627__u64 matrix[12];1628};16291630#if defined(__cplusplus)1631}1632#endif16331634#endif163516361637