Mesa (main): iris: refcount separate screen objects for resource tracking
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue May 11 15:00:20 UTC 2021
Module: Mesa
Branch: main
Commit: eb63c7decedb6188122f01d9851c44aa8d1d0e33
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb63c7decedb6188122f01d9851c44aa8d1d0e33
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Tue May 4 15:08:07 2021 -0400
iris: refcount separate screen objects for resource tracking
this screen object can never, ever be accessed like this in a resource,
as it may have previously been replaced by a wrapper (e.g., driver trace)
which will then explode when it is accessed directly
instead, keep a separate screen ref on the resource which is known to be
the actual driver object and not a wrapper
Fixes: 0a497eb1303 ("iris: make resources take a ref on the screen object")
Reviewed-by: Lionel Landwerlin lionel.g.landwerlin at intel.com
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10632>
---
src/gallium/drivers/iris/iris_resource.c | 5 +++--
src/gallium/drivers/iris/iris_resource.h | 5 +++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index 914a47f6584..dca64cdc9e0 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -456,7 +456,7 @@ iris_resource_destroy(struct pipe_screen *screen,
threaded_resource_deinit(p_res);
iris_bo_unreference(res->bo);
- iris_pscreen_unref(res->base.b.screen);
+ iris_pscreen_unref(res->orig_screen);
free(res);
}
@@ -470,7 +470,8 @@ iris_alloc_resource(struct pipe_screen *pscreen,
return NULL;
res->base.b = *templ;
- res->base.b.screen = iris_pscreen_ref(pscreen);
+ res->base.b.screen = pscreen;
+ res->orig_screen = iris_pscreen_ref(pscreen);
pipe_reference_init(&res->base.b.reference, 1);
threaded_resource_init(&res->base.b);
diff --git a/src/gallium/drivers/iris/iris_resource.h b/src/gallium/drivers/iris/iris_resource.h
index 5bf85e7060f..1e4cd101af9 100644
--- a/src/gallium/drivers/iris/iris_resource.h
+++ b/src/gallium/drivers/iris/iris_resource.h
@@ -168,6 +168,11 @@ struct iris_resource {
* be DRM_FORMAT_MOD_INVALID.
*/
const struct isl_drm_modifier_info *mod_info;
+
+ /**
+ * The screen the resource was originally created with, stored for refcounting.
+ */
+ struct pipe_screen *orig_screen;
};
/**
More information about the mesa-commit
mailing list