]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
drm/ttm: add ttm_bo_move_to_lru_tail function v2
authorChristian König <christian.koenig@amd.com>
Mon, 11 Jan 2016 14:35:20 +0000 (15:35 +0100)
committerTim Gardner <tim.gardner@canonical.com>
Wed, 6 Apr 2016 09:25:44 +0000 (10:25 +0100)
BugLink: http://bugs.launchpad.net/bugs/1546572
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>
(cherry picked from commit ab74961810ba7935b5f9643da10daaa36690f48e)
Signed-off-by: Alberto Milone <alberto.milone@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/gpu/drm/ttm/ttm_bo.c
include/drm/ttm/ttm_bo_api.h

index 3ea9a01c960cfcb327a8917ce0594dc04645d238..4cbf26555093f3d13ed8c917a34bf7e0302bdb8b 100644 (file)
@@ -228,6 +228,27 @@ void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo)
 }
 EXPORT_SYMBOL(ttm_bo_del_sub_from_lru);
 
+void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
+{
+       struct ttm_bo_device *bdev = bo->bdev;
+       struct ttm_mem_type_manager *man;
+
+       lockdep_assert_held(&bo->resv->lock.base);
+
+       if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) {
+               list_del_init(&bo->swap);
+               list_del_init(&bo->lru);
+
+       } else {
+               if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG))
+                       list_move_tail(&bo->swap, &bo->glob->swap_lru);
+
+               man = &bdev->man[bo->mem.mem_type];
+               list_move_tail(&bo->lru, &man->lru);
+       }
+}
+EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
+
 /*
  * Call bo->mutex locked.
  */
index c768ddfbe53ccbbfeedd92809a9d4036adfc1fe2..afae2316bd434e0067f5007f4467c3b0e3f54bb9 100644 (file)
@@ -383,6 +383,16 @@ extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);
  */
 extern int ttm_bo_del_from_lru(struct ttm_buffer_object *bo);
 
+/**
+ * ttm_bo_move_to_lru_tail
+ *
+ * @bo: The buffer object.
+ *
+ * Move this BO to the tail of all lru lists used to lookup and reserve an
+ * object. This function must be called with struct ttm_bo_global::lru_lock
+ * held, and is used to make a BO less likely to be considered for eviction.
+ */
+extern void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo);
 
 /**
  * ttm_bo_lock_delayed_workqueue