23#ifndef KFD_IOCTL_H_INCLUDED
24#define KFD_IOCTL_H_INCLUDED
27#include <linux/ioctl.h>
28#include <linux/types.h>
37#define KFD_IOCTL_MAJOR_VERSION 1
38#define KFD_IOCTL_MINOR_VERSION 3
47#define KFD_IOC_QUEUE_TYPE_COMPUTE 0
48#define KFD_IOC_QUEUE_TYPE_SDMA 1
49#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 2
50#define KFD_IOC_QUEUE_TYPE_SDMA_XGMI 3
52#define KFD_MAX_QUEUE_PERCENTAGE 100
53#define KFD_MAX_QUEUE_PRIORITY 15
109#define KFD_IOC_CACHE_POLICY_COHERENT 0
110#define KFD_IOC_CACHE_POLICY_NONCOHERENT 1
158#define NUM_OF_SUPPORTED_GPUS 7
183#define MAX_ALLOWED_NUM_POINTS 100
184#define MAX_ALLOWED_AW_BUFF_SIZE 4096
185#define MAX_ALLOWED_WAC_BUFF_SIZE 128
214#define KFD_IOC_EVENT_SIGNAL 0
215#define KFD_IOC_EVENT_NODECHANGE 1
216#define KFD_IOC_EVENT_DEVICESTATECHANGE 2
217#define KFD_IOC_EVENT_HW_EXCEPTION 3
218#define KFD_IOC_EVENT_SYSTEM_EVENT 4
219#define KFD_IOC_EVENT_DEBUG_EVENT 5
220#define KFD_IOC_EVENT_PROFILE_EVENT 6
221#define KFD_IOC_EVENT_QUEUE_EVENT 7
222#define KFD_IOC_EVENT_MEMORY 8
224#define KFD_IOC_WAIT_RESULT_COMPLETE 0
225#define KFD_IOC_WAIT_RESULT_TIMEOUT 1
226#define KFD_IOC_WAIT_RESULT_FAIL 2
228#define KFD_SIGNAL_EVENT_LIMIT 4096
231#define KFD_HW_EXCEPTION_WHOLE_GPU_RESET 0
232#define KFD_HW_EXCEPTION_PER_ENGINE_RESET 1
235#define KFD_HW_EXCEPTION_GPU_HANG 0
236#define KFD_HW_EXCEPTION_ECC 1
239#define KFD_MEM_ERR_NO_RAS 0
240#define KFD_MEM_ERR_SRAM_ECC 1
241#define KFD_MEM_ERR_POISON_CONSUMED 2
242#define KFD_MEM_ERR_GPU_HANG 3
375#define KFD_IOC_ALLOC_MEM_FLAGS_VRAM (1 << 0)
376#define KFD_IOC_ALLOC_MEM_FLAGS_GTT (1 << 1)
377#define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR (1 << 2)
378#define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL (1 << 3)
379#define KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP (1 << 4)
381#define KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE (1 << 31)
382#define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE (1 << 30)
383#define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC (1 << 29)
384#define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE (1 << 28)
385#define KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM (1 << 27)
386#define KFD_IOC_ALLOC_MEM_FLAGS_COHERENT (1 << 26)
500#define KFD_SMI_EVENT_MASK_FROM_INDEX(i) (1ULL << ((i) - 1))
516#define AMDKFD_IOCTL_BASE 'K'
517#define AMDKFD_IO(nr) _IO(AMDKFD_IOCTL_BASE, nr)
518#define AMDKFD_IOR(nr, type) _IOR(AMDKFD_IOCTL_BASE, nr, type)
519#define AMDKFD_IOW(nr, type) _IOW(AMDKFD_IOCTL_BASE, nr, type)
520#define AMDKFD_IOWR(nr, type) _IOWR(AMDKFD_IOCTL_BASE, nr, type)
522#define AMDKFD_IOC_GET_VERSION \
523 AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args)
525#define AMDKFD_IOC_CREATE_QUEUE \
526 AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args)
528#define AMDKFD_IOC_DESTROY_QUEUE \
529 AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args)
531#define AMDKFD_IOC_SET_MEMORY_POLICY \
532 AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args)
534#define AMDKFD_IOC_GET_CLOCK_COUNTERS \
535 AMDKFD_IOWR(0x05, struct kfd_ioctl_get_clock_counters_args)
537#define AMDKFD_IOC_GET_PROCESS_APERTURES \
538 AMDKFD_IOR(0x06, struct kfd_ioctl_get_process_apertures_args)
540#define AMDKFD_IOC_UPDATE_QUEUE \
541 AMDKFD_IOW(0x07, struct kfd_ioctl_update_queue_args)
543#define AMDKFD_IOC_CREATE_EVENT \
544 AMDKFD_IOWR(0x08, struct kfd_ioctl_create_event_args)
546#define AMDKFD_IOC_DESTROY_EVENT \
547 AMDKFD_IOW(0x09, struct kfd_ioctl_destroy_event_args)
549#define AMDKFD_IOC_SET_EVENT \
550 AMDKFD_IOW(0x0A, struct kfd_ioctl_set_event_args)
552#define AMDKFD_IOC_RESET_EVENT \
553 AMDKFD_IOW(0x0B, struct kfd_ioctl_reset_event_args)
555#define AMDKFD_IOC_WAIT_EVENTS \
556 AMDKFD_IOWR(0x0C, struct kfd_ioctl_wait_events_args)
558#define AMDKFD_IOC_DBG_REGISTER \
559 AMDKFD_IOW(0x0D, struct kfd_ioctl_dbg_register_args)
561#define AMDKFD_IOC_DBG_UNREGISTER \
562 AMDKFD_IOW(0x0E, struct kfd_ioctl_dbg_unregister_args)
564#define AMDKFD_IOC_DBG_ADDRESS_WATCH \
565 AMDKFD_IOW(0x0F, struct kfd_ioctl_dbg_address_watch_args)
567#define AMDKFD_IOC_DBG_WAVE_CONTROL \
568 AMDKFD_IOW(0x10, struct kfd_ioctl_dbg_wave_control_args)
570#define AMDKFD_IOC_SET_SCRATCH_BACKING_VA \
571 AMDKFD_IOWR(0x11, struct kfd_ioctl_set_scratch_backing_va_args)
573#define AMDKFD_IOC_GET_TILE_CONFIG \
574 AMDKFD_IOWR(0x12, struct kfd_ioctl_get_tile_config_args)
576#define AMDKFD_IOC_SET_TRAP_HANDLER \
577 AMDKFD_IOW(0x13, struct kfd_ioctl_set_trap_handler_args)
579#define AMDKFD_IOC_GET_PROCESS_APERTURES_NEW \
581 struct kfd_ioctl_get_process_apertures_new_args)
583#define AMDKFD_IOC_ACQUIRE_VM \
584 AMDKFD_IOW(0x15, struct kfd_ioctl_acquire_vm_args)
586#define AMDKFD_IOC_ALLOC_MEMORY_OF_GPU \
587 AMDKFD_IOWR(0x16, struct kfd_ioctl_alloc_memory_of_gpu_args)
589#define AMDKFD_IOC_FREE_MEMORY_OF_GPU \
590 AMDKFD_IOW(0x17, struct kfd_ioctl_free_memory_of_gpu_args)
592#define AMDKFD_IOC_MAP_MEMORY_TO_GPU \
593 AMDKFD_IOWR(0x18, struct kfd_ioctl_map_memory_to_gpu_args)
595#define AMDKFD_IOC_UNMAP_MEMORY_FROM_GPU \
596 AMDKFD_IOWR(0x19, struct kfd_ioctl_unmap_memory_from_gpu_args)
598#define AMDKFD_IOC_SET_CU_MASK \
599 AMDKFD_IOW(0x1A, struct kfd_ioctl_set_cu_mask_args)
601#define AMDKFD_IOC_GET_QUEUE_WAVE_STATE \
602 AMDKFD_IOWR(0x1B, struct kfd_ioctl_get_queue_wave_state_args)
604#define AMDKFD_IOC_GET_DMABUF_INFO \
605 AMDKFD_IOWR(0x1C, struct kfd_ioctl_get_dmabuf_info_args)
607#define AMDKFD_IOC_IMPORT_DMABUF \
608 AMDKFD_IOWR(0x1D, struct kfd_ioctl_import_dmabuf_args)
610#define AMDKFD_IOC_ALLOC_QUEUE_GWS \
611 AMDKFD_IOWR(0x1E, struct kfd_ioctl_alloc_queue_gws_args)
613#define AMDKFD_IOC_SMI_EVENTS \
614 AMDKFD_IOWR(0x1F, struct kfd_ioctl_smi_events_args)
616#define AMDKFD_COMMAND_START 0x01
617#define AMDKFD_COMMAND_END 0x20
#define NUM_OF_SUPPORTED_GPUS
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
@ KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL
@ KFD_MMIO_REMAP_HDP_REG_FLUSH_CNTL
@ KFD_SMI_EVENT_GPU_PRE_RESET
@ KFD_SMI_EVENT_GPU_POST_RESET
@ KFD_SMI_EVENT_THERMAL_THROTTLE
uint64_t kfd_event_data_ext
struct kfd_hsa_hw_exception_data hw_exception_data
struct kfd_hsa_memory_exception_data memory_exception_data
struct kfd_memory_exception_failure failure
uint32_t event_slot_index
uint32_t event_trigger_data
uint64_t event_page_offset
uint64_t ring_base_address
uint64_t ctx_save_restore_address
uint32_t ctx_save_restore_size
uint32_t queue_percentage
uint64_t read_pointer_address
uint64_t write_pointer_address
uint64_t eop_buffer_address
uint32_t buf_size_in_bytes
uint32_t buf_size_in_bytes
uint64_t gpu_clock_counter
uint64_t system_clock_counter
uint64_t cpu_clock_counter
uint64_t system_clock_freq
struct kfd_process_device_apertures process_apertures[NUM_OF_SUPPORTED_GPUS]
uint64_t kfd_process_device_apertures_ptr
uint32_t ctl_stack_used_size
uint64_t ctl_stack_address
uint32_t save_area_used_size
uint32_t num_macro_tile_configs
uint32_t num_tile_configs
uint64_t macro_tile_config_ptr
uint64_t device_ids_array_ptr
uint64_t alternate_aperture_base
uint32_t alternate_policy
uint64_t alternate_aperture_size
uint64_t device_ids_array_ptr
uint64_t ring_base_address
uint32_t queue_percentage