From fce3048015d39b2abc72a56a2caf74bf2f0fee9f Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Fri, 26 May 2017 15:24:11 -0400 Subject: [PATCH] Remove deprecated implementation of hsaKmtMapGraphicHandle The KFD implementation has been removed and will not be upstreamed. This API has been superseded by hsaKmtRegisterGraphicsHandleToNodes. Change-Id: I5f2d8da3260974618cdb6ea3fdcd77d37b82c9cb Signed-off-by: Felix Kuehling Signed-off-by: Amber Lin [ROCm/ROCR-Runtime commit: 374bd89d8c05e5a2ee850f3577ff8fc5ab763828] --- .../rocr-runtime/include/linux/kfd_ioctl.h | 20 +------ projects/rocr-runtime/src/fmm.c | 59 ------------------- projects/rocr-runtime/src/fmm.h | 4 -- projects/rocr-runtime/src/memory.c | 30 ++-------- 4 files changed, 7 insertions(+), 106 deletions(-) diff --git a/projects/rocr-runtime/include/linux/kfd_ioctl.h b/projects/rocr-runtime/include/linux/kfd_ioctl.h index 1ff1271e91..b318a8fd92 100644 --- a/projects/rocr-runtime/include/linux/kfd_ioctl.h +++ b/projects/rocr-runtime/include/linux/kfd_ioctl.h @@ -326,20 +326,6 @@ 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 */ - uint32_t gpu_id; /* to KFD */ - int graphic_device_fd; /* to KFD */ - uint32_t graphic_handle; /* to KFD */ - uint32_t pad; -}; - struct kfd_ioctl_set_process_dgpu_aperture_args { uint64_t dgpu_base; uint64_t dgpu_limit; @@ -537,11 +523,7 @@ struct kfd_ioctl_cross_memory_copy_args { #define AMDKFD_IOC_GET_QUEUE_WAVE_STATE \ AMDKFD_IOWR(0x20, struct kfd_ioctl_get_queue_wave_state_args) -/* TODO: remove this */ -#define AMDKFD_IOC_OPEN_GRAPHIC_HANDLE \ - AMDKFD_IOWR(0x21, struct kfd_ioctl_open_graphic_handle_args) - #define AMDKFD_COMMAND_START 0x01 -#define AMDKFD_COMMAND_END 0x22 +#define AMDKFD_COMMAND_END 0x21 #endif diff --git a/projects/rocr-runtime/src/fmm.c b/projects/rocr-runtime/src/fmm.c index 88e6052851..2264e6fa9d 100644 --- a/projects/rocr-runtime/src/fmm.c +++ b/projects/rocr-runtime/src/fmm.c @@ -1235,65 +1235,6 @@ void *fmm_allocate_host(uint32_t node_id, uint64_t MemorySizeInBytes, return fmm_allocate_host_cpu(MemorySizeInBytes, flags); } -void *fmm_open_graphic_handle(uint32_t gpu_id, - int32_t graphic_device_handle, - uint32_t graphic_handle, - uint64_t MemorySizeInBytes) -{ - - void *mem = NULL; - int32_t i = gpu_mem_find_by_gpu_id(gpu_id); - struct kfd_ioctl_open_graphic_handle_args open_graphic_handle_args; - struct kfd_ioctl_unmap_memory_from_gpu_args unmap_args; - - /* If not found or aperture isn't properly initialized/supported */ - if (i < 0 || !aperture_is_valid(gpu_mem[i].gpuvm_aperture.base, - gpu_mem[i].gpuvm_aperture.limit)) - return NULL; - - pthread_mutex_lock(&gpu_mem[i].gpuvm_aperture.fmm_mutex); - /* Allocate address space */ - mem = aperture_allocate_area(&gpu_mem[i].gpuvm_aperture, - MemorySizeInBytes, GPUVM_APP_OFFSET); - if (!mem) - goto out; - - /* Allocate local memory */ - open_graphic_handle_args.gpu_id = gpu_id; - open_graphic_handle_args.graphic_device_fd = graphic_device_handle; - open_graphic_handle_args.graphic_handle = graphic_handle; - open_graphic_handle_args.va_addr = - VOID_PTRS_SUB(mem, gpu_mem[i].gpuvm_aperture.base); - - if (kmtIoctl(kfd_fd, AMDKFD_IOC_OPEN_GRAPHIC_HANDLE, - &open_graphic_handle_args)) - goto release_area; - - /* Allocate object */ - if (!aperture_allocate_object(&gpu_mem[i].gpuvm_aperture, mem, - open_graphic_handle_args.handle, - MemorySizeInBytes, 0)) - goto release_mem; - - pthread_mutex_unlock(&gpu_mem[i].gpuvm_aperture.fmm_mutex); - - /* That's all. Just return the new address */ - return mem; - -release_mem: - unmap_args.handle = open_graphic_handle_args.handle; - unmap_args.device_ids_array_ptr = 0; - unmap_args.device_ids_array_size = 0; - kmtIoctl(kfd_fd, AMDKFD_IOC_UNMAP_MEMORY_FROM_GPU, &unmap_args); -release_area: - aperture_release_area(&gpu_mem[i].gpuvm_aperture, mem, - MemorySizeInBytes); -out: - pthread_mutex_unlock(&gpu_mem[i].gpuvm_aperture.fmm_mutex); - - return NULL; -} - static void __fmm_release(void *address, manageable_aperture_t *aperture) { struct kfd_ioctl_free_memory_of_gpu_args args; diff --git a/projects/rocr-runtime/src/fmm.h b/projects/rocr-runtime/src/fmm.h index f5b65e4209..f3870842fa 100644 --- a/projects/rocr-runtime/src/fmm.h +++ b/projects/rocr-runtime/src/fmm.h @@ -53,10 +53,6 @@ void *fmm_allocate_device(uint32_t gpu_id, uint64_t MemorySizeInBytes, HsaMemFla void *fmm_allocate_doorbell(uint32_t gpu_id, uint64_t MemorySizeInBytes, uint64_t doorbell_offset); void *fmm_allocate_host(uint32_t node_id, uint64_t MemorySizeInBytes, HsaMemFlags flags); -void *fmm_open_graphic_handle(uint32_t gpu_id, - int32_t graphic_device_handle, - uint32_t graphic_handle, - uint64_t MemorySizeInBytes); void fmm_print(uint32_t node); bool fmm_is_inside_some_aperture(void *address); void fmm_release(void *address); diff --git a/projects/rocr-runtime/src/memory.c b/projects/rocr-runtime/src/memory.c index 00aff3cfe3..c4785b9ec1 100644 --- a/projects/rocr-runtime/src/memory.c +++ b/projects/rocr-runtime/src/memory.c @@ -460,30 +460,12 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtMapGraphicHandle(HSAuint32 NodeId, HSAuint64 GraphicResourceSize, HSAuint64 *FlatMemoryAddress) { - - CHECK_KFD_OPEN(); - HSAKMT_STATUS result; - uint32_t gpu_id; - void *graphic_handle; - - if (GraphicResourceOffset != 0) - return HSAKMT_STATUS_NOT_IMPLEMENTED; - - result = validate_nodeid(NodeId, &gpu_id); - if (result != HSAKMT_STATUS_SUCCESS) - return result; - - graphic_handle = fmm_open_graphic_handle(gpu_id, - GraphicDeviceHandle, - GraphicResourceHandle, - GraphicResourceSize); - - *FlatMemoryAddress = PORT_VPTR_TO_UINT64(graphic_handle); - - if (*FlatMemoryAddress) - return HSAKMT_STATUS_SUCCESS; - else - return HSAKMT_STATUS_NO_MEMORY; + /* This API was only ever implemented in KFD for Kaveri and + * was never upstreamed. There are no open-source users of + * this interface. It has been superseded by + * RegisterGraphicsHandleToNodes. + */ + return HSAKMT_STATUS_NOT_IMPLEMENTED; } HSAKMT_STATUS HSAKMTAPI hsaKmtUnmapGraphicHandle(HSAuint32 NodeId,