drm/mm: Fix caching of leftmost node in the interval tree
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 20 Feb 2018 09:37:38 +0000 (09:37 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 20 Feb 2018 16:38:26 +0000 (16:38 +0000)
When we descend the tree to find our slot, if we step to the right, we
are no longer the leftmost node.

Fixes: f808c13fd373 ("lib/interval_tree: fast overlap detection")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Christian König <christian.koenig@amd.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Acked-by: Christian König <christian.koenig@amd.com> for now.
Link: https://patchwork.freedesktop.org/patch/msgid/20180220093738.1461-1-chris@chris-wilson.co.uk
drivers/gpu/drm/drm_mm.c

index 186c4e90cc1cd25e06a19a89da1bf88a7d9e0cf7..a351bd888a6187bf34e45d987b7abc68d1145003 100644 (file)
@@ -180,7 +180,7 @@ static void drm_mm_interval_tree_add_node(struct drm_mm_node *hole_node,
        struct drm_mm *mm = hole_node->mm;
        struct rb_node **link, *rb;
        struct drm_mm_node *parent;
-       bool leftmost = true;
+       bool leftmost;
 
        node->__subtree_last = LAST(node);
 
@@ -201,6 +201,7 @@ static void drm_mm_interval_tree_add_node(struct drm_mm_node *hole_node,
        } else {
                rb = NULL;
                link = &mm->interval_tree.rb_root.rb_node;
+               leftmost = true;
        }
 
        while (*link) {
@@ -208,11 +209,11 @@ static void drm_mm_interval_tree_add_node(struct drm_mm_node *hole_node,
                parent = rb_entry(rb, struct drm_mm_node, rb);
                if (parent->__subtree_last < node->__subtree_last)
                        parent->__subtree_last = node->__subtree_last;
-               if (node->start < parent->start)
+               if (node->start < parent->start) {
                        link = &parent->rb.rb_left;
-               else {
+               else {
                        link = &parent->rb.rb_right;
-                       leftmost = true;
+                       leftmost = false;
                }
        }