freedreno: Fix batch reference handling in flush_resource().
authorEmma Anholt <emma@anholt.net>
Tue, 15 Jun 2021 17:38:49 +0000 (10:38 -0700)
committerEmma Anholt <emma@anholt.net>
Thu, 17 Jun 2021 16:11:02 +0000 (09:11 -0700)
commitfd571565d2c71c47a6894e31db84f2150b5f3e86
tree3a47b947820d9aec093d0e8531e74b7942e1a2f3
parentcf2747e7ace0a62e18e7f0910af1ab1d4f5e1019
freedreno: Fix batch reference handling in flush_resource().

We take references under the lock, but then accessed the lock-requiring
batch_cache structure without holding the lock.  The batches wouldn't get
freed and removed from their slots until the last ref goes away so it was
safe (other than the assert at the end), but writing the simple code is
shorter and requires fewer assumptions.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11439>
src/gallium/drivers/freedreno/freedreno_resource.c