[Mesa-dev] [PATCH] gallium/swr: Fix multi-context sync fence deadlock.

Hota, Alok alok.hota at intel.com
Tue Jan 15 19:59:32 UTC 2019


Reviewed-by: Alok Hota <alok.hota at intel.com>

-Alok

-----Original Message-----
From: mesa-dev [mailto:mesa-dev-bounces at lists.freedesktop.org] On Behalf Of Bruce Cherniak
Sent: Friday, January 4, 2019 2:54 PM
To: mesa-dev at lists.freedesktop.org
Cc: mesa-stable at lists.freedesktop.org
Subject: [Mesa-dev] [PATCH] gallium/swr: Fix multi-context sync fence deadlock.

Various recreation scenarios lead to API thread getting stuck in swr_fence_finish().  This is a multi-context issue, whereby one context overwrites the fence read-value with a previous sync's lesser value.
The fence sync value is supposed to be always increasing.

In swr_fence_cb(), only update the "read" value if the new value is greater.

(This may seem like we're not waiting on the other context to finish, but had we needed for it to finish there would have been a wait prior to submitting a new sync.)

cc: mesa-stable at lists.freedesktop.org
---
 src/gallium/drivers/swr/swr_fence.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/swr/swr_fence.cpp b/src/gallium/drivers/swr/swr_fence.cpp
index b05ac8cec0..074d82a3b4 100644
--- a/src/gallium/drivers/swr/swr_fence.cpp
+++ b/src/gallium/drivers/swr/swr_fence.cpp
@@ -50,7 +50,9 @@ swr_fence_cb(uint64_t userData, uint64_t userData2, uint64_t userData3)
    swr_fence_do_work(fence);
 
    /* Correct value is in SwrSync data, and not the fence write field. */
-   fence->read = userData2;
+   /* Contexts may not finish in order, but fence value always increases */
+   if (fence->read < userData2)
+      fence->read = userData2;
 }
 
 /*
--
2.17.1

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list