1 1.1 riastrad /* $NetBSD: amdgpu_drm.h,v 1.2 2021/12/18 23:45:46 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad /* amdgpu_drm.h -- Public header for the amdgpu driver -*- linux-c -*- 4 1.1 riastrad * 5 1.1 riastrad * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. 6 1.1 riastrad * Copyright 2000 VA Linux Systems, Inc., Fremont, California. 7 1.1 riastrad * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas. 8 1.1 riastrad * Copyright 2014 Advanced Micro Devices, Inc. 9 1.1 riastrad * 10 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 11 1.1 riastrad * copy of this software and associated documentation files (the "Software"), 12 1.1 riastrad * to deal in the Software without restriction, including without limitation 13 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the 15 1.1 riastrad * Software is furnished to do so, subject to the following conditions: 16 1.1 riastrad * 17 1.1 riastrad * The above copyright notice and this permission notice shall be included in 18 1.1 riastrad * all copies or substantial portions of the Software. 19 1.1 riastrad * 20 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 1.1 riastrad * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 24 1.1 riastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 25 1.1 riastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 26 1.1 riastrad * OTHER DEALINGS IN THE SOFTWARE. 27 1.1 riastrad * 28 1.1 riastrad * Authors: 29 1.1 riastrad * Kevin E. Martin <martin (at) valinux.com> 30 1.1 riastrad * Gareth Hughes <gareth (at) valinux.com> 31 1.1 riastrad * Keith Whitwell <keith (at) tungstengraphics.com> 32 1.1 riastrad */ 33 1.1 riastrad 34 1.1 riastrad #ifndef __AMDGPU_DRM_H__ 35 1.1 riastrad #define __AMDGPU_DRM_H__ 36 1.1 riastrad 37 1.1 riastrad #include "drm.h" 38 1.1 riastrad 39 1.1 riastrad #if defined(__cplusplus) 40 1.1 riastrad extern "C" { 41 1.1 riastrad #endif 42 1.1 riastrad 43 1.1 riastrad #define DRM_AMDGPU_GEM_CREATE 0x00 44 1.1 riastrad #define DRM_AMDGPU_GEM_MMAP 0x01 45 1.1 riastrad #define DRM_AMDGPU_CTX 0x02 46 1.1 riastrad #define DRM_AMDGPU_BO_LIST 0x03 47 1.1 riastrad #define DRM_AMDGPU_CS 0x04 48 1.1 riastrad #define DRM_AMDGPU_INFO 0x05 49 1.1 riastrad #define DRM_AMDGPU_GEM_METADATA 0x06 50 1.1 riastrad #define DRM_AMDGPU_GEM_WAIT_IDLE 0x07 51 1.1 riastrad #define DRM_AMDGPU_GEM_VA 0x08 52 1.1 riastrad #define DRM_AMDGPU_WAIT_CS 0x09 53 1.1 riastrad #define DRM_AMDGPU_GEM_OP 0x10 54 1.1 riastrad #define DRM_AMDGPU_GEM_USERPTR 0x11 55 1.1 riastrad #define DRM_AMDGPU_WAIT_FENCES 0x12 56 1.1 riastrad #define DRM_AMDGPU_VM 0x13 57 1.1 riastrad #define DRM_AMDGPU_FENCE_TO_HANDLE 0x14 58 1.1 riastrad #define DRM_AMDGPU_SCHED 0x15 59 1.1 riastrad 60 1.1 riastrad #define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create) 61 1.1 riastrad #define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap) 62 1.1 riastrad #define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx) 63 1.1 riastrad #define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list) 64 1.1 riastrad #define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs) 65 1.1 riastrad #define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info) 66 1.1 riastrad #define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata) 67 1.1 riastrad #define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle) 68 1.1 riastrad #define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va) 69 1.1 riastrad #define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs) 70 1.1 riastrad #define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op) 71 1.1 riastrad #define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr) 72 1.1 riastrad #define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences) 73 1.1 riastrad #define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm) 74 1.1 riastrad #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle) 75 1.1 riastrad #define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched) 76 1.1 riastrad 77 1.1 riastrad /** 78 1.1 riastrad * DOC: memory domains 79 1.1 riastrad * 80 1.1 riastrad * %AMDGPU_GEM_DOMAIN_CPU System memory that is not GPU accessible. 81 1.1 riastrad * Memory in this pool could be swapped out to disk if there is pressure. 82 1.1 riastrad * 83 1.1 riastrad * %AMDGPU_GEM_DOMAIN_GTT GPU accessible system memory, mapped into the 84 1.1 riastrad * GPU's virtual address space via gart. Gart memory linearizes non-contiguous 85 1.1 riastrad * pages of system memory, allows GPU access system memory in a linezrized 86 1.1 riastrad * fashion. 87 1.1 riastrad * 88 1.1 riastrad * %AMDGPU_GEM_DOMAIN_VRAM Local video memory. For APUs, it is memory 89 1.1 riastrad * carved out by the BIOS. 90 1.1 riastrad * 91 1.1 riastrad * %AMDGPU_GEM_DOMAIN_GDS Global on-chip data storage used to share data 92 1.1 riastrad * across shader threads. 93 1.1 riastrad * 94 1.1 riastrad * %AMDGPU_GEM_DOMAIN_GWS Global wave sync, used to synchronize the 95 1.1 riastrad * execution of all the waves on a device. 96 1.1 riastrad * 97 1.1 riastrad * %AMDGPU_GEM_DOMAIN_OA Ordered append, used by 3D or Compute engines 98 1.1 riastrad * for appending data. 99 1.1 riastrad */ 100 1.1 riastrad #define AMDGPU_GEM_DOMAIN_CPU 0x1 101 1.1 riastrad #define AMDGPU_GEM_DOMAIN_GTT 0x2 102 1.1 riastrad #define AMDGPU_GEM_DOMAIN_VRAM 0x4 103 1.1 riastrad #define AMDGPU_GEM_DOMAIN_GDS 0x8 104 1.1 riastrad #define AMDGPU_GEM_DOMAIN_GWS 0x10 105 1.1 riastrad #define AMDGPU_GEM_DOMAIN_OA 0x20 106 1.1 riastrad #define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \ 107 1.1 riastrad AMDGPU_GEM_DOMAIN_GTT | \ 108 1.1 riastrad AMDGPU_GEM_DOMAIN_VRAM | \ 109 1.1 riastrad AMDGPU_GEM_DOMAIN_GDS | \ 110 1.1 riastrad AMDGPU_GEM_DOMAIN_GWS | \ 111 1.1 riastrad AMDGPU_GEM_DOMAIN_OA) 112 1.1 riastrad 113 1.1 riastrad /* Flag that CPU access will be required for the case of VRAM domain */ 114 1.1 riastrad #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0) 115 1.1 riastrad /* Flag that CPU access will not work, this VRAM domain is invisible */ 116 1.1 riastrad #define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1) 117 1.1 riastrad /* Flag that USWC attributes should be used for GTT */ 118 1.1 riastrad #define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2) 119 1.1 riastrad /* Flag that the memory should be in VRAM and cleared */ 120 1.1 riastrad #define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3) 121 1.1 riastrad /* Flag that create shadow bo(GTT) while allocating vram bo */ 122 1.1 riastrad #define AMDGPU_GEM_CREATE_SHADOW (1 << 4) 123 1.1 riastrad /* Flag that allocating the BO should use linear VRAM */ 124 1.1 riastrad #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5) 125 1.1 riastrad /* Flag that BO is always valid in this VM */ 126 1.1 riastrad #define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6) 127 1.1 riastrad /* Flag that BO sharing will be explicitly synchronized */ 128 1.1 riastrad #define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7) 129 1.1 riastrad /* Flag that indicates allocating MQD gart on GFX9, where the mtype 130 1.1 riastrad * for the second page onward should be set to NC. 131 1.1 riastrad */ 132 1.1 riastrad #define AMDGPU_GEM_CREATE_MQD_GFX9 (1 << 8) 133 1.1 riastrad /* Flag that BO may contain sensitive data that must be wiped before 134 1.1 riastrad * releasing the memory 135 1.1 riastrad */ 136 1.1 riastrad #define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE (1 << 9) 137 1.1 riastrad 138 1.1 riastrad struct drm_amdgpu_gem_create_in { 139 1.1 riastrad /** the requested memory size */ 140 1.1 riastrad __u64 bo_size; 141 1.1 riastrad /** physical start_addr alignment in bytes for some HW requirements */ 142 1.1 riastrad __u64 alignment; 143 1.1 riastrad /** the requested memory domains */ 144 1.1 riastrad __u64 domains; 145 1.1 riastrad /** allocation flags */ 146 1.1 riastrad __u64 domain_flags; 147 1.1 riastrad }; 148 1.1 riastrad 149 1.1 riastrad struct drm_amdgpu_gem_create_out { 150 1.1 riastrad /** returned GEM object handle */ 151 1.1 riastrad __u32 handle; 152 1.1 riastrad __u32 _pad; 153 1.1 riastrad }; 154 1.1 riastrad 155 1.1 riastrad union drm_amdgpu_gem_create { 156 1.1 riastrad struct drm_amdgpu_gem_create_in in; 157 1.1 riastrad struct drm_amdgpu_gem_create_out out; 158 1.1 riastrad }; 159 1.1 riastrad 160 1.1 riastrad /** Opcode to create new residency list. */ 161 1.1 riastrad #define AMDGPU_BO_LIST_OP_CREATE 0 162 1.1 riastrad /** Opcode to destroy previously created residency list */ 163 1.1 riastrad #define AMDGPU_BO_LIST_OP_DESTROY 1 164 1.1 riastrad /** Opcode to update resource information in the list */ 165 1.1 riastrad #define AMDGPU_BO_LIST_OP_UPDATE 2 166 1.1 riastrad 167 1.1 riastrad struct drm_amdgpu_bo_list_in { 168 1.1 riastrad /** Type of operation */ 169 1.1 riastrad __u32 operation; 170 1.1 riastrad /** Handle of list or 0 if we want to create one */ 171 1.1 riastrad __u32 list_handle; 172 1.1 riastrad /** Number of BOs in list */ 173 1.1 riastrad __u32 bo_number; 174 1.1 riastrad /** Size of each element describing BO */ 175 1.1 riastrad __u32 bo_info_size; 176 1.1 riastrad /** Pointer to array describing BOs */ 177 1.1 riastrad __u64 bo_info_ptr; 178 1.1 riastrad }; 179 1.1 riastrad 180 1.1 riastrad struct drm_amdgpu_bo_list_entry { 181 1.1 riastrad /** Handle of BO */ 182 1.1 riastrad __u32 bo_handle; 183 1.1 riastrad /** New (if specified) BO priority to be used during migration */ 184 1.1 riastrad __u32 bo_priority; 185 1.1 riastrad }; 186 1.1 riastrad 187 1.1 riastrad struct drm_amdgpu_bo_list_out { 188 1.1 riastrad /** Handle of resource list */ 189 1.1 riastrad __u32 list_handle; 190 1.1 riastrad __u32 _pad; 191 1.1 riastrad }; 192 1.1 riastrad 193 1.1 riastrad union drm_amdgpu_bo_list { 194 1.1 riastrad struct drm_amdgpu_bo_list_in in; 195 1.1 riastrad struct drm_amdgpu_bo_list_out out; 196 1.1 riastrad }; 197 1.1 riastrad 198 1.1 riastrad /* context related */ 199 1.1 riastrad #define AMDGPU_CTX_OP_ALLOC_CTX 1 200 1.1 riastrad #define AMDGPU_CTX_OP_FREE_CTX 2 201 1.1 riastrad #define AMDGPU_CTX_OP_QUERY_STATE 3 202 1.1 riastrad #define AMDGPU_CTX_OP_QUERY_STATE2 4 203 1.1 riastrad 204 1.1 riastrad /* GPU reset status */ 205 1.1 riastrad #define AMDGPU_CTX_NO_RESET 0 206 1.1 riastrad /* this the context caused it */ 207 1.1 riastrad #define AMDGPU_CTX_GUILTY_RESET 1 208 1.1 riastrad /* some other context caused it */ 209 1.1 riastrad #define AMDGPU_CTX_INNOCENT_RESET 2 210 1.1 riastrad /* unknown cause */ 211 1.1 riastrad #define AMDGPU_CTX_UNKNOWN_RESET 3 212 1.1 riastrad 213 1.1 riastrad /* indicate gpu reset occured after ctx created */ 214 1.1 riastrad #define AMDGPU_CTX_QUERY2_FLAGS_RESET (1<<0) 215 1.1 riastrad /* indicate vram lost occured after ctx created */ 216 1.1 riastrad #define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1) 217 1.1 riastrad /* indicate some job from this context once cause gpu hang */ 218 1.1 riastrad #define AMDGPU_CTX_QUERY2_FLAGS_GUILTY (1<<2) 219 1.1 riastrad /* indicate some errors are detected by RAS */ 220 1.1 riastrad #define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE (1<<3) 221 1.1 riastrad #define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE (1<<4) 222 1.1 riastrad 223 1.1 riastrad /* Context priority level */ 224 1.1 riastrad #define AMDGPU_CTX_PRIORITY_UNSET -2048 225 1.1 riastrad #define AMDGPU_CTX_PRIORITY_VERY_LOW -1023 226 1.1 riastrad #define AMDGPU_CTX_PRIORITY_LOW -512 227 1.1 riastrad #define AMDGPU_CTX_PRIORITY_NORMAL 0 228 1.1 riastrad /* 229 1.1 riastrad * When used in struct drm_amdgpu_ctx_in, a priority above NORMAL requires 230 1.1 riastrad * CAP_SYS_NICE or DRM_MASTER 231 1.1 riastrad */ 232 1.1 riastrad #define AMDGPU_CTX_PRIORITY_HIGH 512 233 1.1 riastrad #define AMDGPU_CTX_PRIORITY_VERY_HIGH 1023 234 1.1 riastrad 235 1.1 riastrad struct drm_amdgpu_ctx_in { 236 1.1 riastrad /** AMDGPU_CTX_OP_* */ 237 1.1 riastrad __u32 op; 238 1.1 riastrad /** For future use, no flags defined so far */ 239 1.1 riastrad __u32 flags; 240 1.1 riastrad __u32 ctx_id; 241 1.1 riastrad /** AMDGPU_CTX_PRIORITY_* */ 242 1.1 riastrad __s32 priority; 243 1.1 riastrad }; 244 1.1 riastrad 245 1.1 riastrad union drm_amdgpu_ctx_out { 246 1.1 riastrad struct { 247 1.1 riastrad __u32 ctx_id; 248 1.1 riastrad __u32 _pad; 249 1.1 riastrad } alloc; 250 1.1 riastrad 251 1.1 riastrad struct { 252 1.1 riastrad /** For future use, no flags defined so far */ 253 1.1 riastrad __u64 flags; 254 1.1 riastrad /** Number of resets caused by this context so far. */ 255 1.1 riastrad __u32 hangs; 256 1.1 riastrad /** Reset status since the last call of the ioctl. */ 257 1.1 riastrad __u32 reset_status; 258 1.1 riastrad } state; 259 1.1 riastrad }; 260 1.1 riastrad 261 1.1 riastrad union drm_amdgpu_ctx { 262 1.1 riastrad struct drm_amdgpu_ctx_in in; 263 1.1 riastrad union drm_amdgpu_ctx_out out; 264 1.1 riastrad }; 265 1.1 riastrad 266 1.1 riastrad /* vm ioctl */ 267 1.1 riastrad #define AMDGPU_VM_OP_RESERVE_VMID 1 268 1.1 riastrad #define AMDGPU_VM_OP_UNRESERVE_VMID 2 269 1.1 riastrad 270 1.1 riastrad struct drm_amdgpu_vm_in { 271 1.1 riastrad /** AMDGPU_VM_OP_* */ 272 1.1 riastrad __u32 op; 273 1.1 riastrad __u32 flags; 274 1.1 riastrad }; 275 1.1 riastrad 276 1.1 riastrad struct drm_amdgpu_vm_out { 277 1.1 riastrad /** For future use, no flags defined so far */ 278 1.1 riastrad __u64 flags; 279 1.1 riastrad }; 280 1.1 riastrad 281 1.1 riastrad union drm_amdgpu_vm { 282 1.1 riastrad struct drm_amdgpu_vm_in in; 283 1.1 riastrad struct drm_amdgpu_vm_out out; 284 1.1 riastrad }; 285 1.1 riastrad 286 1.1 riastrad /* sched ioctl */ 287 1.1 riastrad #define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE 1 288 1.1 riastrad #define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE 2 289 1.1 riastrad 290 1.1 riastrad struct drm_amdgpu_sched_in { 291 1.1 riastrad /* AMDGPU_SCHED_OP_* */ 292 1.1 riastrad __u32 op; 293 1.1 riastrad __u32 fd; 294 1.1 riastrad /** AMDGPU_CTX_PRIORITY_* */ 295 1.1 riastrad __s32 priority; 296 1.1 riastrad __u32 ctx_id; 297 1.1 riastrad }; 298 1.1 riastrad 299 1.1 riastrad union drm_amdgpu_sched { 300 1.1 riastrad struct drm_amdgpu_sched_in in; 301 1.1 riastrad }; 302 1.1 riastrad 303 1.1 riastrad /* 304 1.1 riastrad * This is not a reliable API and you should expect it to fail for any 305 1.1 riastrad * number of reasons and have fallback path that do not use userptr to 306 1.1 riastrad * perform any operation. 307 1.1 riastrad */ 308 1.1 riastrad #define AMDGPU_GEM_USERPTR_READONLY (1 << 0) 309 1.1 riastrad #define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1) 310 1.1 riastrad #define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2) 311 1.1 riastrad #define AMDGPU_GEM_USERPTR_REGISTER (1 << 3) 312 1.1 riastrad 313 1.1 riastrad struct drm_amdgpu_gem_userptr { 314 1.1 riastrad __u64 addr; 315 1.1 riastrad __u64 size; 316 1.1 riastrad /* AMDGPU_GEM_USERPTR_* */ 317 1.1 riastrad __u32 flags; 318 1.1 riastrad /* Resulting GEM handle */ 319 1.1 riastrad __u32 handle; 320 1.1 riastrad }; 321 1.1 riastrad 322 1.1 riastrad /* SI-CI-VI: */ 323 1.1 riastrad /* same meaning as the GB_TILE_MODE and GL_MACRO_TILE_MODE fields */ 324 1.1 riastrad #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0 325 1.1 riastrad #define AMDGPU_TILING_ARRAY_MODE_MASK 0xf 326 1.1 riastrad #define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4 327 1.1 riastrad #define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f 328 1.1 riastrad #define AMDGPU_TILING_TILE_SPLIT_SHIFT 9 329 1.1 riastrad #define AMDGPU_TILING_TILE_SPLIT_MASK 0x7 330 1.1 riastrad #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12 331 1.1 riastrad #define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7 332 1.1 riastrad #define AMDGPU_TILING_BANK_WIDTH_SHIFT 15 333 1.1 riastrad #define AMDGPU_TILING_BANK_WIDTH_MASK 0x3 334 1.1 riastrad #define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17 335 1.1 riastrad #define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3 336 1.1 riastrad #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19 337 1.1 riastrad #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3 338 1.1 riastrad #define AMDGPU_TILING_NUM_BANKS_SHIFT 21 339 1.1 riastrad #define AMDGPU_TILING_NUM_BANKS_MASK 0x3 340 1.1 riastrad 341 1.1 riastrad /* GFX9 and later: */ 342 1.1 riastrad #define AMDGPU_TILING_SWIZZLE_MODE_SHIFT 0 343 1.1 riastrad #define AMDGPU_TILING_SWIZZLE_MODE_MASK 0x1f 344 1.1 riastrad #define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT 5 345 1.1 riastrad #define AMDGPU_TILING_DCC_OFFSET_256B_MASK 0xFFFFFF 346 1.1 riastrad #define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT 29 347 1.1 riastrad #define AMDGPU_TILING_DCC_PITCH_MAX_MASK 0x3FFF 348 1.1 riastrad #define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT 43 349 1.1 riastrad #define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK 0x1 350 1.1 riastrad 351 1.1 riastrad /* Set/Get helpers for tiling flags. */ 352 1.1 riastrad #define AMDGPU_TILING_SET(field, value) \ 353 1.1 riastrad (((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT) 354 1.1 riastrad #define AMDGPU_TILING_GET(value, field) \ 355 1.1 riastrad (((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK) 356 1.1 riastrad 357 1.1 riastrad #define AMDGPU_GEM_METADATA_OP_SET_METADATA 1 358 1.1 riastrad #define AMDGPU_GEM_METADATA_OP_GET_METADATA 2 359 1.1 riastrad 360 1.1 riastrad /** The same structure is shared for input/output */ 361 1.1 riastrad struct drm_amdgpu_gem_metadata { 362 1.1 riastrad /** GEM Object handle */ 363 1.1 riastrad __u32 handle; 364 1.1 riastrad /** Do we want get or set metadata */ 365 1.1 riastrad __u32 op; 366 1.1 riastrad struct { 367 1.1 riastrad /** For future use, no flags defined so far */ 368 1.1 riastrad __u64 flags; 369 1.1 riastrad /** family specific tiling info */ 370 1.1 riastrad __u64 tiling_info; 371 1.1 riastrad __u32 data_size_bytes; 372 1.1 riastrad __u32 data[64]; 373 1.1 riastrad } data; 374 1.1 riastrad }; 375 1.1 riastrad 376 1.1 riastrad struct drm_amdgpu_gem_mmap_in { 377 1.1 riastrad /** the GEM object handle */ 378 1.1 riastrad __u32 handle; 379 1.1 riastrad __u32 _pad; 380 1.1 riastrad }; 381 1.1 riastrad 382 1.1 riastrad struct drm_amdgpu_gem_mmap_out { 383 1.1 riastrad /** mmap offset from the vma offset manager */ 384 1.1 riastrad __u64 addr_ptr; 385 1.1 riastrad }; 386 1.1 riastrad 387 1.1 riastrad union drm_amdgpu_gem_mmap { 388 1.1 riastrad struct drm_amdgpu_gem_mmap_in in; 389 1.1 riastrad struct drm_amdgpu_gem_mmap_out out; 390 1.1 riastrad }; 391 1.1 riastrad 392 1.1 riastrad struct drm_amdgpu_gem_wait_idle_in { 393 1.1 riastrad /** GEM object handle */ 394 1.1 riastrad __u32 handle; 395 1.1 riastrad /** For future use, no flags defined so far */ 396 1.1 riastrad __u32 flags; 397 1.1 riastrad /** Absolute timeout to wait */ 398 1.1 riastrad __u64 timeout; 399 1.1 riastrad }; 400 1.1 riastrad 401 1.1 riastrad struct drm_amdgpu_gem_wait_idle_out { 402 1.1 riastrad /** BO status: 0 - BO is idle, 1 - BO is busy */ 403 1.1 riastrad __u32 status; 404 1.1 riastrad /** Returned current memory domain */ 405 1.1 riastrad __u32 domain; 406 1.1 riastrad }; 407 1.1 riastrad 408 1.1 riastrad union drm_amdgpu_gem_wait_idle { 409 1.1 riastrad struct drm_amdgpu_gem_wait_idle_in in; 410 1.1 riastrad struct drm_amdgpu_gem_wait_idle_out out; 411 1.1 riastrad }; 412 1.1 riastrad 413 1.1 riastrad struct drm_amdgpu_wait_cs_in { 414 1.1 riastrad /* Command submission handle 415 1.1 riastrad * handle equals 0 means none to wait for 416 1.1 riastrad * handle equals ~0ull means wait for the latest sequence number 417 1.1 riastrad */ 418 1.1 riastrad __u64 handle; 419 1.1 riastrad /** Absolute timeout to wait */ 420 1.1 riastrad __u64 timeout; 421 1.1 riastrad __u32 ip_type; 422 1.1 riastrad __u32 ip_instance; 423 1.1 riastrad __u32 ring; 424 1.1 riastrad __u32 ctx_id; 425 1.1 riastrad }; 426 1.1 riastrad 427 1.1 riastrad struct drm_amdgpu_wait_cs_out { 428 1.1 riastrad /** CS status: 0 - CS completed, 1 - CS still busy */ 429 1.1 riastrad __u64 status; 430 1.1 riastrad }; 431 1.1 riastrad 432 1.1 riastrad union drm_amdgpu_wait_cs { 433 1.1 riastrad struct drm_amdgpu_wait_cs_in in; 434 1.1 riastrad struct drm_amdgpu_wait_cs_out out; 435 1.1 riastrad }; 436 1.1 riastrad 437 1.1 riastrad struct drm_amdgpu_fence { 438 1.1 riastrad __u32 ctx_id; 439 1.1 riastrad __u32 ip_type; 440 1.1 riastrad __u32 ip_instance; 441 1.1 riastrad __u32 ring; 442 1.1 riastrad __u64 seq_no; 443 1.1 riastrad }; 444 1.1 riastrad 445 1.1 riastrad struct drm_amdgpu_wait_fences_in { 446 1.1 riastrad /** This points to uint64_t * which points to fences */ 447 1.1 riastrad __u64 fences; 448 1.1 riastrad __u32 fence_count; 449 1.1 riastrad __u32 wait_all; 450 1.1 riastrad __u64 timeout_ns; 451 1.1 riastrad }; 452 1.1 riastrad 453 1.1 riastrad struct drm_amdgpu_wait_fences_out { 454 1.1 riastrad __u32 status; 455 1.1 riastrad __u32 first_signaled; 456 1.1 riastrad }; 457 1.1 riastrad 458 1.1 riastrad union drm_amdgpu_wait_fences { 459 1.1 riastrad struct drm_amdgpu_wait_fences_in in; 460 1.1 riastrad struct drm_amdgpu_wait_fences_out out; 461 1.1 riastrad }; 462 1.1 riastrad 463 1.1 riastrad #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0 464 1.1 riastrad #define AMDGPU_GEM_OP_SET_PLACEMENT 1 465 1.1 riastrad 466 1.1 riastrad /* Sets or returns a value associated with a buffer. */ 467 1.1 riastrad struct drm_amdgpu_gem_op { 468 1.1 riastrad /** GEM object handle */ 469 1.1 riastrad __u32 handle; 470 1.1 riastrad /** AMDGPU_GEM_OP_* */ 471 1.1 riastrad __u32 op; 472 1.1 riastrad /** Input or return value */ 473 1.1 riastrad __u64 value; 474 1.1 riastrad }; 475 1.1 riastrad 476 1.1 riastrad #define AMDGPU_VA_OP_MAP 1 477 1.1 riastrad #define AMDGPU_VA_OP_UNMAP 2 478 1.1 riastrad #define AMDGPU_VA_OP_CLEAR 3 479 1.1 riastrad #define AMDGPU_VA_OP_REPLACE 4 480 1.1 riastrad 481 1.1 riastrad /* Delay the page table update till the next CS */ 482 1.1 riastrad #define AMDGPU_VM_DELAY_UPDATE (1 << 0) 483 1.1 riastrad 484 1.1 riastrad /* Mapping flags */ 485 1.1 riastrad /* readable mapping */ 486 1.1 riastrad #define AMDGPU_VM_PAGE_READABLE (1 << 1) 487 1.1 riastrad /* writable mapping */ 488 1.1 riastrad #define AMDGPU_VM_PAGE_WRITEABLE (1 << 2) 489 1.1 riastrad /* executable mapping, new for VI */ 490 1.1 riastrad #define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3) 491 1.1 riastrad /* partially resident texture */ 492 1.1 riastrad #define AMDGPU_VM_PAGE_PRT (1 << 4) 493 1.1 riastrad /* MTYPE flags use bit 5 to 8 */ 494 1.1 riastrad #define AMDGPU_VM_MTYPE_MASK (0xf << 5) 495 1.1 riastrad /* Default MTYPE. Pre-AI must use this. Recommended for newer ASICs. */ 496 1.1 riastrad #define AMDGPU_VM_MTYPE_DEFAULT (0 << 5) 497 1.1 riastrad /* Use NC MTYPE instead of default MTYPE */ 498 1.1 riastrad #define AMDGPU_VM_MTYPE_NC (1 << 5) 499 1.1 riastrad /* Use WC MTYPE instead of default MTYPE */ 500 1.1 riastrad #define AMDGPU_VM_MTYPE_WC (2 << 5) 501 1.1 riastrad /* Use CC MTYPE instead of default MTYPE */ 502 1.1 riastrad #define AMDGPU_VM_MTYPE_CC (3 << 5) 503 1.1 riastrad /* Use UC MTYPE instead of default MTYPE */ 504 1.1 riastrad #define AMDGPU_VM_MTYPE_UC (4 << 5) 505 1.1 riastrad /* Use RW MTYPE instead of default MTYPE */ 506 1.1 riastrad #define AMDGPU_VM_MTYPE_RW (5 << 5) 507 1.1 riastrad 508 1.1 riastrad struct drm_amdgpu_gem_va { 509 1.1 riastrad /** GEM object handle */ 510 1.1 riastrad __u32 handle; 511 1.1 riastrad __u32 _pad; 512 1.1 riastrad /** AMDGPU_VA_OP_* */ 513 1.1 riastrad __u32 operation; 514 1.1 riastrad /** AMDGPU_VM_PAGE_* */ 515 1.1 riastrad __u32 flags; 516 1.1 riastrad /** va address to assign . Must be correctly aligned.*/ 517 1.1 riastrad __u64 va_address; 518 1.1 riastrad /** Specify offset inside of BO to assign. Must be correctly aligned.*/ 519 1.1 riastrad __u64 offset_in_bo; 520 1.1 riastrad /** Specify mapping size. Must be correctly aligned. */ 521 1.1 riastrad __u64 map_size; 522 1.1 riastrad }; 523 1.1 riastrad 524 1.1 riastrad #define AMDGPU_HW_IP_GFX 0 525 1.1 riastrad #define AMDGPU_HW_IP_COMPUTE 1 526 1.1 riastrad #define AMDGPU_HW_IP_DMA 2 527 1.1 riastrad #define AMDGPU_HW_IP_UVD 3 528 1.1 riastrad #define AMDGPU_HW_IP_VCE 4 529 1.1 riastrad #define AMDGPU_HW_IP_UVD_ENC 5 530 1.1 riastrad #define AMDGPU_HW_IP_VCN_DEC 6 531 1.1 riastrad #define AMDGPU_HW_IP_VCN_ENC 7 532 1.1 riastrad #define AMDGPU_HW_IP_VCN_JPEG 8 533 1.1 riastrad #define AMDGPU_HW_IP_NUM 9 534 1.1 riastrad 535 1.1 riastrad #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1 536 1.1 riastrad 537 1.1 riastrad #define AMDGPU_CHUNK_ID_IB 0x01 538 1.1 riastrad #define AMDGPU_CHUNK_ID_FENCE 0x02 539 1.1 riastrad #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03 540 1.1 riastrad #define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04 541 1.1 riastrad #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 542 1.1 riastrad #define AMDGPU_CHUNK_ID_BO_HANDLES 0x06 543 1.1 riastrad #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07 544 1.1 riastrad #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08 545 1.1 riastrad #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09 546 1.1 riastrad 547 1.1 riastrad struct drm_amdgpu_cs_chunk { 548 1.1 riastrad __u32 chunk_id; 549 1.1 riastrad __u32 length_dw; 550 1.1 riastrad __u64 chunk_data; 551 1.1 riastrad }; 552 1.1 riastrad 553 1.1 riastrad struct drm_amdgpu_cs_in { 554 1.1 riastrad /** Rendering context id */ 555 1.1 riastrad __u32 ctx_id; 556 1.1 riastrad /** Handle of resource list associated with CS */ 557 1.1 riastrad __u32 bo_list_handle; 558 1.1 riastrad __u32 num_chunks; 559 1.1 riastrad __u32 _pad; 560 1.1 riastrad /** this points to __u64 * which point to cs chunks */ 561 1.1 riastrad __u64 chunks; 562 1.1 riastrad }; 563 1.1 riastrad 564 1.1 riastrad struct drm_amdgpu_cs_out { 565 1.1 riastrad __u64 handle; 566 1.1 riastrad }; 567 1.1 riastrad 568 1.1 riastrad union drm_amdgpu_cs { 569 1.1 riastrad struct drm_amdgpu_cs_in in; 570 1.1 riastrad struct drm_amdgpu_cs_out out; 571 1.1 riastrad }; 572 1.1 riastrad 573 1.1 riastrad /* Specify flags to be used for IB */ 574 1.1 riastrad 575 1.1 riastrad /* This IB should be submitted to CE */ 576 1.1 riastrad #define AMDGPU_IB_FLAG_CE (1<<0) 577 1.1 riastrad 578 1.1 riastrad /* Preamble flag, which means the IB could be dropped if no context switch */ 579 1.1 riastrad #define AMDGPU_IB_FLAG_PREAMBLE (1<<1) 580 1.1 riastrad 581 1.1 riastrad /* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */ 582 1.1 riastrad #define AMDGPU_IB_FLAG_PREEMPT (1<<2) 583 1.1 riastrad 584 1.1 riastrad /* The IB fence should do the L2 writeback but not invalidate any shader 585 1.1 riastrad * caches (L2/vL1/sL1/I$). */ 586 1.1 riastrad #define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3) 587 1.1 riastrad 588 1.1 riastrad /* Set GDS_COMPUTE_MAX_WAVE_ID = DEFAULT before PACKET3_INDIRECT_BUFFER. 589 1.1 riastrad * This will reset wave ID counters for the IB. 590 1.1 riastrad */ 591 1.1 riastrad #define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4) 592 1.1 riastrad 593 1.1 riastrad struct drm_amdgpu_cs_chunk_ib { 594 1.1 riastrad __u32 _pad; 595 1.1 riastrad /** AMDGPU_IB_FLAG_* */ 596 1.1 riastrad __u32 flags; 597 1.1 riastrad /** Virtual address to begin IB execution */ 598 1.1 riastrad __u64 va_start; 599 1.1 riastrad /** Size of submission */ 600 1.1 riastrad __u32 ib_bytes; 601 1.1 riastrad /** HW IP to submit to */ 602 1.1 riastrad __u32 ip_type; 603 1.1 riastrad /** HW IP index of the same type to submit to */ 604 1.1 riastrad __u32 ip_instance; 605 1.1 riastrad /** Ring index to submit to */ 606 1.1 riastrad __u32 ring; 607 1.1 riastrad }; 608 1.1 riastrad 609 1.1 riastrad struct drm_amdgpu_cs_chunk_dep { 610 1.1 riastrad __u32 ip_type; 611 1.1 riastrad __u32 ip_instance; 612 1.1 riastrad __u32 ring; 613 1.1 riastrad __u32 ctx_id; 614 1.1 riastrad __u64 handle; 615 1.1 riastrad }; 616 1.1 riastrad 617 1.1 riastrad struct drm_amdgpu_cs_chunk_fence { 618 1.1 riastrad __u32 handle; 619 1.1 riastrad __u32 offset; 620 1.1 riastrad }; 621 1.1 riastrad 622 1.1 riastrad struct drm_amdgpu_cs_chunk_sem { 623 1.1 riastrad __u32 handle; 624 1.1 riastrad }; 625 1.1 riastrad 626 1.1 riastrad struct drm_amdgpu_cs_chunk_syncobj { 627 1.1 riastrad __u32 handle; 628 1.1 riastrad __u32 flags; 629 1.1 riastrad __u64 point; 630 1.1 riastrad }; 631 1.1 riastrad 632 1.1 riastrad #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 0 633 1.1 riastrad #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 1 634 1.1 riastrad #define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2 635 1.1 riastrad 636 1.1 riastrad union drm_amdgpu_fence_to_handle { 637 1.1 riastrad struct { 638 1.1 riastrad struct drm_amdgpu_fence fence; 639 1.1 riastrad __u32 what; 640 1.1 riastrad __u32 pad; 641 1.1 riastrad } in; 642 1.1 riastrad struct { 643 1.1 riastrad __u32 handle; 644 1.1 riastrad } out; 645 1.1 riastrad }; 646 1.1 riastrad 647 1.1 riastrad struct drm_amdgpu_cs_chunk_data { 648 1.1 riastrad union { 649 1.1 riastrad struct drm_amdgpu_cs_chunk_ib ib_data; 650 1.1 riastrad struct drm_amdgpu_cs_chunk_fence fence_data; 651 1.1 riastrad }; 652 1.1 riastrad }; 653 1.1 riastrad 654 1.1 riastrad /** 655 1.1 riastrad * Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU 656 1.1 riastrad * 657 1.1 riastrad */ 658 1.1 riastrad #define AMDGPU_IDS_FLAGS_FUSION 0x1 659 1.1 riastrad #define AMDGPU_IDS_FLAGS_PREEMPTION 0x2 660 1.1 riastrad 661 1.1 riastrad /* indicate if acceleration can be working */ 662 1.1 riastrad #define AMDGPU_INFO_ACCEL_WORKING 0x00 663 1.1 riastrad /* get the crtc_id from the mode object id? */ 664 1.1 riastrad #define AMDGPU_INFO_CRTC_FROM_ID 0x01 665 1.1 riastrad /* query hw IP info */ 666 1.1 riastrad #define AMDGPU_INFO_HW_IP_INFO 0x02 667 1.1 riastrad /* query hw IP instance count for the specified type */ 668 1.1 riastrad #define AMDGPU_INFO_HW_IP_COUNT 0x03 669 1.1 riastrad /* timestamp for GL_ARB_timer_query */ 670 1.1 riastrad #define AMDGPU_INFO_TIMESTAMP 0x05 671 1.1 riastrad /* Query the firmware version */ 672 1.1 riastrad #define AMDGPU_INFO_FW_VERSION 0x0e 673 1.1 riastrad /* Subquery id: Query VCE firmware version */ 674 1.1 riastrad #define AMDGPU_INFO_FW_VCE 0x1 675 1.1 riastrad /* Subquery id: Query UVD firmware version */ 676 1.1 riastrad #define AMDGPU_INFO_FW_UVD 0x2 677 1.1 riastrad /* Subquery id: Query GMC firmware version */ 678 1.1 riastrad #define AMDGPU_INFO_FW_GMC 0x03 679 1.1 riastrad /* Subquery id: Query GFX ME firmware version */ 680 1.1 riastrad #define AMDGPU_INFO_FW_GFX_ME 0x04 681 1.1 riastrad /* Subquery id: Query GFX PFP firmware version */ 682 1.1 riastrad #define AMDGPU_INFO_FW_GFX_PFP 0x05 683 1.1 riastrad /* Subquery id: Query GFX CE firmware version */ 684 1.1 riastrad #define AMDGPU_INFO_FW_GFX_CE 0x06 685 1.1 riastrad /* Subquery id: Query GFX RLC firmware version */ 686 1.1 riastrad #define AMDGPU_INFO_FW_GFX_RLC 0x07 687 1.1 riastrad /* Subquery id: Query GFX MEC firmware version */ 688 1.1 riastrad #define AMDGPU_INFO_FW_GFX_MEC 0x08 689 1.1 riastrad /* Subquery id: Query SMC firmware version */ 690 1.1 riastrad #define AMDGPU_INFO_FW_SMC 0x0a 691 1.1 riastrad /* Subquery id: Query SDMA firmware version */ 692 1.1 riastrad #define AMDGPU_INFO_FW_SDMA 0x0b 693 1.1 riastrad /* Subquery id: Query PSP SOS firmware version */ 694 1.1 riastrad #define AMDGPU_INFO_FW_SOS 0x0c 695 1.1 riastrad /* Subquery id: Query PSP ASD firmware version */ 696 1.1 riastrad #define AMDGPU_INFO_FW_ASD 0x0d 697 1.1 riastrad /* Subquery id: Query VCN firmware version */ 698 1.1 riastrad #define AMDGPU_INFO_FW_VCN 0x0e 699 1.1 riastrad /* Subquery id: Query GFX RLC SRLC firmware version */ 700 1.1 riastrad #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f 701 1.1 riastrad /* Subquery id: Query GFX RLC SRLG firmware version */ 702 1.1 riastrad #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10 703 1.1 riastrad /* Subquery id: Query GFX RLC SRLS firmware version */ 704 1.1 riastrad #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11 705 1.1 riastrad /* Subquery id: Query DMCU firmware version */ 706 1.1 riastrad #define AMDGPU_INFO_FW_DMCU 0x12 707 1.1 riastrad #define AMDGPU_INFO_FW_TA 0x13 708 1.1 riastrad /* Subquery id: Query DMCUB firmware version */ 709 1.1 riastrad #define AMDGPU_INFO_FW_DMCUB 0x14 710 1.1 riastrad 711 1.1 riastrad /* number of bytes moved for TTM migration */ 712 1.1 riastrad #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f 713 1.1 riastrad /* the used VRAM size */ 714 1.1 riastrad #define AMDGPU_INFO_VRAM_USAGE 0x10 715 1.1 riastrad /* the used GTT size */ 716 1.1 riastrad #define AMDGPU_INFO_GTT_USAGE 0x11 717 1.1 riastrad /* Information about GDS, etc. resource configuration */ 718 1.1 riastrad #define AMDGPU_INFO_GDS_CONFIG 0x13 719 1.1 riastrad /* Query information about VRAM and GTT domains */ 720 1.1 riastrad #define AMDGPU_INFO_VRAM_GTT 0x14 721 1.1 riastrad /* Query information about register in MMR address space*/ 722 1.1 riastrad #define AMDGPU_INFO_READ_MMR_REG 0x15 723 1.1 riastrad /* Query information about device: rev id, family, etc. */ 724 1.1 riastrad #define AMDGPU_INFO_DEV_INFO 0x16 725 1.1 riastrad /* visible vram usage */ 726 1.1 riastrad #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17 727 1.1 riastrad /* number of TTM buffer evictions */ 728 1.1 riastrad #define AMDGPU_INFO_NUM_EVICTIONS 0x18 729 1.1 riastrad /* Query memory about VRAM and GTT domains */ 730 1.1 riastrad #define AMDGPU_INFO_MEMORY 0x19 731 1.1 riastrad /* Query vce clock table */ 732 1.1 riastrad #define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A 733 1.1 riastrad /* Query vbios related information */ 734 1.1 riastrad #define AMDGPU_INFO_VBIOS 0x1B 735 1.1 riastrad /* Subquery id: Query vbios size */ 736 1.1 riastrad #define AMDGPU_INFO_VBIOS_SIZE 0x1 737 1.1 riastrad /* Subquery id: Query vbios image */ 738 1.1 riastrad #define AMDGPU_INFO_VBIOS_IMAGE 0x2 739 1.1 riastrad /* Query UVD handles */ 740 1.1 riastrad #define AMDGPU_INFO_NUM_HANDLES 0x1C 741 1.1 riastrad /* Query sensor related information */ 742 1.1 riastrad #define AMDGPU_INFO_SENSOR 0x1D 743 1.1 riastrad /* Subquery id: Query GPU shader clock */ 744 1.1 riastrad #define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1 745 1.1 riastrad /* Subquery id: Query GPU memory clock */ 746 1.1 riastrad #define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2 747 1.1 riastrad /* Subquery id: Query GPU temperature */ 748 1.1 riastrad #define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3 749 1.1 riastrad /* Subquery id: Query GPU load */ 750 1.1 riastrad #define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4 751 1.1 riastrad /* Subquery id: Query average GPU power */ 752 1.1 riastrad #define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x5 753 1.1 riastrad /* Subquery id: Query northbridge voltage */ 754 1.1 riastrad #define AMDGPU_INFO_SENSOR_VDDNB 0x6 755 1.1 riastrad /* Subquery id: Query graphics voltage */ 756 1.1 riastrad #define AMDGPU_INFO_SENSOR_VDDGFX 0x7 757 1.1 riastrad /* Subquery id: Query GPU stable pstate shader clock */ 758 1.1 riastrad #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK 0x8 759 1.1 riastrad /* Subquery id: Query GPU stable pstate memory clock */ 760 1.1 riastrad #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK 0x9 761 1.1 riastrad /* Number of VRAM page faults on CPU access. */ 762 1.1 riastrad #define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E 763 1.1 riastrad #define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F 764 1.1 riastrad /* query ras mask of enabled features*/ 765 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_FEATURES 0x20 766 1.1 riastrad 767 1.1 riastrad /* RAS MASK: UMC (VRAM) */ 768 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_UMC (1 << 0) 769 1.1 riastrad /* RAS MASK: SDMA */ 770 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_SDMA (1 << 1) 771 1.1 riastrad /* RAS MASK: GFX */ 772 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_GFX (1 << 2) 773 1.1 riastrad /* RAS MASK: MMHUB */ 774 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_MMHUB (1 << 3) 775 1.1 riastrad /* RAS MASK: ATHUB */ 776 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_ATHUB (1 << 4) 777 1.1 riastrad /* RAS MASK: PCIE */ 778 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_PCIE (1 << 5) 779 1.1 riastrad /* RAS MASK: HDP */ 780 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_HDP (1 << 6) 781 1.1 riastrad /* RAS MASK: XGMI */ 782 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_XGMI (1 << 7) 783 1.1 riastrad /* RAS MASK: DF */ 784 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_DF (1 << 8) 785 1.1 riastrad /* RAS MASK: SMN */ 786 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_SMN (1 << 9) 787 1.1 riastrad /* RAS MASK: SEM */ 788 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_SEM (1 << 10) 789 1.1 riastrad /* RAS MASK: MP0 */ 790 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_MP0 (1 << 11) 791 1.1 riastrad /* RAS MASK: MP1 */ 792 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_MP1 (1 << 12) 793 1.1 riastrad /* RAS MASK: FUSE */ 794 1.1 riastrad #define AMDGPU_INFO_RAS_ENABLED_FUSE (1 << 13) 795 1.1 riastrad 796 1.1 riastrad #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0 797 1.1 riastrad #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff 798 1.1 riastrad #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8 799 1.1 riastrad #define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff 800 1.1 riastrad 801 1.1 riastrad struct drm_amdgpu_query_fw { 802 1.1 riastrad /** AMDGPU_INFO_FW_* */ 803 1.1 riastrad __u32 fw_type; 804 1.1 riastrad /** 805 1.1 riastrad * Index of the IP if there are more IPs of 806 1.1 riastrad * the same type. 807 1.1 riastrad */ 808 1.1 riastrad __u32 ip_instance; 809 1.1 riastrad /** 810 1.1 riastrad * Index of the engine. Whether this is used depends 811 1.1 riastrad * on the firmware type. (e.g. MEC, SDMA) 812 1.1 riastrad */ 813 1.1 riastrad __u32 index; 814 1.1 riastrad __u32 _pad; 815 1.1 riastrad }; 816 1.1 riastrad 817 1.1 riastrad /* Input structure for the INFO ioctl */ 818 1.1 riastrad struct drm_amdgpu_info { 819 1.1 riastrad /* Where the return value will be stored */ 820 1.1 riastrad __u64 return_pointer; 821 1.1 riastrad /* The size of the return value. Just like "size" in "snprintf", 822 1.1 riastrad * it limits how many bytes the kernel can write. */ 823 1.1 riastrad __u32 return_size; 824 1.1 riastrad /* The query request id. */ 825 1.1 riastrad __u32 query; 826 1.1 riastrad 827 1.1 riastrad union { 828 1.1 riastrad struct { 829 1.1 riastrad __u32 id; 830 1.1 riastrad __u32 _pad; 831 1.1 riastrad } mode_crtc; 832 1.1 riastrad 833 1.1 riastrad struct { 834 1.1 riastrad /** AMDGPU_HW_IP_* */ 835 1.1 riastrad __u32 type; 836 1.1 riastrad /** 837 1.1 riastrad * Index of the IP if there are more IPs of the same 838 1.1 riastrad * type. Ignored by AMDGPU_INFO_HW_IP_COUNT. 839 1.1 riastrad */ 840 1.1 riastrad __u32 ip_instance; 841 1.1 riastrad } query_hw_ip; 842 1.1 riastrad 843 1.1 riastrad struct { 844 1.1 riastrad __u32 dword_offset; 845 1.1 riastrad /** number of registers to read */ 846 1.1 riastrad __u32 count; 847 1.1 riastrad __u32 instance; 848 1.1 riastrad /** For future use, no flags defined so far */ 849 1.1 riastrad __u32 flags; 850 1.1 riastrad } read_mmr_reg; 851 1.1 riastrad 852 1.1 riastrad struct drm_amdgpu_query_fw query_fw; 853 1.1 riastrad 854 1.1 riastrad struct { 855 1.1 riastrad __u32 type; 856 1.1 riastrad __u32 offset; 857 1.1 riastrad } vbios_info; 858 1.1 riastrad 859 1.1 riastrad struct { 860 1.1 riastrad __u32 type; 861 1.1 riastrad } sensor_info; 862 1.1 riastrad }; 863 1.1 riastrad }; 864 1.1 riastrad 865 1.1 riastrad struct drm_amdgpu_info_gds { 866 1.1 riastrad /** GDS GFX partition size */ 867 1.1 riastrad __u32 gds_gfx_partition_size; 868 1.1 riastrad /** GDS compute partition size */ 869 1.1 riastrad __u32 compute_partition_size; 870 1.1 riastrad /** total GDS memory size */ 871 1.1 riastrad __u32 gds_total_size; 872 1.1 riastrad /** GWS size per GFX partition */ 873 1.1 riastrad __u32 gws_per_gfx_partition; 874 1.1 riastrad /** GSW size per compute partition */ 875 1.1 riastrad __u32 gws_per_compute_partition; 876 1.1 riastrad /** OA size per GFX partition */ 877 1.1 riastrad __u32 oa_per_gfx_partition; 878 1.1 riastrad /** OA size per compute partition */ 879 1.1 riastrad __u32 oa_per_compute_partition; 880 1.1 riastrad __u32 _pad; 881 1.1 riastrad }; 882 1.1 riastrad 883 1.1 riastrad struct drm_amdgpu_info_vram_gtt { 884 1.1 riastrad __u64 vram_size; 885 1.1 riastrad __u64 vram_cpu_accessible_size; 886 1.1 riastrad __u64 gtt_size; 887 1.1 riastrad }; 888 1.1 riastrad 889 1.1 riastrad struct drm_amdgpu_heap_info { 890 1.1 riastrad /** max. physical memory */ 891 1.1 riastrad __u64 total_heap_size; 892 1.1 riastrad 893 1.1 riastrad /** Theoretical max. available memory in the given heap */ 894 1.1 riastrad __u64 usable_heap_size; 895 1.1 riastrad 896 1.1 riastrad /** 897 1.1 riastrad * Number of bytes allocated in the heap. This includes all processes 898 1.1 riastrad * and private allocations in the kernel. It changes when new buffers 899 1.1 riastrad * are allocated, freed, and moved. It cannot be larger than 900 1.1 riastrad * heap_size. 901 1.1 riastrad */ 902 1.1 riastrad __u64 heap_usage; 903 1.1 riastrad 904 1.1 riastrad /** 905 1.1 riastrad * Theoretical possible max. size of buffer which 906 1.1 riastrad * could be allocated in the given heap 907 1.1 riastrad */ 908 1.1 riastrad __u64 max_allocation; 909 1.1 riastrad }; 910 1.1 riastrad 911 1.1 riastrad struct drm_amdgpu_memory_info { 912 1.1 riastrad struct drm_amdgpu_heap_info vram; 913 1.1 riastrad struct drm_amdgpu_heap_info cpu_accessible_vram; 914 1.1 riastrad struct drm_amdgpu_heap_info gtt; 915 1.1 riastrad }; 916 1.1 riastrad 917 1.1 riastrad struct drm_amdgpu_info_firmware { 918 1.1 riastrad __u32 ver; 919 1.1 riastrad __u32 feature; 920 1.1 riastrad }; 921 1.1 riastrad 922 1.1 riastrad #define AMDGPU_VRAM_TYPE_UNKNOWN 0 923 1.1 riastrad #define AMDGPU_VRAM_TYPE_GDDR1 1 924 1.1 riastrad #define AMDGPU_VRAM_TYPE_DDR2 2 925 1.1 riastrad #define AMDGPU_VRAM_TYPE_GDDR3 3 926 1.1 riastrad #define AMDGPU_VRAM_TYPE_GDDR4 4 927 1.1 riastrad #define AMDGPU_VRAM_TYPE_GDDR5 5 928 1.1 riastrad #define AMDGPU_VRAM_TYPE_HBM 6 929 1.1 riastrad #define AMDGPU_VRAM_TYPE_DDR3 7 930 1.1 riastrad #define AMDGPU_VRAM_TYPE_DDR4 8 931 1.1 riastrad #define AMDGPU_VRAM_TYPE_GDDR6 9 932 1.1 riastrad 933 1.1 riastrad struct drm_amdgpu_info_device { 934 1.1 riastrad /** PCI Device ID */ 935 1.1 riastrad __u32 device_id; 936 1.1 riastrad /** Internal chip revision: A0, A1, etc.) */ 937 1.1 riastrad __u32 chip_rev; 938 1.1 riastrad __u32 external_rev; 939 1.1 riastrad /** Revision id in PCI Config space */ 940 1.1 riastrad __u32 pci_rev; 941 1.1 riastrad __u32 family; 942 1.1 riastrad __u32 num_shader_engines; 943 1.1 riastrad __u32 num_shader_arrays_per_engine; 944 1.1 riastrad /* in KHz */ 945 1.1 riastrad __u32 gpu_counter_freq; 946 1.1 riastrad __u64 max_engine_clock; 947 1.1 riastrad __u64 max_memory_clock; 948 1.1 riastrad /* cu information */ 949 1.1 riastrad __u32 cu_active_number; 950 1.1 riastrad /* NOTE: cu_ao_mask is INVALID, DON'T use it */ 951 1.1 riastrad __u32 cu_ao_mask; 952 1.1 riastrad __u32 cu_bitmap[4][4]; 953 1.1 riastrad /** Render backend pipe mask. One render backend is CB+DB. */ 954 1.1 riastrad __u32 enabled_rb_pipes_mask; 955 1.1 riastrad __u32 num_rb_pipes; 956 1.1 riastrad __u32 num_hw_gfx_contexts; 957 1.1 riastrad __u32 _pad; 958 1.1 riastrad __u64 ids_flags; 959 1.1 riastrad /** Starting virtual address for UMDs. */ 960 1.1 riastrad __u64 virtual_address_offset; 961 1.1 riastrad /** The maximum virtual address */ 962 1.1 riastrad __u64 virtual_address_max; 963 1.1 riastrad /** Required alignment of virtual addresses. */ 964 1.1 riastrad __u32 virtual_address_alignment; 965 1.1 riastrad /** Page table entry - fragment size */ 966 1.1 riastrad __u32 pte_fragment_size; 967 1.1 riastrad __u32 gart_page_size; 968 1.1 riastrad /** constant engine ram size*/ 969 1.1 riastrad __u32 ce_ram_size; 970 1.1 riastrad /** video memory type info*/ 971 1.1 riastrad __u32 vram_type; 972 1.1 riastrad /** video memory bit width*/ 973 1.1 riastrad __u32 vram_bit_width; 974 1.1 riastrad /* vce harvesting instance */ 975 1.1 riastrad __u32 vce_harvest_config; 976 1.1 riastrad /* gfx double offchip LDS buffers */ 977 1.1 riastrad __u32 gc_double_offchip_lds_buf; 978 1.1 riastrad /* NGG Primitive Buffer */ 979 1.1 riastrad __u64 prim_buf_gpu_addr; 980 1.1 riastrad /* NGG Position Buffer */ 981 1.1 riastrad __u64 pos_buf_gpu_addr; 982 1.1 riastrad /* NGG Control Sideband */ 983 1.1 riastrad __u64 cntl_sb_buf_gpu_addr; 984 1.1 riastrad /* NGG Parameter Cache */ 985 1.1 riastrad __u64 param_buf_gpu_addr; 986 1.1 riastrad __u32 prim_buf_size; 987 1.1 riastrad __u32 pos_buf_size; 988 1.1 riastrad __u32 cntl_sb_buf_size; 989 1.1 riastrad __u32 param_buf_size; 990 1.1 riastrad /* wavefront size*/ 991 1.1 riastrad __u32 wave_front_size; 992 1.1 riastrad /* shader visible vgprs*/ 993 1.1 riastrad __u32 num_shader_visible_vgprs; 994 1.1 riastrad /* CU per shader array*/ 995 1.1 riastrad __u32 num_cu_per_sh; 996 1.1 riastrad /* number of tcc blocks*/ 997 1.1 riastrad __u32 num_tcc_blocks; 998 1.1 riastrad /* gs vgt table depth*/ 999 1.1 riastrad __u32 gs_vgt_table_depth; 1000 1.1 riastrad /* gs primitive buffer depth*/ 1001 1.1 riastrad __u32 gs_prim_buffer_depth; 1002 1.1 riastrad /* max gs wavefront per vgt*/ 1003 1.1 riastrad __u32 max_gs_waves_per_vgt; 1004 1.1 riastrad __u32 _pad1; 1005 1.1 riastrad /* always on cu bitmap */ 1006 1.1 riastrad __u32 cu_ao_bitmap[4][4]; 1007 1.1 riastrad /** Starting high virtual address for UMDs. */ 1008 1.1 riastrad __u64 high_va_offset; 1009 1.1 riastrad /** The maximum high virtual address */ 1010 1.1 riastrad __u64 high_va_max; 1011 1.1 riastrad /* gfx10 pa_sc_tile_steering_override */ 1012 1.1 riastrad __u32 pa_sc_tile_steering_override; 1013 1.1 riastrad /* disabled TCCs */ 1014 1.1 riastrad __u64 tcc_disabled_mask; 1015 1.1 riastrad }; 1016 1.1 riastrad 1017 1.1 riastrad struct drm_amdgpu_info_hw_ip { 1018 1.1 riastrad /** Version of h/w IP */ 1019 1.1 riastrad __u32 hw_ip_version_major; 1020 1.1 riastrad __u32 hw_ip_version_minor; 1021 1.1 riastrad /** Capabilities */ 1022 1.1 riastrad __u64 capabilities_flags; 1023 1.1 riastrad /** command buffer address start alignment*/ 1024 1.1 riastrad __u32 ib_start_alignment; 1025 1.1 riastrad /** command buffer size alignment*/ 1026 1.1 riastrad __u32 ib_size_alignment; 1027 1.1 riastrad /** Bitmask of available rings. Bit 0 means ring 0, etc. */ 1028 1.1 riastrad __u32 available_rings; 1029 1.1 riastrad __u32 _pad; 1030 1.1 riastrad }; 1031 1.1 riastrad 1032 1.1 riastrad struct drm_amdgpu_info_num_handles { 1033 1.1 riastrad /** Max handles as supported by firmware for UVD */ 1034 1.1 riastrad __u32 uvd_max_handles; 1035 1.1 riastrad /** Handles currently in use for UVD */ 1036 1.1 riastrad __u32 uvd_used_handles; 1037 1.1 riastrad }; 1038 1.1 riastrad 1039 1.1 riastrad #define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6 1040 1.1 riastrad 1041 1.1 riastrad struct drm_amdgpu_info_vce_clock_table_entry { 1042 1.1 riastrad /** System clock */ 1043 1.1 riastrad __u32 sclk; 1044 1.1 riastrad /** Memory clock */ 1045 1.1 riastrad __u32 mclk; 1046 1.1 riastrad /** VCE clock */ 1047 1.1 riastrad __u32 eclk; 1048 1.1 riastrad __u32 pad; 1049 1.1 riastrad }; 1050 1.1 riastrad 1051 1.1 riastrad struct drm_amdgpu_info_vce_clock_table { 1052 1.1 riastrad struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES]; 1053 1.1 riastrad __u32 num_valid_entries; 1054 1.1 riastrad __u32 pad; 1055 1.1 riastrad }; 1056 1.1 riastrad 1057 1.1 riastrad /* 1058 1.1 riastrad * Supported GPU families 1059 1.1 riastrad */ 1060 1.1 riastrad #define AMDGPU_FAMILY_UNKNOWN 0 1061 1.1 riastrad #define AMDGPU_FAMILY_SI 110 /* Hainan, Oland, Verde, Pitcairn, Tahiti */ 1062 1.1 riastrad #define AMDGPU_FAMILY_CI 120 /* Bonaire, Hawaii */ 1063 1.1 riastrad #define AMDGPU_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */ 1064 1.1 riastrad #define AMDGPU_FAMILY_VI 130 /* Iceland, Tonga */ 1065 1.1 riastrad #define AMDGPU_FAMILY_CZ 135 /* Carrizo, Stoney */ 1066 1.1 riastrad #define AMDGPU_FAMILY_AI 141 /* Vega10 */ 1067 1.1 riastrad #define AMDGPU_FAMILY_RV 142 /* Raven */ 1068 1.1 riastrad #define AMDGPU_FAMILY_NV 143 /* Navi10 */ 1069 1.1 riastrad 1070 1.1 riastrad #if defined(__cplusplus) 1071 1.1 riastrad } 1072 1.1 riastrad #endif 1073 1.1 riastrad 1074 1.1 riastrad #endif 1075