Mesa (master): svga: init svga_screen::swc_mutex with mtx_recursive

Brian Paul brianp at kemper.freedesktop.org
Wed May 24 21:34:14 UTC 2017


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

Author: Brian Paul <brianp at vmware.com>
Date:   Tue May 23 13:16:56 2017 -0600

svga: init svga_screen::swc_mutex with mtx_recursive

If the SVGA3D_BindGBSurface() call in svga_buffer_hw_storage_unmap()
fails, we'll flush and that might involve unmapping other buffers.
That leads to a recursive lock on svga_screen::swc_mutex and causes
a deadlock.  Fix this by initializing the mutex with mtx_recursive.

Note that this only happened on Linux, not Windows.  On Windows, the
mutex functions are implemented with Win32 critical sections which
support recursive locking.

Also add a comment about this.

Fixes VMware bug 1831549 (Unigine Tropics demo freeze on Linux).

Reviewed-by: Thomas Hellstrom <thellstrom at vmware.com>
Reviewed-by: Neha Bhende<bhenden at vmware.com>

---

 src/gallium/drivers/svga/svga_resource_buffer.c | 3 +++
 src/gallium/drivers/svga/svga_screen.c          | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c
index 7808903083..271d0787ab 100644
--- a/src/gallium/drivers/svga/svga_resource_buffer.c
+++ b/src/gallium/drivers/svga/svga_resource_buffer.c
@@ -320,6 +320,9 @@ svga_buffer_transfer_unmap( struct pipe_context *pipe,
    }
 
    if (svga_buffer_has_hw_storage(sbuf)) {
+      /* Note: we may wind up flushing here and unmapping other buffers
+       * which leads to recursively locking ss->swc_mutex.
+       */
       svga_buffer_hw_storage_unmap(svga, sbuf);
    }
 
diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
index 95132fbeb8..74e5485c0e 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -1157,7 +1157,7 @@ svga_screen_create(struct svga_winsys_screen *sws)
    }
 
    (void) mtx_init(&svgascreen->tex_mutex, mtx_plain);
-   (void) mtx_init(&svgascreen->swc_mutex, mtx_plain);
+   (void) mtx_init(&svgascreen->swc_mutex, mtx_recursive);
 
    svga_screen_cache_init(svgascreen);
 




More information about the mesa-commit mailing list