Commit 03651735 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/ttm: once more fix ttm_bo_bulk_move_lru_tail

While cutting the lists we sometimes accidentally added a list_head from
the stack to the LRUs, effectively corrupting the list.

Remove the list cutting and use explicit list manipulation instead.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-and-Tested: Huang Rui <ray.huang@amd.com>
Tested-by: default avatarMike Lothian <mike@fireburn.co.uk>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c37e2d29
...@@ -247,23 +247,18 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, ...@@ -247,23 +247,18 @@ 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, static void ttm_list_move_bulk_tail(struct list_head *list,
struct list_head *lru, bool is_swap) struct list_head *first,
struct list_head *last)
{ {
struct list_head *list; first->prev->next = last->next;
LIST_HEAD(entries); last->next->prev = first->prev;
LIST_HEAD(before);
reservation_object_assert_held(pos->last->resv); list->prev->next = first;
list = is_swap ? &pos->last->swap : &pos->last->lru; first->prev = list->prev;
list_cut_position(&entries, lru, list);
reservation_object_assert_held(pos->first->resv); last->next = list;
list = is_swap ? pos->first->swap.prev : pos->first->lru.prev; list->prev = last;
list_cut_position(&before, &entries, list);
list_splice(&before, lru);
list_splice_tail(&entries, lru);
} }
void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
...@@ -271,23 +266,33 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) ...@@ -271,23 +266,33 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
unsigned i; unsigned i;
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
struct ttm_lru_bulk_move_pos *pos = &bulk->tt[i];
struct ttm_mem_type_manager *man; struct ttm_mem_type_manager *man;
if (!bulk->tt[i].first) if (!pos->first)
continue; continue;
man = &bulk->tt[i].first->bdev->man[TTM_PL_TT]; reservation_object_assert_held(pos->first->resv);
ttm_bo_bulk_move_helper(&bulk->tt[i], &man->lru[i], false); reservation_object_assert_held(pos->last->resv);
man = &pos->first->bdev->man[TTM_PL_TT];
ttm_list_move_bulk_tail(&man->lru[i], &pos->first->lru,
&pos->last->lru);
} }
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
struct ttm_lru_bulk_move_pos *pos = &bulk->vram[i];
struct ttm_mem_type_manager *man; struct ttm_mem_type_manager *man;
if (!bulk->vram[i].first) if (!pos->first)
continue; continue;
man = &bulk->vram[i].first->bdev->man[TTM_PL_VRAM]; reservation_object_assert_held(pos->first->resv);
ttm_bo_bulk_move_helper(&bulk->vram[i], &man->lru[i], false); reservation_object_assert_held(pos->last->resv);
man = &pos->first->bdev->man[TTM_PL_VRAM];
ttm_list_move_bulk_tail(&man->lru[i], &pos->first->lru,
&pos->last->lru);
} }
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
...@@ -297,8 +302,12 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) ...@@ -297,8 +302,12 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
if (!pos->first) if (!pos->first)
continue; continue;
reservation_object_assert_held(pos->first->resv);
reservation_object_assert_held(pos->last->resv);
lru = &pos->first->bdev->glob->swap_lru[i]; lru = &pos->first->bdev->glob->swap_lru[i];
ttm_bo_bulk_move_helper(&bulk->swap[i], lru, true); ttm_list_move_bulk_tail(lru, &pos->first->swap,
&pos->last->swap);
} }
} }
EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail); EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail);
......
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