Commit 83e85d91 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/dma: lookup objects with nvkm_object_search()

Custom code is no longer needed here.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent daad3dfb
...@@ -10,7 +10,6 @@ struct nvkm_client { ...@@ -10,7 +10,6 @@ struct nvkm_client {
struct nvkm_client_notify *notify[16]; struct nvkm_client_notify *notify[16];
struct rb_root objroot; struct rb_root objroot;
struct rb_root dmaroot;
bool super; bool super;
void *data; void *data;
......
...@@ -12,9 +12,6 @@ struct nvkm_dmaobj { ...@@ -12,9 +12,6 @@ struct nvkm_dmaobj {
u32 access; u32 access;
u64 start; u64 start;
u64 limit; u64 limit;
struct rb_node rb;
u64 handle; /*XXX HANDLE MERGE */
}; };
struct nvkm_dma { struct nvkm_dma {
...@@ -22,8 +19,7 @@ struct nvkm_dma { ...@@ -22,8 +19,7 @@ struct nvkm_dma {
struct nvkm_engine engine; struct nvkm_engine engine;
}; };
struct nvkm_dmaobj * struct nvkm_dmaobj *nvkm_dmaobj_search(struct nvkm_client *, u64 object);
nvkm_dma_search(struct nvkm_dma *, struct nvkm_client *, u64 object);
int nv04_dma_new(struct nvkm_device *, int, struct nvkm_dma **); int nv04_dma_new(struct nvkm_device *, int, struct nvkm_dma **);
int nv50_dma_new(struct nvkm_device *, int, struct nvkm_dma **); int nv50_dma_new(struct nvkm_device *, int, struct nvkm_dma **);
......
...@@ -255,6 +255,5 @@ nvkm_client_new(const char *name, u64 device, const char *cfg, ...@@ -255,6 +255,5 @@ nvkm_client_new(const char *name, u64 device, const char *cfg,
client->device = device; client->device = device;
client->debug = nvkm_dbgopt(dbg, "CLIENT"); client->debug = nvkm_dbgopt(dbg, "CLIENT");
client->objroot = RB_ROOT; client->objroot = RB_ROOT;
client->dmaroot = RB_ROOT;
return 0; return 0;
} }
...@@ -137,7 +137,6 @@ nv50_disp_dmac_new_(const struct nv50_disp_dmac_func *func, ...@@ -137,7 +137,6 @@ nv50_disp_dmac_new_(const struct nv50_disp_dmac_func *func,
const struct nvkm_oclass *oclass, const struct nvkm_oclass *oclass,
struct nvkm_object **pobject) struct nvkm_object **pobject)
{ {
struct nvkm_device *device = root->disp->base.engine.subdev.device;
struct nvkm_client *client = oclass->client; struct nvkm_client *client = oclass->client;
struct nvkm_dmaobj *dmaobj; struct nvkm_dmaobj *dmaobj;
struct nv50_disp_dmac *chan; struct nv50_disp_dmac *chan;
...@@ -153,9 +152,9 @@ nv50_disp_dmac_new_(const struct nv50_disp_dmac_func *func, ...@@ -153,9 +152,9 @@ nv50_disp_dmac_new_(const struct nv50_disp_dmac_func *func,
if (ret) if (ret)
return ret; return ret;
dmaobj = nvkm_dma_search(device->dma, client, push); dmaobj = nvkm_dmaobj_search(client, push);
if (!dmaobj) if (IS_ERR(dmaobj))
return -ENOENT; return PTR_ERR(dmaobj);
if (dmaobj->limit - dmaobj->start != 0xfff) if (dmaobj->limit - dmaobj->start != 0xfff)
return -EINVAL; return -EINVAL;
......
...@@ -28,24 +28,6 @@ ...@@ -28,24 +28,6 @@
#include <nvif/class.h> #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 static int
nvkm_dma_oclass_new(struct nvkm_device *device, nvkm_dma_oclass_new(struct nvkm_device *device,
const struct nvkm_oclass *oclass, void *data, u32 size, const struct nvkm_oclass *oclass, void *data, u32 size,
...@@ -53,34 +35,12 @@ nvkm_dma_oclass_new(struct nvkm_device *device, ...@@ -53,34 +35,12 @@ nvkm_dma_oclass_new(struct nvkm_device *device,
{ {
struct nvkm_dma *dma = nvkm_dma(oclass->engine); struct nvkm_dma *dma = nvkm_dma(oclass->engine);
struct nvkm_dmaobj *dmaobj = NULL; 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; int ret;
ret = dma->func->class_new(dma, oclass, data, size, &dmaobj); ret = dma->func->class_new(dma, oclass, data, size, &dmaobj);
if (dmaobj) if (dmaobj)
*pobject = &dmaobj->object; *pobject = &dmaobj->object;
if (ret) return 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;
} }
static const struct nvkm_device_oclass static const struct nvkm_device_oclass
......
...@@ -31,6 +31,19 @@ ...@@ -31,6 +31,19 @@
#include <nvif/cl0002.h> #include <nvif/cl0002.h>
#include <nvif/unpack.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 static int
nvkm_dmaobj_bind(struct nvkm_object *base, struct nvkm_gpuobj *gpuobj, nvkm_dmaobj_bind(struct nvkm_object *base, struct nvkm_gpuobj *gpuobj,
int align, struct nvkm_gpuobj **pgpuobj) int align, struct nvkm_gpuobj **pgpuobj)
...@@ -42,10 +55,7 @@ nvkm_dmaobj_bind(struct nvkm_object *base, struct nvkm_gpuobj *gpuobj, ...@@ -42,10 +55,7 @@ nvkm_dmaobj_bind(struct nvkm_object *base, struct nvkm_gpuobj *gpuobj,
static void * static void *
nvkm_dmaobj_dtor(struct nvkm_object *base) nvkm_dmaobj_dtor(struct nvkm_object *base)
{ {
struct nvkm_dmaobj *dmaobj = nvkm_dmaobj(base); return nvkm_dmaobj(base);
if (!RB_EMPTY_NODE(&dmaobj->rb))
rb_erase(&dmaobj->rb, &dmaobj->object.client->dmaroot);
return dmaobj;
} }
static const struct nvkm_object_func static const struct nvkm_object_func
...@@ -74,7 +84,6 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma, ...@@ -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); nvkm_object_ctor(&nvkm_dmaobj_func, oclass, &dmaobj->object);
dmaobj->func = func; dmaobj->func = func;
dmaobj->dma = dma; dmaobj->dma = dma;
RB_CLEAR_NODE(&dmaobj->rb);
nvif_ioctl(parent, "create dma size %d\n", *psize); nvif_ioctl(parent, "create dma size %d\n", *psize);
if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) { if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
......
...@@ -371,9 +371,9 @@ nvkm_fifo_chan_ctor(const struct nvkm_fifo_chan_func *func, ...@@ -371,9 +371,9 @@ nvkm_fifo_chan_ctor(const struct nvkm_fifo_chan_func *func,
/* allocate push buffer ctxdma instance */ /* allocate push buffer ctxdma instance */
if (push) { if (push) {
dmaobj = nvkm_dma_search(device->dma, oclass->client, push); dmaobj = nvkm_dmaobj_search(client, push);
if (!dmaobj) if (IS_ERR(dmaobj))
return -ENOENT; return PTR_ERR(dmaobj);
ret = nvkm_object_bind(&dmaobj->object, chan->inst, -16, ret = nvkm_object_bind(&dmaobj->object, chan->inst, -16,
&chan->push); &chan->push);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment