diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/debugobjects.c | 9 | ||||
-rw-r--r-- | lib/list_debug.c | 39 | ||||
-rw-r--r-- | lib/nlattr.c | 2 | ||||
-rw-r--r-- | lib/plist.c | 135 | ||||
-rw-r--r-- | lib/swiotlb.c | 6 |
5 files changed, 152 insertions, 39 deletions
diff --git a/lib/debugobjects.c b/lib/debugobjects.c index deebcc57d4e6..9d86e45086f5 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c | |||
@@ -249,14 +249,17 @@ static struct debug_bucket *get_bucket(unsigned long addr) | |||
249 | 249 | ||
250 | static void debug_print_object(struct debug_obj *obj, char *msg) | 250 | static void debug_print_object(struct debug_obj *obj, char *msg) |
251 | { | 251 | { |
252 | struct debug_obj_descr *descr = obj->descr; | ||
252 | static int limit; | 253 | static int limit; |
253 | 254 | ||
254 | if (limit < 5 && obj->descr != descr_test) { | 255 | if (limit < 5 && descr != descr_test) { |
256 | void *hint = descr->debug_hint ? | ||
257 | descr->debug_hint(obj->object) : NULL; | ||
255 | limit++; | 258 | limit++; |
256 | WARN(1, KERN_ERR "ODEBUG: %s %s (active state %u) " | 259 | WARN(1, KERN_ERR "ODEBUG: %s %s (active state %u) " |
257 | "object type: %s\n", | 260 | "object type: %s hint: %pS\n", |
258 | msg, obj_states[obj->state], obj->astate, | 261 | msg, obj_states[obj->state], obj->astate, |
259 | obj->descr->name); | 262 | descr->name, hint); |
260 | } | 263 | } |
261 | debug_objects_warnings++; | 264 | debug_objects_warnings++; |
262 | } | 265 | } |
diff --git a/lib/list_debug.c b/lib/list_debug.c index 344c710d16ca..b8029a5583ff 100644 --- a/lib/list_debug.c +++ b/lib/list_debug.c | |||
@@ -35,6 +35,31 @@ void __list_add(struct list_head *new, | |||
35 | } | 35 | } |
36 | EXPORT_SYMBOL(__list_add); | 36 | EXPORT_SYMBOL(__list_add); |
37 | 37 | ||
38 | void __list_del_entry(struct list_head *entry) | ||
39 | { | ||
40 | struct list_head *prev, *next; | ||
41 | |||
42 | prev = entry->prev; | ||
43 | next = entry->next; | ||
44 | |||
45 | if (WARN(next == LIST_POISON1, | ||
46 | "list_del corruption, %p->next is LIST_POISON1 (%p)\n", | ||
47 | entry, LIST_POISON1) || | ||
48 | WARN(prev == LIST_POISON2, | ||
49 | "list_del corruption, %p->prev is LIST_POISON2 (%p)\n", | ||
50 | entry, LIST_POISON2) || | ||
51 | WARN(prev->next != entry, | ||
52 | "list_del corruption. prev->next should be %p, " | ||
53 | "but was %p\n", entry, prev->next) || | ||
54 | WARN(next->prev != entry, | ||
55 | "list_del corruption. next->prev should be %p, " | ||
56 | "but was %p\n", entry, next->prev)) | ||
57 | return; | ||
58 | |||
59 | __list_del(prev, next); | ||
60 | } | ||
61 | EXPORT_SYMBOL(__list_del_entry); | ||
62 | |||
38 | /** | 63 | /** |
39 | * list_del - deletes entry from list. | 64 | * list_del - deletes entry from list. |
40 | * @entry: the element to delete from the list. | 65 | * @entry: the element to delete from the list. |
@@ -43,19 +68,7 @@ EXPORT_SYMBOL(__list_add); | |||
43 | */ | 68 | */ |
44 | void list_del(struct list_head *entry) | 69 | void list_del(struct list_head *entry) |
45 | { | 70 | { |
46 | WARN(entry->next == LIST_POISON1, | 71 | __list_del_entry(entry); |
47 | "list_del corruption, next is LIST_POISON1 (%p)\n", | ||
48 | LIST_POISON1); | ||
49 | WARN(entry->next != LIST_POISON1 && entry->prev == LIST_POISON2, | ||
50 | "list_del corruption, prev is LIST_POISON2 (%p)\n", | ||
51 | LIST_POISON2); | ||
52 | WARN(entry->prev->next != entry, | ||
53 | "list_del corruption. prev->next should be %p, " | ||
54 | "but was %p\n", entry, entry->prev->next); | ||
55 | WARN(entry->next->prev != entry, | ||
56 | "list_del corruption. next->prev should be %p, " | ||
57 | "but was %p\n", entry, entry->next->prev); | ||
58 | __list_del(entry->prev, entry->next); | ||
59 | entry->next = LIST_POISON1; | 72 | entry->next = LIST_POISON1; |
60 | entry->prev = LIST_POISON2; | 73 | entry->prev = LIST_POISON2; |
61 | } | 74 | } |
diff --git a/lib/nlattr.c b/lib/nlattr.c index 5021cbc34411..ac09f2226dc7 100644 --- a/lib/nlattr.c +++ b/lib/nlattr.c | |||
@@ -148,7 +148,7 @@ nla_policy_len(const struct nla_policy *p, int n) | |||
148 | { | 148 | { |
149 | int i, len = 0; | 149 | int i, len = 0; |
150 | 150 | ||
151 | for (i = 0; i < n; i++) { | 151 | for (i = 0; i < n; i++, p++) { |
152 | if (p->len) | 152 | if (p->len) |
153 | len += nla_total_size(p->len); | 153 | len += nla_total_size(p->len); |
154 | else if (nla_attr_minlen[p->type]) | 154 | else if (nla_attr_minlen[p->type]) |
diff --git a/lib/plist.c b/lib/plist.c index 1471988d9190..0ae7e6431726 100644 --- a/lib/plist.c +++ b/lib/plist.c | |||
@@ -28,6 +28,8 @@ | |||
28 | 28 | ||
29 | #ifdef CONFIG_DEBUG_PI_LIST | 29 | #ifdef CONFIG_DEBUG_PI_LIST |
30 | 30 | ||
31 | static struct plist_head test_head; | ||
32 | |||
31 | static void plist_check_prev_next(struct list_head *t, struct list_head *p, | 33 | static void plist_check_prev_next(struct list_head *t, struct list_head *p, |
32 | struct list_head *n) | 34 | struct list_head *n) |
33 | { | 35 | { |
@@ -54,12 +56,13 @@ static void plist_check_list(struct list_head *top) | |||
54 | 56 | ||
55 | static void plist_check_head(struct plist_head *head) | 57 | static void plist_check_head(struct plist_head *head) |
56 | { | 58 | { |
57 | WARN_ON(!head->rawlock && !head->spinlock); | 59 | WARN_ON(head != &test_head && !head->rawlock && !head->spinlock); |
58 | if (head->rawlock) | 60 | if (head->rawlock) |
59 | WARN_ON_SMP(!raw_spin_is_locked(head->rawlock)); | 61 | WARN_ON_SMP(!raw_spin_is_locked(head->rawlock)); |
60 | if (head->spinlock) | 62 | if (head->spinlock) |
61 | WARN_ON_SMP(!spin_is_locked(head->spinlock)); | 63 | WARN_ON_SMP(!spin_is_locked(head->spinlock)); |
62 | plist_check_list(&head->prio_list); | 64 | if (!plist_head_empty(head)) |
65 | plist_check_list(&plist_first(head)->prio_list); | ||
63 | plist_check_list(&head->node_list); | 66 | plist_check_list(&head->node_list); |
64 | } | 67 | } |
65 | 68 | ||
@@ -75,25 +78,33 @@ static void plist_check_head(struct plist_head *head) | |||
75 | */ | 78 | */ |
76 | void plist_add(struct plist_node *node, struct plist_head *head) | 79 | void plist_add(struct plist_node *node, struct plist_head *head) |
77 | { | 80 | { |
78 | struct plist_node *iter; | 81 | struct plist_node *first, *iter, *prev = NULL; |
82 | struct list_head *node_next = &head->node_list; | ||
79 | 83 | ||
80 | plist_check_head(head); | 84 | plist_check_head(head); |
81 | WARN_ON(!plist_node_empty(node)); | 85 | WARN_ON(!plist_node_empty(node)); |
86 | WARN_ON(!list_empty(&node->prio_list)); | ||
87 | |||
88 | if (plist_head_empty(head)) | ||
89 | goto ins_node; | ||
82 | 90 | ||
83 | list_for_each_entry(iter, &head->prio_list, plist.prio_list) { | 91 | first = iter = plist_first(head); |
84 | if (node->prio < iter->prio) | 92 | |
85 | goto lt_prio; | 93 | do { |
86 | else if (node->prio == iter->prio) { | 94 | if (node->prio < iter->prio) { |
87 | iter = list_entry(iter->plist.prio_list.next, | 95 | node_next = &iter->node_list; |
88 | struct plist_node, plist.prio_list); | 96 | break; |
89 | goto eq_prio; | ||
90 | } | 97 | } |
91 | } | ||
92 | 98 | ||
93 | lt_prio: | 99 | prev = iter; |
94 | list_add_tail(&node->plist.prio_list, &iter->plist.prio_list); | 100 | iter = list_entry(iter->prio_list.next, |
95 | eq_prio: | 101 | struct plist_node, prio_list); |
96 | list_add_tail(&node->plist.node_list, &iter->plist.node_list); | 102 | } while (iter != first); |
103 | |||
104 | if (!prev || prev->prio != node->prio) | ||
105 | list_add_tail(&node->prio_list, &iter->prio_list); | ||
106 | ins_node: | ||
107 | list_add_tail(&node->node_list, node_next); | ||
97 | 108 | ||
98 | plist_check_head(head); | 109 | plist_check_head(head); |
99 | } | 110 | } |
@@ -108,14 +119,98 @@ void plist_del(struct plist_node *node, struct plist_head *head) | |||
108 | { | 119 | { |
109 | plist_check_head(head); | 120 | plist_check_head(head); |
110 | 121 | ||
111 | if (!list_empty(&node->plist.prio_list)) { | 122 | if (!list_empty(&node->prio_list)) { |
112 | struct plist_node *next = plist_first(&node->plist); | 123 | if (node->node_list.next != &head->node_list) { |
124 | struct plist_node *next; | ||
125 | |||
126 | next = list_entry(node->node_list.next, | ||
127 | struct plist_node, node_list); | ||
113 | 128 | ||
114 | list_move_tail(&next->plist.prio_list, &node->plist.prio_list); | 129 | /* add the next plist_node into prio_list */ |
115 | list_del_init(&node->plist.prio_list); | 130 | if (list_empty(&next->prio_list)) |
131 | list_add(&next->prio_list, &node->prio_list); | ||
132 | } | ||
133 | list_del_init(&node->prio_list); | ||
116 | } | 134 | } |
117 | 135 | ||
118 | list_del_init(&node->plist.node_list); | 136 | list_del_init(&node->node_list); |
119 | 137 | ||
120 | plist_check_head(head); | 138 | plist_check_head(head); |
121 | } | 139 | } |
140 | |||
141 | #ifdef CONFIG_DEBUG_PI_LIST | ||
142 | #include <linux/sched.h> | ||
143 | #include <linux/module.h> | ||
144 | #include <linux/init.h> | ||
145 | |||
146 | static struct plist_node __initdata test_node[241]; | ||
147 | |||
148 | static void __init plist_test_check(int nr_expect) | ||
149 | { | ||
150 | struct plist_node *first, *prio_pos, *node_pos; | ||
151 | |||
152 | if (plist_head_empty(&test_head)) { | ||
153 | BUG_ON(nr_expect != 0); | ||
154 | return; | ||
155 | } | ||
156 | |||
157 | prio_pos = first = plist_first(&test_head); | ||
158 | plist_for_each(node_pos, &test_head) { | ||
159 | if (nr_expect-- < 0) | ||
160 | break; | ||
161 | if (node_pos == first) | ||
162 | continue; | ||
163 | if (node_pos->prio == prio_pos->prio) { | ||
164 | BUG_ON(!list_empty(&node_pos->prio_list)); | ||
165 | continue; | ||
166 | } | ||
167 | |||
168 | BUG_ON(prio_pos->prio > node_pos->prio); | ||
169 | BUG_ON(prio_pos->prio_list.next != &node_pos->prio_list); | ||
170 | prio_pos = node_pos; | ||
171 | } | ||
172 | |||
173 | BUG_ON(nr_expect != 0); | ||
174 | BUG_ON(prio_pos->prio_list.next != &first->prio_list); | ||
175 | } | ||
176 | |||
177 | static int __init plist_test(void) | ||
178 | { | ||
179 | int nr_expect = 0, i, loop; | ||
180 | unsigned int r = local_clock(); | ||
181 | |||
182 | printk(KERN_INFO "start plist test\n"); | ||
183 | plist_head_init(&test_head, NULL); | ||
184 | for (i = 0; i < ARRAY_SIZE(test_node); i++) | ||
185 | plist_node_init(test_node + i, 0); | ||
186 | |||
187 | for (loop = 0; loop < 1000; loop++) { | ||
188 | r = r * 193939 % 47629; | ||
189 | i = r % ARRAY_SIZE(test_node); | ||
190 | if (plist_node_empty(test_node + i)) { | ||
191 | r = r * 193939 % 47629; | ||
192 | test_node[i].prio = r % 99; | ||
193 | plist_add(test_node + i, &test_head); | ||
194 | nr_expect++; | ||
195 | } else { | ||
196 | plist_del(test_node + i, &test_head); | ||
197 | nr_expect--; | ||
198 | } | ||
199 | plist_test_check(nr_expect); | ||
200 | } | ||
201 | |||
202 | for (i = 0; i < ARRAY_SIZE(test_node); i++) { | ||
203 | if (plist_node_empty(test_node + i)) | ||
204 | continue; | ||
205 | plist_del(test_node + i, &test_head); | ||
206 | nr_expect--; | ||
207 | plist_test_check(nr_expect); | ||
208 | } | ||
209 | |||
210 | printk(KERN_INFO "end plist test\n"); | ||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | module_init(plist_test); | ||
215 | |||
216 | #endif | ||
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index c47bbe11b804..93ca08b8a451 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -686,8 +686,10 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page, | |||
686 | /* | 686 | /* |
687 | * Ensure that the address returned is DMA'ble | 687 | * Ensure that the address returned is DMA'ble |
688 | */ | 688 | */ |
689 | if (!dma_capable(dev, dev_addr, size)) | 689 | if (!dma_capable(dev, dev_addr, size)) { |
690 | panic("map_single: bounce buffer is not DMA'ble"); | 690 | swiotlb_tbl_unmap_single(dev, map, size, dir); |
691 | dev_addr = swiotlb_virt_to_bus(dev, io_tlb_overflow_buffer); | ||
692 | } | ||
691 | 693 | ||
692 | return dev_addr; | 694 | return dev_addr; |
693 | } | 695 | } |