From 599749570ce95245dd7675a8453297ffe7f9d054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Fri, 14 Apr 2023 06:35:07 -0700 Subject: [PATCH] iris: Fix close of exported bos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On commit 910e659e31cb ("iris: Add function to close gem bos") I used iris_bo_close() to close exported bos with the wrong drm_fd. Causing piglit ext_image_dma_buf_import.ext_image_dma_buf_import* tests to crash during tear-down. So here adding iris_bufmgr_bo_close() that will close bos that belongs to bufmgr->fd and changing the parameters of iris_bo_close() to close the bo of given fd. Fixes: 910e659e31cb ("iris: Add function to close gem bos") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8836 Signed-off-by: José Roberto de Souza Reviewed-by: Marcin Ślusarz Part-of: (cherry picked from commit 670d4a2f71f9338ecc3c5c57cfb3784f6d718eba) --- .pick_status.json | 2 +- src/gallium/drivers/iris/iris_bufmgr.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 27b08828197..2f8c950b360 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -553,7 +553,7 @@ "description": "iris: Fix close of exported bos", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "910e659e31cb248e7ca4c487fa4207c3345db59b" }, diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index a9535f8b8b6..d49788a1bcb 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -1165,12 +1165,18 @@ err_free: } static int -iris_bo_close(struct iris_bufmgr *bufmgr, uint32_t gem_handle) +iris_bo_close(int fd, uint32_t gem_handle) { struct drm_gem_close close = { .handle = gem_handle, }; - return intel_ioctl(bufmgr->fd, DRM_IOCTL_GEM_CLOSE, &close); + return intel_ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close); +} + +static int +iris_bufmgr_bo_close(struct iris_bufmgr *bufmgr, uint32_t gem_handle) +{ + return iris_bo_close(bufmgr->fd, gem_handle); } struct iris_bo * @@ -1225,7 +1231,7 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name, return bo; err_close: - iris_bo_close(bufmgr, bo->gem_handle); + iris_bufmgr_bo_close(bufmgr, bo->gem_handle); err_free: free(bo); return NULL; @@ -1272,7 +1278,7 @@ iris_bo_gem_create_from_name(struct iris_bufmgr *bufmgr, bo = bo_calloc(); if (!bo) { - iris_bo_close(bufmgr, open_arg.handle); + iris_bufmgr_bo_close(bufmgr, open_arg.handle); goto out; } @@ -1334,7 +1340,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) { - iris_bo_close(bufmgr, export->gem_handle); + iris_bo_close(export->drm_fd, export->gem_handle); list_del(&export->link); free(export); @@ -1350,7 +1356,7 @@ bo_close(struct iris_bo *bo) DBG("Unable to unbind vm of buf %u\n", bo->gem_handle); /* Close this object */ - if (iris_bo_close(bufmgr, bo->gem_handle) != 0) { + if (iris_bufmgr_bo_close(bufmgr, bo->gem_handle) != 0) { DBG("DRM_IOCTL_GEM_CLOSE %d failed (%s): %s\n", bo->gem_handle, bo->name, strerror(errno)); }