Back to home page

OSCL-LXR

 
 

    


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