From 344252a27f8d875572bbe65641a825af8e73845d Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 17 Nov 2017 16:49:03 -0800 Subject: i965/bufmgr: Add a helper to mark a BO as external Reviewed-by: Kenneth Graunke Cc: mesa-stable@lists.freedesktop.org --- src/mesa/drivers/dri/i965/brw_bufmgr.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c index 17036b53bcd..60b0dad2be7 100644 --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c @@ -1177,8 +1177,8 @@ err: return NULL; } -int -brw_bo_gem_export_to_prime(struct brw_bo *bo, int *prime_fd) +static void +brw_bo_make_external(struct brw_bo *bo) { struct brw_bufmgr *bufmgr = bo->bufmgr; @@ -1190,6 +1190,14 @@ brw_bo_gem_export_to_prime(struct brw_bo *bo, int *prime_fd) } mtx_unlock(&bufmgr->lock); } +} + +int +brw_bo_gem_export_to_prime(struct brw_bo *bo, int *prime_fd) +{ + struct brw_bufmgr *bufmgr = bo->bufmgr; + + brw_bo_make_external(bo); if (drmPrimeHandleToFD(bufmgr->fd, bo->gem_handle, DRM_CLOEXEC, prime_fd) != 0) @@ -1213,11 +1221,8 @@ brw_bo_flink(struct brw_bo *bo, uint32_t *name) if (drmIoctl(bufmgr->fd, DRM_IOCTL_GEM_FLINK, &flink)) return -errno; + brw_bo_make_external(bo); mtx_lock(&bufmgr->lock); - if (!bo->external) { - _mesa_hash_table_insert(bufmgr->handle_table, &bo->gem_handle, bo); - bo->external = true; - } if (!bo->global_name) { bo->global_name = flink.name; _mesa_hash_table_insert(bufmgr->name_table, &bo->global_name, bo); -- cgit v1.2.3