From 01e729f883af47a6a38fca255f37c7d327c2edee Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 13 Nov 2018 17:55:21 +0000 Subject: [PATCH] iris: Tidy exporting the flink handle --- src/gallium/drivers/iris/iris_bufmgr.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 6ac5e88fa55..b4851711b4a 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -1404,19 +1404,26 @@ err: return NULL; } +static void +iris_bo_make_external_locked(struct iris_bo *bo) +{ + if (!bo->external) { + _mesa_hash_table_insert(bo->bufmgr->handle_table, &bo->gem_handle, bo); + bo->external = true; + } +} + static void iris_bo_make_external(struct iris_bo *bo) { struct iris_bufmgr *bufmgr = bo->bufmgr; - if (!bo->external) { - mtx_lock(&bufmgr->lock); - if (!bo->external) { - _mesa_hash_table_insert(bufmgr->handle_table, &bo->gem_handle, bo); - bo->external = true; - } - mtx_unlock(&bufmgr->lock); - } + if (bo->external) + return; + + mtx_lock(&bufmgr->lock); + iris_bo_make_external_locked(bo); + mtx_unlock(&bufmgr->lock); } int @@ -1454,9 +1461,9 @@ iris_bo_flink(struct iris_bo *bo, uint32_t *name) if (drm_ioctl(bufmgr->fd, DRM_IOCTL_GEM_FLINK, &flink)) return -errno; - iris_bo_make_external(bo); mtx_lock(&bufmgr->lock); if (!bo->global_name) { + iris_bo_make_external_locked(bo); bo->global_name = flink.name; _mesa_hash_table_insert(bufmgr->name_table, &bo->global_name, bo); } -- 2.30.2