<div dir="ltr">Hi <div><br></div><div>This fixes a boot issue I had on Raven (<a href="https://bugs.freedesktop.org/show_bug.cgi?id=107922">https://bugs.freedesktop.org/show_bug.cgi?id=107922</a>)</div><div><br></div><div>Feel free to add to both patches:</div><div><br></div><div>Tested-by: Mike Lothian <<a href="mailto:mike@fireburn.co.uk">mike@fireburn.co.uk</a>></div><div><br></div><div>Cheers</div><div><br></div><div>Mike</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, 13 Sep 2018 at 12:22 Christian König <<a href="mailto:ckoenig.leichtzumerken@gmail.com">ckoenig.leichtzumerken@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">While cutting the lists we sometimes accidentally added a list_head from<br>
the stack to the LRUs, effectively corrupting the list.<br>
<br>
Remove the list cutting and use explicit list manipulation instead.<br>
<br>
v2: separate out new list_bulk_move_tail helper<br>
<br>
Signed-off-by: Christian König <<a href="mailto:christian.koenig@amd.com" target="_blank">christian.koenig@amd.com</a>><br>
---<br>
 drivers/gpu/drm/ttm/ttm_bo.c | 46 +++++++++++++++++++-------------------------<br>
 1 file changed, 20 insertions(+), 26 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c<br>
index 138c98902033..26b889f86670 100644<br>
--- a/drivers/gpu/drm/ttm/ttm_bo.c<br>
+++ b/drivers/gpu/drm/ttm/ttm_bo.c<br>
@@ -247,47 +247,38 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo,<br>
 }<br>
 EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);<br>
<br>
-static void ttm_bo_bulk_move_helper(struct ttm_lru_bulk_move_pos *pos,<br>
-                                   struct list_head *lru, bool is_swap)<br>
-{<br>
-       struct list_head *list;<br>
-       LIST_HEAD(entries);<br>
-       LIST_HEAD(before);<br>
-<br>
-       reservation_object_assert_held(pos->last->resv);<br>
-       list = is_swap ? &pos->last->swap : &pos->last->lru;<br>
-       list_cut_position(&entries, lru, list);<br>
-<br>
-       reservation_object_assert_held(pos->first->resv);<br>
-       list = is_swap ? pos->first->swap.prev : pos->first->lru.prev;<br>
-       list_cut_position(&before, &entries, list);<br>
-<br>
-       list_splice(&before, lru);<br>
-       list_splice_tail(&entries, lru);<br>
-}<br>
-<br>
 void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)<br>
 {<br>
        unsigned i;<br>
<br>
        for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {<br>
+               struct ttm_lru_bulk_move_pos *pos = &bulk->tt[i];<br>
                struct ttm_mem_type_manager *man;<br>
<br>
-               if (!bulk->tt[i].first)<br>
+               if (!pos->first)<br>
                        continue;<br>
<br>
-               man = &bulk->tt[i].first->bdev->man[TTM_PL_TT];<br>
-               ttm_bo_bulk_move_helper(&bulk->tt[i], &man->lru[i], false);<br>
+               reservation_object_assert_held(pos->first->resv);<br>
+               reservation_object_assert_held(pos->last->resv);<br>
+<br>
+               man = &pos->first->bdev->man[TTM_PL_TT];<br>
+               list_bulk_move_tail(&man->lru[i], &pos->first->lru,<br>
+                                   &pos->last->lru);<br>
        }<br>
<br>
        for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {<br>
+               struct ttm_lru_bulk_move_pos *pos = &bulk->vram[i];<br>
                struct ttm_mem_type_manager *man;<br>
<br>
-               if (!bulk->vram[i].first)<br>
+               if (!pos->first)<br>
                        continue;<br>
<br>
-               man = &bulk->vram[i].first->bdev->man[TTM_PL_VRAM];<br>
-               ttm_bo_bulk_move_helper(&bulk->vram[i], &man->lru[i], false);<br>
+               reservation_object_assert_held(pos->first->resv);<br>
+               reservation_object_assert_held(pos->last->resv);<br>
+<br>
+               man = &pos->first->bdev->man[TTM_PL_VRAM];<br>
+               list_bulk_move_tail(&man->lru[i], &pos->first->lru,<br>
+                                   &pos->last->lru);<br>
        }<br>
<br>
        for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {<br>
@@ -297,8 +288,11 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)<br>
                if (!pos->first)<br>
                        continue;<br>
<br>
+               reservation_object_assert_held(pos->first->resv);<br>
+               reservation_object_assert_held(pos->last->resv);<br>
+<br>
                lru = &pos->first->bdev->glob->swap_lru[i];<br>
-               ttm_bo_bulk_move_helper(&bulk->swap[i], lru, true);<br>
+               list_bulk_move_tail(lru, &pos->first->swap, &pos->last->swap);<br>
        }<br>
 }<br>
 EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail);<br>
-- <br>
2.14.1<br>
<br>
_______________________________________________<br>
dri-devel mailing list<br>
<a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
</blockquote></div>