OSDN Git Service

intel: Avoid pthread mutex recursion in bufmgr_fake.
authorEric Anholt <eric@anholt.net>
Mon, 13 Oct 2008 20:41:10 +0000 (13:41 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 13 Oct 2008 20:41:10 +0000 (13:41 -0700)
Bug #18035. Fixes deadlock in glean texCube testcase.

libdrm/intel/intel_bufmgr_fake.c

index 1be4698..cfe9a73 100644 (file)
@@ -717,20 +717,25 @@ dri_bufmgr_fake_wait_idle(dri_bufmgr_fake *bufmgr_fake)
  * the necessary flushing.
  */
 static void
-dri_fake_bo_wait_rendering(dri_bo *bo)
+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;
 
-   pthread_mutex_lock(&bufmgr_fake->lock);
-
-   if (bo_fake->block == NULL || !bo_fake->block->fenced) {
-      pthread_mutex_unlock(&bufmgr_fake->lock);
+   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)
+{
+   dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bo->bufmgr;
+   dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
 
+   pthread_mutex_lock(&bufmgr_fake->lock);
+   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;