From 01a3b175574b3c8904c0daa6f4e38035c9b886e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Tue, 15 Oct 2013 11:35:03 +0200 Subject: [PATCH] winsys/radeon: workaround fork problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- src/gallium/winsys/radeon/drm/radeon_drm_cs.c | 4 ++-- src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 11 +++++++++-- src/gallium/winsys/radeon/drm/radeon_drm_winsys.h | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c index 0782e10..360bd4b 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c @@ -453,7 +453,7 @@ void radeon_drm_cs_sync_flush(struct radeon_winsys_cs *rcs) struct radeon_drm_cs *cs = radeon_drm_cs(rcs); /* Wait for any pending ioctl to complete. */ - if (cs->ws->thread) { + if (radeon_drm_ws_thread_valid(cs->ws)) { pipe_semaphore_wait(&cs->flush_completed); pipe_semaphore_signal(&cs->flush_completed); } @@ -566,7 +566,7 @@ static void radeon_drm_cs_flush(struct radeon_winsys_cs *rcs, unsigned flags, ui break; } - if (cs->ws->thread) { + if (radeon_drm_ws_thread_valid(cs->ws)) { pipe_semaphore_wait(&cs->flush_completed); radeon_drm_ws_queue_cs(cs->ws, cs); if (!(flags & RADEON_FLUSH_ASYNC)) diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c index 4f43093..576c293 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c @@ -424,7 +424,7 @@ static void radeon_winsys_destroy(struct radeon_winsys *rws) { struct radeon_drm_winsys *ws = (struct radeon_drm_winsys*)rws; - if (ws->thread) { + if (radeon_drm_ws_thread_valid(ws)) { ws->kill_thread = 1; pipe_semaphore_signal(&ws->cs_queued); pipe_thread_wait(ws->thread); @@ -553,6 +553,11 @@ retry: pipe_semaphore_signal(&ws->cs_queued); } +boolean radeon_drm_ws_thread_valid(struct radeon_drm_winsys *ws) +{ + return ws->thread && ws->pid == getpid(); +} + static PIPE_THREAD_ROUTINE(radeon_drm_cs_emit_ioctl, param) { struct radeon_drm_winsys *ws = (struct radeon_drm_winsys *)param; @@ -657,8 +662,10 @@ struct radeon_winsys *radeon_drm_winsys_create(int fd) p_atomic_set(&ws->ncs, 0); pipe_semaphore_init(&ws->cs_queued, 0); - if (ws->num_cpus > 1 && debug_get_option_thread()) + if (ws->num_cpus > 1 && debug_get_option_thread()) { ws->thread = pipe_thread_create(radeon_drm_cs_emit_ioctl, ws); + ws->pid = getpid(); + } return &ws->base; diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h index ed90194..2a0a76a 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h @@ -68,6 +68,7 @@ struct radeon_drm_winsys { pipe_mutex cs_stack_lock; pipe_semaphore cs_queued; pipe_thread thread; + pid_t pid; int kill_thread; int ncs; struct radeon_drm_cs *cs_stack[RING_LAST]; @@ -80,5 +81,6 @@ radeon_drm_winsys(struct radeon_winsys *base) } void radeon_drm_ws_queue_cs(struct radeon_drm_winsys *ws, struct radeon_drm_cs *cs); +boolean radeon_drm_ws_thread_valid(struct radeon_drm_winsys *ws); #endif -- 1.8.1.2