@@ -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;
@@ -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,
Not a walk parameter but important to have that status around. Signed-off-by: Christian König <christian.koenig@amd.com> --- 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(-)