Commit 2546db0e authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/fifo: index base engctx by engine id

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent 64f7c698
......@@ -7,6 +7,7 @@
struct nvkm_fault_data;
#define NVKM_FIFO_CHID_NR 4096
#define NVKM_FIFO_ENGN_NR 16
struct nvkm_fifo_engn {
struct nvkm_object *object;
......@@ -29,7 +30,7 @@ struct nvkm_fifo_chan {
u64 addr;
u32 size;
struct nvkm_fifo_engn engn[NVKM_SUBDEV_NR];
struct nvkm_fifo_engn engn[NVKM_FIFO_ENGN_NR];
};
struct nvkm_fifo {
......
......@@ -35,6 +35,15 @@ struct nvkm_fifo_chan_object {
int hash;
};
static struct nvkm_fifo_engn *
nvkm_fifo_chan_engn(struct nvkm_fifo_chan *chan, struct nvkm_engine *engine)
{
int engi = chan->fifo->func->engine_id(chan->fifo, engine);
if (engi >= 0)
return &chan->engn[engi];
return NULL;
}
static int
nvkm_fifo_chan_child_fini(struct nvkm_oproxy *base, bool suspend)
{
......@@ -42,7 +51,7 @@ nvkm_fifo_chan_child_fini(struct nvkm_oproxy *base, bool suspend)
container_of(base, typeof(*object), oproxy);
struct nvkm_engine *engine = object->oproxy.object->engine;
struct nvkm_fifo_chan *chan = object->chan;
struct nvkm_fifo_engn *engn = &chan->engn[engine->subdev.index];
struct nvkm_fifo_engn *engn = nvkm_fifo_chan_engn(chan, engine);
const char *name = engine->subdev.name;
int ret = 0;
......@@ -75,7 +84,7 @@ nvkm_fifo_chan_child_init(struct nvkm_oproxy *base)
container_of(base, typeof(*object), oproxy);
struct nvkm_engine *engine = object->oproxy.object->engine;
struct nvkm_fifo_chan *chan = object->chan;
struct nvkm_fifo_engn *engn = &chan->engn[engine->subdev.index];
struct nvkm_fifo_engn *engn = nvkm_fifo_chan_engn(chan, engine);
const char *name = engine->subdev.name;
int ret;
......@@ -108,7 +117,7 @@ nvkm_fifo_chan_child_del(struct nvkm_oproxy *base)
container_of(base, typeof(*object), oproxy);
struct nvkm_engine *engine = object->oproxy.base.engine;
struct nvkm_fifo_chan *chan = object->chan;
struct nvkm_fifo_engn *engn = &chan->engn[engine->subdev.index];
struct nvkm_fifo_engn *engn = nvkm_fifo_chan_engn(chan, engine);
if (chan->func->object_dtor)
chan->func->object_dtor(chan, object->hash);
......@@ -135,7 +144,7 @@ nvkm_fifo_chan_child_new(const struct nvkm_oclass *oclass, void *data, u32 size,
{
struct nvkm_engine *engine = oclass->engine;
struct nvkm_fifo_chan *chan = nvkm_fifo_chan(oclass->parent);
struct nvkm_fifo_engn *engn = &chan->engn[engine->subdev.index];
struct nvkm_fifo_engn *engn = nvkm_fifo_chan_engn(chan, engine);
struct nvkm_fifo_chan_object *object;
int ret = 0;
......
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