From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] drm/ttm: once more fix ttm_bo_bulk_move_lru_tail v2
Date: Thu, 13 Sep 2018 13:22:08 +0200 [thread overview]
Message-ID: <20180913112208.1353-2-christian.koenig@amd.com> (raw)
In-Reply-To: <20180913112208.1353-1-christian.koenig@amd.com>
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.
v2: separate out new list_bulk_move_tail helper
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 46 +++++++++++++++++++-------------------------
1 file changed, 20 insertions(+), 26 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 138c98902033..26b889f86670 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -247,47 +247,38 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo,
}
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 *list;
- LIST_HEAD(entries);
- LIST_HEAD(before);
-
- reservation_object_assert_held(pos->last->resv);
- list = is_swap ? &pos->last->swap : &pos->last->lru;
- list_cut_position(&entries, lru, list);
-
- reservation_object_assert_held(pos->first->resv);
- list = is_swap ? pos->first->swap.prev : pos->first->lru.prev;
- 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)
{
unsigned 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;
- if (!bulk->tt[i].first)
+ if (!pos->first)
continue;
- man = &bulk->tt[i].first->bdev->man[TTM_PL_TT];
- ttm_bo_bulk_move_helper(&bulk->tt[i], &man->lru[i], false);
+ reservation_object_assert_held(pos->first->resv);
+ reservation_object_assert_held(pos->last->resv);
+
+ man = &pos->first->bdev->man[TTM_PL_TT];
+ list_bulk_move_tail(&man->lru[i], &pos->first->lru,
+ &pos->last->lru);
}
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;
- if (!bulk->vram[i].first)
+ if (!pos->first)
continue;
- man = &bulk->vram[i].first->bdev->man[TTM_PL_VRAM];
- ttm_bo_bulk_move_helper(&bulk->vram[i], &man->lru[i], false);
+ reservation_object_assert_held(pos->first->resv);
+ reservation_object_assert_held(pos->last->resv);
+
+ man = &pos->first->bdev->man[TTM_PL_VRAM];
+ list_bulk_move_tail(&man->lru[i], &pos->first->lru,
+ &pos->last->lru);
}
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
@@ -297,8 +288,11 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)
if (!pos->first)
continue;
+ reservation_object_assert_held(pos->first->resv);
+ reservation_object_assert_held(pos->last->resv);
+
lru = &pos->first->bdev->glob->swap_lru[i];
- ttm_bo_bulk_move_helper(&bulk->swap[i], lru, true);
+ list_bulk_move_tail(lru, &pos->first->swap, &pos->last->swap);
}
}
EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail);
--
2.14.1
next prev parent reply other threads:[~2018-09-13 11:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-13 11:22 [PATCH 1/2] list: introduce list_bulk_move_tail helper Christian König
2018-09-13 11:22 ` Christian König [this message]
2018-09-13 15:52 ` [PATCH 2/2] drm/ttm: once more fix ttm_bo_bulk_move_lru_tail v2 Mike Lothian
2018-09-14 2:53 ` [PATCH 1/2] list: introduce list_bulk_move_tail helper Huang Rui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180913112208.1353-2-christian.koenig@amd.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox