From 4ebda913cd4046337a5d6f9a4741256e7bc3628c Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Wed, 10 Mar 2021 20:36:41 -0500 Subject: [PATCH] Revert "libhsakmt: add SVM thunk implementation" This reverts commit 75e8fe383f269ed8aac28c3e7904d234d9417ea2. SVM is not ready yet. This was merged by accident. Change-Id: I372f7d293fd38429ec570bc0e0add7e612871594 Signed-off-by: Felix Kuehling --- CMakeLists.txt | 3 +- src/libhsakmt.h | 1 - src/libhsakmt.ver | 2 - src/svm.c | 185 ---------------------------------------------- 4 files changed, 1 insertion(+), 190 deletions(-) delete mode 100644 src/svm.c diff --git a/CMakeLists.txt b/CMakeLists.txt index ccf39e8d82..a3a4d999c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,8 +129,7 @@ set ( HSAKMT_SRC "src/debug.c" "src/topology.c" "src/rbtree.c" "src/spm.c" - "src/version.c" - "src/svm.c") + "src/version.c") ## Declare the library target name add_library ( ${HSAKMT_TARGET} "") diff --git a/src/libhsakmt.h b/src/libhsakmt.h index 9c5b91f7b6..f455699c6d 100644 --- a/src/libhsakmt.h +++ b/src/libhsakmt.h @@ -26,7 +26,6 @@ #ifndef LIBHSAKMT_H_INCLUDED #define LIBHSAKMT_H_INCLUDED -#include "linux/kfd_ioctl.h" #include "hsakmt.h" #include "pci_ids.h" #include diff --git a/src/libhsakmt.ver b/src/libhsakmt.ver index 3992e6535a..4383695e98 100644 --- a/src/libhsakmt.ver +++ b/src/libhsakmt.ver @@ -75,8 +75,6 @@ hsaKmtClearAddressWatch; hsaKmtSPMAcquire; hsaKmtSPMRelease; hsaKmtSPMSetDestBuffer; -hsaKmtSVMSetAttr; -hsaKmtSVMGetAttr; local: *; }; diff --git a/src/svm.c b/src/svm.c deleted file mode 100644 index d4bf896069..0000000000 --- a/src/svm.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright © 2020 Advanced Micro Devices, Inc. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including - * the next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include "libhsakmt.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Helper functions for calling KFD SVM ioctl */ - -HSAKMT_STATUS HSAKMTAPI -hsaKmtSVMSetAttr(void *start_addr, HSAuint64 size, unsigned int nattr, - HSA_SVM_ATTRIBUTE *attrs) -{ - struct kfd_ioctl_svm_args *args; - HSAuint64 s_attr; - HSAKMT_STATUS r; - HSAuint32 i; - - CHECK_KFD_OPEN(); - - pr_debug("%s: address 0x%p size 0x%lx\n", __func__, start_addr, size); - - if (!start_addr || !size) - return HSAKMT_STATUS_INVALID_PARAMETER; - if ((uint64_t)start_addr & (PAGE_SIZE - 1)) - return HSAKMT_STATUS_INVALID_PARAMETER; - if (size & (PAGE_SIZE - 1)) - return HSAKMT_STATUS_INVALID_PARAMETER; - - s_attr = sizeof(*attrs) * nattr; - args = alloca(sizeof(*args) + s_attr); - - args->start_addr = (uint64_t)start_addr; - args->size = size; - args->op = KFD_IOCTL_SVM_OP_SET_ATTR; - args->nattr = nattr; - memcpy(args->attrs, attrs, s_attr); - - for (i = 0; i < nattr; i++) { - if (attrs[i].type != KFD_IOCTL_SVM_ATTR_PREFERRED_LOC && - attrs[i].type != KFD_IOCTL_SVM_ATTR_PREFETCH_LOC && - attrs[i].type != KFD_IOCTL_SVM_ATTR_ACCESS && - attrs[i].type != KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE && - attrs[i].type != KFD_IOCTL_SVM_ATTR_NO_ACCESS) - continue; - - if (attrs[i].type == KFD_IOCTL_SVM_ATTR_PREFERRED_LOC && - attrs[i].value == INVALID_NODEID) { - args->attrs[i].value = KFD_IOCTL_SVM_LOCATION_UNDEFINED; - continue; - } - - r = validate_nodeid(attrs[i].value, &args->attrs[i].value); - if (r != HSAKMT_STATUS_SUCCESS) { - pr_debug("invalid node ID: %d\n", attrs[i].value); - return r; - } else if (!args->attrs[i].value && - (attrs[i].type == KFD_IOCTL_SVM_ATTR_ACCESS || - attrs[i].type == KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE || - attrs[i].type == KFD_IOCTL_SVM_ATTR_NO_ACCESS)) { - pr_debug("CPU node invalid for access attribute\n"); - return HSAKMT_STATUS_INVALID_NODE_UNIT; - } - } - - /* Driver does one copy_from_user, with extra attrs size */ - r = kmtIoctl(kfd_fd, AMDKFD_IOC_SVM + (s_attr << _IOC_SIZESHIFT), args); - if (r) { - pr_debug("op set range attrs failed %s\n", strerror(errno)); - return HSAKMT_STATUS_ERROR; - } - - return HSAKMT_STATUS_SUCCESS; -} - -HSAKMT_STATUS HSAKMTAPI -hsaKmtSVMGetAttr(void *start_addr, HSAuint64 size, unsigned int nattr, - HSA_SVM_ATTRIBUTE *attrs) -{ - struct kfd_ioctl_svm_args *args; - HSAuint64 s_attr; - HSAKMT_STATUS r; - HSAuint32 i; - - CHECK_KFD_OPEN(); - - pr_debug("%s: address 0x%p size 0x%lx\n", __func__, start_addr, size); - - if (!start_addr || !size) - return HSAKMT_STATUS_INVALID_PARAMETER; - if ((uint64_t)start_addr & (PAGE_SIZE - 1)) - return HSAKMT_STATUS_INVALID_PARAMETER; - if (size & (PAGE_SIZE - 1)) - return HSAKMT_STATUS_INVALID_PARAMETER; - - s_attr = sizeof(*attrs) * nattr; - args = alloca(sizeof(*args) + s_attr); - - args->start_addr = (uint64_t)start_addr; - args->size = size; - args->op = KFD_IOCTL_SVM_OP_GET_ATTR; - args->nattr = nattr; - memcpy(args->attrs, attrs, s_attr); - - for (i = 0; i < nattr; i++) { - if (attrs[i].type != KFD_IOCTL_SVM_ATTR_ACCESS && - attrs[i].type != KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE && - attrs[i].type != KFD_IOCTL_SVM_ATTR_NO_ACCESS) - continue; - - r = validate_nodeid(attrs[i].value, &args->attrs[i].value); - if (r != HSAKMT_STATUS_SUCCESS) { - pr_debug("invalid node ID: %d\n", attrs[i].value); - return r; - } else if (!args->attrs[i].value) { - pr_debug("CPU node invalid for access attribute\n"); - return HSAKMT_STATUS_INVALID_NODE_UNIT; - } - } - - /* Driver does one copy_from_user, with extra attrs size */ - r = kmtIoctl(kfd_fd, AMDKFD_IOC_SVM + (s_attr << _IOC_SIZESHIFT), args); - if (r) { - pr_debug("op get range attrs failed %s\n", strerror(errno)); - return HSAKMT_STATUS_ERROR; - } - - memcpy(attrs, args->attrs, s_attr); - - for (i = 0; i < nattr; i++) { - if (attrs[i].type != KFD_IOCTL_SVM_ATTR_PREFERRED_LOC && - attrs[i].type != KFD_IOCTL_SVM_ATTR_PREFETCH_LOC && - attrs[i].type != KFD_IOCTL_SVM_ATTR_ACCESS && - attrs[i].type != KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE && - attrs[i].type != KFD_IOCTL_SVM_ATTR_NO_ACCESS) - continue; - - switch (attrs[i].value) { - case KFD_IOCTL_SVM_LOCATION_SYSMEM: - attrs[i].value = 0; - break; - case KFD_IOCTL_SVM_LOCATION_UNDEFINED: - attrs[i].value = INVALID_NODEID; - break; - default: - r = gpuid_to_nodeid(attrs[i].value, &attrs[i].value); - if (r != HSAKMT_STATUS_SUCCESS) { - pr_debug("invalid GPU ID: %d\n", - attrs[i].value); - return r; - } - } - } - - return HSAKMT_STATUS_SUCCESS; -}