aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_mm.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2010-07-02 10:02:14 -0400
committerDave Airlie <airlied@redhat.com>2010-07-06 22:27:53 -0400
commitd1024ce91ff4c2c4ccbf692d204c71cbf215157a (patch)
tree70bef4a1ad212c81020d2deadeb5aaca02df4aa1 /drivers/gpu/drm/drm_mm.c
parentca31efa89ae16c66966b8d5a5df3ae5cbffa61de (diff)
drm: sane naming for drm_mm.c
Yeah, I've kinda noticed that fl_entry is the free stack. Still give it (and the memory node list ml_entry) decent names. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Thomas Hellstrom <thellstrom@vmwgfx.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_mm.c')
-rw-r--r--drivers/gpu/drm/drm_mm.c72
1 files changed, 35 insertions, 37 deletions
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index a5a7a16c4301..d2267ffd2b7a 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -64,8 +64,8 @@ static struct drm_mm_node *drm_mm_kmalloc(struct drm_mm *mm, int atomic)
64 else { 64 else {
65 child = 65 child =
66 list_entry(mm->unused_nodes.next, 66 list_entry(mm->unused_nodes.next,
67 struct drm_mm_node, fl_entry); 67 struct drm_mm_node, free_stack);
68 list_del(&child->fl_entry); 68 list_del(&child->free_stack);
69 --mm->num_unused; 69 --mm->num_unused;
70 } 70 }
71 spin_unlock(&mm->unused_lock); 71 spin_unlock(&mm->unused_lock);
@@ -94,7 +94,7 @@ int drm_mm_pre_get(struct drm_mm *mm)
94 return ret; 94 return ret;
95 } 95 }
96 ++mm->num_unused; 96 ++mm->num_unused;
97 list_add_tail(&node->fl_entry, &mm->unused_nodes); 97 list_add_tail(&node->free_stack, &mm->unused_nodes);
98 } 98 }
99 spin_unlock(&mm->unused_lock); 99 spin_unlock(&mm->unused_lock);
100 return 0; 100 return 0;
@@ -116,8 +116,8 @@ static int drm_mm_create_tail_node(struct drm_mm *mm,
116 child->start = start; 116 child->start = start;
117 child->mm = mm; 117 child->mm = mm;
118 118
119 list_add_tail(&child->ml_entry, &mm->ml_entry); 119 list_add_tail(&child->node_list, &mm->node_list);
120 list_add_tail(&child->fl_entry, &mm->fl_entry); 120 list_add_tail(&child->free_stack, &mm->free_stack);
121 121
122 return 0; 122 return 0;
123} 123}
@@ -132,15 +132,15 @@ static struct drm_mm_node *drm_mm_split_at_start(struct drm_mm_node *parent,
132 if (unlikely(child == NULL)) 132 if (unlikely(child == NULL))
133 return NULL; 133 return NULL;
134 134
135 INIT_LIST_HEAD(&child->fl_entry); 135 INIT_LIST_HEAD(&child->free_stack);
136 136
137 child->free = 0; 137 child->free = 0;
138 child->size = size; 138 child->size = size;
139 child->start = parent->start; 139 child->start = parent->start;
140 child->mm = parent->mm; 140 child->mm = parent->mm;
141 141
142 list_add_tail(&child->ml_entry, &parent->ml_entry); 142 list_add_tail(&child->node_list, &parent->node_list);
143 INIT_LIST_HEAD(&child->fl_entry); 143 INIT_LIST_HEAD(&child->free_stack);
144 144
145 parent->size -= size; 145 parent->size -= size;
146 parent->start += size; 146 parent->start += size;
@@ -168,7 +168,7 @@ struct drm_mm_node *drm_mm_get_block_generic(struct drm_mm_node *node,
168 } 168 }
169 169
170 if (node->size == size) { 170 if (node->size == size) {
171 list_del_init(&node->fl_entry); 171 list_del_init(&node->free_stack);
172 node->free = 0; 172 node->free = 0;
173 } else { 173 } else {
174 node = drm_mm_split_at_start(node, size, atomic); 174 node = drm_mm_split_at_start(node, size, atomic);
@@ -206,7 +206,7 @@ struct drm_mm_node *drm_mm_get_block_range_generic(struct drm_mm_node *node,
206 } 206 }
207 207
208 if (node->size == size) { 208 if (node->size == size) {
209 list_del_init(&node->fl_entry); 209 list_del_init(&node->free_stack);
210 node->free = 0; 210 node->free = 0;
211 } else { 211 } else {
212 node = drm_mm_split_at_start(node, size, atomic); 212 node = drm_mm_split_at_start(node, size, atomic);
@@ -228,8 +228,8 @@ void drm_mm_put_block(struct drm_mm_node *cur)
228{ 228{
229 229
230 struct drm_mm *mm = cur->mm; 230 struct drm_mm *mm = cur->mm;
231 struct list_head *cur_head = &cur->ml_entry; 231 struct list_head *cur_head = &cur->node_list;
232 struct list_head *root_head = &mm->ml_entry; 232 struct list_head *root_head = &mm->node_list;
233 struct drm_mm_node *prev_node = NULL; 233 struct drm_mm_node *prev_node = NULL;
234 struct drm_mm_node *next_node; 234 struct drm_mm_node *next_node;
235 235
@@ -237,7 +237,7 @@ void drm_mm_put_block(struct drm_mm_node *cur)
237 237
238 if (cur_head->prev != root_head) { 238 if (cur_head->prev != root_head) {
239 prev_node = 239 prev_node =
240 list_entry(cur_head->prev, struct drm_mm_node, ml_entry); 240 list_entry(cur_head->prev, struct drm_mm_node, node_list);
241 if (prev_node->free) { 241 if (prev_node->free) {
242 prev_node->size += cur->size; 242 prev_node->size += cur->size;
243 merged = 1; 243 merged = 1;
@@ -245,15 +245,15 @@ void drm_mm_put_block(struct drm_mm_node *cur)
245 } 245 }
246 if (cur_head->next != root_head) { 246 if (cur_head->next != root_head) {
247 next_node = 247 next_node =
248 list_entry(cur_head->next, struct drm_mm_node, ml_entry); 248 list_entry(cur_head->next, struct drm_mm_node, node_list);
249 if (next_node->free) { 249 if (next_node->free) {
250 if (merged) { 250 if (merged) {
251 prev_node->size += next_node->size; 251 prev_node->size += next_node->size;
252 list_del(&next_node->ml_entry); 252 list_del(&next_node->node_list);
253 list_del(&next_node->fl_entry); 253 list_del(&next_node->free_stack);
254 spin_lock(&mm->unused_lock); 254 spin_lock(&mm->unused_lock);
255 if (mm->num_unused < MM_UNUSED_TARGET) { 255 if (mm->num_unused < MM_UNUSED_TARGET) {
256 list_add(&next_node->fl_entry, 256 list_add(&next_node->free_stack,
257 &mm->unused_nodes); 257 &mm->unused_nodes);
258 ++mm->num_unused; 258 ++mm->num_unused;
259 } else 259 } else
@@ -268,12 +268,12 @@ void drm_mm_put_block(struct drm_mm_node *cur)
268 } 268 }
269 if (!merged) { 269 if (!merged) {
270 cur->free = 1; 270 cur->free = 1;
271 list_add(&cur->fl_entry, &mm->fl_entry); 271 list_add(&cur->free_stack, &mm->free_stack);
272 } else { 272 } else {
273 list_del(&cur->ml_entry); 273 list_del(&cur->node_list);
274 spin_lock(&mm->unused_lock); 274 spin_lock(&mm->unused_lock);
275 if (mm->num_unused < MM_UNUSED_TARGET) { 275 if (mm->num_unused < MM_UNUSED_TARGET) {
276 list_add(&cur->fl_entry, &mm->unused_nodes); 276 list_add(&cur->free_stack, &mm->unused_nodes);
277 ++mm->num_unused; 277 ++mm->num_unused;
278 } else 278 } else
279 kfree(cur); 279 kfree(cur);
@@ -287,7 +287,6 @@ struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm,
287 unsigned long size, 287 unsigned long size,
288 unsigned alignment, int best_match) 288 unsigned alignment, int best_match)
289{ 289{
290 const struct list_head *free_stack = &mm->fl_entry;
291 struct drm_mm_node *entry; 290 struct drm_mm_node *entry;
292 struct drm_mm_node *best; 291 struct drm_mm_node *best;
293 unsigned long best_size; 292 unsigned long best_size;
@@ -296,7 +295,7 @@ struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm,
296 best = NULL; 295 best = NULL;
297 best_size = ~0UL; 296 best_size = ~0UL;
298 297
299 list_for_each_entry(entry, free_stack, fl_entry) { 298 list_for_each_entry(entry, &mm->free_stack, free_stack) {
300 wasted = 0; 299 wasted = 0;
301 300
302 if (entry->size < size) 301 if (entry->size < size)
@@ -329,7 +328,6 @@ struct drm_mm_node *drm_mm_search_free_in_range(const struct drm_mm *mm,
329 unsigned long end, 328 unsigned long end,
330 int best_match) 329 int best_match)
331{ 330{
332 const struct list_head *free_stack = &mm->fl_entry;
333 struct drm_mm_node *entry; 331 struct drm_mm_node *entry;
334 struct drm_mm_node *best; 332 struct drm_mm_node *best;
335 unsigned long best_size; 333 unsigned long best_size;
@@ -338,7 +336,7 @@ struct drm_mm_node *drm_mm_search_free_in_range(const struct drm_mm *mm,
338 best = NULL; 336 best = NULL;
339 best_size = ~0UL; 337 best_size = ~0UL;
340 338
341 list_for_each_entry(entry, free_stack, fl_entry) { 339 list_for_each_entry(entry, &mm->free_stack, free_stack) {
342 wasted = 0; 340 wasted = 0;
343 341
344 if (entry->size < size) 342 if (entry->size < size)
@@ -373,7 +371,7 @@ EXPORT_SYMBOL(drm_mm_search_free_in_range);
373 371
374int drm_mm_clean(struct drm_mm * mm) 372int drm_mm_clean(struct drm_mm * mm)
375{ 373{
376 struct list_head *head = &mm->ml_entry; 374 struct list_head *head = &mm->node_list;
377 375
378 return (head->next->next == head); 376 return (head->next->next == head);
379} 377}
@@ -381,8 +379,8 @@ EXPORT_SYMBOL(drm_mm_clean);
381 379
382int drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size) 380int drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size)
383{ 381{
384 INIT_LIST_HEAD(&mm->ml_entry); 382 INIT_LIST_HEAD(&mm->node_list);
385 INIT_LIST_HEAD(&mm->fl_entry); 383 INIT_LIST_HEAD(&mm->free_stack);
386 INIT_LIST_HEAD(&mm->unused_nodes); 384 INIT_LIST_HEAD(&mm->unused_nodes);
387 mm->num_unused = 0; 385 mm->num_unused = 0;
388 spin_lock_init(&mm->unused_lock); 386 spin_lock_init(&mm->unused_lock);
@@ -393,25 +391,25 @@ EXPORT_SYMBOL(drm_mm_init);
393 391
394void drm_mm_takedown(struct drm_mm * mm) 392void drm_mm_takedown(struct drm_mm * mm)
395{ 393{
396 struct list_head *bnode = mm->fl_entry.next; 394 struct list_head *bnode = mm->free_stack.next;
397 struct drm_mm_node *entry; 395 struct drm_mm_node *entry;
398 struct drm_mm_node *next; 396 struct drm_mm_node *next;
399 397
400 entry = list_entry(bnode, struct drm_mm_node, fl_entry); 398 entry = list_entry(bnode, struct drm_mm_node, free_stack);
401 399
402 if (entry->ml_entry.next != &mm->ml_entry || 400 if (entry->node_list.next != &mm->node_list ||
403 entry->fl_entry.next != &mm->fl_entry) { 401 entry->free_stack.next != &mm->free_stack) {
404 DRM_ERROR("Memory manager not clean. Delaying takedown\n"); 402 DRM_ERROR("Memory manager not clean. Delaying takedown\n");
405 return; 403 return;
406 } 404 }
407 405
408 list_del(&entry->fl_entry); 406 list_del(&entry->free_stack);
409 list_del(&entry->ml_entry); 407 list_del(&entry->node_list);
410 kfree(entry); 408 kfree(entry);
411 409
412 spin_lock(&mm->unused_lock); 410 spin_lock(&mm->unused_lock);
413 list_for_each_entry_safe(entry, next, &mm->unused_nodes, fl_entry) { 411 list_for_each_entry_safe(entry, next, &mm->unused_nodes, free_stack) {
414 list_del(&entry->fl_entry); 412 list_del(&entry->free_stack);
415 kfree(entry); 413 kfree(entry);
416 --mm->num_unused; 414 --mm->num_unused;
417 } 415 }
@@ -426,7 +424,7 @@ void drm_mm_debug_table(struct drm_mm *mm, const char *prefix)
426 struct drm_mm_node *entry; 424 struct drm_mm_node *entry;
427 int total_used = 0, total_free = 0, total = 0; 425 int total_used = 0, total_free = 0, total = 0;
428 426
429 list_for_each_entry(entry, &mm->ml_entry, ml_entry) { 427 list_for_each_entry(entry, &mm->node_list, node_list) {
430 printk(KERN_DEBUG "%s 0x%08lx-0x%08lx: %8ld: %s\n", 428 printk(KERN_DEBUG "%s 0x%08lx-0x%08lx: %8ld: %s\n",
431 prefix, entry->start, entry->start + entry->size, 429 prefix, entry->start, entry->start + entry->size,
432 entry->size, entry->free ? "free" : "used"); 430 entry->size, entry->free ? "free" : "used");
@@ -447,7 +445,7 @@ int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm)
447 struct drm_mm_node *entry; 445 struct drm_mm_node *entry;
448 int total_used = 0, total_free = 0, total = 0; 446 int total_used = 0, total_free = 0, total = 0;
449 447
450 list_for_each_entry(entry, &mm->ml_entry, ml_entry) { 448 list_for_each_entry(entry, &mm->node_list, node_list) {
451 seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: %s\n", entry->start, entry->start + entry->size, entry->size, entry->free ? "free" : "used"); 449 seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: %s\n", entry->start, entry->start + entry->size, entry->size, entry->free ? "free" : "used");
452 total += entry->size; 450 total += entry->size;
453 if (entry->free) 451 if (entry->free)