aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2016-01-11 09:35:20 -0500
committerAlex Deucher <alexander.deucher@amd.com>2016-01-13 12:21:21 -0500
commitab74961810ba7935b5f9643da10daaa36690f48e (patch)
treee821b843633d9869e7a74c56c1ced05170d01acf
parented704a43e84cc536081423dcd3491acf2791aaeb (diff)
drm/ttm: add ttm_bo_move_to_lru_tail function v2
This allows the drivers to move a BO to the end of the LRU without removing and adding it again. v2: Make it more robust, handle pinned and swapable BOs as well. Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c21
-rw-r--r--include/drm/ttm/ttm_bo_api.h10
2 files changed, 31 insertions, 0 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 3ea9a01c960c..4cbf26555093 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -228,6 +228,27 @@ void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo)
228} 228}
229EXPORT_SYMBOL(ttm_bo_del_sub_from_lru); 229EXPORT_SYMBOL(ttm_bo_del_sub_from_lru);
230 230
231void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
232{
233 struct ttm_bo_device *bdev = bo->bdev;
234 struct ttm_mem_type_manager *man;
235
236 lockdep_assert_held(&bo->resv->lock.base);
237
238 if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) {
239 list_del_init(&bo->swap);
240 list_del_init(&bo->lru);
241
242 } else {
243 if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG))
244 list_move_tail(&bo->swap, &bo->glob->swap_lru);
245
246 man = &bdev->man[bo->mem.mem_type];
247 list_move_tail(&bo->lru, &man->lru);
248 }
249}
250EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
251
231/* 252/*
232 * Call bo->mutex locked. 253 * Call bo->mutex locked.
233 */ 254 */
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index c768ddfbe53c..afae2316bd43 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -383,6 +383,16 @@ extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);
383 */ 383 */
384extern int ttm_bo_del_from_lru(struct ttm_buffer_object *bo); 384extern int ttm_bo_del_from_lru(struct ttm_buffer_object *bo);
385 385
386/**
387 * ttm_bo_move_to_lru_tail
388 *
389 * @bo: The buffer object.
390 *
391 * Move this BO to the tail of all lru lists used to lookup and reserve an
392 * object. This function must be called with struct ttm_bo_global::lru_lock
393 * held, and is used to make a BO less likely to be considered for eviction.
394 */
395extern void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo);
386 396
387/** 397/**
388 * ttm_bo_lock_delayed_workqueue 398 * ttm_bo_lock_delayed_workqueue