Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 09:17:45

0001 /* amdgpu_drm.h -- Public header for the amdgpu driver -*- linux-c -*-
0002  *
0003  * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
0004  * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
0005  * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
0006  * Copyright 2014 Advanced Micro Devices, Inc.
0007  *
0008  * Permission is hereby granted, free of charge, to any person obtaining a
0009  * copy of this software and associated documentation files (the "Software"),
0010  * to deal in the Software without restriction, including without limitation
0011  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0012  * and/or sell copies of the Software, and to permit persons to whom the
0013  * Software is furnished to do so, subject to the following conditions:
0014  *
0015  * The above copyright notice and this permission notice shall be included in
0016  * all copies or substantial portions of the Software.
0017  *
0018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0019  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0020  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0021  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0022  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0023  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0024  * OTHER DEALINGS IN THE SOFTWARE.
0025  *
0026  * Authors:
0027  *    Kevin E. Martin <martin@valinux.com>
0028  *    Gareth Hughes <gareth@valinux.com>
0029  *    Keith Whitwell <keith@tungstengraphics.com>
0030  */
0031 
0032 #ifndef __AMDGPU_DRM_H__
0033 #define __AMDGPU_DRM_H__
0034 
0035 #include "drm.h"
0036 
0037 #if defined(__cplusplus)
0038 extern "C" {
0039 #endif
0040 
0041 #define DRM_AMDGPU_GEM_CREATE       0x00
0042 #define DRM_AMDGPU_GEM_MMAP     0x01
0043 #define DRM_AMDGPU_CTX          0x02
0044 #define DRM_AMDGPU_BO_LIST      0x03
0045 #define DRM_AMDGPU_CS           0x04
0046 #define DRM_AMDGPU_INFO         0x05
0047 #define DRM_AMDGPU_GEM_METADATA     0x06
0048 #define DRM_AMDGPU_GEM_WAIT_IDLE    0x07
0049 #define DRM_AMDGPU_GEM_VA       0x08
0050 #define DRM_AMDGPU_WAIT_CS      0x09
0051 #define DRM_AMDGPU_GEM_OP       0x10
0052 #define DRM_AMDGPU_GEM_USERPTR      0x11
0053 #define DRM_AMDGPU_WAIT_FENCES      0x12
0054 #define DRM_AMDGPU_VM           0x13
0055 #define DRM_AMDGPU_FENCE_TO_HANDLE  0x14
0056 #define DRM_AMDGPU_SCHED        0x15
0057 #define DRM_AMDGPU_USERQ        0x16
0058 #define DRM_AMDGPU_USERQ_SIGNAL     0x17
0059 #define DRM_AMDGPU_USERQ_WAIT       0x18
0060 
0061 #define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
0062 #define DRM_IOCTL_AMDGPU_GEM_MMAP   DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
0063 #define DRM_IOCTL_AMDGPU_CTX        DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
0064 #define DRM_IOCTL_AMDGPU_BO_LIST    DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
0065 #define DRM_IOCTL_AMDGPU_CS     DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
0066 #define DRM_IOCTL_AMDGPU_INFO       DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
0067 #define DRM_IOCTL_AMDGPU_GEM_METADATA   DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
0068 #define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE  DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
0069 #define DRM_IOCTL_AMDGPU_GEM_VA     DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
0070 #define DRM_IOCTL_AMDGPU_WAIT_CS    DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
0071 #define DRM_IOCTL_AMDGPU_GEM_OP     DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
0072 #define DRM_IOCTL_AMDGPU_GEM_USERPTR    DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
0073 #define DRM_IOCTL_AMDGPU_WAIT_FENCES    DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)
0074 #define DRM_IOCTL_AMDGPU_VM     DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
0075 #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
0076 #define DRM_IOCTL_AMDGPU_SCHED      DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
0077 #define DRM_IOCTL_AMDGPU_USERQ      DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ, union drm_amdgpu_userq)
0078 #define DRM_IOCTL_AMDGPU_USERQ_SIGNAL   DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_SIGNAL, struct drm_amdgpu_userq_signal)
0079 #define DRM_IOCTL_AMDGPU_USERQ_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_WAIT, struct drm_amdgpu_userq_wait)
0080 
0081 /**
0082  * DOC: memory domains
0083  *
0084  * %AMDGPU_GEM_DOMAIN_CPU   System memory that is not GPU accessible.
0085  * Memory in this pool could be swapped out to disk if there is pressure.
0086  *
0087  * %AMDGPU_GEM_DOMAIN_GTT   GPU accessible system memory, mapped into the
0088  * GPU's virtual address space via gart. Gart memory linearizes non-contiguous
0089  * pages of system memory, allows GPU access system memory in a linearized
0090  * fashion.
0091  *
0092  * %AMDGPU_GEM_DOMAIN_VRAM  Local video memory. For APUs, it is memory
0093  * carved out by the BIOS.
0094  *
0095  * %AMDGPU_GEM_DOMAIN_GDS   Global on-chip data storage used to share data
0096  * across shader threads.
0097  *
0098  * %AMDGPU_GEM_DOMAIN_GWS   Global wave sync, used to synchronize the
0099  * execution of all the waves on a device.
0100  *
0101  * %AMDGPU_GEM_DOMAIN_OA    Ordered append, used by 3D or Compute engines
0102  * for appending data.
0103  *
0104  * %AMDGPU_GEM_DOMAIN_DOORBELL  Doorbell. It is an MMIO region for
0105  * signalling user mode queues.
0106  */
0107 #define AMDGPU_GEM_DOMAIN_CPU       0x1
0108 #define AMDGPU_GEM_DOMAIN_GTT       0x2
0109 #define AMDGPU_GEM_DOMAIN_VRAM      0x4
0110 #define AMDGPU_GEM_DOMAIN_GDS       0x8
0111 #define AMDGPU_GEM_DOMAIN_GWS       0x10
0112 #define AMDGPU_GEM_DOMAIN_OA        0x20
0113 #define AMDGPU_GEM_DOMAIN_DOORBELL  0x40
0114 #define AMDGPU_GEM_DOMAIN_MASK      (AMDGPU_GEM_DOMAIN_CPU | \
0115                      AMDGPU_GEM_DOMAIN_GTT | \
0116                      AMDGPU_GEM_DOMAIN_VRAM | \
0117                      AMDGPU_GEM_DOMAIN_GDS | \
0118                      AMDGPU_GEM_DOMAIN_GWS | \
0119                      AMDGPU_GEM_DOMAIN_OA | \
0120                      AMDGPU_GEM_DOMAIN_DOORBELL)
0121 
0122 /* Flag that CPU access will be required for the case of VRAM domain */
0123 #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED   (1 << 0)
0124 /* Flag that CPU access will not work, this VRAM domain is invisible */
0125 #define AMDGPU_GEM_CREATE_NO_CPU_ACCESS     (1 << 1)
0126 /* Flag that USWC attributes should be used for GTT */
0127 #define AMDGPU_GEM_CREATE_CPU_GTT_USWC      (1 << 2)
0128 /* Flag that the memory should be in VRAM and cleared */
0129 #define AMDGPU_GEM_CREATE_VRAM_CLEARED      (1 << 3)
0130 /* Flag that allocating the BO should use linear VRAM */
0131 #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS   (1 << 5)
0132 /* Flag that BO is always valid in this VM */
0133 #define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID   (1 << 6)
0134 /* Flag that BO sharing will be explicitly synchronized */
0135 #define AMDGPU_GEM_CREATE_EXPLICIT_SYNC     (1 << 7)
0136 /* Flag that indicates allocating MQD gart on GFX9, where the mtype
0137  * for the second page onward should be set to NC. It should never
0138  * be used by user space applications.
0139  */
0140 #define AMDGPU_GEM_CREATE_CP_MQD_GFX9       (1 << 8)
0141 /* Flag that BO may contain sensitive data that must be wiped before
0142  * releasing the memory
0143  */
0144 #define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE  (1 << 9)
0145 /* Flag that BO will be encrypted and that the TMZ bit should be
0146  * set in the PTEs when mapping this buffer via GPUVM or
0147  * accessing it with various hw blocks
0148  */
0149 #define AMDGPU_GEM_CREATE_ENCRYPTED     (1 << 10)
0150 /* Flag that BO will be used only in preemptible context, which does
0151  * not require GTT memory accounting
0152  */
0153 #define AMDGPU_GEM_CREATE_PREEMPTIBLE       (1 << 11)
0154 /* Flag that BO can be discarded under memory pressure without keeping the
0155  * content.
0156  */
0157 #define AMDGPU_GEM_CREATE_DISCARDABLE       (1 << 12)
0158 /* Flag that BO is shared coherently between multiple devices or CPU threads.
0159  * May depend on GPU instructions to flush caches to system scope explicitly.
0160  *
0161  * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
0162  * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
0163  */
0164 #define AMDGPU_GEM_CREATE_COHERENT      (1 << 13)
0165 /* Flag that BO should not be cached by GPU. Coherent without having to flush
0166  * GPU caches explicitly
0167  *
0168  * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
0169  * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
0170  */
0171 #define AMDGPU_GEM_CREATE_UNCACHED      (1 << 14)
0172 /* Flag that BO should be coherent across devices when using device-level
0173  * atomics. May depend on GPU instructions to flush caches to device scope
0174  * explicitly, promoting them to system scope automatically.
0175  *
0176  * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
0177  * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
0178  */
0179 #define AMDGPU_GEM_CREATE_EXT_COHERENT      (1 << 15)
0180 
0181 struct drm_amdgpu_gem_create_in  {
0182     /** the requested memory size */
0183     __u64 bo_size;
0184     /** physical start_addr alignment in bytes for some HW requirements */
0185     __u64 alignment;
0186     /** the requested memory domains */
0187     __u64 domains;
0188     /** allocation flags */
0189     __u64 domain_flags;
0190 };
0191 
0192 struct drm_amdgpu_gem_create_out  {
0193     /** returned GEM object handle */
0194     __u32 handle;
0195     __u32 _pad;
0196 };
0197 
0198 union drm_amdgpu_gem_create {
0199     struct drm_amdgpu_gem_create_in     in;
0200     struct drm_amdgpu_gem_create_out    out;
0201 };
0202 
0203 /** Opcode to create new residency list.  */
0204 #define AMDGPU_BO_LIST_OP_CREATE    0
0205 /** Opcode to destroy previously created residency list */
0206 #define AMDGPU_BO_LIST_OP_DESTROY   1
0207 /** Opcode to update resource information in the list */
0208 #define AMDGPU_BO_LIST_OP_UPDATE    2
0209 
0210 struct drm_amdgpu_bo_list_in {
0211     /** Type of operation */
0212     __u32 operation;
0213     /** Handle of list or 0 if we want to create one */
0214     __u32 list_handle;
0215     /** Number of BOs in list  */
0216     __u32 bo_number;
0217     /** Size of each element describing BO */
0218     __u32 bo_info_size;
0219     /** Pointer to array describing BOs */
0220     __u64 bo_info_ptr;
0221 };
0222 
0223 struct drm_amdgpu_bo_list_entry {
0224     /** Handle of BO */
0225     __u32 bo_handle;
0226     /** New (if specified) BO priority to be used during migration */
0227     __u32 bo_priority;
0228 };
0229 
0230 struct drm_amdgpu_bo_list_out {
0231     /** Handle of resource list  */
0232     __u32 list_handle;
0233     __u32 _pad;
0234 };
0235 
0236 union drm_amdgpu_bo_list {
0237     struct drm_amdgpu_bo_list_in in;
0238     struct drm_amdgpu_bo_list_out out;
0239 };
0240 
0241 /* context related */
0242 #define AMDGPU_CTX_OP_ALLOC_CTX 1
0243 #define AMDGPU_CTX_OP_FREE_CTX  2
0244 #define AMDGPU_CTX_OP_QUERY_STATE   3
0245 #define AMDGPU_CTX_OP_QUERY_STATE2  4
0246 #define AMDGPU_CTX_OP_GET_STABLE_PSTATE 5
0247 #define AMDGPU_CTX_OP_SET_STABLE_PSTATE 6
0248 
0249 /* GPU reset status */
0250 #define AMDGPU_CTX_NO_RESET     0
0251 /* this the context caused it */
0252 #define AMDGPU_CTX_GUILTY_RESET     1
0253 /* some other context caused it */
0254 #define AMDGPU_CTX_INNOCENT_RESET   2
0255 /* unknown cause */
0256 #define AMDGPU_CTX_UNKNOWN_RESET    3
0257 
0258 /* indicate gpu reset occurred after ctx created */
0259 #define AMDGPU_CTX_QUERY2_FLAGS_RESET    (1<<0)
0260 /* indicate vram lost occurred after ctx created */
0261 #define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)
0262 /* indicate some job from this context once cause gpu hang */
0263 #define AMDGPU_CTX_QUERY2_FLAGS_GUILTY   (1<<2)
0264 /* indicate some errors are detected by RAS */
0265 #define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE   (1<<3)
0266 #define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE   (1<<4)
0267 /* indicate that the reset hasn't completed yet */
0268 #define AMDGPU_CTX_QUERY2_FLAGS_RESET_IN_PROGRESS (1<<5)
0269 
0270 /* Context priority level */
0271 #define AMDGPU_CTX_PRIORITY_UNSET       -2048
0272 #define AMDGPU_CTX_PRIORITY_VERY_LOW    -1023
0273 #define AMDGPU_CTX_PRIORITY_LOW         -512
0274 #define AMDGPU_CTX_PRIORITY_NORMAL      0
0275 /*
0276  * When used in struct drm_amdgpu_ctx_in, a priority above NORMAL requires
0277  * CAP_SYS_NICE or DRM_MASTER
0278 */
0279 #define AMDGPU_CTX_PRIORITY_HIGH        512
0280 #define AMDGPU_CTX_PRIORITY_VERY_HIGH   1023
0281 
0282 /* select a stable profiling pstate for perfmon tools */
0283 #define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK  0xf
0284 #define AMDGPU_CTX_STABLE_PSTATE_NONE  0
0285 #define AMDGPU_CTX_STABLE_PSTATE_STANDARD  1
0286 #define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK  2
0287 #define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK  3
0288 #define AMDGPU_CTX_STABLE_PSTATE_PEAK  4
0289 
0290 struct drm_amdgpu_ctx_in {
0291     /** AMDGPU_CTX_OP_* */
0292     __u32   op;
0293     /** Flags */
0294     __u32   flags;
0295     __u32   ctx_id;
0296     /** AMDGPU_CTX_PRIORITY_* */
0297     __s32   priority;
0298 };
0299 
0300 union drm_amdgpu_ctx_out {
0301         struct {
0302             __u32   ctx_id;
0303             __u32   _pad;
0304         } alloc;
0305 
0306         struct {
0307             /** For future use, no flags defined so far */
0308             __u64   flags;
0309             /** Number of resets caused by this context so far. */
0310             __u32   hangs;
0311             /** Reset status since the last call of the ioctl. */
0312             __u32   reset_status;
0313         } state;
0314 
0315         struct {
0316             __u32   flags;
0317             __u32   _pad;
0318         } pstate;
0319 };
0320 
0321 union drm_amdgpu_ctx {
0322     struct drm_amdgpu_ctx_in in;
0323     union drm_amdgpu_ctx_out out;
0324 };
0325 
0326 /* user queue IOCTL operations */
0327 #define AMDGPU_USERQ_OP_CREATE  1
0328 #define AMDGPU_USERQ_OP_FREE    2
0329 
0330 /* queue priority levels */
0331 #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_MASK  0x3
0332 #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_SHIFT 0
0333 #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_NORMAL_LOW 0
0334 #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_LOW 1
0335 #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_NORMAL_HIGH 2
0336 #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH 3 /* admin only */
0337 /* for queues that need access to protected content */
0338 #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE  (1 << 2)
0339 
0340 /*
0341  * This structure is a container to pass input configuration
0342  * info for all supported userqueue related operations.
0343  * For operation AMDGPU_USERQ_OP_CREATE: user is expected
0344  *  to set all fields, excep the parameter 'queue_id'.
0345  * For operation AMDGPU_USERQ_OP_FREE: the only input parameter expected
0346  *  to be set is 'queue_id', eveything else is ignored.
0347  */
0348 struct drm_amdgpu_userq_in {
0349     /** AMDGPU_USERQ_OP_* */
0350     __u32   op;
0351     /** Queue id passed for operation USERQ_OP_FREE */
0352     __u32   queue_id;
0353     /** the target GPU engine to execute workload (AMDGPU_HW_IP_*) */
0354     __u32   ip_type;
0355     /**
0356      * @doorbell_handle: the handle of doorbell GEM object
0357      * associated to this userqueue client.
0358      */
0359     __u32   doorbell_handle;
0360     /**
0361      * @doorbell_offset: 32-bit offset of the doorbell in the doorbell bo.
0362      * Kernel will generate absolute doorbell offset using doorbell_handle
0363      * and doorbell_offset in the doorbell bo.
0364      */
0365     __u32   doorbell_offset;
0366     /**
0367      * @flags: flags used for queue parameters
0368      */
0369     __u32 flags;
0370 
0371     /**
0372      * @queue_va: Virtual address of the GPU memory which holds the queue
0373      * object. The queue holds the workload packets.
0374      */
0375     __u64   queue_va;
0376     /**
0377      * @queue_size: Size of the queue in bytes, this needs to be 256-byte
0378      * aligned.
0379      */
0380     __u64   queue_size;
0381     /**
0382      * @rptr_va : Virtual address of the GPU memory which holds the ring RPTR.
0383      * This object must be at least 8 byte in size and aligned to 8-byte offset.
0384      */
0385     __u64   rptr_va;
0386     /**
0387      * @wptr_va : Virtual address of the GPU memory which holds the ring WPTR.
0388      * This object must be at least 8 byte in size and aligned to 8-byte offset.
0389      *
0390      * Queue, RPTR and WPTR can come from the same object, as long as the size
0391      * and alignment related requirements are met.
0392      */
0393     __u64   wptr_va;
0394     /**
0395      * @mqd: MQD (memory queue descriptor) is a set of parameters which allow
0396      * the GPU to uniquely define and identify a usermode queue.
0397      *
0398      * MQD data can be of different size for different GPU IP/engine and
0399      * their respective versions/revisions, so this points to a __u64 *
0400      * which holds IP specific MQD of this usermode queue.
0401      */
0402     __u64 mqd;
0403     /**
0404      * @size: size of MQD data in bytes, it must match the MQD structure
0405      * size of the respective engine/revision defined in UAPI for ex, for
0406      * gfx11 workloads, size = sizeof(drm_amdgpu_userq_mqd_gfx11).
0407      */
0408     __u64 mqd_size;
0409 };
0410 
0411 /* The structure to carry output of userqueue ops */
0412 struct drm_amdgpu_userq_out {
0413     /**
0414      * For operation AMDGPU_USERQ_OP_CREATE: This field contains a unique
0415      * queue ID to represent the newly created userqueue in the system, otherwise
0416      * it should be ignored.
0417      */
0418     __u32   queue_id;
0419     __u32   _pad;
0420 };
0421 
0422 union drm_amdgpu_userq {
0423     struct drm_amdgpu_userq_in in;
0424     struct drm_amdgpu_userq_out out;
0425 };
0426 
0427 /* GFX V11 IP specific MQD parameters */
0428 struct drm_amdgpu_userq_mqd_gfx11 {
0429     /**
0430      * @shadow_va: Virtual address of the GPU memory to hold the shadow buffer.
0431      * Use AMDGPU_INFO_IOCTL to find the exact size of the object.
0432      */
0433     __u64   shadow_va;
0434     /**
0435      * @csa_va: Virtual address of the GPU memory to hold the CSA buffer.
0436      * Use AMDGPU_INFO_IOCTL to find the exact size of the object.
0437      */
0438     __u64   csa_va;
0439 };
0440 
0441 /* GFX V11 SDMA IP specific MQD parameters */
0442 struct drm_amdgpu_userq_mqd_sdma_gfx11 {
0443     /**
0444      * @csa_va: Virtual address of the GPU memory to hold the CSA buffer.
0445      * This must be a from a separate GPU object, and use AMDGPU_INFO IOCTL
0446      * to get the size.
0447      */
0448     __u64   csa_va;
0449 };
0450 
0451 /* GFX V11 Compute IP specific MQD parameters */
0452 struct drm_amdgpu_userq_mqd_compute_gfx11 {
0453     /**
0454      * @eop_va: Virtual address of the GPU memory to hold the EOP buffer.
0455      * This must be a from a separate GPU object, and use AMDGPU_INFO IOCTL
0456      * to get the size.
0457      */
0458     __u64   eop_va;
0459 };
0460 
0461 /* userq signal/wait ioctl */
0462 struct drm_amdgpu_userq_signal {
0463     /**
0464      * @queue_id: Queue handle used by the userq fence creation function
0465      * to retrieve the WPTR.
0466      */
0467     __u32   queue_id;
0468     __u32   pad;
0469     /**
0470      * @syncobj_handles: The list of syncobj handles submitted by the user queue
0471      * job to be signaled.
0472      */
0473     __u64   syncobj_handles;
0474     /**
0475      * @num_syncobj_handles: A count that represents the number of syncobj handles in
0476      * @syncobj_handles.
0477      */
0478     __u64   num_syncobj_handles;
0479     /**
0480      * @bo_read_handles: The list of BO handles that the submitted user queue job
0481      * is using for read only. This will update BO fences in the kernel.
0482      */
0483     __u64   bo_read_handles;
0484     /**
0485      * @bo_write_handles: The list of BO handles that the submitted user queue job
0486      * is using for write only. This will update BO fences in the kernel.
0487      */
0488     __u64   bo_write_handles;
0489     /**
0490      * @num_bo_read_handles: A count that represents the number of read BO handles in
0491      * @bo_read_handles.
0492      */
0493     __u32   num_bo_read_handles;
0494     /**
0495      * @num_bo_write_handles: A count that represents the number of write BO handles in
0496      * @bo_write_handles.
0497      */
0498     __u32   num_bo_write_handles;
0499 
0500 };
0501 
0502 struct drm_amdgpu_userq_fence_info {
0503     /**
0504      * @va: A gpu address allocated for each queue which stores the
0505      * read pointer (RPTR) value.
0506      */
0507     __u64   va;
0508     /**
0509      * @value: A 64 bit value represents the write pointer (WPTR) of the
0510      * queue commands which compared with the RPTR value to signal the
0511      * fences.
0512      */
0513     __u64   value;
0514 };
0515 
0516 struct drm_amdgpu_userq_wait {
0517     /**
0518      * @waitq_id: Queue handle used by the userq wait IOCTL to retrieve the
0519      * wait queue and maintain the fence driver references in it.
0520      */
0521     __u32   waitq_id;
0522     __u32   pad;
0523     /**
0524      * @syncobj_handles: The list of syncobj handles submitted by the user queue
0525      * job to get the va/value pairs.
0526      */
0527     __u64   syncobj_handles;
0528     /**
0529      * @syncobj_timeline_handles: The list of timeline syncobj handles submitted by
0530      * the user queue job to get the va/value pairs at given @syncobj_timeline_points.
0531      */
0532     __u64   syncobj_timeline_handles;
0533     /**
0534      * @syncobj_timeline_points: The list of timeline syncobj points submitted by the
0535      * user queue job for the corresponding @syncobj_timeline_handles.
0536      */
0537     __u64   syncobj_timeline_points;
0538     /**
0539      * @bo_read_handles: The list of read BO handles submitted by the user queue
0540      * job to get the va/value pairs.
0541      */
0542     __u64   bo_read_handles;
0543     /**
0544      * @bo_write_handles: The list of write BO handles submitted by the user queue
0545      * job to get the va/value pairs.
0546      */
0547     __u64   bo_write_handles;
0548     /**
0549      * @num_syncobj_timeline_handles: A count that represents the number of timeline
0550      * syncobj handles in @syncobj_timeline_handles.
0551      */
0552     __u16   num_syncobj_timeline_handles;
0553     /**
0554      * @num_fences: This field can be used both as input and output. As input it defines
0555      * the maximum number of fences that can be returned and as output it will specify
0556      * how many fences were actually returned from the ioctl.
0557      */
0558     __u16   num_fences;
0559     /**
0560      * @num_syncobj_handles: A count that represents the number of syncobj handles in
0561      * @syncobj_handles.
0562      */
0563     __u32   num_syncobj_handles;
0564     /**
0565      * @num_bo_read_handles: A count that represents the number of read BO handles in
0566      * @bo_read_handles.
0567      */
0568     __u32   num_bo_read_handles;
0569     /**
0570      * @num_bo_write_handles: A count that represents the number of write BO handles in
0571      * @bo_write_handles.
0572      */
0573     __u32   num_bo_write_handles;
0574     /**
0575      * @out_fences: The field is a return value from the ioctl containing the list of
0576      * address/value pairs to wait for.
0577      */
0578     __u64   out_fences;
0579 };
0580 
0581 /* vm ioctl */
0582 #define AMDGPU_VM_OP_RESERVE_VMID   1
0583 #define AMDGPU_VM_OP_UNRESERVE_VMID 2
0584 
0585 struct drm_amdgpu_vm_in {
0586     /** AMDGPU_VM_OP_* */
0587     __u32   op;
0588     __u32   flags;
0589 };
0590 
0591 struct drm_amdgpu_vm_out {
0592     /** For future use, no flags defined so far */
0593     __u64   flags;
0594 };
0595 
0596 union drm_amdgpu_vm {
0597     struct drm_amdgpu_vm_in in;
0598     struct drm_amdgpu_vm_out out;
0599 };
0600 
0601 /* sched ioctl */
0602 #define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE   1
0603 #define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE   2
0604 
0605 struct drm_amdgpu_sched_in {
0606     /* AMDGPU_SCHED_OP_* */
0607     __u32   op;
0608     __u32   fd;
0609     /** AMDGPU_CTX_PRIORITY_* */
0610     __s32   priority;
0611     __u32   ctx_id;
0612 };
0613 
0614 union drm_amdgpu_sched {
0615     struct drm_amdgpu_sched_in in;
0616 };
0617 
0618 /*
0619  * This is not a reliable API and you should expect it to fail for any
0620  * number of reasons and have fallback path that do not use userptr to
0621  * perform any operation.
0622  */
0623 #define AMDGPU_GEM_USERPTR_READONLY (1 << 0)
0624 #define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)
0625 #define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)
0626 #define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)
0627 
0628 struct drm_amdgpu_gem_userptr {
0629     __u64       addr;
0630     __u64       size;
0631     /* AMDGPU_GEM_USERPTR_* */
0632     __u32       flags;
0633     /* Resulting GEM handle */
0634     __u32       handle;
0635 };
0636 
0637 /* SI-CI-VI: */
0638 /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */
0639 #define AMDGPU_TILING_ARRAY_MODE_SHIFT          0
0640 #define AMDGPU_TILING_ARRAY_MODE_MASK           0xf
0641 #define AMDGPU_TILING_PIPE_CONFIG_SHIFT         4
0642 #define AMDGPU_TILING_PIPE_CONFIG_MASK          0x1f
0643 #define AMDGPU_TILING_TILE_SPLIT_SHIFT          9
0644 #define AMDGPU_TILING_TILE_SPLIT_MASK           0x7
0645 #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT     12
0646 #define AMDGPU_TILING_MICRO_TILE_MODE_MASK      0x7
0647 #define AMDGPU_TILING_BANK_WIDTH_SHIFT          15
0648 #define AMDGPU_TILING_BANK_WIDTH_MASK           0x3
0649 #define AMDGPU_TILING_BANK_HEIGHT_SHIFT         17
0650 #define AMDGPU_TILING_BANK_HEIGHT_MASK          0x3
0651 #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT       19
0652 #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK        0x3
0653 #define AMDGPU_TILING_NUM_BANKS_SHIFT           21
0654 #define AMDGPU_TILING_NUM_BANKS_MASK            0x3
0655 
0656 /* GFX9 - GFX11: */
0657 #define AMDGPU_TILING_SWIZZLE_MODE_SHIFT        0
0658 #define AMDGPU_TILING_SWIZZLE_MODE_MASK         0x1f
0659 #define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT     5
0660 #define AMDGPU_TILING_DCC_OFFSET_256B_MASK      0xFFFFFF
0661 #define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT       29
0662 #define AMDGPU_TILING_DCC_PITCH_MAX_MASK        0x3FFF
0663 #define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT     43
0664 #define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK      0x1
0665 #define AMDGPU_TILING_DCC_INDEPENDENT_128B_SHIFT    44
0666 #define AMDGPU_TILING_DCC_INDEPENDENT_128B_MASK     0x1
0667 #define AMDGPU_TILING_SCANOUT_SHIFT         63
0668 #define AMDGPU_TILING_SCANOUT_MASK          0x1
0669 
0670 /* GFX12 and later: */
0671 #define AMDGPU_TILING_GFX12_SWIZZLE_MODE_SHIFT          0
0672 #define AMDGPU_TILING_GFX12_SWIZZLE_MODE_MASK           0x7
0673 /* These are DCC recompression setting for memory management: */
0674 #define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_SHIFT  3
0675 #define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_MASK   0x3 /* 0:64B, 1:128B, 2:256B */
0676 #define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_SHIFT       5
0677 #define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_MASK        0x7 /* CB_COLOR0_INFO.NUMBER_TYPE */
0678 #define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_SHIFT       8
0679 #define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_MASK        0x3f /* [0:4]:CB_COLOR0_INFO.FORMAT, [5]:MM */
0680 
0681 /* Set/Get helpers for tiling flags. */
0682 #define AMDGPU_TILING_SET(field, value) \
0683     (((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
0684 #define AMDGPU_TILING_GET(value, field) \
0685     (((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
0686 
0687 #define AMDGPU_GEM_METADATA_OP_SET_METADATA                  1
0688 #define AMDGPU_GEM_METADATA_OP_GET_METADATA                  2
0689 
0690 /** The same structure is shared for input/output */
0691 struct drm_amdgpu_gem_metadata {
0692     /** GEM Object handle */
0693     __u32   handle;
0694     /** Do we want get or set metadata */
0695     __u32   op;
0696     struct {
0697         /** For future use, no flags defined so far */
0698         __u64   flags;
0699         /** family specific tiling info */
0700         __u64   tiling_info;
0701         __u32   data_size_bytes;
0702         __u32   data[64];
0703     } data;
0704 };
0705 
0706 struct drm_amdgpu_gem_mmap_in {
0707     /** the GEM object handle */
0708     __u32 handle;
0709     __u32 _pad;
0710 };
0711 
0712 struct drm_amdgpu_gem_mmap_out {
0713     /** mmap offset from the vma offset manager */
0714     __u64 addr_ptr;
0715 };
0716 
0717 union drm_amdgpu_gem_mmap {
0718     struct drm_amdgpu_gem_mmap_in   in;
0719     struct drm_amdgpu_gem_mmap_out out;
0720 };
0721 
0722 struct drm_amdgpu_gem_wait_idle_in {
0723     /** GEM object handle */
0724     __u32 handle;
0725     /** For future use, no flags defined so far */
0726     __u32 flags;
0727     /** Absolute timeout to wait */
0728     __u64 timeout;
0729 };
0730 
0731 struct drm_amdgpu_gem_wait_idle_out {
0732     /** BO status:  0 - BO is idle, 1 - BO is busy */
0733     __u32 status;
0734     /** Returned current memory domain */
0735     __u32 domain;
0736 };
0737 
0738 union drm_amdgpu_gem_wait_idle {
0739     struct drm_amdgpu_gem_wait_idle_in  in;
0740     struct drm_amdgpu_gem_wait_idle_out out;
0741 };
0742 
0743 struct drm_amdgpu_wait_cs_in {
0744     /* Command submission handle
0745          * handle equals 0 means none to wait for
0746          * handle equals ~0ull means wait for the latest sequence number
0747          */
0748     __u64 handle;
0749     /** Absolute timeout to wait */
0750     __u64 timeout;
0751     __u32 ip_type;
0752     __u32 ip_instance;
0753     __u32 ring;
0754     __u32 ctx_id;
0755 };
0756 
0757 struct drm_amdgpu_wait_cs_out {
0758     /** CS status:  0 - CS completed, 1 - CS still busy */
0759     __u64 status;
0760 };
0761 
0762 union drm_amdgpu_wait_cs {
0763     struct drm_amdgpu_wait_cs_in in;
0764     struct drm_amdgpu_wait_cs_out out;
0765 };
0766 
0767 struct drm_amdgpu_fence {
0768     __u32 ctx_id;
0769     __u32 ip_type;
0770     __u32 ip_instance;
0771     __u32 ring;
0772     __u64 seq_no;
0773 };
0774 
0775 struct drm_amdgpu_wait_fences_in {
0776     /** This points to uint64_t * which points to fences */
0777     __u64 fences;
0778     __u32 fence_count;
0779     __u32 wait_all;
0780     __u64 timeout_ns;
0781 };
0782 
0783 struct drm_amdgpu_wait_fences_out {
0784     __u32 status;
0785     __u32 first_signaled;
0786 };
0787 
0788 union drm_amdgpu_wait_fences {
0789     struct drm_amdgpu_wait_fences_in in;
0790     struct drm_amdgpu_wait_fences_out out;
0791 };
0792 
0793 #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO   0
0794 #define AMDGPU_GEM_OP_SET_PLACEMENT     1
0795 
0796 /* Sets or returns a value associated with a buffer. */
0797 struct drm_amdgpu_gem_op {
0798     /** GEM object handle */
0799     __u32   handle;
0800     /** AMDGPU_GEM_OP_* */
0801     __u32   op;
0802     /** Input or return value */
0803     __u64   value;
0804 };
0805 
0806 #define AMDGPU_VA_OP_MAP            1
0807 #define AMDGPU_VA_OP_UNMAP          2
0808 #define AMDGPU_VA_OP_CLEAR          3
0809 #define AMDGPU_VA_OP_REPLACE            4
0810 
0811 /* Delay the page table update till the next CS */
0812 #define AMDGPU_VM_DELAY_UPDATE      (1 << 0)
0813 
0814 /* Mapping flags */
0815 /* readable mapping */
0816 #define AMDGPU_VM_PAGE_READABLE     (1 << 1)
0817 /* writable mapping */
0818 #define AMDGPU_VM_PAGE_WRITEABLE    (1 << 2)
0819 /* executable mapping, new for VI */
0820 #define AMDGPU_VM_PAGE_EXECUTABLE   (1 << 3)
0821 /* partially resident texture */
0822 #define AMDGPU_VM_PAGE_PRT      (1 << 4)
0823 /* MTYPE flags use bit 5 to 8 */
0824 #define AMDGPU_VM_MTYPE_MASK        (0xf << 5)
0825 /* Default MTYPE. Pre-AI must use this.  Recommended for newer ASICs. */
0826 #define AMDGPU_VM_MTYPE_DEFAULT     (0 << 5)
0827 /* Use Non Coherent MTYPE instead of default MTYPE */
0828 #define AMDGPU_VM_MTYPE_NC      (1 << 5)
0829 /* Use Write Combine MTYPE instead of default MTYPE */
0830 #define AMDGPU_VM_MTYPE_WC      (2 << 5)
0831 /* Use Cache Coherent MTYPE instead of default MTYPE */
0832 #define AMDGPU_VM_MTYPE_CC      (3 << 5)
0833 /* Use UnCached MTYPE instead of default MTYPE */
0834 #define AMDGPU_VM_MTYPE_UC      (4 << 5)
0835 /* Use Read Write MTYPE instead of default MTYPE */
0836 #define AMDGPU_VM_MTYPE_RW      (5 << 5)
0837 /* don't allocate MALL */
0838 #define AMDGPU_VM_PAGE_NOALLOC      (1 << 9)
0839 
0840 struct drm_amdgpu_gem_va {
0841     /** GEM object handle */
0842     __u32 handle;
0843     __u32 _pad;
0844     /** AMDGPU_VA_OP_* */
0845     __u32 operation;
0846     /** AMDGPU_VM_PAGE_* */
0847     __u32 flags;
0848     /** va address to assign . Must be correctly aligned.*/
0849     __u64 va_address;
0850     /** Specify offset inside of BO to assign. Must be correctly aligned.*/
0851     __u64 offset_in_bo;
0852     /** Specify mapping size. Must be correctly aligned. */
0853     __u64 map_size;
0854     /**
0855      * vm_timeline_point is a sequence number used to add new timeline point.
0856      */
0857     __u64 vm_timeline_point;
0858     /**
0859      * The vm page table update fence is installed in given vm_timeline_syncobj_out
0860      * at vm_timeline_point.
0861      */
0862     __u32 vm_timeline_syncobj_out;
0863     /** the number of syncobj handles in @input_fence_syncobj_handles */
0864     __u32 num_syncobj_handles;
0865     /** Array of sync object handle to wait for given input fences */
0866     __u64 input_fence_syncobj_handles;
0867 };
0868 
0869 #define AMDGPU_HW_IP_GFX          0
0870 #define AMDGPU_HW_IP_COMPUTE      1
0871 #define AMDGPU_HW_IP_DMA          2
0872 #define AMDGPU_HW_IP_UVD          3
0873 #define AMDGPU_HW_IP_VCE          4
0874 #define AMDGPU_HW_IP_UVD_ENC      5
0875 #define AMDGPU_HW_IP_VCN_DEC      6
0876 /*
0877  * From VCN4, AMDGPU_HW_IP_VCN_ENC is re-used to support
0878  * both encoding and decoding jobs.
0879  */
0880 #define AMDGPU_HW_IP_VCN_ENC      7
0881 #define AMDGPU_HW_IP_VCN_JPEG     8
0882 #define AMDGPU_HW_IP_VPE          9
0883 #define AMDGPU_HW_IP_NUM          10
0884 
0885 #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
0886 
0887 #define AMDGPU_CHUNK_ID_IB      0x01
0888 #define AMDGPU_CHUNK_ID_FENCE       0x02
0889 #define AMDGPU_CHUNK_ID_DEPENDENCIES    0x03
0890 #define AMDGPU_CHUNK_ID_SYNCOBJ_IN      0x04
0891 #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT     0x05
0892 #define AMDGPU_CHUNK_ID_BO_HANDLES      0x06
0893 #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES  0x07
0894 #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
0895 #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
0896 #define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
0897 
0898 struct drm_amdgpu_cs_chunk {
0899     __u32       chunk_id;
0900     __u32       length_dw;
0901     __u64       chunk_data;
0902 };
0903 
0904 struct drm_amdgpu_cs_in {
0905     /** Rendering context id */
0906     __u32       ctx_id;
0907     /**  Handle of resource list associated with CS */
0908     __u32       bo_list_handle;
0909     __u32       num_chunks;
0910     __u32       flags;
0911     /** this points to __u64 * which point to cs chunks */
0912     __u64       chunks;
0913 };
0914 
0915 struct drm_amdgpu_cs_out {
0916     __u64 handle;
0917 };
0918 
0919 union drm_amdgpu_cs {
0920     struct drm_amdgpu_cs_in in;
0921     struct drm_amdgpu_cs_out out;
0922 };
0923 
0924 /* Specify flags to be used for IB */
0925 
0926 /* This IB should be submitted to CE */
0927 #define AMDGPU_IB_FLAG_CE   (1<<0)
0928 
0929 /* Preamble flag, which means the IB could be dropped if no context switch */
0930 #define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
0931 
0932 /* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */
0933 #define AMDGPU_IB_FLAG_PREEMPT (1<<2)
0934 
0935 /* The IB fence should do the L2 writeback but not invalidate any shader
0936  * caches (L2/vL1/sL1/I$). */
0937 #define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3)
0938 
0939 /* Set GDS_COMPUTE_MAX_WAVE_ID = DEFAULT before PACKET3_INDIRECT_BUFFER.
0940  * This will reset wave ID counters for the IB.
0941  */
0942 #define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4)
0943 
0944 /* Flag the IB as secure (TMZ)
0945  */
0946 #define AMDGPU_IB_FLAGS_SECURE  (1 << 5)
0947 
0948 /* Tell KMD to flush and invalidate caches
0949  */
0950 #define AMDGPU_IB_FLAG_EMIT_MEM_SYNC  (1 << 6)
0951 
0952 struct drm_amdgpu_cs_chunk_ib {
0953     __u32 _pad;
0954     /** AMDGPU_IB_FLAG_* */
0955     __u32 flags;
0956     /** Virtual address to begin IB execution */
0957     __u64 va_start;
0958     /** Size of submission */
0959     __u32 ib_bytes;
0960     /** HW IP to submit to */
0961     __u32 ip_type;
0962     /** HW IP index of the same type to submit to  */
0963     __u32 ip_instance;
0964     /** Ring index to submit to */
0965     __u32 ring;
0966 };
0967 
0968 struct drm_amdgpu_cs_chunk_dep {
0969     __u32 ip_type;
0970     __u32 ip_instance;
0971     __u32 ring;
0972     __u32 ctx_id;
0973     __u64 handle;
0974 };
0975 
0976 struct drm_amdgpu_cs_chunk_fence {
0977     __u32 handle;
0978     __u32 offset;
0979 };
0980 
0981 struct drm_amdgpu_cs_chunk_sem {
0982     __u32 handle;
0983 };
0984 
0985 struct drm_amdgpu_cs_chunk_syncobj {
0986        __u32 handle;
0987        __u32 flags;
0988        __u64 point;
0989 };
0990 
0991 #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ  0
0992 #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD   1
0993 #define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2
0994 
0995 union drm_amdgpu_fence_to_handle {
0996     struct {
0997         struct drm_amdgpu_fence fence;
0998         __u32 what;
0999         __u32 pad;
1000     } in;
1001     struct {
1002         __u32 handle;
1003     } out;
1004 };
1005 
1006 struct drm_amdgpu_cs_chunk_data {
1007     union {
1008         struct drm_amdgpu_cs_chunk_ib       ib_data;
1009         struct drm_amdgpu_cs_chunk_fence    fence_data;
1010     };
1011 };
1012 
1013 #define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW         0x1
1014 
1015 struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
1016     __u64 shadow_va;
1017     __u64 csa_va;
1018     __u64 gds_va;
1019     __u64 flags;
1020 };
1021 
1022 /*
1023  *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
1024  *
1025  */
1026 #define AMDGPU_IDS_FLAGS_FUSION         0x1
1027 #define AMDGPU_IDS_FLAGS_PREEMPTION     0x2
1028 #define AMDGPU_IDS_FLAGS_TMZ            0x4
1029 #define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x8
1030 
1031 /*
1032  *  Query h/w info: Flag identifying VF/PF/PT mode
1033  *
1034  */
1035 #define AMDGPU_IDS_FLAGS_MODE_MASK      0x300
1036 #define AMDGPU_IDS_FLAGS_MODE_SHIFT     0x8
1037 #define AMDGPU_IDS_FLAGS_MODE_PF        0x0
1038 #define AMDGPU_IDS_FLAGS_MODE_VF        0x1
1039 #define AMDGPU_IDS_FLAGS_MODE_PT        0x2
1040 
1041 /* indicate if acceleration can be working */
1042 #define AMDGPU_INFO_ACCEL_WORKING       0x00
1043 /* get the crtc_id from the mode object id? */
1044 #define AMDGPU_INFO_CRTC_FROM_ID        0x01
1045 /* query hw IP info */
1046 #define AMDGPU_INFO_HW_IP_INFO          0x02
1047 /* query hw IP instance count for the specified type */
1048 #define AMDGPU_INFO_HW_IP_COUNT         0x03
1049 /* timestamp for GL_ARB_timer_query */
1050 #define AMDGPU_INFO_TIMESTAMP           0x05
1051 /* Query the firmware version */
1052 #define AMDGPU_INFO_FW_VERSION          0x0e
1053     /* Subquery id: Query VCE firmware version */
1054     #define AMDGPU_INFO_FW_VCE      0x1
1055     /* Subquery id: Query UVD firmware version */
1056     #define AMDGPU_INFO_FW_UVD      0x2
1057     /* Subquery id: Query GMC firmware version */
1058     #define AMDGPU_INFO_FW_GMC      0x03
1059     /* Subquery id: Query GFX ME firmware version */
1060     #define AMDGPU_INFO_FW_GFX_ME       0x04
1061     /* Subquery id: Query GFX PFP firmware version */
1062     #define AMDGPU_INFO_FW_GFX_PFP      0x05
1063     /* Subquery id: Query GFX CE firmware version */
1064     #define AMDGPU_INFO_FW_GFX_CE       0x06
1065     /* Subquery id: Query GFX RLC firmware version */
1066     #define AMDGPU_INFO_FW_GFX_RLC      0x07
1067     /* Subquery id: Query GFX MEC firmware version */
1068     #define AMDGPU_INFO_FW_GFX_MEC      0x08
1069     /* Subquery id: Query SMC firmware version */
1070     #define AMDGPU_INFO_FW_SMC      0x0a
1071     /* Subquery id: Query SDMA firmware version */
1072     #define AMDGPU_INFO_FW_SDMA     0x0b
1073     /* Subquery id: Query PSP SOS firmware version */
1074     #define AMDGPU_INFO_FW_SOS      0x0c
1075     /* Subquery id: Query PSP ASD firmware version */
1076     #define AMDGPU_INFO_FW_ASD      0x0d
1077     /* Subquery id: Query VCN firmware version */
1078     #define AMDGPU_INFO_FW_VCN      0x0e
1079     /* Subquery id: Query GFX RLC SRLC firmware version */
1080     #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f
1081     /* Subquery id: Query GFX RLC SRLG firmware version */
1082     #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10
1083     /* Subquery id: Query GFX RLC SRLS firmware version */
1084     #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11
1085     /* Subquery id: Query DMCU firmware version */
1086     #define AMDGPU_INFO_FW_DMCU     0x12
1087     #define AMDGPU_INFO_FW_TA       0x13
1088     /* Subquery id: Query DMCUB firmware version */
1089     #define AMDGPU_INFO_FW_DMCUB        0x14
1090     /* Subquery id: Query TOC firmware version */
1091     #define AMDGPU_INFO_FW_TOC      0x15
1092     /* Subquery id: Query CAP firmware version */
1093     #define AMDGPU_INFO_FW_CAP      0x16
1094     /* Subquery id: Query GFX RLCP firmware version */
1095     #define AMDGPU_INFO_FW_GFX_RLCP     0x17
1096     /* Subquery id: Query GFX RLCV firmware version */
1097     #define AMDGPU_INFO_FW_GFX_RLCV     0x18
1098     /* Subquery id: Query MES_KIQ firmware version */
1099     #define AMDGPU_INFO_FW_MES_KIQ      0x19
1100     /* Subquery id: Query MES firmware version */
1101     #define AMDGPU_INFO_FW_MES      0x1a
1102     /* Subquery id: Query IMU firmware version */
1103     #define AMDGPU_INFO_FW_IMU      0x1b
1104     /* Subquery id: Query VPE firmware version */
1105     #define AMDGPU_INFO_FW_VPE      0x1c
1106 
1107 /* number of bytes moved for TTM migration */
1108 #define AMDGPU_INFO_NUM_BYTES_MOVED     0x0f
1109 /* the used VRAM size */
1110 #define AMDGPU_INFO_VRAM_USAGE          0x10
1111 /* the used GTT size */
1112 #define AMDGPU_INFO_GTT_USAGE           0x11
1113 /* Information about GDS, etc. resource configuration */
1114 #define AMDGPU_INFO_GDS_CONFIG          0x13
1115 /* Query information about VRAM and GTT domains */
1116 #define AMDGPU_INFO_VRAM_GTT            0x14
1117 /* Query information about register in MMR address space*/
1118 #define AMDGPU_INFO_READ_MMR_REG        0x15
1119 /* Query information about device: rev id, family, etc. */
1120 #define AMDGPU_INFO_DEV_INFO            0x16
1121 /* visible vram usage */
1122 #define AMDGPU_INFO_VIS_VRAM_USAGE      0x17
1123 /* number of TTM buffer evictions */
1124 #define AMDGPU_INFO_NUM_EVICTIONS       0x18
1125 /* Query memory about VRAM and GTT domains */
1126 #define AMDGPU_INFO_MEMORY          0x19
1127 /* Query vce clock table */
1128 #define AMDGPU_INFO_VCE_CLOCK_TABLE     0x1A
1129 /* Query vbios related information */
1130 #define AMDGPU_INFO_VBIOS           0x1B
1131     /* Subquery id: Query vbios size */
1132     #define AMDGPU_INFO_VBIOS_SIZE      0x1
1133     /* Subquery id: Query vbios image */
1134     #define AMDGPU_INFO_VBIOS_IMAGE     0x2
1135     /* Subquery id: Query vbios info */
1136     #define AMDGPU_INFO_VBIOS_INFO      0x3
1137 /* Query UVD handles */
1138 #define AMDGPU_INFO_NUM_HANDLES         0x1C
1139 /* Query sensor related information */
1140 #define AMDGPU_INFO_SENSOR          0x1D
1141     /* Subquery id: Query GPU shader clock */
1142     #define AMDGPU_INFO_SENSOR_GFX_SCLK     0x1
1143     /* Subquery id: Query GPU memory clock */
1144     #define AMDGPU_INFO_SENSOR_GFX_MCLK     0x2
1145     /* Subquery id: Query GPU temperature */
1146     #define AMDGPU_INFO_SENSOR_GPU_TEMP     0x3
1147     /* Subquery id: Query GPU load */
1148     #define AMDGPU_INFO_SENSOR_GPU_LOAD     0x4
1149     /* Subquery id: Query average GPU power */
1150     #define AMDGPU_INFO_SENSOR_GPU_AVG_POWER    0x5
1151     /* Subquery id: Query northbridge voltage */
1152     #define AMDGPU_INFO_SENSOR_VDDNB        0x6
1153     /* Subquery id: Query graphics voltage */
1154     #define AMDGPU_INFO_SENSOR_VDDGFX       0x7
1155     /* Subquery id: Query GPU stable pstate shader clock */
1156     #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK       0x8
1157     /* Subquery id: Query GPU stable pstate memory clock */
1158     #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK       0x9
1159     /* Subquery id: Query GPU peak pstate shader clock */
1160     #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_SCLK         0xa
1161     /* Subquery id: Query GPU peak pstate memory clock */
1162     #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_MCLK         0xb
1163     /* Subquery id: Query input GPU power   */
1164     #define AMDGPU_INFO_SENSOR_GPU_INPUT_POWER  0xc
1165 /* Number of VRAM page faults on CPU access. */
1166 #define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS    0x1E
1167 #define AMDGPU_INFO_VRAM_LOST_COUNTER       0x1F
1168 /* query ras mask of enabled features*/
1169 #define AMDGPU_INFO_RAS_ENABLED_FEATURES    0x20
1170 /* RAS MASK: UMC (VRAM) */
1171 #define AMDGPU_INFO_RAS_ENABLED_UMC         (1 << 0)
1172 /* RAS MASK: SDMA */
1173 #define AMDGPU_INFO_RAS_ENABLED_SDMA            (1 << 1)
1174 /* RAS MASK: GFX */
1175 #define AMDGPU_INFO_RAS_ENABLED_GFX         (1 << 2)
1176 /* RAS MASK: MMHUB */
1177 #define AMDGPU_INFO_RAS_ENABLED_MMHUB           (1 << 3)
1178 /* RAS MASK: ATHUB */
1179 #define AMDGPU_INFO_RAS_ENABLED_ATHUB           (1 << 4)
1180 /* RAS MASK: PCIE */
1181 #define AMDGPU_INFO_RAS_ENABLED_PCIE            (1 << 5)
1182 /* RAS MASK: HDP */
1183 #define AMDGPU_INFO_RAS_ENABLED_HDP         (1 << 6)
1184 /* RAS MASK: XGMI */
1185 #define AMDGPU_INFO_RAS_ENABLED_XGMI            (1 << 7)
1186 /* RAS MASK: DF */
1187 #define AMDGPU_INFO_RAS_ENABLED_DF          (1 << 8)
1188 /* RAS MASK: SMN */
1189 #define AMDGPU_INFO_RAS_ENABLED_SMN         (1 << 9)
1190 /* RAS MASK: SEM */
1191 #define AMDGPU_INFO_RAS_ENABLED_SEM         (1 << 10)
1192 /* RAS MASK: MP0 */
1193 #define AMDGPU_INFO_RAS_ENABLED_MP0         (1 << 11)
1194 /* RAS MASK: MP1 */
1195 #define AMDGPU_INFO_RAS_ENABLED_MP1         (1 << 12)
1196 /* RAS MASK: FUSE */
1197 #define AMDGPU_INFO_RAS_ENABLED_FUSE            (1 << 13)
1198 /* query video encode/decode caps */
1199 #define AMDGPU_INFO_VIDEO_CAPS          0x21
1200     /* Subquery id: Decode */
1201     #define AMDGPU_INFO_VIDEO_CAPS_DECODE       0
1202     /* Subquery id: Encode */
1203     #define AMDGPU_INFO_VIDEO_CAPS_ENCODE       1
1204 /* Query the max number of IBs per gang per submission */
1205 #define AMDGPU_INFO_MAX_IBS         0x22
1206 /* query last page fault info */
1207 #define AMDGPU_INFO_GPUVM_FAULT         0x23
1208 /* query FW object size and alignment */
1209 #define AMDGPU_INFO_UQ_FW_AREAS         0x24
1210 
1211 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT  0
1212 #define AMDGPU_INFO_MMR_SE_INDEX_MASK   0xff
1213 #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT  8
1214 #define AMDGPU_INFO_MMR_SH_INDEX_MASK   0xff
1215 
1216 struct drm_amdgpu_query_fw {
1217     /** AMDGPU_INFO_FW_* */
1218     __u32 fw_type;
1219     /**
1220      * Index of the IP if there are more IPs of
1221      * the same type.
1222      */
1223     __u32 ip_instance;
1224     /**
1225      * Index of the engine. Whether this is used depends
1226      * on the firmware type. (e.g. MEC, SDMA)
1227      */
1228     __u32 index;
1229     __u32 _pad;
1230 };
1231 
1232 /* Input structure for the INFO ioctl */
1233 struct drm_amdgpu_info {
1234     /* Where the return value will be stored */
1235     __u64 return_pointer;
1236     /* The size of the return value. Just like "size" in "snprintf",
1237      * it limits how many bytes the kernel can write. */
1238     __u32 return_size;
1239     /* The query request id. */
1240     __u32 query;
1241 
1242     union {
1243         struct {
1244             __u32 id;
1245             __u32 _pad;
1246         } mode_crtc;
1247 
1248         struct {
1249             /** AMDGPU_HW_IP_* */
1250             __u32 type;
1251             /**
1252              * Index of the IP if there are more IPs of the same
1253              * type. Ignored by AMDGPU_INFO_HW_IP_COUNT.
1254              */
1255             __u32 ip_instance;
1256         } query_hw_ip;
1257 
1258         struct {
1259             __u32 dword_offset;
1260             /** number of registers to read */
1261             __u32 count;
1262             __u32 instance;
1263             /** For future use, no flags defined so far */
1264             __u32 flags;
1265         } read_mmr_reg;
1266 
1267         struct drm_amdgpu_query_fw query_fw;
1268 
1269         struct {
1270             __u32 type;
1271             __u32 offset;
1272         } vbios_info;
1273 
1274         struct {
1275             __u32 type;
1276         } sensor_info;
1277 
1278         struct {
1279             __u32 type;
1280         } video_cap;
1281     };
1282 };
1283 
1284 struct drm_amdgpu_info_gds {
1285     /** GDS GFX partition size */
1286     __u32 gds_gfx_partition_size;
1287     /** GDS compute partition size */
1288     __u32 compute_partition_size;
1289     /** total GDS memory size */
1290     __u32 gds_total_size;
1291     /** GWS size per GFX partition */
1292     __u32 gws_per_gfx_partition;
1293     /** GSW size per compute partition */
1294     __u32 gws_per_compute_partition;
1295     /** OA size per GFX partition */
1296     __u32 oa_per_gfx_partition;
1297     /** OA size per compute partition */
1298     __u32 oa_per_compute_partition;
1299     __u32 _pad;
1300 };
1301 
1302 struct drm_amdgpu_info_vram_gtt {
1303     __u64 vram_size;
1304     __u64 vram_cpu_accessible_size;
1305     __u64 gtt_size;
1306 };
1307 
1308 struct drm_amdgpu_heap_info {
1309     /** max. physical memory */
1310     __u64 total_heap_size;
1311 
1312     /** Theoretical max. available memory in the given heap */
1313     __u64 usable_heap_size;
1314 
1315     /**
1316      * Number of bytes allocated in the heap. This includes all processes
1317      * and private allocations in the kernel. It changes when new buffers
1318      * are allocated, freed, and moved. It cannot be larger than
1319      * heap_size.
1320      */
1321     __u64 heap_usage;
1322 
1323     /**
1324      * Theoretical possible max. size of buffer which
1325      * could be allocated in the given heap
1326      */
1327     __u64 max_allocation;
1328 };
1329 
1330 struct drm_amdgpu_memory_info {
1331     struct drm_amdgpu_heap_info vram;
1332     struct drm_amdgpu_heap_info cpu_accessible_vram;
1333     struct drm_amdgpu_heap_info gtt;
1334 };
1335 
1336 struct drm_amdgpu_info_firmware {
1337     __u32 ver;
1338     __u32 feature;
1339 };
1340 
1341 struct drm_amdgpu_info_vbios {
1342     __u8 name[64];
1343     __u8 vbios_pn[64];
1344     __u32 version;
1345     __u32 pad;
1346     __u8 vbios_ver_str[32];
1347     __u8 date[32];
1348 };
1349 
1350 #define AMDGPU_VRAM_TYPE_UNKNOWN 0
1351 #define AMDGPU_VRAM_TYPE_GDDR1 1
1352 #define AMDGPU_VRAM_TYPE_DDR2  2
1353 #define AMDGPU_VRAM_TYPE_GDDR3 3
1354 #define AMDGPU_VRAM_TYPE_GDDR4 4
1355 #define AMDGPU_VRAM_TYPE_GDDR5 5
1356 #define AMDGPU_VRAM_TYPE_HBM   6
1357 #define AMDGPU_VRAM_TYPE_DDR3  7
1358 #define AMDGPU_VRAM_TYPE_DDR4  8
1359 #define AMDGPU_VRAM_TYPE_GDDR6 9
1360 #define AMDGPU_VRAM_TYPE_DDR5  10
1361 #define AMDGPU_VRAM_TYPE_LPDDR4 11
1362 #define AMDGPU_VRAM_TYPE_LPDDR5 12
1363 
1364 struct drm_amdgpu_info_device {
1365     /** PCI Device ID */
1366     __u32 device_id;
1367     /** Internal chip revision: A0, A1, etc.) */
1368     __u32 chip_rev;
1369     __u32 external_rev;
1370     /** Revision id in PCI Config space */
1371     __u32 pci_rev;
1372     __u32 family;
1373     __u32 num_shader_engines;
1374     __u32 num_shader_arrays_per_engine;
1375     /* in KHz */
1376     __u32 gpu_counter_freq;
1377     __u64 max_engine_clock;
1378     __u64 max_memory_clock;
1379     /* cu information */
1380     __u32 cu_active_number;
1381     /* NOTE: cu_ao_mask is INVALID, DON'T use it */
1382     __u32 cu_ao_mask;
1383     __u32 cu_bitmap[4][4];
1384     /** Render backend pipe mask. One render backend is CB+DB. */
1385     __u32 enabled_rb_pipes_mask;
1386     __u32 num_rb_pipes;
1387     __u32 num_hw_gfx_contexts;
1388     /* PCIe version (the smaller of the GPU and the CPU/motherboard) */
1389     __u32 pcie_gen;
1390     __u64 ids_flags;
1391     /** Starting virtual address for UMDs. */
1392     __u64 virtual_address_offset;
1393     /** The maximum virtual address */
1394     __u64 virtual_address_max;
1395     /** Required alignment of virtual addresses. */
1396     __u32 virtual_address_alignment;
1397     /** Page table entry - fragment size */
1398     __u32 pte_fragment_size;
1399     __u32 gart_page_size;
1400     /** constant engine ram size*/
1401     __u32 ce_ram_size;
1402     /** video memory type info*/
1403     __u32 vram_type;
1404     /** video memory bit width*/
1405     __u32 vram_bit_width;
1406     /* vce harvesting instance */
1407     __u32 vce_harvest_config;
1408     /* gfx double offchip LDS buffers */
1409     __u32 gc_double_offchip_lds_buf;
1410     /* NGG Primitive Buffer */
1411     __u64 prim_buf_gpu_addr;
1412     /* NGG Position Buffer */
1413     __u64 pos_buf_gpu_addr;
1414     /* NGG Control Sideband */
1415     __u64 cntl_sb_buf_gpu_addr;
1416     /* NGG Parameter Cache */
1417     __u64 param_buf_gpu_addr;
1418     __u32 prim_buf_size;
1419     __u32 pos_buf_size;
1420     __u32 cntl_sb_buf_size;
1421     __u32 param_buf_size;
1422     /* wavefront size*/
1423     __u32 wave_front_size;
1424     /* shader visible vgprs*/
1425     __u32 num_shader_visible_vgprs;
1426     /* CU per shader array*/
1427     __u32 num_cu_per_sh;
1428     /* number of tcc blocks*/
1429     __u32 num_tcc_blocks;
1430     /* gs vgt table depth*/
1431     __u32 gs_vgt_table_depth;
1432     /* gs primitive buffer depth*/
1433     __u32 gs_prim_buffer_depth;
1434     /* max gs wavefront per vgt*/
1435     __u32 max_gs_waves_per_vgt;
1436     /* PCIe number of lanes (the smaller of the GPU and the CPU/motherboard) */
1437     __u32 pcie_num_lanes;
1438     /* always on cu bitmap */
1439     __u32 cu_ao_bitmap[4][4];
1440     /** Starting high virtual address for UMDs. */
1441     __u64 high_va_offset;
1442     /** The maximum high virtual address */
1443     __u64 high_va_max;
1444     /* gfx10 pa_sc_tile_steering_override */
1445     __u32 pa_sc_tile_steering_override;
1446     /* disabled TCCs */
1447     __u64 tcc_disabled_mask;
1448     __u64 min_engine_clock;
1449     __u64 min_memory_clock;
1450     /* The following fields are only set on gfx11+, older chips set 0. */
1451     __u32 tcp_cache_size;       /* AKA GL0, VMEM cache */
1452     __u32 num_sqc_per_wgp;
1453     __u32 sqc_data_cache_size;  /* AKA SMEM cache */
1454     __u32 sqc_inst_cache_size;
1455     __u32 gl1c_cache_size;
1456     __u32 gl2c_cache_size;
1457     __u64 mall_size;            /* AKA infinity cache */
1458     /* high 32 bits of the rb pipes mask */
1459     __u32 enabled_rb_pipes_mask_hi;
1460     /* shadow area size for gfx11 */
1461     __u32 shadow_size;
1462     /* shadow area base virtual alignment for gfx11 */
1463     __u32 shadow_alignment;
1464     /* context save area size for gfx11 */
1465     __u32 csa_size;
1466     /* context save area base virtual alignment for gfx11 */
1467     __u32 csa_alignment;
1468     /* Userq IP mask (1 << AMDGPU_HW_IP_*) */
1469     __u32 userq_ip_mask;
1470     __u32 pad;
1471 };
1472 
1473 struct drm_amdgpu_info_hw_ip {
1474     /** Version of h/w IP */
1475     __u32  hw_ip_version_major;
1476     __u32  hw_ip_version_minor;
1477     /** Capabilities */
1478     __u64  capabilities_flags;
1479     /** command buffer address start alignment*/
1480     __u32  ib_start_alignment;
1481     /** command buffer size alignment*/
1482     __u32  ib_size_alignment;
1483     /** Bitmask of available rings. Bit 0 means ring 0, etc. */
1484     __u32  available_rings;
1485     /** version info: bits 23:16 major, 15:8 minor, 7:0 revision */
1486     __u32  ip_discovery_version;
1487 };
1488 
1489 /* GFX metadata BO sizes and alignment info (in bytes) */
1490 struct drm_amdgpu_info_uq_fw_areas_gfx {
1491     /* shadow area size */
1492     __u32 shadow_size;
1493     /* shadow area base virtual mem alignment */
1494     __u32 shadow_alignment;
1495     /* context save area size */
1496     __u32 csa_size;
1497     /* context save area base virtual mem alignment */
1498     __u32 csa_alignment;
1499 };
1500 
1501 /* IP specific metadata related information used in the
1502  * subquery AMDGPU_INFO_UQ_FW_AREAS
1503  */
1504 struct drm_amdgpu_info_uq_fw_areas {
1505     union {
1506         struct drm_amdgpu_info_uq_fw_areas_gfx gfx;
1507     };
1508 };
1509 
1510 struct drm_amdgpu_info_num_handles {
1511     /** Max handles as supported by firmware for UVD */
1512     __u32  uvd_max_handles;
1513     /** Handles currently in use for UVD */
1514     __u32  uvd_used_handles;
1515 };
1516 
1517 #define AMDGPU_VCE_CLOCK_TABLE_ENTRIES      6
1518 
1519 struct drm_amdgpu_info_vce_clock_table_entry {
1520     /** System clock */
1521     __u32 sclk;
1522     /** Memory clock */
1523     __u32 mclk;
1524     /** VCE clock */
1525     __u32 eclk;
1526     __u32 pad;
1527 };
1528 
1529 struct drm_amdgpu_info_vce_clock_table {
1530     struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
1531     __u32 num_valid_entries;
1532     __u32 pad;
1533 };
1534 
1535 /* query video encode/decode caps */
1536 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2          0
1537 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4          1
1538 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1            2
1539 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC      3
1540 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC           4
1541 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG           5
1542 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9            6
1543 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1            7
1544 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT          8
1545 
1546 struct drm_amdgpu_info_video_codec_info {
1547     __u32 valid;
1548     __u32 max_width;
1549     __u32 max_height;
1550     __u32 max_pixels_per_frame;
1551     __u32 max_level;
1552     __u32 pad;
1553 };
1554 
1555 struct drm_amdgpu_info_video_caps {
1556     struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT];
1557 };
1558 
1559 #define AMDGPU_VMHUB_TYPE_MASK          0xff
1560 #define AMDGPU_VMHUB_TYPE_SHIFT         0
1561 #define AMDGPU_VMHUB_TYPE_GFX           0
1562 #define AMDGPU_VMHUB_TYPE_MM0           1
1563 #define AMDGPU_VMHUB_TYPE_MM1           2
1564 #define AMDGPU_VMHUB_IDX_MASK           0xff00
1565 #define AMDGPU_VMHUB_IDX_SHIFT          8
1566 
1567 struct drm_amdgpu_info_gpuvm_fault {
1568     __u64 addr;
1569     __u32 status;
1570     __u32 vmhub;
1571 };
1572 
1573 /*
1574  * Supported GPU families
1575  */
1576 #define AMDGPU_FAMILY_UNKNOWN           0
1577 #define AMDGPU_FAMILY_SI            110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */
1578 #define AMDGPU_FAMILY_CI            120 /* Bonaire, Hawaii */
1579 #define AMDGPU_FAMILY_KV            125 /* Kaveri, Kabini, Mullins */
1580 #define AMDGPU_FAMILY_VI            130 /* Iceland, Tonga */
1581 #define AMDGPU_FAMILY_CZ            135 /* Carrizo, Stoney */
1582 #define AMDGPU_FAMILY_AI            141 /* Vega10 */
1583 #define AMDGPU_FAMILY_RV            142 /* Raven */
1584 #define AMDGPU_FAMILY_NV            143 /* Navi10 */
1585 #define AMDGPU_FAMILY_VGH           144 /* Van Gogh */
1586 #define AMDGPU_FAMILY_GC_11_0_0         145 /* GC 11.0.0 */
1587 #define AMDGPU_FAMILY_YC            146 /* Yellow Carp */
1588 #define AMDGPU_FAMILY_GC_11_0_1         148 /* GC 11.0.1 */
1589 #define AMDGPU_FAMILY_GC_10_3_6         149 /* GC 10.3.6 */
1590 #define AMDGPU_FAMILY_GC_10_3_7         151 /* GC 10.3.7 */
1591 #define AMDGPU_FAMILY_GC_11_5_0         150 /* GC 11.5.0 */
1592 #define AMDGPU_FAMILY_GC_12_0_0         152 /* GC 12.0.0 */
1593 
1594 #if defined(__cplusplus)
1595 }
1596 #endif
1597 
1598 #endif