amdgpu: Add wrappers for AMDGPU_VM IOCTL.
authorAndrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Fri, 27 Oct 2017 15:09:10 +0000 (11:09 -0400)
committerChristian König <christian.koenig@amd.com>
Fri, 27 Oct 2017 16:25:53 +0000 (18:25 +0200)
v2:
Rename wrappers to match the IOCTL naming, fix
identation and fix make check error.

Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
amdgpu/Makefile.sources
amdgpu/amdgpu-symbol-check
amdgpu/amdgpu.h
amdgpu/amdgpu_vm.c [new file with mode: 0644]

index bc3abaa..498b64c 100644 (file)
@@ -6,6 +6,7 @@ LIBDRM_AMDGPU_FILES := \
        amdgpu_gpu_info.c \
        amdgpu_internal.h \
        amdgpu_vamgr.c \
+       amdgpu_vm.c \
        util_hash.c \
        util_hash.h \
        util_hash_table.c \
index 095c3a0..d476038 100755 (executable)
@@ -64,6 +64,8 @@ amdgpu_read_mm_registers
 amdgpu_va_range_alloc
 amdgpu_va_range_free
 amdgpu_va_range_query
+amdgpu_vm_reserve_vmid
+amdgpu_vm_unreserve_vmid
 EOF
 done)
 
index ecc975f..597fc2b 100644 (file)
@@ -1489,6 +1489,24 @@ void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
 void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
                                        struct drm_amdgpu_cs_chunk_data *data);
 
+/**
+ * Reserve VMID
+ * \param   context - \c [in]  GPU Context
+ * \param   flags - \c [in]  TBD
+ *
+ * \return  0 on success otherwise POSIX Error code
+*/
+int amdgpu_vm_reserve_vmid(amdgpu_context_handle context, uint32_t flags);
+
+/**
+ * Free reserved VMID
+ * \param   context - \c [in]  GPU Context
+ * \param   flags - \c [in]  TBD
+ *
+ * \return  0 on success otherwise POSIX Error code
+*/
+int amdgpu_vm_unreserve_vmid(amdgpu_context_handle context, uint32_t flags);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/amdgpu/amdgpu_vm.c b/amdgpu/amdgpu_vm.c
new file mode 100644 (file)
index 0000000..8a9a0a1
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2017 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 "amdgpu.h"
+#include "amdgpu_drm.h"
+#include "xf86drm.h"
+#include "amdgpu_internal.h"
+
+int amdgpu_vm_reserve_vmid(amdgpu_context_handle context, uint32_t flags)
+{
+       union drm_amdgpu_vm vm;
+
+       vm.in.op = AMDGPU_VM_OP_RESERVE_VMID;
+       vm.in.flags = flags;
+
+       return drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_VM,
+                                  &vm, sizeof(vm));
+}
+
+int amdgpu_vm_unreserve_vmid(amdgpu_context_handle context, uint32_t flags)
+{
+       union drm_amdgpu_vm vm;
+
+       vm.in.op = AMDGPU_VM_OP_UNRESERVE_VMID;
+       vm.in.flags = flags;
+
+       return drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_VM,
+                                  &vm, sizeof(vm));
+}