Mesa (main): freedreno: Lock access to msm_pipe for RB object suballocation.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 22 22:06:09 UTC 2021


Module: Mesa
Branch: main
Commit: b1dbbc3dc1a763fff40e13de5dda4a227af4a583
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b1dbbc3dc1a763fff40e13de5dda4a227af4a583

Author: Emma Anholt <emma at anholt.net>
Date:   Wed Jul 21 11:50:24 2021 -0700

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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12002>

---

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



More information about the mesa-commit mailing list