1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
From b9b3ecb9c11ed76978b1d1d84654ad37f4ff95f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
Date: Wed, 12 Sep 2018 21:19:57 +0200
Subject: [PATCH 0191/2940] drm/ttm: once more fix ttm_bo_bulk_move_lru_tail
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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: Christian König <christian.koenig@amd.com>
Reviewed-and-Tested: Huang Rui <ray.huang@amd.com>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
---
drivers/gpu/drm/ttm/ttm_bo.c | 51 +++++++++++++++++++++---------------
1 file changed, 30 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index b2a7ff5c704d..263d467d0042 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -247,23 +247,18 @@ 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)
+static void ttm_list_move_bulk_tail(struct list_head *list,
+ struct list_head *first,
+ struct list_head *last)
{
- struct list_head *list;
- LIST_HEAD(entries);
- LIST_HEAD(before);
+ first->prev->next = last->next;
+ last->next->prev = first->prev;
- reservation_object_assert_held(pos->last->resv);
- list = is_swap ? &pos->last->swap : &pos->last->lru;
- list_cut_position(&entries, lru, list);
+ list->prev->next = first;
+ first->prev = list->prev;
- 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);
+ last->next = list;
+ list->prev = last;
}
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;
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];
+ ttm_list_move_bulk_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];
+ ttm_list_move_bulk_tail(&man->lru[i], &pos->first->lru,
+ &pos->last->lru);
}
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)
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);
+ ttm_list_move_bulk_tail(lru, &pos->first->swap,
+ &pos->last->swap);
}
}
EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail);
--
2.17.1
|