drm/ttm: call ttm_bo_wait while inside a reservation
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>
Tue, 21 Jan 2014 12:07:01 +0000 (13:07 +0100)
committerMaarten Lankhorst <maarten.lankhorst@canonical.com>
Mon, 1 Sep 2014 08:16:43 +0000 (10:16 +0200)
This is the last remaining function that doesn't use the reservation
lock completely to fence off access to a buffer.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
drivers/gpu/drm/ttm/ttm_bo.c

index b992ec3c318a2bb7ddb0ca5064d374186cb6bbd6..4f1bc948bda04b507d760a010d3d4180b2f1aca9 100644 (file)
@@ -503,17 +503,6 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo,
                if (ret)
                        return ret;
 
-               /*
-                * remove sync_obj with ttm_bo_wait, the wait should be
-                * finished, and no new wait object should have been added.
-                */
-               spin_lock(&bdev->fence_lock);
-               ret = ttm_bo_wait(bo, false, false, true);
-               WARN_ON(ret);
-               spin_unlock(&bdev->fence_lock);
-               if (ret)
-                       return ret;
-
                spin_lock(&glob->lru_lock);
                ret = __ttm_bo_reserve(bo, false, true, false, NULL);
 
@@ -529,8 +518,16 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo,
                        spin_unlock(&glob->lru_lock);
                        return 0;
                }
-       } else
-               spin_unlock(&bdev->fence_lock);
+
+               /*
+                * remove sync_obj with ttm_bo_wait, the wait should be
+                * finished, and no new wait object should have been added.
+                */
+               spin_lock(&bdev->fence_lock);
+               ret = ttm_bo_wait(bo, false, false, true);
+               WARN_ON(ret);
+       }
+       spin_unlock(&bdev->fence_lock);
 
        if (ret || unlikely(list_empty(&bo->ddestroy))) {
                __ttm_bo_unreserve(bo);
@@ -1524,6 +1521,8 @@ int ttm_bo_wait(struct ttm_buffer_object *bo,
        void *sync_obj;
        int ret = 0;
 
+       lockdep_assert_held(&bo->resv->lock.base);
+
        if (likely(bo->sync_obj == NULL))
                return 0;