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