Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7040138f authored by Maarten Lankhorst's avatar Maarten Lankhorst
Browse files

drm/ttm: call ttm_bo_wait while inside a reservation



This is the last remaining function that doesn't use the reservation
lock completely to fence off access to a buffer.

Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@canonical.com>
parent bdaf7ddf
Loading
Loading
Loading
Loading
+12 −13
Original line number Diff line number Diff line
@@ -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,7 +518,15 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo,
			spin_unlock(&glob->lru_lock);
			return 0;
		}
	} else

		/*
		 * 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))) {
@@ -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;