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

Submitted by Rob Herring on July 22, 2016, 4:22 p.m.

Details

Message ID 20160722162222.21871-3-robh@kernel.org
State New
Headers show
Series "Common pipe screen ref counting" ( rev: 4 ) in Mesa

Not browsing as part of any series.

Commit Message

Rob Herring July 22, 2016, 4:22 p.m.
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@kernel.org>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch hide | download patch | download mbox

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;
 }