From af47cce81dadd41140bd3f714edd9c45406cf463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 7 Oct 2013 12:08:29 +0200 Subject: [PATCH] radeon/winsys: fix handling in radeon_drm_cs_flush MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling radeon_drm_cs_flush from multiple threads might cause deadlocks, fix this by immediately signaling the semaphore after waiting for it. This is a candidate for the stable branch(es). For master we might want to use a condition instead, since this is probably more efficient. Might fix: https://bugs.freedesktop.org/show_bug.cgi?id=70123 Signed-off-by: Christian König --- src/gallium/winsys/radeon/drm/radeon_drm_cs.c | 8 ++++---- src/gallium/winsys/radeon/drm/radeon_drm_cs.h | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c index 62f7704..0782e10 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c @@ -178,7 +178,7 @@ static struct radeon_winsys_cs *radeon_drm_cs_create(struct radeon_winsys *rws, if (!cs) { return NULL; } - pipe_semaphore_init(&cs->flush_completed, 0); + pipe_semaphore_init(&cs->flush_completed, 1); cs->ws = ws; cs->trace_buf = (struct radeon_bo*)trace_buf; @@ -453,9 +453,9 @@ 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 && cs->flush_started) { + if (cs->ws->thread) { pipe_semaphore_wait(&cs->flush_completed); - cs->flush_started = 0; + pipe_semaphore_signal(&cs->flush_completed); } } @@ -567,7 +567,7 @@ static void radeon_drm_cs_flush(struct radeon_winsys_cs *rcs, unsigned flags, ui } if (cs->ws->thread) { - cs->flush_started = 1; + pipe_semaphore_wait(&cs->flush_completed); radeon_drm_ws_queue_cs(cs->ws, cs); if (!(flags & RADEON_FLUSH_ASYNC)) radeon_drm_cs_sync_flush(rcs); diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h index 7683e96..ebec161 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h @@ -76,7 +76,6 @@ struct radeon_drm_cs { void (*flush_cs)(void *ctx, unsigned flags); void *flush_data; - int flush_started; pipe_semaphore flush_completed; struct radeon_bo *trace_buf; }; -- 1.8.1.2