File indexing completed on 2025-01-18 10:01:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #ifndef __AMDGPU_DRM_H__
0033 #define __AMDGPU_DRM_H__
0034
0035 #include "drm.h"
0036
0037 #if defined(__cplusplus)
0038 extern "C" {
0039 #endif
0040
0041 #define DRM_AMDGPU_GEM_CREATE 0x00
0042 #define DRM_AMDGPU_GEM_MMAP 0x01
0043 #define DRM_AMDGPU_CTX 0x02
0044 #define DRM_AMDGPU_BO_LIST 0x03
0045 #define DRM_AMDGPU_CS 0x04
0046 #define DRM_AMDGPU_INFO 0x05
0047 #define DRM_AMDGPU_GEM_METADATA 0x06
0048 #define DRM_AMDGPU_GEM_WAIT_IDLE 0x07
0049 #define DRM_AMDGPU_GEM_VA 0x08
0050 #define DRM_AMDGPU_WAIT_CS 0x09
0051 #define DRM_AMDGPU_GEM_OP 0x10
0052 #define DRM_AMDGPU_GEM_USERPTR 0x11
0053 #define DRM_AMDGPU_WAIT_FENCES 0x12
0054 #define DRM_AMDGPU_VM 0x13
0055 #define DRM_AMDGPU_FENCE_TO_HANDLE 0x14
0056 #define DRM_AMDGPU_SCHED 0x15
0057
0058 #define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
0059 #define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
0060 #define DRM_IOCTL_AMDGPU_CTX DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CTX, union drm_amdgpu_ctx)
0061 #define DRM_IOCTL_AMDGPU_BO_LIST DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_BO_LIST, union drm_amdgpu_bo_list)
0062 #define DRM_IOCTL_AMDGPU_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_CS, union drm_amdgpu_cs)
0063 #define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)
0064 #define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)
0065 #define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle)
0066 #define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)
0067 #define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
0068 #define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
0069 #define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
0070 #define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)
0071 #define DRM_IOCTL_AMDGPU_VM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
0072 #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
0073 #define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101 #define AMDGPU_GEM_DOMAIN_CPU 0x1
0102 #define AMDGPU_GEM_DOMAIN_GTT 0x2
0103 #define AMDGPU_GEM_DOMAIN_VRAM 0x4
0104 #define AMDGPU_GEM_DOMAIN_GDS 0x8
0105 #define AMDGPU_GEM_DOMAIN_GWS 0x10
0106 #define AMDGPU_GEM_DOMAIN_OA 0x20
0107 #define AMDGPU_GEM_DOMAIN_DOORBELL 0x40
0108 #define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \
0109 AMDGPU_GEM_DOMAIN_GTT | \
0110 AMDGPU_GEM_DOMAIN_VRAM | \
0111 AMDGPU_GEM_DOMAIN_GDS | \
0112 AMDGPU_GEM_DOMAIN_GWS | \
0113 AMDGPU_GEM_DOMAIN_OA | \
0114 AMDGPU_GEM_DOMAIN_DOORBELL)
0115
0116
0117 #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0)
0118
0119 #define AMDGPU_GEM_CREATE_NO_CPU_ACCESS (1 << 1)
0120
0121 #define AMDGPU_GEM_CREATE_CPU_GTT_USWC (1 << 2)
0122
0123 #define AMDGPU_GEM_CREATE_VRAM_CLEARED (1 << 3)
0124
0125 #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5)
0126
0127 #define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6)
0128
0129 #define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7)
0130
0131
0132
0133
0134 #define AMDGPU_GEM_CREATE_CP_MQD_GFX9 (1 << 8)
0135
0136
0137
0138 #define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE (1 << 9)
0139
0140
0141
0142
0143 #define AMDGPU_GEM_CREATE_ENCRYPTED (1 << 10)
0144
0145
0146
0147 #define AMDGPU_GEM_CREATE_PREEMPTIBLE (1 << 11)
0148
0149
0150
0151 #define AMDGPU_GEM_CREATE_DISCARDABLE (1 << 12)
0152
0153
0154
0155
0156
0157
0158 #define AMDGPU_GEM_CREATE_COHERENT (1 << 13)
0159
0160
0161
0162
0163
0164
0165 #define AMDGPU_GEM_CREATE_UNCACHED (1 << 14)
0166
0167
0168
0169
0170
0171
0172
0173 #define AMDGPU_GEM_CREATE_EXT_COHERENT (1 << 15)
0174
0175 struct drm_amdgpu_gem_create_in {
0176
0177 __u64 bo_size;
0178
0179 __u64 alignment;
0180
0181 __u64 domains;
0182
0183 __u64 domain_flags;
0184 };
0185
0186 struct drm_amdgpu_gem_create_out {
0187
0188 __u32 handle;
0189 __u32 _pad;
0190 };
0191
0192 union drm_amdgpu_gem_create {
0193 struct drm_amdgpu_gem_create_in in;
0194 struct drm_amdgpu_gem_create_out out;
0195 };
0196
0197
0198 #define AMDGPU_BO_LIST_OP_CREATE 0
0199
0200 #define AMDGPU_BO_LIST_OP_DESTROY 1
0201
0202 #define AMDGPU_BO_LIST_OP_UPDATE 2
0203
0204 struct drm_amdgpu_bo_list_in {
0205
0206 __u32 operation;
0207
0208 __u32 list_handle;
0209
0210 __u32 bo_number;
0211
0212 __u32 bo_info_size;
0213
0214 __u64 bo_info_ptr;
0215 };
0216
0217 struct drm_amdgpu_bo_list_entry {
0218
0219 __u32 bo_handle;
0220
0221 __u32 bo_priority;
0222 };
0223
0224 struct drm_amdgpu_bo_list_out {
0225
0226 __u32 list_handle;
0227 __u32 _pad;
0228 };
0229
0230 union drm_amdgpu_bo_list {
0231 struct drm_amdgpu_bo_list_in in;
0232 struct drm_amdgpu_bo_list_out out;
0233 };
0234
0235
0236 #define AMDGPU_CTX_OP_ALLOC_CTX 1
0237 #define AMDGPU_CTX_OP_FREE_CTX 2
0238 #define AMDGPU_CTX_OP_QUERY_STATE 3
0239 #define AMDGPU_CTX_OP_QUERY_STATE2 4
0240 #define AMDGPU_CTX_OP_GET_STABLE_PSTATE 5
0241 #define AMDGPU_CTX_OP_SET_STABLE_PSTATE 6
0242
0243
0244 #define AMDGPU_CTX_NO_RESET 0
0245
0246 #define AMDGPU_CTX_GUILTY_RESET 1
0247
0248 #define AMDGPU_CTX_INNOCENT_RESET 2
0249
0250 #define AMDGPU_CTX_UNKNOWN_RESET 3
0251
0252
0253 #define AMDGPU_CTX_QUERY2_FLAGS_RESET (1<<0)
0254
0255 #define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)
0256
0257 #define AMDGPU_CTX_QUERY2_FLAGS_GUILTY (1<<2)
0258
0259 #define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE (1<<3)
0260 #define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE (1<<4)
0261
0262 #define AMDGPU_CTX_QUERY2_FLAGS_RESET_IN_PROGRESS (1<<5)
0263
0264
0265 #define AMDGPU_CTX_PRIORITY_UNSET -2048
0266 #define AMDGPU_CTX_PRIORITY_VERY_LOW -1023
0267 #define AMDGPU_CTX_PRIORITY_LOW -512
0268 #define AMDGPU_CTX_PRIORITY_NORMAL 0
0269
0270
0271
0272
0273 #define AMDGPU_CTX_PRIORITY_HIGH 512
0274 #define AMDGPU_CTX_PRIORITY_VERY_HIGH 1023
0275
0276
0277 #define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK 0xf
0278 #define AMDGPU_CTX_STABLE_PSTATE_NONE 0
0279 #define AMDGPU_CTX_STABLE_PSTATE_STANDARD 1
0280 #define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK 2
0281 #define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK 3
0282 #define AMDGPU_CTX_STABLE_PSTATE_PEAK 4
0283
0284 struct drm_amdgpu_ctx_in {
0285
0286 __u32 op;
0287
0288 __u32 flags;
0289 __u32 ctx_id;
0290
0291 __s32 priority;
0292 };
0293
0294 union drm_amdgpu_ctx_out {
0295 struct {
0296 __u32 ctx_id;
0297 __u32 _pad;
0298 } alloc;
0299
0300 struct {
0301
0302 __u64 flags;
0303
0304 __u32 hangs;
0305
0306 __u32 reset_status;
0307 } state;
0308
0309 struct {
0310 __u32 flags;
0311 __u32 _pad;
0312 } pstate;
0313 };
0314
0315 union drm_amdgpu_ctx {
0316 struct drm_amdgpu_ctx_in in;
0317 union drm_amdgpu_ctx_out out;
0318 };
0319
0320
0321 #define AMDGPU_VM_OP_RESERVE_VMID 1
0322 #define AMDGPU_VM_OP_UNRESERVE_VMID 2
0323
0324 struct drm_amdgpu_vm_in {
0325
0326 __u32 op;
0327 __u32 flags;
0328 };
0329
0330 struct drm_amdgpu_vm_out {
0331
0332 __u64 flags;
0333 };
0334
0335 union drm_amdgpu_vm {
0336 struct drm_amdgpu_vm_in in;
0337 struct drm_amdgpu_vm_out out;
0338 };
0339
0340
0341 #define AMDGPU_SCHED_OP_PROCESS_PRIORITY_OVERRIDE 1
0342 #define AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE 2
0343
0344 struct drm_amdgpu_sched_in {
0345
0346 __u32 op;
0347 __u32 fd;
0348
0349 __s32 priority;
0350 __u32 ctx_id;
0351 };
0352
0353 union drm_amdgpu_sched {
0354 struct drm_amdgpu_sched_in in;
0355 };
0356
0357
0358
0359
0360
0361
0362 #define AMDGPU_GEM_USERPTR_READONLY (1 << 0)
0363 #define AMDGPU_GEM_USERPTR_ANONONLY (1 << 1)
0364 #define AMDGPU_GEM_USERPTR_VALIDATE (1 << 2)
0365 #define AMDGPU_GEM_USERPTR_REGISTER (1 << 3)
0366
0367 struct drm_amdgpu_gem_userptr {
0368 __u64 addr;
0369 __u64 size;
0370
0371 __u32 flags;
0372
0373 __u32 handle;
0374 };
0375
0376
0377
0378 #define AMDGPU_TILING_ARRAY_MODE_SHIFT 0
0379 #define AMDGPU_TILING_ARRAY_MODE_MASK 0xf
0380 #define AMDGPU_TILING_PIPE_CONFIG_SHIFT 4
0381 #define AMDGPU_TILING_PIPE_CONFIG_MASK 0x1f
0382 #define AMDGPU_TILING_TILE_SPLIT_SHIFT 9
0383 #define AMDGPU_TILING_TILE_SPLIT_MASK 0x7
0384 #define AMDGPU_TILING_MICRO_TILE_MODE_SHIFT 12
0385 #define AMDGPU_TILING_MICRO_TILE_MODE_MASK 0x7
0386 #define AMDGPU_TILING_BANK_WIDTH_SHIFT 15
0387 #define AMDGPU_TILING_BANK_WIDTH_MASK 0x3
0388 #define AMDGPU_TILING_BANK_HEIGHT_SHIFT 17
0389 #define AMDGPU_TILING_BANK_HEIGHT_MASK 0x3
0390 #define AMDGPU_TILING_MACRO_TILE_ASPECT_SHIFT 19
0391 #define AMDGPU_TILING_MACRO_TILE_ASPECT_MASK 0x3
0392 #define AMDGPU_TILING_NUM_BANKS_SHIFT 21
0393 #define AMDGPU_TILING_NUM_BANKS_MASK 0x3
0394
0395
0396 #define AMDGPU_TILING_SWIZZLE_MODE_SHIFT 0
0397 #define AMDGPU_TILING_SWIZZLE_MODE_MASK 0x1f
0398 #define AMDGPU_TILING_DCC_OFFSET_256B_SHIFT 5
0399 #define AMDGPU_TILING_DCC_OFFSET_256B_MASK 0xFFFFFF
0400 #define AMDGPU_TILING_DCC_PITCH_MAX_SHIFT 29
0401 #define AMDGPU_TILING_DCC_PITCH_MAX_MASK 0x3FFF
0402 #define AMDGPU_TILING_DCC_INDEPENDENT_64B_SHIFT 43
0403 #define AMDGPU_TILING_DCC_INDEPENDENT_64B_MASK 0x1
0404 #define AMDGPU_TILING_DCC_INDEPENDENT_128B_SHIFT 44
0405 #define AMDGPU_TILING_DCC_INDEPENDENT_128B_MASK 0x1
0406 #define AMDGPU_TILING_SCANOUT_SHIFT 63
0407 #define AMDGPU_TILING_SCANOUT_MASK 0x1
0408
0409
0410 #define AMDGPU_TILING_GFX12_SWIZZLE_MODE_SHIFT 0
0411 #define AMDGPU_TILING_GFX12_SWIZZLE_MODE_MASK 0x7
0412
0413 #define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_SHIFT 3
0414 #define AMDGPU_TILING_GFX12_DCC_MAX_COMPRESSED_BLOCK_MASK 0x3
0415 #define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_SHIFT 5
0416 #define AMDGPU_TILING_GFX12_DCC_NUMBER_TYPE_MASK 0x7
0417 #define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_SHIFT 8
0418 #define AMDGPU_TILING_GFX12_DCC_DATA_FORMAT_MASK 0x3f
0419
0420
0421 #define AMDGPU_TILING_SET(field, value) \
0422 (((__u64)(value) & AMDGPU_TILING_##field##_MASK) << AMDGPU_TILING_##field##_SHIFT)
0423 #define AMDGPU_TILING_GET(value, field) \
0424 (((__u64)(value) >> AMDGPU_TILING_##field##_SHIFT) & AMDGPU_TILING_##field##_MASK)
0425
0426 #define AMDGPU_GEM_METADATA_OP_SET_METADATA 1
0427 #define AMDGPU_GEM_METADATA_OP_GET_METADATA 2
0428
0429
0430 struct drm_amdgpu_gem_metadata {
0431
0432 __u32 handle;
0433
0434 __u32 op;
0435 struct {
0436
0437 __u64 flags;
0438
0439 __u64 tiling_info;
0440 __u32 data_size_bytes;
0441 __u32 data[64];
0442 } data;
0443 };
0444
0445 struct drm_amdgpu_gem_mmap_in {
0446
0447 __u32 handle;
0448 __u32 _pad;
0449 };
0450
0451 struct drm_amdgpu_gem_mmap_out {
0452
0453 __u64 addr_ptr;
0454 };
0455
0456 union drm_amdgpu_gem_mmap {
0457 struct drm_amdgpu_gem_mmap_in in;
0458 struct drm_amdgpu_gem_mmap_out out;
0459 };
0460
0461 struct drm_amdgpu_gem_wait_idle_in {
0462
0463 __u32 handle;
0464
0465 __u32 flags;
0466
0467 __u64 timeout;
0468 };
0469
0470 struct drm_amdgpu_gem_wait_idle_out {
0471
0472 __u32 status;
0473
0474 __u32 domain;
0475 };
0476
0477 union drm_amdgpu_gem_wait_idle {
0478 struct drm_amdgpu_gem_wait_idle_in in;
0479 struct drm_amdgpu_gem_wait_idle_out out;
0480 };
0481
0482 struct drm_amdgpu_wait_cs_in {
0483
0484
0485
0486
0487 __u64 handle;
0488
0489 __u64 timeout;
0490 __u32 ip_type;
0491 __u32 ip_instance;
0492 __u32 ring;
0493 __u32 ctx_id;
0494 };
0495
0496 struct drm_amdgpu_wait_cs_out {
0497
0498 __u64 status;
0499 };
0500
0501 union drm_amdgpu_wait_cs {
0502 struct drm_amdgpu_wait_cs_in in;
0503 struct drm_amdgpu_wait_cs_out out;
0504 };
0505
0506 struct drm_amdgpu_fence {
0507 __u32 ctx_id;
0508 __u32 ip_type;
0509 __u32 ip_instance;
0510 __u32 ring;
0511 __u64 seq_no;
0512 };
0513
0514 struct drm_amdgpu_wait_fences_in {
0515
0516 __u64 fences;
0517 __u32 fence_count;
0518 __u32 wait_all;
0519 __u64 timeout_ns;
0520 };
0521
0522 struct drm_amdgpu_wait_fences_out {
0523 __u32 status;
0524 __u32 first_signaled;
0525 };
0526
0527 union drm_amdgpu_wait_fences {
0528 struct drm_amdgpu_wait_fences_in in;
0529 struct drm_amdgpu_wait_fences_out out;
0530 };
0531
0532 #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0
0533 #define AMDGPU_GEM_OP_SET_PLACEMENT 1
0534
0535
0536 struct drm_amdgpu_gem_op {
0537
0538 __u32 handle;
0539
0540 __u32 op;
0541
0542 __u64 value;
0543 };
0544
0545 #define AMDGPU_VA_OP_MAP 1
0546 #define AMDGPU_VA_OP_UNMAP 2
0547 #define AMDGPU_VA_OP_CLEAR 3
0548 #define AMDGPU_VA_OP_REPLACE 4
0549
0550
0551 #define AMDGPU_VM_DELAY_UPDATE (1 << 0)
0552
0553
0554
0555 #define AMDGPU_VM_PAGE_READABLE (1 << 1)
0556
0557 #define AMDGPU_VM_PAGE_WRITEABLE (1 << 2)
0558
0559 #define AMDGPU_VM_PAGE_EXECUTABLE (1 << 3)
0560
0561 #define AMDGPU_VM_PAGE_PRT (1 << 4)
0562
0563 #define AMDGPU_VM_MTYPE_MASK (0xf << 5)
0564
0565 #define AMDGPU_VM_MTYPE_DEFAULT (0 << 5)
0566
0567 #define AMDGPU_VM_MTYPE_NC (1 << 5)
0568
0569 #define AMDGPU_VM_MTYPE_WC (2 << 5)
0570
0571 #define AMDGPU_VM_MTYPE_CC (3 << 5)
0572
0573 #define AMDGPU_VM_MTYPE_UC (4 << 5)
0574
0575 #define AMDGPU_VM_MTYPE_RW (5 << 5)
0576
0577 #define AMDGPU_VM_PAGE_NOALLOC (1 << 9)
0578
0579 struct drm_amdgpu_gem_va {
0580
0581 __u32 handle;
0582 __u32 _pad;
0583
0584 __u32 operation;
0585
0586 __u32 flags;
0587
0588 __u64 va_address;
0589
0590 __u64 offset_in_bo;
0591
0592 __u64 map_size;
0593 };
0594
0595 #define AMDGPU_HW_IP_GFX 0
0596 #define AMDGPU_HW_IP_COMPUTE 1
0597 #define AMDGPU_HW_IP_DMA 2
0598 #define AMDGPU_HW_IP_UVD 3
0599 #define AMDGPU_HW_IP_VCE 4
0600 #define AMDGPU_HW_IP_UVD_ENC 5
0601 #define AMDGPU_HW_IP_VCN_DEC 6
0602
0603
0604
0605
0606 #define AMDGPU_HW_IP_VCN_ENC 7
0607 #define AMDGPU_HW_IP_VCN_JPEG 8
0608 #define AMDGPU_HW_IP_VPE 9
0609 #define AMDGPU_HW_IP_NUM 10
0610
0611 #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
0612
0613 #define AMDGPU_CHUNK_ID_IB 0x01
0614 #define AMDGPU_CHUNK_ID_FENCE 0x02
0615 #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
0616 #define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04
0617 #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05
0618 #define AMDGPU_CHUNK_ID_BO_HANDLES 0x06
0619 #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
0620 #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT 0x08
0621 #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL 0x09
0622 #define AMDGPU_CHUNK_ID_CP_GFX_SHADOW 0x0a
0623
0624 struct drm_amdgpu_cs_chunk {
0625 __u32 chunk_id;
0626 __u32 length_dw;
0627 __u64 chunk_data;
0628 };
0629
0630 struct drm_amdgpu_cs_in {
0631
0632 __u32 ctx_id;
0633
0634 __u32 bo_list_handle;
0635 __u32 num_chunks;
0636 __u32 flags;
0637
0638 __u64 chunks;
0639 };
0640
0641 struct drm_amdgpu_cs_out {
0642 __u64 handle;
0643 };
0644
0645 union drm_amdgpu_cs {
0646 struct drm_amdgpu_cs_in in;
0647 struct drm_amdgpu_cs_out out;
0648 };
0649
0650
0651
0652
0653 #define AMDGPU_IB_FLAG_CE (1<<0)
0654
0655
0656 #define AMDGPU_IB_FLAG_PREAMBLE (1<<1)
0657
0658
0659 #define AMDGPU_IB_FLAG_PREEMPT (1<<2)
0660
0661
0662
0663 #define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3)
0664
0665
0666
0667
0668 #define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4)
0669
0670
0671
0672 #define AMDGPU_IB_FLAGS_SECURE (1 << 5)
0673
0674
0675
0676 #define AMDGPU_IB_FLAG_EMIT_MEM_SYNC (1 << 6)
0677
0678 struct drm_amdgpu_cs_chunk_ib {
0679 __u32 _pad;
0680
0681 __u32 flags;
0682
0683 __u64 va_start;
0684
0685 __u32 ib_bytes;
0686
0687 __u32 ip_type;
0688
0689 __u32 ip_instance;
0690
0691 __u32 ring;
0692 };
0693
0694 struct drm_amdgpu_cs_chunk_dep {
0695 __u32 ip_type;
0696 __u32 ip_instance;
0697 __u32 ring;
0698 __u32 ctx_id;
0699 __u64 handle;
0700 };
0701
0702 struct drm_amdgpu_cs_chunk_fence {
0703 __u32 handle;
0704 __u32 offset;
0705 };
0706
0707 struct drm_amdgpu_cs_chunk_sem {
0708 __u32 handle;
0709 };
0710
0711 struct drm_amdgpu_cs_chunk_syncobj {
0712 __u32 handle;
0713 __u32 flags;
0714 __u64 point;
0715 };
0716
0717 #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 0
0718 #define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 1
0719 #define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2
0720
0721 union drm_amdgpu_fence_to_handle {
0722 struct {
0723 struct drm_amdgpu_fence fence;
0724 __u32 what;
0725 __u32 pad;
0726 } in;
0727 struct {
0728 __u32 handle;
0729 } out;
0730 };
0731
0732 struct drm_amdgpu_cs_chunk_data {
0733 union {
0734 struct drm_amdgpu_cs_chunk_ib ib_data;
0735 struct drm_amdgpu_cs_chunk_fence fence_data;
0736 };
0737 };
0738
0739 #define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW 0x1
0740
0741 struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
0742 __u64 shadow_va;
0743 __u64 csa_va;
0744 __u64 gds_va;
0745 __u64 flags;
0746 };
0747
0748
0749
0750
0751
0752 #define AMDGPU_IDS_FLAGS_FUSION 0x1
0753 #define AMDGPU_IDS_FLAGS_PREEMPTION 0x2
0754 #define AMDGPU_IDS_FLAGS_TMZ 0x4
0755 #define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x8
0756
0757
0758
0759
0760
0761 #define AMDGPU_IDS_FLAGS_MODE_MASK 0x300
0762 #define AMDGPU_IDS_FLAGS_MODE_SHIFT 0x8
0763 #define AMDGPU_IDS_FLAGS_MODE_PF 0x0
0764 #define AMDGPU_IDS_FLAGS_MODE_VF 0x1
0765 #define AMDGPU_IDS_FLAGS_MODE_PT 0x2
0766
0767
0768 #define AMDGPU_INFO_ACCEL_WORKING 0x00
0769
0770 #define AMDGPU_INFO_CRTC_FROM_ID 0x01
0771
0772 #define AMDGPU_INFO_HW_IP_INFO 0x02
0773
0774 #define AMDGPU_INFO_HW_IP_COUNT 0x03
0775
0776 #define AMDGPU_INFO_TIMESTAMP 0x05
0777
0778 #define AMDGPU_INFO_FW_VERSION 0x0e
0779
0780 #define AMDGPU_INFO_FW_VCE 0x1
0781
0782 #define AMDGPU_INFO_FW_UVD 0x2
0783
0784 #define AMDGPU_INFO_FW_GMC 0x03
0785
0786 #define AMDGPU_INFO_FW_GFX_ME 0x04
0787
0788 #define AMDGPU_INFO_FW_GFX_PFP 0x05
0789
0790 #define AMDGPU_INFO_FW_GFX_CE 0x06
0791
0792 #define AMDGPU_INFO_FW_GFX_RLC 0x07
0793
0794 #define AMDGPU_INFO_FW_GFX_MEC 0x08
0795
0796 #define AMDGPU_INFO_FW_SMC 0x0a
0797
0798 #define AMDGPU_INFO_FW_SDMA 0x0b
0799
0800 #define AMDGPU_INFO_FW_SOS 0x0c
0801
0802 #define AMDGPU_INFO_FW_ASD 0x0d
0803
0804 #define AMDGPU_INFO_FW_VCN 0x0e
0805
0806 #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f
0807
0808 #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10
0809
0810 #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11
0811
0812 #define AMDGPU_INFO_FW_DMCU 0x12
0813 #define AMDGPU_INFO_FW_TA 0x13
0814
0815 #define AMDGPU_INFO_FW_DMCUB 0x14
0816
0817 #define AMDGPU_INFO_FW_TOC 0x15
0818
0819 #define AMDGPU_INFO_FW_CAP 0x16
0820
0821 #define AMDGPU_INFO_FW_GFX_RLCP 0x17
0822
0823 #define AMDGPU_INFO_FW_GFX_RLCV 0x18
0824
0825 #define AMDGPU_INFO_FW_MES_KIQ 0x19
0826
0827 #define AMDGPU_INFO_FW_MES 0x1a
0828
0829 #define AMDGPU_INFO_FW_IMU 0x1b
0830
0831 #define AMDGPU_INFO_FW_VPE 0x1c
0832
0833
0834 #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
0835
0836 #define AMDGPU_INFO_VRAM_USAGE 0x10
0837
0838 #define AMDGPU_INFO_GTT_USAGE 0x11
0839
0840 #define AMDGPU_INFO_GDS_CONFIG 0x13
0841
0842 #define AMDGPU_INFO_VRAM_GTT 0x14
0843
0844 #define AMDGPU_INFO_READ_MMR_REG 0x15
0845
0846 #define AMDGPU_INFO_DEV_INFO 0x16
0847
0848 #define AMDGPU_INFO_VIS_VRAM_USAGE 0x17
0849
0850 #define AMDGPU_INFO_NUM_EVICTIONS 0x18
0851
0852 #define AMDGPU_INFO_MEMORY 0x19
0853
0854 #define AMDGPU_INFO_VCE_CLOCK_TABLE 0x1A
0855
0856 #define AMDGPU_INFO_VBIOS 0x1B
0857
0858 #define AMDGPU_INFO_VBIOS_SIZE 0x1
0859
0860 #define AMDGPU_INFO_VBIOS_IMAGE 0x2
0861
0862 #define AMDGPU_INFO_VBIOS_INFO 0x3
0863
0864 #define AMDGPU_INFO_NUM_HANDLES 0x1C
0865
0866 #define AMDGPU_INFO_SENSOR 0x1D
0867
0868 #define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1
0869
0870 #define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2
0871
0872 #define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3
0873
0874 #define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4
0875
0876 #define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x5
0877
0878 #define AMDGPU_INFO_SENSOR_VDDNB 0x6
0879
0880 #define AMDGPU_INFO_SENSOR_VDDGFX 0x7
0881
0882 #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK 0x8
0883
0884 #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK 0x9
0885
0886 #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_SCLK 0xa
0887
0888 #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_MCLK 0xb
0889
0890 #define AMDGPU_INFO_SENSOR_GPU_INPUT_POWER 0xc
0891
0892 #define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E
0893 #define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F
0894
0895 #define AMDGPU_INFO_RAS_ENABLED_FEATURES 0x20
0896
0897 #define AMDGPU_INFO_RAS_ENABLED_UMC (1 << 0)
0898
0899 #define AMDGPU_INFO_RAS_ENABLED_SDMA (1 << 1)
0900
0901 #define AMDGPU_INFO_RAS_ENABLED_GFX (1 << 2)
0902
0903 #define AMDGPU_INFO_RAS_ENABLED_MMHUB (1 << 3)
0904
0905 #define AMDGPU_INFO_RAS_ENABLED_ATHUB (1 << 4)
0906
0907 #define AMDGPU_INFO_RAS_ENABLED_PCIE (1 << 5)
0908
0909 #define AMDGPU_INFO_RAS_ENABLED_HDP (1 << 6)
0910
0911 #define AMDGPU_INFO_RAS_ENABLED_XGMI (1 << 7)
0912
0913 #define AMDGPU_INFO_RAS_ENABLED_DF (1 << 8)
0914
0915 #define AMDGPU_INFO_RAS_ENABLED_SMN (1 << 9)
0916
0917 #define AMDGPU_INFO_RAS_ENABLED_SEM (1 << 10)
0918
0919 #define AMDGPU_INFO_RAS_ENABLED_MP0 (1 << 11)
0920
0921 #define AMDGPU_INFO_RAS_ENABLED_MP1 (1 << 12)
0922
0923 #define AMDGPU_INFO_RAS_ENABLED_FUSE (1 << 13)
0924
0925 #define AMDGPU_INFO_VIDEO_CAPS 0x21
0926
0927 #define AMDGPU_INFO_VIDEO_CAPS_DECODE 0
0928
0929 #define AMDGPU_INFO_VIDEO_CAPS_ENCODE 1
0930
0931 #define AMDGPU_INFO_MAX_IBS 0x22
0932
0933 #define AMDGPU_INFO_GPUVM_FAULT 0x23
0934
0935 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
0936 #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
0937 #define AMDGPU_INFO_MMR_SH_INDEX_SHIFT 8
0938 #define AMDGPU_INFO_MMR_SH_INDEX_MASK 0xff
0939
0940 struct drm_amdgpu_query_fw {
0941
0942 __u32 fw_type;
0943
0944
0945
0946
0947 __u32 ip_instance;
0948
0949
0950
0951
0952 __u32 index;
0953 __u32 _pad;
0954 };
0955
0956
0957 struct drm_amdgpu_info {
0958
0959 __u64 return_pointer;
0960
0961
0962 __u32 return_size;
0963
0964 __u32 query;
0965
0966 union {
0967 struct {
0968 __u32 id;
0969 __u32 _pad;
0970 } mode_crtc;
0971
0972 struct {
0973
0974 __u32 type;
0975
0976
0977
0978
0979 __u32 ip_instance;
0980 } query_hw_ip;
0981
0982 struct {
0983 __u32 dword_offset;
0984
0985 __u32 count;
0986 __u32 instance;
0987
0988 __u32 flags;
0989 } read_mmr_reg;
0990
0991 struct drm_amdgpu_query_fw query_fw;
0992
0993 struct {
0994 __u32 type;
0995 __u32 offset;
0996 } vbios_info;
0997
0998 struct {
0999 __u32 type;
1000 } sensor_info;
1001
1002 struct {
1003 __u32 type;
1004 } video_cap;
1005 };
1006 };
1007
1008 struct drm_amdgpu_info_gds {
1009
1010 __u32 gds_gfx_partition_size;
1011
1012 __u32 compute_partition_size;
1013
1014 __u32 gds_total_size;
1015
1016 __u32 gws_per_gfx_partition;
1017
1018 __u32 gws_per_compute_partition;
1019
1020 __u32 oa_per_gfx_partition;
1021
1022 __u32 oa_per_compute_partition;
1023 __u32 _pad;
1024 };
1025
1026 struct drm_amdgpu_info_vram_gtt {
1027 __u64 vram_size;
1028 __u64 vram_cpu_accessible_size;
1029 __u64 gtt_size;
1030 };
1031
1032 struct drm_amdgpu_heap_info {
1033
1034 __u64 total_heap_size;
1035
1036
1037 __u64 usable_heap_size;
1038
1039
1040
1041
1042
1043
1044
1045 __u64 heap_usage;
1046
1047
1048
1049
1050
1051 __u64 max_allocation;
1052 };
1053
1054 struct drm_amdgpu_memory_info {
1055 struct drm_amdgpu_heap_info vram;
1056 struct drm_amdgpu_heap_info cpu_accessible_vram;
1057 struct drm_amdgpu_heap_info gtt;
1058 };
1059
1060 struct drm_amdgpu_info_firmware {
1061 __u32 ver;
1062 __u32 feature;
1063 };
1064
1065 struct drm_amdgpu_info_vbios {
1066 __u8 name[64];
1067 __u8 vbios_pn[64];
1068 __u32 version;
1069 __u32 pad;
1070 __u8 vbios_ver_str[32];
1071 __u8 date[32];
1072 };
1073
1074 #define AMDGPU_VRAM_TYPE_UNKNOWN 0
1075 #define AMDGPU_VRAM_TYPE_GDDR1 1
1076 #define AMDGPU_VRAM_TYPE_DDR2 2
1077 #define AMDGPU_VRAM_TYPE_GDDR3 3
1078 #define AMDGPU_VRAM_TYPE_GDDR4 4
1079 #define AMDGPU_VRAM_TYPE_GDDR5 5
1080 #define AMDGPU_VRAM_TYPE_HBM 6
1081 #define AMDGPU_VRAM_TYPE_DDR3 7
1082 #define AMDGPU_VRAM_TYPE_DDR4 8
1083 #define AMDGPU_VRAM_TYPE_GDDR6 9
1084 #define AMDGPU_VRAM_TYPE_DDR5 10
1085 #define AMDGPU_VRAM_TYPE_LPDDR4 11
1086 #define AMDGPU_VRAM_TYPE_LPDDR5 12
1087
1088 struct drm_amdgpu_info_device {
1089
1090 __u32 device_id;
1091
1092 __u32 chip_rev;
1093 __u32 external_rev;
1094
1095 __u32 pci_rev;
1096 __u32 family;
1097 __u32 num_shader_engines;
1098 __u32 num_shader_arrays_per_engine;
1099
1100 __u32 gpu_counter_freq;
1101 __u64 max_engine_clock;
1102 __u64 max_memory_clock;
1103
1104 __u32 cu_active_number;
1105
1106 __u32 cu_ao_mask;
1107 __u32 cu_bitmap[4][4];
1108
1109 __u32 enabled_rb_pipes_mask;
1110 __u32 num_rb_pipes;
1111 __u32 num_hw_gfx_contexts;
1112
1113 __u32 pcie_gen;
1114 __u64 ids_flags;
1115
1116 __u64 virtual_address_offset;
1117
1118 __u64 virtual_address_max;
1119
1120 __u32 virtual_address_alignment;
1121
1122 __u32 pte_fragment_size;
1123 __u32 gart_page_size;
1124
1125 __u32 ce_ram_size;
1126
1127 __u32 vram_type;
1128
1129 __u32 vram_bit_width;
1130
1131 __u32 vce_harvest_config;
1132
1133 __u32 gc_double_offchip_lds_buf;
1134
1135 __u64 prim_buf_gpu_addr;
1136
1137 __u64 pos_buf_gpu_addr;
1138
1139 __u64 cntl_sb_buf_gpu_addr;
1140
1141 __u64 param_buf_gpu_addr;
1142 __u32 prim_buf_size;
1143 __u32 pos_buf_size;
1144 __u32 cntl_sb_buf_size;
1145 __u32 param_buf_size;
1146
1147 __u32 wave_front_size;
1148
1149 __u32 num_shader_visible_vgprs;
1150
1151 __u32 num_cu_per_sh;
1152
1153 __u32 num_tcc_blocks;
1154
1155 __u32 gs_vgt_table_depth;
1156
1157 __u32 gs_prim_buffer_depth;
1158
1159 __u32 max_gs_waves_per_vgt;
1160
1161 __u32 pcie_num_lanes;
1162
1163 __u32 cu_ao_bitmap[4][4];
1164
1165 __u64 high_va_offset;
1166
1167 __u64 high_va_max;
1168
1169 __u32 pa_sc_tile_steering_override;
1170
1171 __u64 tcc_disabled_mask;
1172 __u64 min_engine_clock;
1173 __u64 min_memory_clock;
1174
1175 __u32 tcp_cache_size;
1176 __u32 num_sqc_per_wgp;
1177 __u32 sqc_data_cache_size;
1178 __u32 sqc_inst_cache_size;
1179 __u32 gl1c_cache_size;
1180 __u32 gl2c_cache_size;
1181 __u64 mall_size;
1182
1183 __u32 enabled_rb_pipes_mask_hi;
1184
1185 __u32 shadow_size;
1186
1187 __u32 shadow_alignment;
1188
1189 __u32 csa_size;
1190
1191 __u32 csa_alignment;
1192 };
1193
1194 struct drm_amdgpu_info_hw_ip {
1195
1196 __u32 hw_ip_version_major;
1197 __u32 hw_ip_version_minor;
1198
1199 __u64 capabilities_flags;
1200
1201 __u32 ib_start_alignment;
1202
1203 __u32 ib_size_alignment;
1204
1205 __u32 available_rings;
1206
1207 __u32 ip_discovery_version;
1208 };
1209
1210 struct drm_amdgpu_info_num_handles {
1211
1212 __u32 uvd_max_handles;
1213
1214 __u32 uvd_used_handles;
1215 };
1216
1217 #define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6
1218
1219 struct drm_amdgpu_info_vce_clock_table_entry {
1220
1221 __u32 sclk;
1222
1223 __u32 mclk;
1224
1225 __u32 eclk;
1226 __u32 pad;
1227 };
1228
1229 struct drm_amdgpu_info_vce_clock_table {
1230 struct drm_amdgpu_info_vce_clock_table_entry entries[AMDGPU_VCE_CLOCK_TABLE_ENTRIES];
1231 __u32 num_valid_entries;
1232 __u32 pad;
1233 };
1234
1235
1236 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 0
1237 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 1
1238 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 2
1239 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC 3
1240 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC 4
1241 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG 5
1242 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9 6
1243 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1 7
1244 #define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT 8
1245
1246 struct drm_amdgpu_info_video_codec_info {
1247 __u32 valid;
1248 __u32 max_width;
1249 __u32 max_height;
1250 __u32 max_pixels_per_frame;
1251 __u32 max_level;
1252 __u32 pad;
1253 };
1254
1255 struct drm_amdgpu_info_video_caps {
1256 struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT];
1257 };
1258
1259 #define AMDGPU_VMHUB_TYPE_MASK 0xff
1260 #define AMDGPU_VMHUB_TYPE_SHIFT 0
1261 #define AMDGPU_VMHUB_TYPE_GFX 0
1262 #define AMDGPU_VMHUB_TYPE_MM0 1
1263 #define AMDGPU_VMHUB_TYPE_MM1 2
1264 #define AMDGPU_VMHUB_IDX_MASK 0xff00
1265 #define AMDGPU_VMHUB_IDX_SHIFT 8
1266
1267 struct drm_amdgpu_info_gpuvm_fault {
1268 __u64 addr;
1269 __u32 status;
1270 __u32 vmhub;
1271 };
1272
1273
1274
1275
1276 #define AMDGPU_FAMILY_UNKNOWN 0
1277 #define AMDGPU_FAMILY_SI 110
1278 #define AMDGPU_FAMILY_CI 120
1279 #define AMDGPU_FAMILY_KV 125
1280 #define AMDGPU_FAMILY_VI 130
1281 #define AMDGPU_FAMILY_CZ 135
1282 #define AMDGPU_FAMILY_AI 141
1283 #define AMDGPU_FAMILY_RV 142
1284 #define AMDGPU_FAMILY_NV 143
1285 #define AMDGPU_FAMILY_VGH 144
1286 #define AMDGPU_FAMILY_GC_11_0_0 145
1287 #define AMDGPU_FAMILY_YC 146
1288 #define AMDGPU_FAMILY_GC_11_0_1 148
1289 #define AMDGPU_FAMILY_GC_10_3_6 149
1290 #define AMDGPU_FAMILY_GC_10_3_7 151
1291 #define AMDGPU_FAMILY_GC_11_5_0 150
1292 #define AMDGPU_FAMILY_GC_12_0_0 152
1293
1294 #if defined(__cplusplus)
1295 }
1296 #endif
1297
1298 #endif