.. | .. |
---|
26 | 26 | #include <drm/drm.h> |
---|
27 | 27 | #include <linux/ioctl.h> |
---|
28 | 28 | |
---|
| 29 | +/* |
---|
| 30 | + * - 1.1 - initial version |
---|
| 31 | + * - 1.3 - Add SMI events support |
---|
| 32 | + */ |
---|
29 | 33 | #define KFD_IOCTL_MAJOR_VERSION 1 |
---|
30 | | -#define KFD_IOCTL_MINOR_VERSION 1 |
---|
| 34 | +#define KFD_IOCTL_MINOR_VERSION 3 |
---|
31 | 35 | |
---|
32 | 36 | struct kfd_ioctl_get_version_args { |
---|
33 | 37 | __u32 major_version; /* from KFD */ |
---|
.. | .. |
---|
35 | 39 | }; |
---|
36 | 40 | |
---|
37 | 41 | /* For kfd_ioctl_create_queue_args.queue_type. */ |
---|
38 | | -#define KFD_IOC_QUEUE_TYPE_COMPUTE 0 |
---|
39 | | -#define KFD_IOC_QUEUE_TYPE_SDMA 1 |
---|
40 | | -#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 2 |
---|
| 42 | +#define KFD_IOC_QUEUE_TYPE_COMPUTE 0x0 |
---|
| 43 | +#define KFD_IOC_QUEUE_TYPE_SDMA 0x1 |
---|
| 44 | +#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 0x2 |
---|
| 45 | +#define KFD_IOC_QUEUE_TYPE_SDMA_XGMI 0x3 |
---|
41 | 46 | |
---|
42 | 47 | #define KFD_MAX_QUEUE_PERCENTAGE 100 |
---|
43 | 48 | #define KFD_MAX_QUEUE_PRIORITY 15 |
---|
.. | .. |
---|
80 | 85 | __u32 queue_id; /* to KFD */ |
---|
81 | 86 | __u32 num_cu_mask; /* to KFD */ |
---|
82 | 87 | __u64 cu_mask_ptr; /* to KFD */ |
---|
| 88 | +}; |
---|
| 89 | + |
---|
| 90 | +struct kfd_ioctl_get_queue_wave_state_args { |
---|
| 91 | + __u64 ctl_stack_address; /* to KFD */ |
---|
| 92 | + __u32 ctl_stack_used_size; /* from KFD */ |
---|
| 93 | + __u32 save_area_used_size; /* from KFD */ |
---|
| 94 | + __u32 queue_id; /* to KFD */ |
---|
| 95 | + __u32 pad; |
---|
83 | 96 | }; |
---|
84 | 97 | |
---|
85 | 98 | /* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */ |
---|
.. | .. |
---|
203 | 216 | #define KFD_HW_EXCEPTION_GPU_HANG 0 |
---|
204 | 217 | #define KFD_HW_EXCEPTION_ECC 1 |
---|
205 | 218 | |
---|
| 219 | +/* For kfd_hsa_memory_exception_data.ErrorType */ |
---|
| 220 | +#define KFD_MEM_ERR_NO_RAS 0 |
---|
| 221 | +#define KFD_MEM_ERR_SRAM_ECC 1 |
---|
| 222 | +#define KFD_MEM_ERR_POISON_CONSUMED 2 |
---|
| 223 | +#define KFD_MEM_ERR_GPU_HANG 3 |
---|
206 | 224 | |
---|
207 | 225 | struct kfd_ioctl_create_event_args { |
---|
208 | 226 | __u64 event_page_offset; /* from KFD */ |
---|
.. | .. |
---|
237 | 255 | __u32 imprecise; /* Can't determine the exact fault address */ |
---|
238 | 256 | }; |
---|
239 | 257 | |
---|
240 | | -/* memory exception data*/ |
---|
| 258 | +/* memory exception data */ |
---|
241 | 259 | struct kfd_hsa_memory_exception_data { |
---|
242 | 260 | struct kfd_memory_exception_failure failure; |
---|
243 | 261 | __u64 va; |
---|
244 | 262 | __u32 gpu_id; |
---|
245 | | - __u32 pad; |
---|
| 263 | + __u32 ErrorType; /* 0 = no RAS error, |
---|
| 264 | + * 1 = ECC_SRAM, |
---|
| 265 | + * 2 = Link_SYNFLOOD (poison), |
---|
| 266 | + * 3 = GPU hang (not attributable to a specific cause), |
---|
| 267 | + * other values reserved |
---|
| 268 | + */ |
---|
246 | 269 | }; |
---|
247 | 270 | |
---|
248 | 271 | /* hw exception data */ |
---|
.. | .. |
---|
320 | 343 | #define KFD_IOC_ALLOC_MEM_FLAGS_GTT (1 << 1) |
---|
321 | 344 | #define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR (1 << 2) |
---|
322 | 345 | #define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL (1 << 3) |
---|
| 346 | +#define KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP (1 << 4) |
---|
323 | 347 | /* Allocation flags: attributes/access options */ |
---|
324 | 348 | #define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE (1 << 31) |
---|
325 | 349 | #define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE (1 << 30) |
---|
.. | .. |
---|
388 | 412 | __u64 device_ids_array_ptr; /* to KFD */ |
---|
389 | 413 | __u32 n_devices; /* to KFD */ |
---|
390 | 414 | __u32 n_success; /* to/from KFD */ |
---|
| 415 | +}; |
---|
| 416 | + |
---|
| 417 | +/* Allocate GWS for specific queue |
---|
| 418 | + * |
---|
| 419 | + * @queue_id: queue's id that GWS is allocated for |
---|
| 420 | + * @num_gws: how many GWS to allocate |
---|
| 421 | + * @first_gws: index of the first GWS allocated. |
---|
| 422 | + * only support contiguous GWS allocation |
---|
| 423 | + */ |
---|
| 424 | +struct kfd_ioctl_alloc_queue_gws_args { |
---|
| 425 | + __u32 queue_id; /* to KFD */ |
---|
| 426 | + __u32 num_gws; /* to KFD */ |
---|
| 427 | + __u32 first_gws; /* from KFD */ |
---|
| 428 | + __u32 pad; |
---|
| 429 | +}; |
---|
| 430 | + |
---|
| 431 | +struct kfd_ioctl_get_dmabuf_info_args { |
---|
| 432 | + __u64 size; /* from KFD */ |
---|
| 433 | + __u64 metadata_ptr; /* to KFD */ |
---|
| 434 | + __u32 metadata_size; /* to KFD (space allocated by user) |
---|
| 435 | + * from KFD (actual metadata size) |
---|
| 436 | + */ |
---|
| 437 | + __u32 gpu_id; /* from KFD */ |
---|
| 438 | + __u32 flags; /* from KFD (KFD_IOC_ALLOC_MEM_FLAGS) */ |
---|
| 439 | + __u32 dmabuf_fd; /* to KFD */ |
---|
| 440 | +}; |
---|
| 441 | + |
---|
| 442 | +struct kfd_ioctl_import_dmabuf_args { |
---|
| 443 | + __u64 va_addr; /* to KFD */ |
---|
| 444 | + __u64 handle; /* from KFD */ |
---|
| 445 | + __u32 gpu_id; /* to KFD */ |
---|
| 446 | + __u32 dmabuf_fd; /* to KFD */ |
---|
| 447 | +}; |
---|
| 448 | + |
---|
| 449 | +/* |
---|
| 450 | + * KFD SMI(System Management Interface) events |
---|
| 451 | + */ |
---|
| 452 | +enum kfd_smi_event { |
---|
| 453 | + KFD_SMI_EVENT_NONE = 0, /* not used */ |
---|
| 454 | + KFD_SMI_EVENT_VMFAULT = 1, /* event start counting at 1 */ |
---|
| 455 | + KFD_SMI_EVENT_THERMAL_THROTTLE = 2, |
---|
| 456 | + KFD_SMI_EVENT_GPU_PRE_RESET = 3, |
---|
| 457 | + KFD_SMI_EVENT_GPU_POST_RESET = 4, |
---|
| 458 | +}; |
---|
| 459 | + |
---|
| 460 | +#define KFD_SMI_EVENT_MASK_FROM_INDEX(i) (1ULL << ((i) - 1)) |
---|
| 461 | + |
---|
| 462 | +struct kfd_ioctl_smi_events_args { |
---|
| 463 | + __u32 gpuid; /* to KFD */ |
---|
| 464 | + __u32 anon_fd; /* from KFD */ |
---|
| 465 | +}; |
---|
| 466 | + |
---|
| 467 | +/* Register offset inside the remapped mmio page |
---|
| 468 | + */ |
---|
| 469 | +enum kfd_mmio_remap { |
---|
| 470 | + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL = 0, |
---|
| 471 | + KFD_MMIO_REMAP_HDP_REG_FLUSH_CNTL = 4, |
---|
391 | 472 | }; |
---|
392 | 473 | |
---|
393 | 474 | #define AMDKFD_IOCTL_BASE 'K' |
---|
.. | .. |
---|
475 | 556 | #define AMDKFD_IOC_SET_CU_MASK \ |
---|
476 | 557 | AMDKFD_IOW(0x1A, struct kfd_ioctl_set_cu_mask_args) |
---|
477 | 558 | |
---|
| 559 | +#define AMDKFD_IOC_GET_QUEUE_WAVE_STATE \ |
---|
| 560 | + AMDKFD_IOWR(0x1B, struct kfd_ioctl_get_queue_wave_state_args) |
---|
| 561 | + |
---|
| 562 | +#define AMDKFD_IOC_GET_DMABUF_INFO \ |
---|
| 563 | + AMDKFD_IOWR(0x1C, struct kfd_ioctl_get_dmabuf_info_args) |
---|
| 564 | + |
---|
| 565 | +#define AMDKFD_IOC_IMPORT_DMABUF \ |
---|
| 566 | + AMDKFD_IOWR(0x1D, struct kfd_ioctl_import_dmabuf_args) |
---|
| 567 | + |
---|
| 568 | +#define AMDKFD_IOC_ALLOC_QUEUE_GWS \ |
---|
| 569 | + AMDKFD_IOWR(0x1E, struct kfd_ioctl_alloc_queue_gws_args) |
---|
| 570 | + |
---|
| 571 | +#define AMDKFD_IOC_SMI_EVENTS \ |
---|
| 572 | + AMDKFD_IOWR(0x1F, struct kfd_ioctl_smi_events_args) |
---|
| 573 | + |
---|
478 | 574 | #define AMDKFD_COMMAND_START 0x01 |
---|
479 | | -#define AMDKFD_COMMAND_END 0x1B |
---|
| 575 | +#define AMDKFD_COMMAND_END 0x20 |
---|
480 | 576 | |
---|
481 | 577 | #endif |
---|