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/nouveau Use our rbtree, which...



details:   https://anonhg.NetBSD.org/src/rev/6849f3c0c8a3
branches:  trunk
changeset: 366023:6849f3c0c8a3
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 07:36:07 2018 +0000

description:
Use our rbtree, which conveniently has find/insert/remove operations.

diffstat:

 sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/client.h                     |   9 +-
 sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/object.h                     |   3 +-
 sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/engine/dma.h                      |   3 +-
 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_client.c           |  64 +++++++++-
 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_object.c           |   8 +-
 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/dma/nouveau_nvkm_engine_dma_base.c |  53 +++++++-
 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/dma/nouveau_nvkm_engine_dma_user.c |  13 +-
 7 files changed, 142 insertions(+), 11 deletions(-)

diffs (truncated from 373 to 300 lines):

diff -r 87663e745376 -r 6849f3c0c8a3 sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/client.h
--- a/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/client.h Mon Aug 27 07:35:56 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/client.h Mon Aug 27 07:36:07 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: client.h,v 1.3 2018/08/27 07:35:22 riastradh Exp $     */
+/*     $NetBSD: client.h,v 1.4 2018/08/27 07:36:07 riastradh Exp $     */
 
 #ifndef __NVKM_CLIENT_H__
 #define __NVKM_CLIENT_H__
@@ -11,8 +11,13 @@
        u32 debug;
 
        struct nvkm_client_notify *notify[16];
+#ifdef __NetBSD__
+       struct rb_tree objtree;
+       struct rb_tree dmatree;
+#else
        struct rb_root objroot;
        struct rb_root dmaroot;
+#endif
 
        bool super;
        void *data;
@@ -21,6 +26,8 @@
        struct nvkm_vm *vm;
 };
 
+extern const rb_tree_ops_t nvkm_client_dmatree_ops;
+
 bool nvkm_client_insert(struct nvkm_client *, struct nvkm_object *);
 void nvkm_client_remove(struct nvkm_client *, struct nvkm_object *);
 struct nvkm_object *nvkm_client_search(struct nvkm_client *, u64 object);
diff -r 87663e745376 -r 6849f3c0c8a3 sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/object.h
--- a/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/object.h Mon Aug 27 07:35:56 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/object.h Mon Aug 27 07:36:07 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: object.h,v 1.3 2018/08/27 07:35:56 riastradh Exp $     */
+/*     $NetBSD: object.h,v 1.4 2018/08/27 07:36:07 riastradh Exp $     */
 
 #ifndef __NVKM_OBJECT_H__
 #define __NVKM_OBJECT_H__
@@ -21,6 +21,7 @@
        u64 token;
        u64 object;
        struct rb_node node;
+       bool on_tree;
 };
 
 struct nvkm_object_func {
diff -r 87663e745376 -r 6849f3c0c8a3 sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/engine/dma.h
--- a/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/engine/dma.h  Mon Aug 27 07:35:56 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/engine/dma.h  Mon Aug 27 07:36:07 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dma.h,v 1.2 2018/08/27 04:58:30 riastradh Exp $        */
+/*     $NetBSD: dma.h,v 1.3 2018/08/27 07:36:07 riastradh Exp $        */
 
 #ifndef __NVKM_DMA_H__
 #define __NVKM_DMA_H__
@@ -16,6 +16,7 @@
        u64 limit;
 
        struct rb_node rb;
+       bool on_tree;
        u64 handle; /*XXX HANDLE MERGE */
 };
 
diff -r 87663e745376 -r 6849f3c0c8a3 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_client.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_client.c       Mon Aug 27 07:35:56 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_client.c       Mon Aug 27 07:36:07 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_nvkm_core_client.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $   */
+/*     $NetBSD: nouveau_nvkm_core_client.c,v 1.3 2018/08/27 07:36:07 riastradh Exp $   */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -24,7 +24,7 @@
  * Authors: Ben Skeggs
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_client.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_client.c,v 1.3 2018/08/27 07:36:07 riastradh Exp $");
 
 #include <core/client.h>
 #include <core/device.h>
@@ -213,13 +213,29 @@
 void
 nvkm_client_remove(struct nvkm_client *client, struct nvkm_object *object)
 {
+#ifdef __NetBSD__
+       if (object->on_tree) {
+               rb_tree_remove_node(&client->objtree, object);
+               object->on_tree = false;
+       }
+#else
        if (!RB_EMPTY_NODE(&object->node))
                rb_erase(&object->node, &client->objroot);
+#endif
 }
 
 bool
 nvkm_client_insert(struct nvkm_client *client, struct nvkm_object *object)
 {
+#ifdef __NetBSD__
+       struct nvkm_object *collision;
+
+       collision = rb_tree_insert_node(&client->objtree, object);
+       if (collision != object)
+               return false;
+       object->on_tree = true;
+       return true;
+#else
        struct rb_node **ptr = &client->objroot.rb_node;
        struct rb_node *parent = NULL;
 
@@ -239,11 +255,15 @@
        rb_link_node(&object->node, parent, ptr);
        rb_insert_color(&object->node, &client->objroot);
        return true;
+#endif
 }
 
 struct nvkm_object *
 nvkm_client_search(struct nvkm_client *client, u64 handle)
 {
+#ifdef __NetBSD__
+       return rb_tree_find_node(&client->objtree, &handle);
+#else
        struct rb_node *node = client->objroot.rb_node;
        while (node) {
                struct nvkm_object *object =
@@ -257,6 +277,7 @@
                        return object;
        }
        return NULL;
+#endif
 }
 
 int
@@ -292,6 +313,40 @@
        }
 }
 
+#ifdef __NetBSD__
+static int
+compare_object_nodes(void *cookie, const void *va, const void *vb)
+{
+       const struct nvkm_object *oa = va;
+       const struct nvkm_object *ob = vb;
+
+       if (oa->object < ob->object)
+               return -1;
+       if (oa->object > ob->object)
+               return +1;
+       return 0;
+}
+
+static int
+compare_object_key(void *cookie, const void *vo, const void *vk)
+{
+       const struct nvkm_object *o = vo;
+       const u64 *k = vk;
+
+       if (o->object < *k)
+               return -1;
+       if (o->object > *k)
+               return +1;
+       return 0;
+}
+
+static const rb_tree_ops_t nvkm_client_objtree_ops = {
+       .rbto_compare_nodes = compare_object_nodes,
+       .rbto_compare_key = compare_object_key,
+       .rbto_node_offset = offsetof(struct nvkm_object, node),
+};
+#endif
+
 int
 nvkm_client_new(const char *name, u64 device, const char *cfg,
                const char *dbg, struct nvkm_client **pclient)
@@ -307,7 +362,12 @@
        snprintf(client->name, sizeof(client->name), "%s", name);
        client->device = device;
        client->debug = nvkm_dbgopt(dbg, "CLIENT");
+#ifdef __NetBSD__
+       rb_tree_init(&client->objtree, &nvkm_client_objtree_ops);
+       rb_tree_init(&client->dmatree, &nvkm_client_dmatree_ops);
+#else
        client->objroot = RB_ROOT;
        client->dmaroot = RB_ROOT;
+#endif
        return 0;
 }
diff -r 87663e745376 -r 6849f3c0c8a3 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_object.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_object.c       Mon Aug 27 07:35:56 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_object.c       Mon Aug 27 07:36:07 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_nvkm_core_object.c,v 1.3 2018/08/27 07:35:56 riastradh Exp $   */
+/*     $NetBSD: nouveau_nvkm_core_object.c,v 1.4 2018/08/27 07:36:07 riastradh Exp $   */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -24,7 +24,7 @@
  * Authors: Ben Skeggs
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_object.c,v 1.3 2018/08/27 07:35:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_object.c,v 1.4 2018/08/27 07:36:07 riastradh Exp $");
 
 #include <core/object.h>
 #include <core/client.h>
@@ -238,7 +238,11 @@
        object->handle = oclass->handle;
        INIT_LIST_HEAD(&object->head);
        INIT_LIST_HEAD(&object->tree);
+#ifdef __NetBSD__
+       object->on_tree = false;
+#else
        RB_CLEAR_NODE(&object->node);
+#endif
        WARN_ON(oclass->engine && !object->engine);
 }
 
diff -r 87663e745376 -r 6849f3c0c8a3 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/dma/nouveau_nvkm_engine_dma_base.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/dma/nouveau_nvkm_engine_dma_base.c     Mon Aug 27 07:35:56 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/dma/nouveau_nvkm_engine_dma_base.c     Mon Aug 27 07:36:07 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_nvkm_engine_dma_base.c,v 1.2 2018/08/27 04:58:31 riastradh Exp $       */
+/*     $NetBSD: nouveau_nvkm_engine_dma_base.c,v 1.3 2018/08/27 07:36:07 riastradh Exp $       */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -24,7 +24,7 @@
  * Authors: Ben Skeggs
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_dma_base.c,v 1.2 2018/08/27 04:58:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_dma_base.c,v 1.3 2018/08/27 07:36:07 riastradh Exp $");
 
 #include "priv.h"
 
@@ -33,9 +33,46 @@
 
 #include <nvif/class.h>
 
+#ifdef __NetBSD__
+static int
+compare_dmaobj_nodes(void *cookie, const void *va, const void *vb)
+{
+       const struct nvkm_dmaobj *da = va;
+       const struct nvkm_dmaobj *db = vb;
+
+       if (da->handle < db->handle)
+               return -1;
+       if (da->handle > db->handle)
+               return +1;
+       return 0;
+}
+
+static int
+compare_dmaobj_key(void *cookie, const void *vo, const void *vk)
+{
+       const struct nvkm_dmaobj *d = vo;
+       const u64 *k = vk;
+
+       if (d->handle < *k)
+               return -1;
+       if (d->handle > *k)
+               return +1;
+       return 0;
+}
+
+const rb_tree_ops_t nvkm_client_dmatree_ops = {
+       .rbto_compare_nodes = compare_dmaobj_nodes,
+       .rbto_compare_key = compare_dmaobj_key,
+       .rbto_node_offset = offsetof(struct nvkm_dmaobj, rb),
+};
+#endif
+
 struct nvkm_dmaobj *
 nvkm_dma_search(struct nvkm_dma *dma, struct nvkm_client *client, u64 object)
 {
+#ifdef __NetBSD__
+       return rb_tree_find_node(&client->dmatree, &object);
+#else
        struct rb_node *node = client->dmaroot.rb_node;
        while (node) {
                struct nvkm_dmaobj *dmaobj =
@@ -49,6 +86,7 @@
                        return dmaobj;
        }
        return NULL;
+#endif
 }
 
 static int
@@ -59,8 +97,12 @@
        struct nvkm_dma *dma = nvkm_dma(oclass->engine);
        struct nvkm_dmaobj *dmaobj = NULL;
        struct nvkm_client *client = oclass->client;
+#ifdef __NetBSD__



Home | Main Index | Thread Index | Old Index