Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:49

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