[Mesa-dev] [PATCH 02/11] pipe-loader-drm: protect create_screen() calls with a mutex

Rob Herring robh at kernel.org
Wed Jul 20 21:26:13 UTC 2016


Creating a screen needs to be serialized in order to support reusing
existing screen. With this, driver private mutexes in create_screen()
functions can be removed.

Signed-off-by: Rob Herring <robh at kernel.org>
Cc: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 7bdd2ec..554e59a 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -41,6 +41,7 @@
 #include "pipe_loader_priv.h"
 #include "pipe/p_screen.h"
 
+#include "os/os_thread.h"
 #include "util/u_memory.h"
 #include "util/u_dl.h"
 #include "util/u_debug.h"
@@ -63,6 +64,8 @@ struct pipe_loader_drm_device {
 
 static const struct pipe_loader_ops pipe_loader_drm_ops;
 
+pipe_static_mutex(loader_mutex);
+
 #ifdef GALLIUM_STATIC_TARGETS
 static const struct drm_conf_ret throttle_ret = {
    DRM_CONF_INT,
@@ -303,8 +306,10 @@ pipe_loader_drm_create_screen(struct pipe_loader_device *dev)
    struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
    struct pipe_screen *pscreen;
 
+   pipe_mutex_lock(loader_mutex);
    pscreen = ddev->dd->create_screen(ddev->fd);
    ddev->base.pscreen = pscreen;
+   pipe_mutex_unlock(loader_mutex);
    return pscreen;
 }
 
-- 
2.9.2



More information about the mesa-dev mailing list