]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/nouveau/dma: lookup objects with nvkm_object_search()
authorBen Skeggs <bskeggs@redhat.com>
Tue, 17 May 2016 09:40:29 +0000 (19:40 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 17 Feb 2017 05:14:57 +0000 (15:14 +1000)
Custom code is no longer needed here.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/core/client.h
drivers/gpu/drm/nouveau/include/nvkm/engine/dma.h
drivers/gpu/drm/nouveau/nvkm/core/client.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/dmacnv50.c
drivers/gpu/drm/nouveau/nvkm/engine/dma/base.c
drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/chan.c

index 361ad8cee02ce084dfc6a3e12d2f654388661353..f5861ab4ecff44919df26da47fe1e0692f77e957 100644 (file)
@@ -10,7 +10,6 @@ struct nvkm_client {
 
        struct nvkm_client_notify *notify[16];
        struct rb_root objroot;
-       struct rb_root dmaroot;
 
        bool super;
        void *data;
index 114bfb737a8123c321a2d240f132a759c0054a4b..d2a6532ce3b990226daac5b5672d4a11f5ff2889 100644 (file)
@@ -12,9 +12,6 @@ struct nvkm_dmaobj {
        u32 access;
        u64 start;
        u64 limit;
-
-       struct rb_node rb;
-       u64 handle; /*XXX HANDLE MERGE */
 };
 
 struct nvkm_dma {
@@ -22,8 +19,7 @@ struct nvkm_dma {
        struct nvkm_engine engine;
 };
 
-struct nvkm_dmaobj *
-nvkm_dma_search(struct nvkm_dma *, struct nvkm_client *, u64 object);
+struct nvkm_dmaobj *nvkm_dmaobj_search(struct nvkm_client *, u64 object);
 
 int nv04_dma_new(struct nvkm_device *, int, struct nvkm_dma **);
 int nv50_dma_new(struct nvkm_device *, int, struct nvkm_dma **);
index 0c2fdf14201ef46516c67409028ab31415f44024..8087b253845c105ee77a8a3f62c470c61437c24f 100644 (file)
@@ -255,6 +255,5 @@ nvkm_client_new(const char *name, u64 device, const char *cfg,
        client->device = device;
        client->debug = nvkm_dbgopt(dbg, "CLIENT");
        client->objroot = RB_ROOT;
-       client->dmaroot = RB_ROOT;
        return 0;
 }
index 0a1381a84552dced96167738295512f36cf8ddb1..070ec5e18fdb43797069ce275d7e35fb0905bc4e 100644 (file)
@@ -137,7 +137,6 @@ nv50_disp_dmac_new_(const struct nv50_disp_dmac_func *func,
                    const struct nvkm_oclass *oclass,
                    struct nvkm_object **pobject)
 {
-       struct nvkm_device *device = root->disp->base.engine.subdev.device;
        struct nvkm_client *client = oclass->client;
        struct nvkm_dmaobj *dmaobj;
        struct nv50_disp_dmac *chan;
@@ -153,9 +152,9 @@ nv50_disp_dmac_new_(const struct nv50_disp_dmac_func *func,
        if (ret)
                return ret;
 
-       dmaobj = nvkm_dma_search(device->dma, client, push);
-       if (!dmaobj)
-               return -ENOENT;
+       dmaobj = nvkm_dmaobj_search(client, push);
+       if (IS_ERR(dmaobj))
+               return PTR_ERR(dmaobj);
 
        if (dmaobj->limit - dmaobj->start != 0xfff)
                return -EINVAL;
index 4655d1750b9518135882e7de79111b3cd3a9f16e..11b7b8fd5ddaf356b5a9bee8dbde507c70cf92ac 100644 (file)
 
 #include <nvif/class.h>
 
-struct nvkm_dmaobj *
-nvkm_dma_search(struct nvkm_dma *dma, struct nvkm_client *client, u64 object)
-{
-       struct rb_node *node = client->dmaroot.rb_node;
-       while (node) {
-               struct nvkm_dmaobj *dmaobj =
-                       rb_entry(node, typeof(*dmaobj), rb);
-               if (object < dmaobj->handle)
-                       node = node->rb_left;
-               else
-               if (object > dmaobj->handle)
-                       node = node->rb_right;
-               else
-                       return dmaobj;
-       }
-       return NULL;
-}
-
 static int
 nvkm_dma_oclass_new(struct nvkm_device *device,
                    const struct nvkm_oclass *oclass, void *data, u32 size,
@@ -53,34 +35,12 @@ nvkm_dma_oclass_new(struct nvkm_device *device,
 {
        struct nvkm_dma *dma = nvkm_dma(oclass->engine);
        struct nvkm_dmaobj *dmaobj = NULL;
-       struct nvkm_client *client = oclass->client;
-       struct rb_node **ptr = &client->dmaroot.rb_node;
-       struct rb_node *parent = NULL;
        int ret;
 
        ret = dma->func->class_new(dma, oclass, data, size, &dmaobj);
        if (dmaobj)
                *pobject = &dmaobj->object;
-       if (ret)
-               return ret;
-
-       dmaobj->handle = oclass->object;
-
-       while (*ptr) {
-               struct nvkm_dmaobj *obj = rb_entry(*ptr, typeof(*obj), rb);
-               parent = *ptr;
-               if (dmaobj->handle < obj->handle)
-                       ptr = &parent->rb_left;
-               else
-               if (dmaobj->handle > obj->handle)
-                       ptr = &parent->rb_right;
-               else
-                       return -EEXIST;
-       }
-
-       rb_link_node(&dmaobj->rb, parent, ptr);
-       rb_insert_color(&dmaobj->rb, &client->dmaroot);
-       return 0;
+       return ret;
 }
 
 static const struct nvkm_device_oclass
index 13c661b1ef14e13e3123addb65b0d6a99be9211c..d20cc0681a8844f1e150df1b72f045a5b14976cd 100644 (file)
 #include <nvif/cl0002.h>
 #include <nvif/unpack.h>
 
+static const struct nvkm_object_func nvkm_dmaobj_func;
+struct nvkm_dmaobj *
+nvkm_dmaobj_search(struct nvkm_client *client, u64 handle)
+{
+       struct nvkm_object *object;
+
+       object = nvkm_object_search(client, handle, &nvkm_dmaobj_func);
+       if (IS_ERR(object))
+               return (void *)object;
+
+       return nvkm_dmaobj(object);
+}
+
 static int
 nvkm_dmaobj_bind(struct nvkm_object *base, struct nvkm_gpuobj *gpuobj,
                 int align, struct nvkm_gpuobj **pgpuobj)
@@ -42,10 +55,7 @@ nvkm_dmaobj_bind(struct nvkm_object *base, struct nvkm_gpuobj *gpuobj,
 static void *
 nvkm_dmaobj_dtor(struct nvkm_object *base)
 {
-       struct nvkm_dmaobj *dmaobj = nvkm_dmaobj(base);
-       if (!RB_EMPTY_NODE(&dmaobj->rb))
-               rb_erase(&dmaobj->rb, &dmaobj->object.client->dmaroot);
-       return dmaobj;
+       return nvkm_dmaobj(base);
 }
 
 static const struct nvkm_object_func
@@ -74,7 +84,6 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma,
        nvkm_object_ctor(&nvkm_dmaobj_func, oclass, &dmaobj->object);
        dmaobj->func = func;
        dmaobj->dma = dma;
-       RB_CLEAR_NODE(&dmaobj->rb);
 
        nvif_ioctl(parent, "create dma size %d\n", *psize);
        if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
index dc6d4678f22850ac72d1b2db8c5558b5e7270b10..3b87e09e31efff9d68c138e25e116e75171f036b 100644 (file)
@@ -371,9 +371,9 @@ nvkm_fifo_chan_ctor(const struct nvkm_fifo_chan_func *func,
 
        /* allocate push buffer ctxdma instance */
        if (push) {
-               dmaobj = nvkm_dma_search(device->dma, oclass->client, push);
-               if (!dmaobj)
-                       return -ENOENT;
+               dmaobj = nvkm_dmaobj_search(client, push);
+               if (IS_ERR(dmaobj))
+                       return PTR_ERR(dmaobj);
 
                ret = nvkm_object_bind(&dmaobj->object, chan->inst, -16,
                                       &chan->push);