diff options
author | Christian König <christian.koenig@amd.com> | 2018-08-02 10:45:19 +0200 |
---|---|---|
committer | Christian König <christian.koenig@amd.com> | 2018-08-07 13:27:39 +0200 |
commit | cbf0bb7f192b814be84dff538fb90dacf65958c7 (patch) | |
tree | b5467cd5c74bf56a46e2105cf5a8cdd02ef5c40b | |
parent | d6cb0ee408e88310f2b4caefc51b655410072974 (diff) |
amdgpu: always add all BOs to handle table
This way we can always find a BO structure by its handle.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-and-Tested-by: Junwei Zhang <Jerry.Zhang@amd.com>
-rw-r--r-- | amdgpu/amdgpu_bo.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index 02592377..422c7c99 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -87,6 +87,10 @@ int amdgpu_bo_alloc(amdgpu_device_handle dev, bo->handle = args.out.handle; + 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) @@ -171,13 +175,6 @@ int amdgpu_bo_query_info(amdgpu_bo_handle bo, return 0; } -static void amdgpu_add_handle_to_table(amdgpu_bo_handle bo) -{ - pthread_mutex_lock(&bo->dev->bo_table_mutex); - handle_table_insert(&bo->dev->bo_handles, bo->handle, bo); - pthread_mutex_unlock(&bo->dev->bo_table_mutex); -} - static int amdgpu_bo_export_flink(amdgpu_bo_handle bo) { struct drm_gem_flink flink; @@ -240,14 +237,11 @@ int amdgpu_bo_export(amdgpu_bo_handle bo, return 0; case amdgpu_bo_handle_type_kms: - amdgpu_add_handle_to_table(bo); - /* fall through */ case amdgpu_bo_handle_type_kms_noimport: *shared_handle = bo->handle; return 0; case amdgpu_bo_handle_type_dma_buf_fd: - amdgpu_add_handle_to_table(bo); return drmPrimeHandleToFD(bo->dev->fd, bo->handle, DRM_CLOEXEC | DRM_RDWR, (int*)shared_handle); |