Mesa (master): radeonsi: prevent a deadlock in util_queue_add_job with too many GL contexts

Marek Olšák mareko at kemper.freedesktop.org
Mon Jul 17 15:13:25 UTC 2017


Module: Mesa
Branch: master
Commit: 4cae27411607d8680401faa2fc971d2be0f715fd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4cae27411607d8680401faa2fc971d2be0f715fd

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Mon Jul 10 21:59:43 2017 +0200

radeonsi: prevent a deadlock in util_queue_add_job with too many GL contexts

If the queue is full, util_queue_add_job will wait while bo_fence_lock is
held.

It pb_slab wants to reuse a buffer, it will lock the pb_slab mutex and
try to check BO fence busyness, but it has to wait for bo_fence_lock to get
released. Both bo_fence_lock and pb_slab mutex are locked now.

When the CS thread unreferences and releases a suballocated buffer,
it will try to lock the pb_slab mutex and has to wait. The CS thread
can't finish its job in order to free a queue slot and unblock
util_queue_add_job ==> deadlock.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index 30f4dfb769..837c1e2aae 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -316,7 +316,8 @@ amdgpu_winsys_create(int fd, unsigned flags,
    (void) mtx_init(&ws->global_bo_list_lock, mtx_plain);
    (void) mtx_init(&ws->bo_fence_lock, mtx_plain);
 
-   if (!util_queue_init(&ws->cs_queue, "amdgpu_cs", 8, 1, 0)) {
+   if (!util_queue_init(&ws->cs_queue, "amdgpu_cs", 8, 1,
+                        UTIL_QUEUE_INIT_RESIZE_IF_FULL)) {
       amdgpu_winsys_destroy(&ws->base);
       mtx_unlock(&dev_tab_mutex);
       return NULL;




More information about the mesa-commit mailing list