panfrost: Protect the variants array with a lock
authorAlyssa Rosenzweig <alyssa@collabora.com>
Thu, 12 Aug 2021 20:17:48 +0000 (20:17 +0000)
committerAlyssa Rosenzweig <alyssa@collabora.com>
Tue, 24 Aug 2021 18:31:54 +0000 (14:31 -0400)
commit40edc87956aac09b60d17eb4e479bcb02b8fa20c
treed26b075483ac86aa4c85fe02a28b27a0381d6e0c
parent67821af1de8100c069df9bf600e65a02f61a2ce4
panfrost: Protect the variants array with a lock

Without a lock, two threads may bind the same shader CSO simultaneously,
allocate the same variant simultaneously, and then race each other in
the compiler. This manifests in various ways, most commonly failing the
assertion that UBO pushing has only run once. The simple_mtx_t solution
is used in Iris. Fixes the crash in:

dEQP-EGL.functional.sharing.gles2.multithread.simple.buffers.bufferdata_render

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12525>
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h