[PATCH] amdgpu: add amdgpu_create_bo_from_userptr()
Christian König
deathsimple at vodafone.de
Fri Mar 11 14:38:47 UTC 2016
From: Christian König <christian.koenig at amd.com>
We somehow forgot the flags paramter in amdgpu_create_bo_from_user_mem(). Fix
that with a new function.
Signed-off-by: Christian König <christian.koenig at amd.com>
---
amdgpu/amdgpu.h | 8 ++++++++
amdgpu/amdgpu_bo.c | 26 ++++++++++++++++++--------
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
index 0851306..be7b924 100644
--- a/amdgpu/amdgpu.h
+++ b/amdgpu/amdgpu.h
@@ -637,6 +637,7 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
* want to map to GPU address space (make GPU accessible)
* (This address must be correctly aligned).
* \param size - [in] Size of allocation (must be correctly aligned)
+ * \param flags - [in] AMDGPU_GEM_USERPTR_* flags for userptr
* \param buf_handle - [out] Buffer handle for the userptr memory
* resource on submission and be used in other operations.
*
@@ -660,6 +661,13 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
* It is responsibility of caller to correctly specify access rights
* on VA assignment.
*/
+int amdgpu_create_bo_from_userptr(amdgpu_device_handle dev,
+ void *cpu, uint64_t size, uint32_t flags,
+ amdgpu_bo_handle *buf_handle);
+
+/**
+ * Deprecated, don't use for new implementations
+ */
int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
void *cpu, uint64_t size,
amdgpu_bo_handle *buf_handle);
diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index d30fd1e..61152fc 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -529,18 +529,16 @@ int amdgpu_bo_wait_for_idle(amdgpu_bo_handle bo,
}
}
-int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
- void *cpu,
- uint64_t size,
- amdgpu_bo_handle *buf_handle)
+int amdgpu_create_bo_from_userptr(amdgpu_device_handle dev,
+ void *cpu, uint64_t size, uint32_t flags,
+ amdgpu_bo_handle *buf_handle)
{
- int r;
- struct amdgpu_bo *bo;
struct drm_amdgpu_gem_userptr args;
+ struct amdgpu_bo *bo;
+ int r;
args.addr = (uintptr_t)cpu;
- args.flags = AMDGPU_GEM_USERPTR_ANONONLY | AMDGPU_GEM_USERPTR_REGISTER |
- AMDGPU_GEM_USERPTR_VALIDATE;
+ args.flags = flags;
args.size = size;
r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_GEM_USERPTR,
&args, sizeof(args));
@@ -561,6 +559,18 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
return r;
}
+int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
+ void *cpu, uint64_t size,
+ amdgpu_bo_handle *buf_handle)
+{
+ uint32_t flags = AMDGPU_GEM_USERPTR_ANONONLY |
+ AMDGPU_GEM_USERPTR_REGISTER |
+ AMDGPU_GEM_USERPTR_VALIDATE;
+
+ return amdgpu_create_bo_from_user_mem(dev, cpu, size,
+ flags, buf_handle);
+}
+
int amdgpu_bo_list_create(amdgpu_device_handle dev,
uint32_t number_of_resources,
amdgpu_bo_handle *resources,
--
2.5.0
More information about the dri-devel
mailing list