Mesa (main): freedreno/drm: Close bo handle after bo->destroy()
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Apr 27 23:33:33 UTC 2022
Module: Mesa
Branch: main
Commit: d52455a9620ff596488634cdcf205776555feb8b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d52455a9620ff596488634cdcf205776555feb8b
Author: Rob Clark <robdclark at chromium.org>
Date: Fri Mar 25 09:29:41 2022 -0700
freedreno/drm: Close bo handle after bo->destroy()
For userspace allocated iova, we want to give the backend a chance to
release the iova before the handle is closed.
Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16086>
---
src/freedreno/drm/freedreno_bo.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/freedreno/drm/freedreno_bo.c b/src/freedreno/drm/freedreno_bo.c
index fe41b251539..eae3f56a626 100644
--- a/src/freedreno/drm/freedreno_bo.c
+++ b/src/freedreno/drm/freedreno_bo.c
@@ -350,6 +350,9 @@ cleanup_fences(struct fd_bo *bo, bool expired)
void
bo_del(struct fd_bo *bo)
{
+ struct fd_device *dev = bo->dev;
+ uint32_t handle = bo->handle;
+
VG_BO_FREE(bo);
simple_mtx_assert_locked(&table_lock);
@@ -361,21 +364,20 @@ bo_del(struct fd_bo *bo)
if (bo->map)
os_munmap(bo->map, bo->size);
- /* TODO probably bo's in bucket list get removed from
- * handle table??
- */
-
- if (bo->handle) {
- struct drm_gem_close req = {
- .handle = bo->handle,
- };
- _mesa_hash_table_remove_key(bo->dev->handle_table, &bo->handle);
+ if (handle) {
+ _mesa_hash_table_remove_key(dev->handle_table, &handle);
if (bo->name)
- _mesa_hash_table_remove_key(bo->dev->name_table, &bo->name);
- drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &req);
+ _mesa_hash_table_remove_key(dev->name_table, &bo->name);
}
bo->funcs->destroy(bo);
+
+ if (handle) {
+ struct drm_gem_close req = {
+ .handle = handle,
+ };
+ drmIoctl(dev->fd, DRM_IOCTL_GEM_CLOSE, &req);
+ }
}
static void
More information about the mesa-commit
mailing list