Skip to content

panfrost: Protect pandecode by a mutex

Alyssa Rosenzweig requested to merge alyssa/mesa:panfrost/pandecode-lock into main

Pandecode is not thread-safe (for a large number of reasons) and does not even try to be. This is a problem when tracing (or just using PAN_MESA_DEBUG=sync) multithreaded applications. The most common symptom of the problem are assertion failures deep in the red-black tree implementation, which is not thread-safe.

Just protect the whole thing by a "in pandecode?" mutex, since this is not performance sensitive code and we don't really care about the extra serialization incurred. As pandecode does not recurse into itself, we may simply lock at the beginning and unlock at the end of each entrypoint in pandecode, which is thread-safe regardless of how pandecode is used. A few entrypoints are refactored to avoid early returns to keep the lock/unlock calls in obvious visual pairs.

Fixes flakes when running the CL CTS with PAN_MESA_DEBUG=sync like we would in CI (e.g: events.event_flush)

Cc @icecream95 -- does this fix the issues you were seeing with v10?

Merge request reports