llvmpipe: Add some missing locking

The lp_rasterizer is shared across contexts, and lp_rast_fence called
without holding rast_mutex could race with rast_mutex being replaced and
unref'd on a different thread.

Fixes: a680fd078c ("llvmpipe: make last_fence a screen/rast object not a context one.")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18116>
(cherry picked from commit f228c26520)
This commit is contained in:
Rob Clark 2022-08-17 14:19:36 -07:00 committed by Dylan Baker
parent 185b583ae1
commit 1faced9ec7
3 changed files with 5 additions and 1 deletions

View file

@ -418,7 +418,7 @@
"description": "llvmpipe: Add some missing locking",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "a680fd078c0a7574b60fbf9a7e5c9f42c97a744e"
},

View file

@ -57,7 +57,9 @@ llvmpipe_flush( struct pipe_context *pipe,
/* ask the setup module to flush */
lp_setup_flush(llvmpipe->setup, reason);
mtx_lock(&screen->rast_mutex);
lp_rast_fence(screen->rast, (struct lp_fence **)fence);
mtx_unlock(&screen->rast_mutex);
if (fence && (!*fence))
*fence = (struct pipe_fence_handle *)lp_fence_create(0);

View file

@ -1714,7 +1714,9 @@ lp_setup_end_query(struct lp_setup_context *setup, struct llvmpipe_query *pq)
}
else {
struct llvmpipe_screen *screen = llvmpipe_screen(setup->pipe->screen);
mtx_lock(&screen->rast_mutex);
lp_rast_fence(screen->rast, &pq->fence);
mtx_unlock(&screen->rast_mutex);
}
fail: