From 3e03d781f7c41a88d5d5f895be9c443bf3592ef0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 13 Oct 2008 13:41:10 -0700 Subject: [PATCH] intel: Avoid pthread mutex recursion in bufmgr_fake. Bug #18035. Fixes deadlock in glean texCube testcase. --- libdrm/intel/intel_bufmgr_fake.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/libdrm/intel/intel_bufmgr_fake.c b/libdrm/intel/intel_bufmgr_fake.c index 1be4698b..cfe9a731 100644 --- a/libdrm/intel/intel_bufmgr_fake.c +++ b/libdrm/intel/intel_bufmgr_fake.c @@ -716,6 +716,18 @@ dri_bufmgr_fake_wait_idle(dri_bufmgr_fake *bufmgr_fake) * It is assumed that the bathcbuffer which performed the rendering included * the necessary flushing. */ +static void +dri_fake_bo_wait_rendering_locked(dri_bo *bo) +{ + dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bo->bufmgr; + dri_bo_fake *bo_fake = (dri_bo_fake *)bo; + + if (bo_fake->block == NULL || !bo_fake->block->fenced) + return; + + _fence_wait_internal(bufmgr_fake, bo_fake->block->fence); +} + static void dri_fake_bo_wait_rendering(dri_bo *bo) { @@ -723,14 +735,7 @@ dri_fake_bo_wait_rendering(dri_bo *bo) dri_bo_fake *bo_fake = (dri_bo_fake *)bo; pthread_mutex_lock(&bufmgr_fake->lock); - - if (bo_fake->block == NULL || !bo_fake->block->fenced) { - pthread_mutex_unlock(&bufmgr_fake->lock); - return; - } - - _fence_wait_internal(bufmgr_fake, bo_fake->block->fence); - + dri_fake_bo_wait_rendering_locked(bo); pthread_mutex_unlock(&bufmgr_fake->lock); } @@ -972,7 +977,7 @@ dri_fake_bo_map_locked(dri_bo *bo, int write_enable) if (!(bo_fake->flags & BM_NO_FENCE_SUBDATA) && bo_fake->block->fenced) { - dri_fake_bo_wait_rendering(bo); + dri_fake_bo_wait_rendering_locked(bo); } bo->virtual = bo_fake->block->virtual; @@ -987,7 +992,7 @@ dri_fake_bo_map_locked(dri_bo *bo, int write_enable) if ((bo_fake->card_dirty == 1) && bo_fake->block) { if (bo_fake->block->fenced) - dri_fake_bo_wait_rendering(bo); + dri_fake_bo_wait_rendering_locked(bo); memcpy(bo_fake->backing_store, bo_fake->block->virtual, bo_fake->block->bo->size); bo_fake->card_dirty = 0;