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

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
This commit is contained in:
Ben Skeggs 2021-02-06 19:27:08 +10:00
parent 64f7c698be
commit 2546db0e0f
2 changed files with 15 additions and 5 deletions

View File

@ -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 {

View File

@ -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;