[PATCH 5/7] drm/ttm: move needs_unlock into the walk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Not a walk parameter but important to have that status around.

Signed-off-by: Christian König <christian.koenig@xxxxxxx>
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 26 ++++++++++++--------------
 drivers/gpu/drm/ttm/ttm_bo_util.h |  2 ++
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 03e28e3d0d03..7a4bc7e9950b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -772,15 +772,14 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo)
 }
 
 static bool ttm_lru_walk_trylock(struct ttm_lru_walk *walk,
-				 struct ttm_buffer_object *bo,
-				 bool *needs_unlock)
+				 struct ttm_buffer_object *bo)
 {
 	struct ttm_operation_ctx *ctx = walk->ctx;
 
-	*needs_unlock = false;
+	walk->needs_unlock = false;
 
 	if (dma_resv_trylock(bo->base.resv)) {
-		*needs_unlock = true;
+		walk->needs_unlock = true;
 		return true;
 	}
 
@@ -793,8 +792,7 @@ static bool ttm_lru_walk_trylock(struct ttm_lru_walk *walk,
 }
 
 static int ttm_lru_walk_ticketlock(struct ttm_lru_walk *walk,
-				   struct ttm_buffer_object *bo,
-				   bool *needs_unlock)
+				   struct ttm_buffer_object *bo)
 {
 	struct dma_resv *resv = bo->base.resv;
 	int ret;
@@ -805,7 +803,7 @@ static int ttm_lru_walk_ticketlock(struct ttm_lru_walk *walk,
 		ret = dma_resv_lock(resv, walk->ticket);
 
 	if (!ret) {
-		*needs_unlock = true;
+		walk->needs_unlock = true;
 		/*
 		 * Only a single ticketlock per loop. Ticketlocks are prone
 		 * to return -EDEADLK causing the eviction to fail, so
@@ -821,9 +819,10 @@ static int ttm_lru_walk_ticketlock(struct ttm_lru_walk *walk,
 	return ret;
 }
 
-static void ttm_lru_walk_unlock(struct ttm_buffer_object *bo, bool locked)
+static void ttm_lru_walk_unlock(struct ttm_lru_walk *walk,
+				struct ttm_buffer_object *bo)
 {
-	if (locked)
+	if (walk->needs_unlock)
 		dma_resv_unlock(bo->base.resv);
 }
 
@@ -869,7 +868,6 @@ s64 ttm_lru_walk_for_evict(struct ttm_lru_walk *walk, struct ttm_device *bdev,
 	spin_lock(&bdev->lru_lock);
 	ttm_resource_manager_for_each_res(man, &cursor, res) {
 		struct ttm_buffer_object *bo = res->bo;
-		bool bo_needs_unlock = false;
 		bool bo_locked = false;
 		int mem_type;
 
@@ -878,14 +876,14 @@ s64 ttm_lru_walk_for_evict(struct ttm_lru_walk *walk, struct ttm_device *bdev,
 		 * since if we do it the other way around, and the trylock fails,
 		 * we need to drop the lru lock to put the bo.
 		 */
-		if (ttm_lru_walk_trylock(walk, bo, &bo_needs_unlock))
+		if (ttm_lru_walk_trylock(walk, bo))
 			bo_locked = true;
 		else if (!walk->ticket || walk->ctx->no_wait_gpu ||
 			 walk->trylock_only)
 			continue;
 
 		if (!ttm_bo_get_unless_zero(bo)) {
-			ttm_lru_walk_unlock(bo, bo_needs_unlock);
+			ttm_lru_walk_unlock(walk, bo);
 			continue;
 		}
 
@@ -894,7 +892,7 @@ s64 ttm_lru_walk_for_evict(struct ttm_lru_walk *walk, struct ttm_device *bdev,
 
 		lret = 0;
 		if (!bo_locked)
-			lret = ttm_lru_walk_ticketlock(walk, bo, &bo_needs_unlock);
+			lret = ttm_lru_walk_ticketlock(walk, bo);
 
 		/*
 		 * Note that in between the release of the lru lock and the
@@ -906,7 +904,7 @@ s64 ttm_lru_walk_for_evict(struct ttm_lru_walk *walk, struct ttm_device *bdev,
 		if (!lret && bo->resource && bo->resource->mem_type == mem_type)
 			lret = walk->ops->process_bo(walk, bo);
 
-		ttm_lru_walk_unlock(bo, bo_needs_unlock);
+		ttm_lru_walk_unlock(walk, bo);
 		ttm_bo_put(bo);
 		if (lret == -EBUSY || lret == -EALREADY)
 			lret = 0;
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.h b/drivers/gpu/drm/ttm/ttm_bo_util.h
index c19b50809208..c653e16ccb76 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.h
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.h
@@ -59,6 +59,8 @@ struct ttm_lru_walk {
 	struct ww_acquire_ctx *ticket;
 	/** @tryock_only: Only use trylock for locking. */
 	bool trylock_only;
+	/** @needs_unlock: If the current BO needs unlocking */
+	bool needs_unlock;
 };
 
 s64 ttm_lru_walk_for_evict(struct ttm_lru_walk *walk, struct ttm_device *bdev,
-- 
2.34.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux