Commit 7748e2dc authored by Huang Rui's avatar Huang Rui Committed by Alex Deucher

drm/ttm: add bulk move function on LRU

This function allow us to bulk move a group of BOs to the tail of their LRU.
The positions of group of BOs are stored on the (first, last) bulk_move_pos
structure.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarHuang Rui <ray.huang@amd.com>
Tested-by: default avatarMike Lothian <mike@fireburn.co.uk>
Tested-by: default avatarDieter Nützel <Dieter@nuetzel-hh.de>
Acked-by: default avatarChunming Zhou <david1.zhou@amd.com>
Reviewed-by: default avatarJunwei Zhang <Jerry.Zhang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 9a277952
...@@ -247,6 +247,58 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, ...@@ -247,6 +247,58 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo,
} }
EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
static void ttm_bo_bulk_move_helper(struct ttm_lru_bulk_move_pos *pos,
struct list_head *lru, bool is_swap)
{
struct list_head entries, before;
struct list_head *list1, *list2;
list1 = is_swap ? &pos->last->swap : &pos->last->lru;
list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev;
list_cut_position(&entries, lru, list1);
list_cut_position(&before, &entries, list2);
list_splice(&before, lru);
list_splice_tail(&entries, lru);
}
void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
{
unsigned i;
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
struct ttm_mem_type_manager *man;
if (!bulk->tt[i].first)
continue;
man = &bulk->tt[i].first->bdev->man[TTM_PL_TT];
ttm_bo_bulk_move_helper(&bulk->tt[i], &man->lru[i], false);
}
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
struct ttm_mem_type_manager *man;
if (!bulk->vram[i].first)
continue;
man = &bulk->vram[i].first->bdev->man[TTM_PL_VRAM];
ttm_bo_bulk_move_helper(&bulk->vram[i], &man->lru[i], false);
}
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
struct ttm_lru_bulk_move_pos *pos = &bulk->swap[i];
struct list_head *lru;
if (!pos->first)
continue;
lru = &pos->first->bdev->glob->swap_lru[i];
ttm_bo_bulk_move_helper(&bulk->swap[i], lru, true);
}
}
EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail);
static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
struct ttm_mem_reg *mem, bool evict, struct ttm_mem_reg *mem, bool evict,
struct ttm_operation_ctx *ctx) struct ttm_operation_ctx *ctx)
......
...@@ -416,6 +416,16 @@ void ttm_bo_del_from_lru(struct ttm_buffer_object *bo); ...@@ -416,6 +416,16 @@ void ttm_bo_del_from_lru(struct ttm_buffer_object *bo);
void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo,
struct ttm_lru_bulk_move *bulk); struct ttm_lru_bulk_move *bulk);
/**
* ttm_bo_bulk_move_lru_tail
*
* @bulk: bulk move structure
*
* Bulk move BOs to the LRU tail, only valid to use when driver makes sure that
* BO order never changes. Should be called with ttm_bo_global::lru_lock held.
*/
void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk);
/** /**
* ttm_bo_lock_delayed_workqueue * ttm_bo_lock_delayed_workqueue
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment