drm/radeon: add error handling to radeon_vm_unbind_locked
authorChristian König <deathsimple@vodafone.de>
Mon, 25 Jun 2012 13:13:50 +0000 (15:13 +0200)
committerChristian König <deathsimple@vodafone.de>
Tue, 17 Jul 2012 08:31:47 +0000 (10:31 +0200)
Waiting for a fence can fail for different reasons,
the most common is a deadlock.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_gart.c

index 2b34c1a91421d4d0cc7c438cd09446de82cfaaea..ee11c5073726e59a8d89fb4125325352d4499655 100644 (file)
@@ -316,10 +316,21 @@ static void radeon_vm_unbind_locked(struct radeon_device *rdev,
        }
 
        /* wait for vm use to end */
-       if (vm->fence) {
-               radeon_fence_wait(vm->fence, false);
-               radeon_fence_unref(&vm->fence);
+       while (vm->fence) {
+               int r;
+               r = radeon_fence_wait(vm->fence, false);
+               if (r)
+                       DRM_ERROR("error while waiting for fence: %d\n", r);
+               if (r == -EDEADLK) {
+                       mutex_unlock(&rdev->vm_manager.lock);
+                       r = radeon_gpu_reset(rdev);
+                       mutex_lock(&rdev->vm_manager.lock);
+                       if (!r)
+                               continue;
+               }
+               break;
        }
+       radeon_fence_unref(&vm->fence);
 
        /* hw unbind */
        rdev->vm_manager.funcs->unbind(rdev, vm);