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>
This commit is contained in:
Lepton Wu 2021-03-19 13:57:13 -07:00 committed by Marge Bot
parent 25c002bae9
commit 921dafc98b
1 changed files with 7 additions and 2 deletions

View File

@ -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;
}