summaryrefslogtreecommitdiffstats
path: root/src/gallium/targets
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2014-04-09 01:07:52 +0200
committerMarek Olšák <[email protected]>2014-04-10 20:50:17 +0200
commit3b0b44f7def0acb4f7a7aef086c0bece321418a6 (patch)
treeb156e7e948909c0a31d127d30099da60cb178b5d /src/gallium/targets
parentac330d4130cb005c75972da2a701b674413456ba (diff)
winsys/radeon: fix a race condition in initialization of radeon_winsys::screen
Create the screen in the winsys while the mutex is locked. This also results in a nice code cleanup! Reviewed-by: Michel Dänzer <[email protected]> Reviewed-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/targets')
-rw-r--r--src/gallium/targets/egl-static/egl_pipe.c42
-rw-r--r--src/gallium/targets/pipe-loader/pipe_r300.c14
-rw-r--r--src/gallium/targets/pipe-loader/pipe_r600.c14
-rw-r--r--src/gallium/targets/pipe-loader/pipe_radeonsi.c14
-rw-r--r--src/gallium/targets/r300/common/drm_target.c15
-rw-r--r--src/gallium/targets/r600/common/drm_target.c15
-rw-r--r--src/gallium/targets/radeonsi/common/drm_target.c15
7 files changed, 18 insertions, 111 deletions
diff --git a/src/gallium/targets/egl-static/egl_pipe.c b/src/gallium/targets/egl-static/egl_pipe.c
index eb1cff9c76b..ce734fb4711 100644
--- a/src/gallium/targets/egl-static/egl_pipe.c
+++ b/src/gallium/targets/egl-static/egl_pipe.c
@@ -119,19 +119,9 @@ pipe_r300_create_screen(int fd)
{
#if _EGL_PIPE_R300
struct radeon_winsys *sws;
- struct pipe_screen *screen;
-
- sws = radeon_drm_winsys_create(fd);
- if (!sws)
- return NULL;
-
- screen = r300_screen_create(sws);
- if (!screen)
- return NULL;
- screen = debug_screen_wrap(screen);
-
- return screen;
+ sws = radeon_drm_winsys_create(fd, r300_screen_create);
+ return sws ? debug_screen_wrap(sws->screen) : NULL;
#else
return NULL;
#endif
@@ -142,19 +132,9 @@ pipe_r600_create_screen(int fd)
{
#if _EGL_PIPE_R600
struct radeon_winsys *rw;
- struct pipe_screen *screen;
-
- rw = radeon_drm_winsys_create(fd);
- if (!rw)
- return NULL;
-
- screen = r600_screen_create(rw);
- if (!screen)
- return NULL;
-
- screen = debug_screen_wrap(screen);
- return screen;
+ rw = radeon_drm_winsys_create(fd, r600_screen_create);
+ return rw ? debug_screen_wrap(rw->screen) : NULL;
#else
return NULL;
#endif
@@ -165,19 +145,9 @@ pipe_radeonsi_create_screen(int fd)
{
#if _EGL_PIPE_RADEONSI
struct radeon_winsys *rw;
- struct pipe_screen *screen;
-
- rw = radeon_drm_winsys_create(fd);
- if (!rw)
- return NULL;
-
- screen = radeonsi_screen_create(rw);
- if (!screen)
- return NULL;
- screen = debug_screen_wrap(screen);
-
- return screen;
+ rw = radeon_drm_winsys_create(fd, radeonsi_screen_create);
+ return rw ? debug_screen_wrap(rw->screen) : NULL;
#else
return NULL;
#endif
diff --git a/src/gallium/targets/pipe-loader/pipe_r300.c b/src/gallium/targets/pipe-loader/pipe_r300.c
index 055685996e6..388b091f144 100644
--- a/src/gallium/targets/pipe-loader/pipe_r300.c
+++ b/src/gallium/targets/pipe-loader/pipe_r300.c
@@ -8,19 +8,9 @@ static struct pipe_screen *
create_screen(int fd)
{
struct radeon_winsys *sws;
- struct pipe_screen *screen;
- sws = radeon_drm_winsys_create(fd);
- if (!sws)
- return NULL;
-
- screen = r300_screen_create(sws);
- if (!screen)
- return NULL;
-
- screen = debug_screen_wrap(screen);
-
- return screen;
+ sws = radeon_drm_winsys_create(fd, r300_screen_create);
+ return sws ? debug_screen_wrap(sws->screen) : NULL;
}
PUBLIC
diff --git a/src/gallium/targets/pipe-loader/pipe_r600.c b/src/gallium/targets/pipe-loader/pipe_r600.c
index 5d89aca6ec3..0c590875784 100644
--- a/src/gallium/targets/pipe-loader/pipe_r600.c
+++ b/src/gallium/targets/pipe-loader/pipe_r600.c
@@ -7,19 +7,9 @@ static struct pipe_screen *
create_screen(int fd)
{
struct radeon_winsys *rw;
- struct pipe_screen *screen;
- rw = radeon_drm_winsys_create(fd);
- if (!rw)
- return NULL;
-
- screen = r600_screen_create(rw);
- if (!screen)
- return NULL;
-
- screen = debug_screen_wrap(screen);
-
- return screen;
+ rw = radeon_drm_winsys_create(fd, r600_screen_create);
+ return rw ? debug_screen_wrap(rw->screen) : NULL;
}
PUBLIC
diff --git a/src/gallium/targets/pipe-loader/pipe_radeonsi.c b/src/gallium/targets/pipe-loader/pipe_radeonsi.c
index 48b2b5dff3f..406ba1e1ddb 100644
--- a/src/gallium/targets/pipe-loader/pipe_radeonsi.c
+++ b/src/gallium/targets/pipe-loader/pipe_radeonsi.c
@@ -7,19 +7,9 @@ static struct pipe_screen *
create_screen(int fd)
{
struct radeon_winsys *rw;
- struct pipe_screen *screen;
- rw = radeon_drm_winsys_create(fd);
- if (!rw)
- return NULL;
-
- screen = radeonsi_screen_create(rw);
- if (!screen)
- return NULL;
-
- screen = debug_screen_wrap(screen);
-
- return screen;
+ rw = radeon_drm_winsys_create(fd, radeonsi_screen_create);
+ return rw ? debug_screen_wrap(rw->screen) : NULL;
}
PUBLIC
diff --git a/src/gallium/targets/r300/common/drm_target.c b/src/gallium/targets/r300/common/drm_target.c
index 9b484469d47..dff83dacba2 100644
--- a/src/gallium/targets/r300/common/drm_target.c
+++ b/src/gallium/targets/r300/common/drm_target.c
@@ -36,19 +36,8 @@ create_screen(int fd)
{
struct radeon_winsys *sws;
- sws = radeon_drm_winsys_create(fd);
- if (!sws)
- return NULL;
-
- if (!sws->screen) {
- sws->screen = r300_screen_create(sws);
- if (!sws->screen)
- return NULL;
-
- sws->screen = debug_screen_wrap(sws->screen);
- }
-
- return sws->screen;
+ sws = radeon_drm_winsys_create(fd, r300_screen_create);
+ return sws ? debug_screen_wrap(sws->screen) : NULL;
}
/* Technically this is only true for kernels >= 3.12, which
diff --git a/src/gallium/targets/r600/common/drm_target.c b/src/gallium/targets/r600/common/drm_target.c
index ab1eec6ac9a..09250c79fb9 100644
--- a/src/gallium/targets/r600/common/drm_target.c
+++ b/src/gallium/targets/r600/common/drm_target.c
@@ -35,19 +35,8 @@ static struct pipe_screen *create_screen(int fd)
{
struct radeon_winsys *radeon;
- radeon = radeon_drm_winsys_create(fd);
- if (!radeon)
- return NULL;
-
- if (!radeon->screen) {
- radeon->screen = r600_screen_create(radeon);
- if (!radeon->screen)
- return NULL;
-
- radeon->screen = debug_screen_wrap(radeon->screen);
- }
-
- return radeon->screen;
+ radeon = radeon_drm_winsys_create(fd, r600_screen_create);
+ return radeon ? debug_screen_wrap(radeon->screen) : NULL;
}
static const struct drm_conf_ret throttle_ret = {
diff --git a/src/gallium/targets/radeonsi/common/drm_target.c b/src/gallium/targets/radeonsi/common/drm_target.c
index c695dde51ed..74980af5281 100644
--- a/src/gallium/targets/radeonsi/common/drm_target.c
+++ b/src/gallium/targets/radeonsi/common/drm_target.c
@@ -35,19 +35,8 @@ static struct pipe_screen *create_screen(int fd)
{
struct radeon_winsys *radeon;
- radeon = radeon_drm_winsys_create(fd);
- if (!radeon)
- return NULL;
-
- if (!radeon->screen) {
- radeon->screen = radeonsi_screen_create(radeon);
- if (!radeon->screen)
- return NULL;
-
- radeon->screen = debug_screen_wrap(radeon->screen);
- }
-
- return radeon->screen;
+ radeon = radeon_drm_winsys_create(fd, radeonsi_screen_create);
+ return radeon ? debug_screen_wrap(radeon->screen) : NULL;
}
static const struct drm_conf_ret throttle_ret = {