From f49dccbb24c51de9905582a788bd70e1f3a28efa Mon Sep 17 00:00:00 2001 From: Junwei Zhang Date: Wed, 8 Aug 2018 17:56:45 +0800 Subject: [PATCH] amdgpu: add bo from user memory to handle table MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When create bo from user memory, add it to handle table for future query. Signed-off-by: Junwei Zhang Reviewed-by: Christian König --- amdgpu/amdgpu_bo.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index 422c7c9..b24e698 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -556,7 +556,16 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, bo->alloc_size = size; bo->handle = args.handle; - *buf_handle = bo; + pthread_mutex_lock(&bo->dev->bo_table_mutex); + r = handle_table_insert(&bo->dev->bo_handles, bo->handle, bo); + pthread_mutex_unlock(&bo->dev->bo_table_mutex); + + pthread_mutex_init(&bo->cpu_access_mutex, NULL); + + if (r) + amdgpu_bo_free(bo); + else + *buf_handle = bo; return r; } -- 2.7.4