[Mesa-dev] [PATCH v5 02/12] pipe-loader: serialize create_screen() calls with a mutex
Rob Herring
robh at kernel.org
Mon Aug 7 22:58:01 UTC 2017
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.
pipe_loader_create_screen is made an exported symbol to ensure the same
library function (and mutex) is used when multiple libraries are loaded.
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.c | 13 +++++++++++--
src/gallium/targets/dri-vdpau.dyn | 2 ++
src/gallium/targets/dri/dri.sym | 2 ++
src/gallium/targets/vdpau/vdpau.sym | 2 ++
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.c b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
index 61e5786a2528..4ea3dc81a64a 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
@@ -31,6 +31,7 @@
#include "util/u_memory.h"
#include "util/u_string.h"
#include "util/u_dl.h"
+#include "util/u_thread.h"
#include "util/xmlconfig.h"
#include "util/xmlpool.h"
@@ -43,6 +44,8 @@
#define MODULE_PREFIX "pipe_"
+static mtx_t loader_mutex = _MTX_INITIALIZER_NP;
+
static int (*backends[])(struct pipe_loader_device **, int) = {
#ifdef HAVE_LIBDRM
&pipe_loader_drm_probe,
@@ -70,11 +73,15 @@ pipe_loader_probe(struct pipe_loader_device **devs, int ndev)
static void
pipe_loader_release_dev(struct pipe_loader_device *dev)
{
+ mtx_lock(&loader_mutex);
+
dev->pscreen->destroy(dev->pscreen);
dev->ops->release(&dev);
+
+ mtx_unlock(&loader_mutex);
}
-void
+PUBLIC void
pipe_loader_release(struct pipe_loader_device **devs, int ndev)
{
int i;
@@ -129,7 +136,7 @@ pipe_loader_get_driinfo_xml(const char *driver_name)
return xml;
}
-struct pipe_screen *
+PUBLIC struct pipe_screen *
pipe_loader_create_screen(struct pipe_loader_device *dev)
{
struct pipe_screen *pscreen;
@@ -138,8 +145,10 @@ pipe_loader_create_screen(struct pipe_loader_device *dev)
pipe_loader_load_options(dev);
config.options = &dev->option_cache;
+ mtx_lock(&loader_mutex);
pscreen = dev->ops->create_screen(dev, &config);
dev->pscreen = pscreen;
+ mtx_unlock(&loader_mutex);
return pscreen;
}
diff --git a/src/gallium/targets/dri-vdpau.dyn b/src/gallium/targets/dri-vdpau.dyn
index a7919f7d3ba3..03e9e432b699 100644
--- a/src/gallium/targets/dri-vdpau.dyn
+++ b/src/gallium/targets/dri-vdpau.dyn
@@ -1,4 +1,6 @@
{
+ pipe_loader_create_screen;
+ pipe_loader_release;
nouveau_drm_screen_create;
radeon_drm_winsys_create;
amdgpu_winsys_create;
diff --git a/src/gallium/targets/dri/dri.sym b/src/gallium/targets/dri/dri.sym
index 1fdf18beee76..38b13544ddbf 100644
--- a/src/gallium/targets/dri/dri.sym
+++ b/src/gallium/targets/dri/dri.sym
@@ -2,6 +2,8 @@
global:
__driDriverExtensions;
__driDriverGetExtensions*;
+ pipe_loader_create_screen;
+ pipe_loader_release;
nouveau_drm_screen_create;
radeon_drm_winsys_create;
amdgpu_winsys_create;
diff --git a/src/gallium/targets/vdpau/vdpau.sym b/src/gallium/targets/vdpau/vdpau.sym
index 5e71c6285a64..65b6d1c4ebcc 100644
--- a/src/gallium/targets/vdpau/vdpau.sym
+++ b/src/gallium/targets/vdpau/vdpau.sym
@@ -1,6 +1,8 @@
{
global:
vdp_imp_device_create_x11;
+ pipe_loader_create_screen;
+ pipe_loader_release;
nouveau_drm_screen_create;
radeon_drm_winsys_create;
amdgpu_winsys_create;
--
2.11.0
More information about the mesa-dev
mailing list