drm/nouveau: Fix sleep while atomic in nouveau_bo_fence().
authorFrancisco Jerez <currojerez@riseup.net>
Thu, 28 Oct 2010 21:10:29 +0000 (23:10 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 3 Dec 2010 05:11:23 +0000 (15:11 +1000)
Reported-by: Pekka Paalanen <pq@iki.fi>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_bo.c

index 8d5dd980240d29e200aae7ae4dcbbc8343093945..f4ee43db00aaf2db1a08e0b023ffb98e839de54e 100644 (file)
@@ -942,13 +942,17 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
 void
 nouveau_bo_fence(struct nouveau_bo *nvbo, struct nouveau_fence *fence)
 {
-       spin_lock(&nvbo->bo.bdev->fence_lock);
-       __nouveau_fence_unref(&nvbo->bo.sync_obj);
+       struct nouveau_fence *old_fence;
 
        if (likely(fence))
-               nvbo->bo.sync_obj = nouveau_fence_ref(fence);
+               nouveau_fence_ref(fence);
 
+       spin_lock(&nvbo->bo.bdev->fence_lock);
+       old_fence = nvbo->bo.sync_obj;
+       nvbo->bo.sync_obj = fence;
        spin_unlock(&nvbo->bo.bdev->fence_lock);
+
+       nouveau_fence_unref(&old_fence);
 }
 
 struct ttm_bo_driver nouveau_bo_driver = {