Module Name: src Committed By: riastradh Date: Sun Dec 19 01:35:25 UTC 2021
Modified Files: src/sys/external/bsd/drm2/dist/drm/i915: i915_vma.c Log Message: Port rbtree initialization. (TODO: lookups and insertion.) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/drm2/dist/drm/i915/i915_vma.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_vma.c diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_vma.c:1.3 src/sys/external/bsd/drm2/dist/drm/i915/i915_vma.c:1.4 --- src/sys/external/bsd/drm2/dist/drm/i915/i915_vma.c:1.3 Sun Dec 19 01:24:26 2021 +++ src/sys/external/bsd/drm2/dist/drm/i915/i915_vma.c Sun Dec 19 01:35:25 2021 @@ -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 @@ int i915_vma_move_to_active(struct i915_ 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;