From b1dbbc3dc1a763fff40e13de5dda4a227af4a583 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 21 Jul 2021 11:50:24 -0700 Subject: [PATCH] freedreno: Lock access to msm_pipe for RB object suballocation. Hopefully this fixes the flakes that have happened since the suballoc changes. Fixes: 737d4caa83a9 ("freedreno: Suballocate our long-lived ring objects.") Part-of: --- src/freedreno/drm/msm_ringbuffer_sp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/freedreno/drm/msm_ringbuffer_sp.c b/src/freedreno/drm/msm_ringbuffer_sp.c index 62e3a30fb4f..14c75eb846d 100644 --- a/src/freedreno/drm/msm_ringbuffer_sp.c +++ b/src/freedreno/drm/msm_ringbuffer_sp.c @@ -828,6 +828,13 @@ msm_ringbuffer_sp_new_object(struct fd_pipe *pipe, uint32_t size) struct msm_pipe *msm_pipe = to_msm_pipe(pipe); struct msm_ringbuffer_sp *msm_ring = malloc(sizeof(*msm_ring)); + /* Lock access to the msm_pipe->suballoc_* since ringbuffer object allocation + * can happen both on the frontend (most CSOs) and the driver thread (a6xx + * cached tex state, for example) + */ + static simple_mtx_t suballoc_lock = _SIMPLE_MTX_INITIALIZER_NP; + simple_mtx_lock(&suballoc_lock); + /* Maximum known alignment requirement is a6xx's TEX_CONST at 16 dwords */ msm_ring->offset = align(msm_pipe->suballoc_offset, 64); if (!msm_pipe->suballoc_bo || @@ -845,5 +852,7 @@ msm_ringbuffer_sp_new_object(struct fd_pipe *pipe, uint32_t size) msm_pipe->suballoc_offset = msm_ring->offset + size; + simple_mtx_unlock(&suballoc_lock); + return msm_ringbuffer_sp_init(msm_ring, size, _FD_RINGBUFFER_OBJECT); }