Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/dist/drm drm/mm: Assert invariant of r...



details:   https://anonhg.NetBSD.org/src/rev/9bdce9e99f03
branches:  trunk
changeset: 361567:9bdce9e99f03
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Feb 14 13:02:31 2022 +0000

description:
drm/mm: Assert invariant of rb lookup.

Just to make sure I didn't get the sense of the lookup reversed,
which is quite likely, because I've done it probably more than once
in this code before...

diffstat:

 sys/external/bsd/drm2/dist/drm/drm_mm.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (32 lines):

diff -r 6197cdf7ff42 -r 9bdce9e99f03 sys/external/bsd/drm2/dist/drm/drm_mm.c
--- a/sys/external/bsd/drm2/dist/drm/drm_mm.c   Mon Feb 14 09:25:39 2022 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_mm.c   Mon Feb 14 13:02:31 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_mm.c,v 1.14 2021/12/19 11:51:32 riastradh Exp $    */
+/*     $NetBSD: drm_mm.c,v 1.15 2022/02/14 13:02:31 riastradh Exp $    */
 
 /**************************************************************************
  *
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_mm.c,v 1.14 2021/12/19 11:51:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_mm.c,v 1.15 2022/02/14 13:02:31 riastradh Exp $");
 
 #include <linux/export.h>
 #include <linux/interval_tree_generic.h>
@@ -401,7 +401,12 @@
 static struct drm_mm_node *best_hole(struct drm_mm *mm, u64 size)
 {
 #ifdef __NetBSD__
-       return rb_tree_find_node_leq(&mm->holes_size.rb_root.rbr_tree, &size);
+       struct drm_mm_node *best;
+
+       best = rb_tree_find_node_leq(&mm->holes_size.rb_root.rbr_tree, &size);
+       KASSERT(best == NULL || size <= best->hole_size);
+
+       return best;
 #else
        struct rb_node *rb = mm->holes_size.rb_root.rb_node;
        struct drm_mm_node *best = NULL;



Home | Main Index | Thread Index | Old Index