[PATCH 08/11] drm/ttm: put new BOs immediately on the LRU

Christian König ckoenig.leichtzumerken at gmail.com
Tue May 14 12:31:24 UTC 2019


This way they are available for eviction immediately.

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 233bfb86068b..a301c876ae31 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1390,21 +1390,18 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
 		WARN_ON(!locked);
 	}
 
-	if (likely(!ret))
+	if (likely(!ret)) {
+		spin_lock(&bdev->glob->lru_lock);
+		ttm_bo_add_to_lru(bo);
+		spin_unlock(&bdev->glob->lru_lock);
 		ret = ttm_bo_validate(bo, placement, ctx);
+	}
 
 	if (unlikely(ret)) {
 		if (!resv)
 			ttm_bo_unreserve(bo);
 
 		ttm_bo_put(bo);
-		return ret;
-	}
-
-	if (resv && !(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
-		spin_lock(&bdev->glob->lru_lock);
-		ttm_bo_add_to_lru(bo);
-		spin_unlock(&bdev->glob->lru_lock);
 	}
 
 	return ret;
-- 
2.17.1



More information about the amd-gfx mailing list