When create bo from user memory, add it to handle table
for future query.
Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
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;
}