Fix KFD ioctl ABI

This change breaks the ABI, and aligns it with the upstream ABI.
It also fixes some ioctl structures that are not 64-bit safe and
consolidates ioctl numbers.

Change-Id: Ib79944721534bd55a5299c5baf7bb5b3246cccd2
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>


[ROCm/ROCR-Runtime commit: 15764e2897]
Dieser Commit ist enthalten in:
Felix Kuehling
2017-05-09 14:59:13 -04:00
Ursprung 2cc06c88ff
Commit e5b910be20
2 geänderte Dateien mit 77 neuen und 77 gelöschten Zeilen
@@ -133,6 +133,10 @@ struct kfd_process_device_apertures {
uint32_t pad;
};
/* This IOCTL and the limited NUM_OF_SUPPORTED_GPUS is deprecated. Use
* kfd_ioctl_get_process_apertures_new instead, which supports
* arbitrary numbers of GPUs.
*/
struct kfd_ioctl_get_process_apertures_args {
struct kfd_process_device_apertures
process_apertures[NUM_OF_SUPPORTED_GPUS];/* from KFD */
@@ -142,6 +146,19 @@ struct kfd_ioctl_get_process_apertures_args {
uint32_t pad;
};
struct kfd_ioctl_get_process_apertures_new_args {
/* User allocated. Pointer to struct kfd_process_device_apertures
* filled in by Kernel
*/
uint64_t kfd_process_device_apertures_ptr;
/* to KFD - indicates amount of memory present in
* kfd_process_device_apertures_ptr
* from KFD - Number of entries filled by KFD.
*/
uint32_t num_of_nodes;
uint32_t pad;
};
#define MAX_ALLOWED_NUM_POINTS 100
#define MAX_ALLOWED_AW_BUFF_SIZE 4096
#define MAX_ALLOWED_WAC_BUFF_SIZE 128
@@ -156,18 +173,16 @@ struct kfd_ioctl_dbg_unregister_args {
uint32_t pad;
};
/* FIXME: This is not 32-on-64 safe, fixed upstream, we should match it */
struct kfd_ioctl_dbg_address_watch_args {
uint64_t content_ptr; /* a pointer to the actual content */
uint32_t gpu_id; /* to KFD */
uint32_t buf_size_in_bytes; /*including gpu_id and buf_size */
void *content_ptr; /* a pointer to the actual content */
};
/* FIXME: This is not 32-on-64 safe, fixed upstream, we should match it */
struct kfd_ioctl_dbg_wave_control_args {
uint64_t content_ptr; /* a pointer to the actual content */
uint32_t gpu_id; /* to KFD */
uint32_t buf_size_in_bytes; /*including gpu_id and buf_size */
void *content_ptr; /* a pointer to the actual content */
};
/* Matching HSA_EVENTTYPE */
@@ -199,7 +214,8 @@ struct kfd_ioctl_create_event_args {
uint32_t event_trigger_data; /* from KFD - signal events only */
uint32_t event_type; /* to KFD */
uint32_t auto_reset; /* to KFD */
uint32_t node_id; /* to KFD - only valid for certain event types */
uint32_t node_id; /* to KFD - only valid for certain
event types */
uint32_t event_id; /* from KFD */
uint32_t event_slot_index; /* from KFD */
};
@@ -220,21 +236,21 @@ struct kfd_ioctl_reset_event_args {
};
struct kfd_memory_exception_failure {
bool NotPresent; /* Page not present or supervisor privilege */
bool ReadOnly; /* Write access to a read-only page */
bool NoExecute; /* Execute access to a page marked NX */
bool imprecise; /* Can't determine the exact fault address */
uint32_t NotPresent; /* Page not present or supervisor privilege */
uint32_t ReadOnly; /* Write access to a read-only page */
uint32_t NoExecute; /* Execute access to a page marked NX */
uint32_t imprecise; /* Can't determine the exact fault address */
};
/* memory exception data*/
/* FIXME: Make this 32-on-64 safe. Will break ABI. */
/* memory exception data */
struct kfd_hsa_memory_exception_data {
struct kfd_memory_exception_failure failure;
uint64_t va;
uint32_t gpu_id;
struct kfd_memory_exception_failure failure;
uint32_t pad;
};
/* Event data*/
/* Event data */
struct kfd_event_data {
union {
struct kfd_hsa_memory_exception_data memory_exception_data;
@@ -254,13 +270,34 @@ struct kfd_ioctl_wait_events_args {
uint32_t wait_result; /* from KFD */
};
/* FIXME: remove unused fields and make it 32-on-64 safe. Will break ABI. */
struct kfd_ioctl_alloc_memory_of_scratch_args {
uint64_t va_addr; /* to KFD */
uint64_t size; /* to KFD */
uint64_t handle; /* from KFD */
uint32_t gpu_id; /* to KFD */
uint64_t mmap_offset; /* from KFD */
uint32_t pad;
};
/* Allocation flags: memory types */
#define KFD_IOC_ALLOC_MEM_FLAGS_VRAM (1 << 0)
#define KFD_IOC_ALLOC_MEM_FLAGS_GTT (1 << 1)
#define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR (1 << 2)
#define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL (1 << 3)
/* Allocation flags: attributes/access options */
#define KFD_IOC_ALLOC_MEM_FLAGS_NONPAGED (1 << 31)
#define KFD_IOC_ALLOC_MEM_FLAGS_READONLY (1 << 30)
#define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC (1 << 29)
#define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE (1 << 28)
#define KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM (1 << 27)
#define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTE_ACCESS (1 << 26)
#define KFD_IOC_ALLOC_MEM_FLAGS_COHERENT (1 << 25)
struct kfd_ioctl_alloc_memory_of_gpu_args {
uint64_t va_addr; /* to KFD */
uint64_t size; /* to KFD */
uint64_t handle; /* from KFD */
uint64_t mmap_offset; /* to KFD (userptr), from KFD (mmap offset) */
uint32_t gpu_id; /* to KFD */
uint32_t flags;
};
struct kfd_ioctl_free_memory_of_gpu_args {
@@ -281,6 +318,11 @@ struct kfd_ioctl_unmap_memory_from_gpu_args {
uint32_t pad;
};
/* TODO: remove this. It's only implemented for Kaveri and was never
* upstreamed. There are no open-source users of this interface. It
* has been superseded by the pair of get_dmabuf_info and
* import_dmabuf, which is implemented for all supported GPUs.
*/
struct kfd_ioctl_open_graphic_handle_args {
uint64_t va_addr; /* to KFD */
uint64_t handle; /* from KFD */
@@ -290,52 +332,10 @@ struct kfd_ioctl_open_graphic_handle_args {
uint32_t pad;
};
/* FIXME: Make this 32-on-64 safe. Will break ABI. */
struct kfd_ioctl_set_process_dgpu_aperture_args {
uint32_t gpu_id;
uint64_t dgpu_base;
uint64_t dgpu_limit;
};
/*
* Memory types
*/
#define KFD_IOC_ALLOC_MEM_FLAGS_VRAM (1 << 0)
#define KFD_IOC_ALLOC_MEM_FLAGS_GTT (1 << 1)
#define KFD_IOC_ALLOC_MEM_FLAGS_USERPTR (1 << 2)
#define KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL (1 << 3)
/*
* Allocation flags attributes/access options.
*/
#define KFD_IOC_ALLOC_MEM_FLAGS_NONPAGED (1 << 31)
#define KFD_IOC_ALLOC_MEM_FLAGS_READONLY (1 << 30)
#define KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC (1 << 29)
#define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE (1 << 28)
#define KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM (1 << 27)
#define KFD_IOC_ALLOC_MEM_FLAGS_EXECUTE_ACCESS (1 << 26)
#define KFD_IOC_ALLOC_MEM_FLAGS_COHERENT (1 << 25)
struct kfd_ioctl_alloc_memory_of_gpu_args {
uint64_t va_addr; /* to KFD */
uint64_t size; /* to KFD */
uint64_t handle; /* from KFD */
uint64_t mmap_offset; /* to KFD (userptr), from KFD (mmap offset) */
uint32_t gpu_id; /* to KFD */
uint32_t flags;
};
struct kfd_ioctl_get_process_apertures_new_args {
/* User allocated. Pointer to struct kfd_process_device_apertures
* filled in by Kernel */
uint64_t kfd_process_device_apertures_ptr;
/* to KFD - indicates amount of memory present in
* kfd_process_device_apertures_ptr
* from KFD - Number of entries filled by KFD.
*/
uint32_t num_of_nodes;
uint32_t gpu_id;
uint32_t pad;
};
@@ -492,45 +492,45 @@ struct kfd_ioctl_cross_memory_copy_args {
#define AMDKFD_IOC_UNMAP_MEMORY_FROM_GPU \
AMDKFD_IOWR(0x14, struct kfd_ioctl_unmap_memory_from_gpu_args)
#define AMDKFD_IOC_OPEN_GRAPHIC_HANDLE \
AMDKFD_IOWR(0x15, struct kfd_ioctl_open_graphic_handle_args)
#define AMDKFD_IOC_ALLOC_MEMORY_OF_SCRATCH \
AMDKFD_IOWR(0x16, struct kfd_ioctl_alloc_memory_of_scratch_args)
AMDKFD_IOWR(0x15, struct kfd_ioctl_alloc_memory_of_scratch_args)
#define AMDKFD_IOC_SET_CU_MASK \
AMDKFD_IOW(0x17, struct kfd_ioctl_set_cu_mask_args)
AMDKFD_IOW(0x16, struct kfd_ioctl_set_cu_mask_args)
#define AMDKFD_IOC_SET_PROCESS_DGPU_APERTURE \
AMDKFD_IOW(0x18, \
AMDKFD_IOW(0x17, \
struct kfd_ioctl_set_process_dgpu_aperture_args)
#define AMDKFD_IOC_SET_TRAP_HANDLER \
AMDKFD_IOW(0x1a, struct kfd_ioctl_set_trap_handler_args)
AMDKFD_IOW(0x18, struct kfd_ioctl_set_trap_handler_args)
#define AMDKFD_IOC_GET_PROCESS_APERTURES_NEW \
AMDKFD_IOWR(0x1d, struct kfd_ioctl_get_process_apertures_new_args)
AMDKFD_IOWR(0x19, struct kfd_ioctl_get_process_apertures_new_args)
#define AMDKFD_IOC_GET_DMABUF_INFO \
AMDKFD_IOWR(0x1f, struct kfd_ioctl_get_dmabuf_info_args)
AMDKFD_IOWR(0x1A, struct kfd_ioctl_get_dmabuf_info_args)
#define AMDKFD_IOC_IMPORT_DMABUF \
AMDKFD_IOWR(0x20, struct kfd_ioctl_import_dmabuf_args)
AMDKFD_IOWR(0x1B, struct kfd_ioctl_import_dmabuf_args)
#define AMDKFD_IOC_GET_TILE_CONFIG \
AMDKFD_IOWR(0x21, struct kfd_ioctl_get_tile_config_args)
AMDKFD_IOWR(0x1C, struct kfd_ioctl_get_tile_config_args)
#define AMDKFD_IOC_IPC_IMPORT_HANDLE \
AMDKFD_IOWR(0x22, struct kfd_ioctl_ipc_import_handle_args)
AMDKFD_IOWR(0x1D, struct kfd_ioctl_ipc_import_handle_args)
#define AMDKFD_IOC_IPC_EXPORT_HANDLE \
AMDKFD_IOWR(0x23, struct kfd_ioctl_ipc_export_handle_args)
AMDKFD_IOWR(0x1E, struct kfd_ioctl_ipc_export_handle_args)
#define AMDKFD_IOC_CROSS_MEMORY_COPY \
AMDKFD_IOWR(0x24, struct kfd_ioctl_cross_memory_copy_args)
AMDKFD_IOWR(0x1F, struct kfd_ioctl_cross_memory_copy_args)
/* TODO: remove this */
#define AMDKFD_IOC_OPEN_GRAPHIC_HANDLE \
AMDKFD_IOWR(0x20, struct kfd_ioctl_open_graphic_handle_args)
#define AMDKFD_COMMAND_START 0x01
#define AMDKFD_COMMAND_END 0x25
#define AMDKFD_COMMAND_END 0x21
#endif
+2 -2
Datei anzeigen
@@ -159,7 +159,7 @@ hsaKmtDbgWavefrontControl(
unsigned char* run_ptr = (unsigned char*)args + sizeof(*args);
/* save variable content pointer for kfd */
args->content_ptr = (void *)run_ptr;
args->content_ptr = (uint64_t)run_ptr;
/* insert items, and increment pointer accordingly */
@@ -258,7 +258,7 @@ hsaKmtDbgAddressWatch(
unsigned char* run_ptr = (unsigned char*)args + sizeof(*args);
/* save variable content pointer for kfd */
args->content_ptr = (void *)run_ptr;
args->content_ptr = (uint64_t)run_ptr;
/* insert items, and increment pointer accordingly */
*((HSAuint32*)run_ptr) = NumWatchPoints;