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/i915 Port rbtree initializati...



details:   https://anonhg.NetBSD.org/src/rev/0c32b5018ff9
branches:  trunk
changeset: 1028008:0c32b5018ff9
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 01:35:25 2021 +0000

description:
Port rbtree initialization. (TODO: lookups and insertion.)

diffstat:

 sys/external/bsd/drm2/dist/drm/i915/i915_vma.c |  38 ++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 2 deletions(-)

diffs (59 lines):

diff -r 6e8cfd7f0a9b -r 0c32b5018ff9 sys/external/bsd/drm2/dist/drm/i915/i915_vma.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_vma.c    Sun Dec 19 01:35:18 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_vma.c    Sun Dec 19 01:35:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_vma.c,v 1.3 2021/12/19 01:24:26 riastradh Exp $   */
+/*     $NetBSD: i915_vma.c,v 1.4 2021/12/19 01:35:25 riastradh Exp $   */
 
 /*
  * Copyright © 2016 Intel Corporation
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_vma.c,v 1.3 2021/12/19 01:24:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_vma.c,v 1.4 2021/12/19 01:35:25 riastradh Exp $");
 
 #include <linux/sched/mm.h>
 #include <drm/drm_gem.h>
@@ -1199,6 +1199,40 @@
        return 0;
 }
 
+#ifdef __NetBSD__
+static int
+compare_active(void *cookie, const void *va, const void *vb)
+{
+       const struct i915_vma_active *a = va;
+       const struct i915_vma_active *b = vb;
+
+       if (a->timeline < b->timeline)
+               return -1;
+       if (a->timeline > b->timeline)
+               return +1;
+       return 0;
+}
+
+static int
+compare_active_key(void *cookie, const void *vn, const void *vk)
+{
+       const struct i915_vma_active *a = vn;
+       const uint64_t *k = vk;
+
+       if (a->timeline < *k)
+               return -1;
+       if (a->timeline > *k)
+               return +1;
+       return 0;
+}
+
+static const rb_tree_ops_t vma_active_rb_ops = {
+       .rbto_compare_nodes = compare_active,
+       .rbto_compare_key = compare_active_key,
+       .rbto_node_offset = offsetof(struct i915_vma_active, node),
+};
+#endif
+
 int __i915_vma_unbind(struct i915_vma *vma)
 {
        int ret;



Home | Main Index | Thread Index | Old Index