[PATCH 4/4] amdgpu: add a new bo va function to support NULL bo

Junwei Zhang Jerry.Zhang at amd.com
Thu Mar 16 03:56:41 UTC 2017


Signed-off-by: Junwei Zhang <Jerry.Zhang at amd.com>
---
 amdgpu/amdgpu.h    |  7 +++++++
 amdgpu/amdgpu_bo.c | 40 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
index 84ab688..a9fddd6 100644
--- a/amdgpu/amdgpu.h
+++ b/amdgpu/amdgpu.h
@@ -1429,6 +1429,13 @@ int amdgpu_bo_va_op(amdgpu_bo_handle bo,
 		    uint64_t flags,
 		    uint32_t ops);
 
+int amdgpu_bo_va_op2(amdgpu_device_handle dev,
+		     amdgpu_bo_handle bo,
+		     uint64_t offset,
+		     uint64_t size,
+		     uint64_t addr,
+		     uint64_t flags,
+		     uint32_t ops);
 /**
  *  VA mapping/unmapping for the buffer object
  *
diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index 800b77a..421e440 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -924,13 +924,51 @@ int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
 	return r;
 }
 
-int amdgpu_bo_va_op(amdgpu_bo_handle bo,
+int amdgpu_bo_va_op2(amdgpu_device_handle dev,
+		     amdgpu_bo_handle bo,
 		     uint64_t offset,
 		     uint64_t size,
 		     uint64_t addr,
 		     uint64_t flags,
 		     uint32_t ops)
 {
+	struct drm_amdgpu_gem_va va;
+	int r;
+
+	if (ops != AMDGPU_VA_OP_MAP && ops != AMDGPU_VA_OP_UNMAP &&
+			ops != AMDGPU_VA_OP_REPLACE &&
+			ops != AMDGPU_VA_OP_CLEAR)
+		return -EINVAL;
+
+	memset(&va, 0, sizeof(va));
+	if (bo)
+		va.handle = bo->handle;
+	else
+		va.handle = NULL;
+	if (flags & AMDGPU_VM_PAGE_PRT)
+		flags &= AMDGPU_VM_PAGE_PRT;
+	else
+		flags |= AMDGPU_VM_PAGE_READABLE | AMDGPU_VM_PAGE_WRITEABLE |
+			AMDGPU_VM_PAGE_EXECUTABLE;
+
+	va.operation = ops;
+	va.flags = flags;
+	va.va_address = addr;
+	va.offset_in_bo = offset;
+	va.map_size = ALIGN(size, getpagesize());
+
+	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_GEM_VA, &va, sizeof(va));
+
+	return r;
+}
+
+int amdgpu_bo_va_op(amdgpu_bo_handle bo,
+		    uint64_t offset,
+		    uint64_t size,
+		    uint64_t addr,
+		    uint64_t flags,
+		    uint32_t ops)
+{
 	amdgpu_device_handle dev = bo->dev;
 	struct drm_amdgpu_gem_va va;
 	int r;
-- 
1.9.1



More information about the amd-gfx mailing list