diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index f8a9f8c59f6..2ef41f5cd01 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -1161,12 +1161,20 @@ err_free: return NULL; } +static int +iris_bo_close(struct iris_bufmgr *bufmgr, uint32_t gem_handle) +{ + struct drm_gem_close close = { + .handle = gem_handle, + }; + return intel_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &close); +} + struct iris_bo * iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name, void *ptr, size_t size, enum iris_memory_zone memzone) { - struct drm_gem_close close = { 0, }; struct iris_bo *bo; bo = bo_calloc(); @@ -1214,8 +1222,7 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name, return bo; err_close: - close.handle = bo->gem_handle; - intel_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &close); + iris_bo_close(bufmgr, bo->gem_handle); err_free: free(bo); return NULL; @@ -1262,8 +1269,7 @@ iris_bo_gem_create_from_name(struct iris_bufmgr *bufmgr, bo = bo_calloc(); if (!bo) { - struct drm_gem_close close = { .handle = open_arg.handle, }; - intel_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &close); + iris_bo_close(bufmgr, open_arg.handle); goto out; } @@ -1325,8 +1331,7 @@ bo_close(struct iris_bo *bo) _mesa_hash_table_remove(bufmgr->handle_table, entry); list_for_each_entry_safe(struct bo_export, export, &bo->real.exports, link) { - struct drm_gem_close close = { .handle = export->gem_handle }; - intel_ioctl(export->drm_fd, DRM_IOCTL_GEM_CLOSE, &close); + iris_bo_close(bufmgr, export->gem_handle); list_del(&export->link); free(export); @@ -1342,9 +1347,7 @@ bo_close(struct iris_bo *bo) DBG("Unable to unbind vm of buf %u\n", bo->gem_handle); /* Close this object */ - struct drm_gem_close close = { .handle = bo->gem_handle }; - int ret = intel_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &close); - if (ret != 0) { + if (iris_bo_close(bufmgr, bo->gem_handle) != 0) { DBG("DRM_IOCTL_GEM_CLOSE %d failed (%s): %s\n", bo->gem_handle, bo->name, strerror(errno)); }