diff options
author | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2006-12-21 10:32:13 +0100 |
---|---|---|
committer | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2006-12-21 10:43:46 +0100 |
commit | a467d248293f9384092ab39a9214fbf725d21927 (patch) | |
tree | dbe3d7a3ee407ac76ee167f7319f78dd944e9613 | |
parent | b7586ab539e5f8d16b473543ab829d0a4441f87c (diff) |
Fix buggy aligned allocations.
-rw-r--r-- | linux-core/drm_mm.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/linux-core/drm_mm.c b/linux-core/drm_mm.c index 0e544470..5889ee4d 100644 --- a/linux-core/drm_mm.c +++ b/linux-core/drm_mm.c @@ -148,7 +148,7 @@ drm_mm_node_t *drm_mm_get_block(drm_mm_node_t * parent, unsigned tmp = 0; if (alignment) - tmp = size % alignment; + tmp = parent->start % alignment; if (tmp) { align_splitoff = drm_mm_split_at_start(parent, alignment - tmp); @@ -162,12 +162,8 @@ drm_mm_node_t *drm_mm_get_block(drm_mm_node_t * parent, return parent; } else { child = drm_mm_split_at_start(parent, size); - if (!child) { - if (align_splitoff) - drm_mm_put_block(align_splitoff); - return NULL; - } } + if (align_splitoff) drm_mm_put_block(align_splitoff); @@ -240,8 +236,11 @@ drm_mm_node_t *drm_mm_search_free(const drm_mm_t * mm, entry = list_entry(list, drm_mm_node_t, fl_entry); wasted = 0; + if (entry->size < size) + continue; + if (alignment) { - register unsigned tmp = size % alignment; + register unsigned tmp = entry->start % alignment; if (tmp) wasted += alignment - tmp; } |