summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/virgl/drm
diff options
context:
space:
mode:
authorLepton Wu <lepton@chromium.org>2021-03-19 13:57:13 -0700
committerMarge Bot <eric+marge@anholt.net>2021-03-19 23:57:58 +0000
commit921dafc98b2c9926be0902ef158cd0ea4779c9a3 (patch)
treef55d1c3a56bf9cdd61b18e19272ec9f5657df2d5 /src/gallium/winsys/virgl/drm
parent25c002bae9737d0ec22ff5f4895e28ecd21e6be4 (diff)
virgl: Use atomic operation directly.
This make sure we don't trigger assert in pipe_reference Signed-off-by: Lepton Wu <lepton@chromium.org> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: John Bates <jbates@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9722>
Diffstat (limited to 'src/gallium/winsys/virgl/drm')
-rw-r--r--src/gallium/winsys/virgl/drm/virgl_drm_winsys.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index 0031db7d278..76e122536b2 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -474,8 +474,13 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws,
}
if (res) {
- struct virgl_hw_res *r = NULL;
- virgl_drm_resource_reference(&qdws->base, &r, res);
+ /* qdws->bo_{names,handles} hold weak pointers to virgl_hw_res. Because
+ * virgl_drm_resource_reference does not take qdws->bo_handles_mutex
+ * until it enters virgl_hw_res_destroy, there is a small window that
+ * the refcount can drop to zero. Call p_atomic_inc directly instead of
+ * virgl_drm_resource_reference to avoid hitting assert failures.
+ */
+ p_atomic_inc(&res->reference.count);
goto done;
}