drm/mm: fix logic for selection of best fit block
authorBob Gleitsmann <rjgleits@bellsouth.net>
Mon, 21 Dec 2009 03:52:09 +0000 (13:52 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 23 Dec 2009 00:08:08 +0000 (10:08 +1000)
This is from bug 25728.

[airlied: I'm just forwarding the patch for review, Thomas, ickle?]

Acked-by: Jerome Glisse <jglisse@redhat.com>
Acked-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_mm.c

index d7d7eac3ddd264c1104027fae06f6b48c57fedfb..cdec32977129b98bf00179f01e919dc297fcf333 100644 (file)
@@ -358,7 +358,7 @@ struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm,
                if (entry->size >= size + wasted) {
                        if (!best_match)
                                return entry;
-                       if (size < best_size) {
+                       if (entry->size < best_size) {
                                best = entry;
                                best_size = entry->size;
                        }
@@ -408,7 +408,7 @@ struct drm_mm_node *drm_mm_search_free_in_range(const struct drm_mm *mm,
                if (entry->size >= size + wasted) {
                        if (!best_match)
                                return entry;
-                       if (size < best_size) {
+                       if (entry->size < best_size) {
                                best = entry;
                                best_size = entry->size;
                        }