drm/nouveau/fifo: use runlist engine info to lookup engine classes
authorBen Skeggs <bskeggs@redhat.com>
Wed, 1 Jun 2022 10:47:26 +0000 (20:47 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 9 Nov 2022 00:44:47 +0000 (10:44 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
22 files changed:
drivers/gpu/drm/nouveau/include/nvkm/engine/fifo.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/chan.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/g84.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/g98.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk110.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk208.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk20a.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm107.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm200.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gp100.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gv100.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/nv04.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/nv10.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/nv17.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/nv40.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/nv50.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/nv50.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/priv.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/tu102.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c

index 62fe64dab11a28e6fc1ed23dbfcfca4db7c90627..446d058f558a2b1e9c8353ef174fb248f5b2527e 100644 (file)
@@ -22,7 +22,6 @@ struct nvkm_chan {
        union { int id; int chid; }; /*FIXME: remove later */
 
        struct nvkm_fifo *fifo;
-       u32 engm;
        struct nvkm_object object;
 
        struct list_head head;
index e2178a8f78a7f5e85a9896f668359fd279fa7cc3..5fabf73730796110094bcae9129994c8d9141273 100644 (file)
@@ -216,50 +216,6 @@ nvkm_fifo_chan_child_new(const struct nvkm_oclass *oclass, void *data, u32 size,
        return 0;
 }
 
-static int
-nvkm_fifo_chan_child_get(struct nvkm_object *object, int index,
-                        struct nvkm_oclass *oclass)
-{
-       struct nvkm_fifo_chan *chan = nvkm_fifo_chan(object);
-       struct nvkm_fifo *fifo = chan->fifo;
-       struct nvkm_engine *engine;
-       u32 engm = chan->engm;
-       int engi, ret, c;
-
-       for (; c = 0, engi = __ffs(engm), engm; engm &= ~(1ULL << engi)) {
-               if (!(engine = fifo->func->id_engine(fifo, engi)))
-                       continue;
-               oclass->engine = engine;
-               oclass->base.oclass = 0;
-
-               if (engine->func->fifo.sclass) {
-                       ret = engine->func->fifo.sclass(oclass, index);
-                       if (oclass->base.oclass) {
-                               if (!oclass->base.ctor)
-                                       oclass->base.ctor = nvkm_object_new;
-                               oclass->ctor = nvkm_fifo_chan_child_new;
-                               return 0;
-                       }
-
-                       index -= ret;
-                       continue;
-               }
-
-               while (engine->func->sclass[c].oclass) {
-                       if (c++ == index) {
-                               oclass->base = engine->func->sclass[index];
-                               if (!oclass->base.ctor)
-                                       oclass->base.ctor = nvkm_object_new;
-                               oclass->ctor = nvkm_fifo_chan_child_new;
-                               return 0;
-                       }
-               }
-               index -= c;
-       }
-
-       return -EINVAL;
-}
-
 static int
 nvkm_fifo_chan_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
 {
@@ -355,7 +311,6 @@ nvkm_fifo_chan_func = {
        .init = nvkm_fifo_chan_init,
        .fini = nvkm_fifo_chan_fini,
        .map = nvkm_fifo_chan_map,
-       .sclass = nvkm_fifo_chan_child_get,
        .uevent = nvkm_fifo_chan_uevent,
 };
 
@@ -407,7 +362,6 @@ nvkm_fifo_chan_ctor(const struct nvkm_fifo_chan_func *fn,
 
        nvkm_object_ctor(&nvkm_fifo_chan_func, oclass, &chan->object);
        chan->fifo = fifo;
-       chan->engm = engm;
        INIT_LIST_HEAD(&chan->head);
 
        /* Join channel group.
index 3d242350fdee480ca8a280074581eea6976f1346..122929b7d74fe6a0bfc2853fb6a4b7de7db67412 100644 (file)
@@ -51,52 +51,6 @@ g84_fifo_uevent_init(struct nvkm_fifo *fifo)
        nvkm_mask(device, 0x002140, 0x40000000, 0x40000000);
 }
 
-struct nvkm_engine *
-g84_fifo_id_engine(struct nvkm_fifo *fifo, int engi)
-{
-       struct nvkm_device *device = fifo->engine.subdev.device;
-       struct nvkm_engine *engine;
-       enum nvkm_subdev_type type;
-
-       switch (engi) {
-       case G84_FIFO_ENGN_SW    : type = NVKM_ENGINE_SW; break;
-       case G84_FIFO_ENGN_GR    : type = NVKM_ENGINE_GR; break;
-       case G84_FIFO_ENGN_MPEG  :
-               if ((engine = nvkm_device_engine(device, NVKM_ENGINE_MSPPP, 0)))
-                       return engine;
-               type = NVKM_ENGINE_MPEG;
-               break;
-       case G84_FIFO_ENGN_ME    :
-               if ((engine = nvkm_device_engine(device, NVKM_ENGINE_CE, 0)))
-                       return engine;
-               type = NVKM_ENGINE_ME;
-               break;
-       case G84_FIFO_ENGN_VP    :
-               if ((engine = nvkm_device_engine(device, NVKM_ENGINE_MSPDEC, 0)))
-                       return engine;
-               type = NVKM_ENGINE_VP;
-               break;
-       case G84_FIFO_ENGN_CIPHER:
-               if ((engine = nvkm_device_engine(device, NVKM_ENGINE_VIC, 0)))
-                       return engine;
-               if ((engine = nvkm_device_engine(device, NVKM_ENGINE_SEC, 0)))
-                       return engine;
-               type = NVKM_ENGINE_CIPHER;
-               break;
-       case G84_FIFO_ENGN_BSP   :
-               if ((engine = nvkm_device_engine(device, NVKM_ENGINE_MSVLD, 0)))
-                       return engine;
-               type = NVKM_ENGINE_BSP;
-               break;
-       case G84_FIFO_ENGN_DMA   : type = NVKM_ENGINE_DMAOBJ; break;
-       default:
-               WARN_ON(1);
-               return NULL;
-       }
-
-       return nvkm_device_engine(fifo->engine.subdev.device, type, 0);
-}
-
 int
 g84_fifo_engine_id(struct nvkm_fifo *base, struct nvkm_engine *engine)
 {
@@ -149,7 +103,6 @@ g84_fifo = {
        .init = nv50_fifo_init,
        .intr = nv04_fifo_intr,
        .engine_id = g84_fifo_engine_id,
-       .id_engine = g84_fifo_id_engine,
        .pause = nv04_fifo_pause,
        .start = nv04_fifo_start,
        .uevent_init = g84_fifo_uevent_init,
index 39177ec0eca649921d527400473e86564abef960..118a773412fc2054f8275b76484389601d476832 100644 (file)
@@ -57,7 +57,6 @@ g98_fifo = {
        .init = nv50_fifo_init,
        .intr = nv04_fifo_intr,
        .engine_id = g84_fifo_engine_id,
-       .id_engine = g84_fifo_id_engine,
        .pause = nv04_fifo_pause,
        .start = nv04_fifo_start,
        .uevent_init = g84_fifo_uevent_init,
index 43cce02151d7831dcaa8e160f226ee72b6066e00..3d169f3ef5123421f9eddfe371024cdd18c97781 100644 (file)
@@ -741,7 +741,6 @@ gf100_fifo = {
        .intr = gf100_fifo_intr,
        .mmu_fault = &gf100_fifo_mmu_fault,
        .engine_id = gf100_fifo_engine_id,
-       .id_engine = gf100_fifo_id_engine,
        .uevent_init = gf100_fifo_uevent_init,
        .uevent_fini = gf100_fifo_uevent_fini,
        .runl = &gf100_runl,
index b41481c984d105a5079492fddc3762bd61122354..9d66aafc2dd3de04b350f6be4a45cdd4be8e6147 100644 (file)
@@ -303,15 +303,6 @@ gk104_fifo_pbdma = {
        .init = gk104_fifo_pbdma_init,
 };
 
-struct nvkm_engine *
-gk104_fifo_id_engine(struct nvkm_fifo *base, int engi)
-{
-       if (engi == GK104_FIFO_ENGN_SW)
-               return nvkm_device_engine(base->engine.subdev.device, NVKM_ENGINE_SW, 0);
-
-       return gk104_fifo(base)->engine[engi].engine;
-}
-
 int
 gk104_fifo_engine_id(struct nvkm_fifo *base, struct nvkm_engine *engine)
 {
@@ -1185,7 +1176,6 @@ gk104_fifo = {
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
        .engine_id = gk104_fifo_engine_id,
-       .id_engine = gk104_fifo_id_engine,
        .uevent_init = gk104_fifo_uevent_init,
        .uevent_fini = gk104_fifo_uevent_fini,
        .recover_chan = gk104_fifo_recover_chan,
index 64bdd3fd3ae66dcdc7666b2546d8b77a399a1de8..ed3aa170d429e08b7eae68a64c4ec0e41a2d4c27 100644 (file)
@@ -93,7 +93,6 @@ gk110_fifo = {
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
        .engine_id = gk104_fifo_engine_id,
-       .id_engine = gk104_fifo_id_engine,
        .uevent_init = gk104_fifo_uevent_init,
        .uevent_fini = gk104_fifo_uevent_fini,
        .recover_chan = gk104_fifo_recover_chan,
index 3e074a976c44073292d8e05253e9658a031a3ce6..7219dc92f4512400ba410ed0d8842cab69ac0977 100644 (file)
@@ -72,7 +72,6 @@ gk208_fifo = {
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
        .engine_id = gk104_fifo_engine_id,
-       .id_engine = gk104_fifo_id_engine,
        .uevent_init = gk104_fifo_uevent_init,
        .uevent_fini = gk104_fifo_uevent_fini,
        .recover_chan = gk104_fifo_recover_chan,
index a494dacad37e0d7c9ac40f2dbcab4cde2b43ece7..9dfa93d914e00850efed1305b6122a03311e8ecc 100644 (file)
@@ -43,7 +43,6 @@ gk20a_fifo = {
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
        .engine_id = gk104_fifo_engine_id,
-       .id_engine = gk104_fifo_id_engine,
        .uevent_init = gk104_fifo_uevent_init,
        .uevent_fini = gk104_fifo_uevent_fini,
        .recover_chan = gk104_fifo_recover_chan,
index c4a6972ee473e90d4f103dc5e5d74a2393a8a1d9..4b67fe1ed81a20b6b2bda47fee29c51b2d9f5b4d 100644 (file)
@@ -133,7 +133,6 @@ gm107_fifo = {
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
        .engine_id = gk104_fifo_engine_id,
-       .id_engine = gk104_fifo_id_engine,
        .uevent_init = gk104_fifo_uevent_init,
        .uevent_fini = gk104_fifo_uevent_fini,
        .recover_chan = gk104_fifo_recover_chan,
index bc9893c4d297b1e71ff61270db6ccef4f95d0f32..5c81f8b8d6c000d9f3e510d3279769248e930fa3 100644 (file)
@@ -63,7 +63,6 @@ gm200_fifo = {
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
        .engine_id = gk104_fifo_engine_id,
-       .id_engine = gk104_fifo_id_engine,
        .uevent_init = gk104_fifo_uevent_init,
        .uevent_fini = gk104_fifo_uevent_fini,
        .recover_chan = gk104_fifo_recover_chan,
index 4ac4afbf3147d284316e4a6637cc11560309f30d..d90ba4170d989f0e182bdedd52bcc2f04c05c76e 100644 (file)
@@ -105,7 +105,6 @@ gp100_fifo = {
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
        .engine_id = gk104_fifo_engine_id,
-       .id_engine = gk104_fifo_id_engine,
        .uevent_init = gk104_fifo_uevent_init,
        .uevent_fini = gk104_fifo_uevent_fini,
        .recover_chan = gk104_fifo_recover_chan,
index e1069c672438cef8c9de741f1f69a3472294e1c7..c2b32688cbd1e09b643b1f3b6ff416f7ad3d93fe 100644 (file)
@@ -332,7 +332,6 @@ gv100_fifo = {
        .fault.hubclient = gv100_fifo_fault_hubclient,
        .fault.gpcclient = gv100_fifo_fault_gpcclient,
        .engine_id = gk104_fifo_engine_id,
-       .id_engine = gk104_fifo_id_engine,
        .uevent_init = gk104_fifo_uevent_init,
        .uevent_fini = gk104_fifo_uevent_fini,
        .recover_chan = gk104_fifo_recover_chan,
index 52fe9d5a5a4ab9cbae2d3cef5e476dd5971cac52..120eb8b7611ffb50e4ada30bf7e7e7402cc6ca30 100644 (file)
@@ -182,24 +182,6 @@ const struct nvkm_runl_func
 nv04_runl = {
 };
 
-struct nvkm_engine *
-nv04_fifo_id_engine(struct nvkm_fifo *fifo, int engi)
-{
-       enum nvkm_subdev_type type;
-
-       switch (engi) {
-       case NV04_FIFO_ENGN_SW  : type = NVKM_ENGINE_SW; break;
-       case NV04_FIFO_ENGN_GR  : type = NVKM_ENGINE_GR; break;
-       case NV04_FIFO_ENGN_MPEG: type = NVKM_ENGINE_MPEG; break;
-       case NV04_FIFO_ENGN_DMA : type = NVKM_ENGINE_DMAOBJ; break;
-       default:
-               WARN_ON(1);
-               return NULL;
-       }
-
-       return nvkm_device_engine(fifo->engine.subdev.device, type, 0);
-}
-
 int
 nv04_fifo_engine_id(struct nvkm_fifo *base, struct nvkm_engine *engine)
 {
@@ -500,7 +482,6 @@ nv04_fifo = {
        .init = nv04_fifo_init,
        .intr = nv04_fifo_intr,
        .engine_id = nv04_fifo_engine_id,
-       .id_engine = nv04_fifo_id_engine,
        .pause = nv04_fifo_pause,
        .start = nv04_fifo_start,
        .runl = &nv04_runl,
index 84416440a82212ba7e5e6d74350319dc3163a977..0f7c88ae5a1c6bd06f19e662349b71291ff5d71d 100644 (file)
@@ -61,7 +61,6 @@ nv10_fifo = {
        .init = nv04_fifo_init,
        .intr = nv04_fifo_intr,
        .engine_id = nv04_fifo_engine_id,
-       .id_engine = nv04_fifo_id_engine,
        .pause = nv04_fifo_pause,
        .start = nv04_fifo_start,
        .runl = &nv04_runl,
index 28ae10a78ee4b983ad746a7bd282cec274a425da..59b752986ac1d793899b96da194b998bdadad63a 100644 (file)
@@ -93,7 +93,6 @@ nv17_fifo = {
        .init = nv17_fifo_init,
        .intr = nv04_fifo_intr,
        .engine_id = nv04_fifo_engine_id,
-       .id_engine = nv04_fifo_id_engine,
        .pause = nv04_fifo_pause,
        .start = nv04_fifo_start,
        .runl = &nv04_runl,
index 492609780c9bc23f5021421bc069d29ba9869880..d0fc6c528825e1f5d5d7f25dd0f388eaba9cb90c 100644 (file)
@@ -133,7 +133,6 @@ nv40_fifo = {
        .init = nv40_fifo_init,
        .intr = nv04_fifo_intr,
        .engine_id = nv04_fifo_engine_id,
-       .id_engine = nv04_fifo_id_engine,
        .pause = nv04_fifo_pause,
        .start = nv04_fifo_start,
        .runl = &nv04_runl,
index 4fcf49dbfd907b777e2bc614de945e5d5f9c3348..46013aea97d6c43729bc4fd20c4c70b08c494d2d 100644 (file)
@@ -168,7 +168,6 @@ nv50_fifo = {
        .init = nv50_fifo_init,
        .intr = nv04_fifo_intr,
        .engine_id = nv04_fifo_engine_id,
-       .id_engine = nv04_fifo_id_engine,
        .pause = nv04_fifo_pause,
        .start = nv04_fifo_start,
        .runl = &nv50_runl,
index 9a23a84ea7f4951dd39dea72a8759f8de6505d40..b8f7201ba7f5e8bd5440d92e91ca53dca0ce80f9 100644 (file)
@@ -19,7 +19,6 @@ void nv50_fifo_init(struct nvkm_fifo *);
 void nv50_fifo_runlist_update(struct nv50_fifo *);
 
 int g84_fifo_engine_id(struct nvkm_fifo *, struct nvkm_engine *);
-struct nvkm_engine *g84_fifo_id_engine(struct nvkm_fifo *, int);
 void g84_fifo_uevent_init(struct nvkm_fifo *);
 void g84_fifo_uevent_fini(struct nvkm_fifo *);
 #endif
index b0fa9d1df91da1a13509947ec864d91c5c08a53a..1b0a3027f297c0b7494184757a948fdf6fa77827 100644 (file)
@@ -44,7 +44,6 @@ struct nvkm_fifo_func {
        } fault;
 
        int (*engine_id)(struct nvkm_fifo *, struct nvkm_engine *);
-       struct nvkm_engine *(*id_engine)(struct nvkm_fifo *, int engi);
        void (*pause)(struct nvkm_fifo *, unsigned long *);
        void (*start)(struct nvkm_fifo *, unsigned long *);
        void (*uevent_init)(struct nvkm_fifo *);
@@ -98,7 +97,6 @@ int nv04_fifo_runl_ctor(struct nvkm_fifo *);
 void nv04_fifo_init(struct nvkm_fifo *);
 void nv04_fifo_intr(struct nvkm_fifo *);
 int nv04_fifo_engine_id(struct nvkm_fifo *, struct nvkm_engine *);
-struct nvkm_engine *nv04_fifo_id_engine(struct nvkm_fifo *, int);
 void nv04_fifo_pause(struct nvkm_fifo *, unsigned long *);
 void nv04_fifo_start(struct nvkm_fifo *, unsigned long *);
 extern const struct nvkm_runl_func nv04_runl;
@@ -127,7 +125,6 @@ extern const struct nvkm_fifo_func_mmu_fault gk104_fifo_mmu_fault;
 void gk104_fifo_fault(struct nvkm_fifo *, struct nvkm_fault_data *);
 void gk104_fifo_recover_chan(struct nvkm_fifo *, int);
 int gk104_fifo_engine_id(struct nvkm_fifo *, struct nvkm_engine *);
-struct nvkm_engine *gk104_fifo_id_engine(struct nvkm_fifo *, int);
 extern const struct nvkm_runq_func gk104_runq;
 extern const struct nvkm_engn_func gk104_engn;
 extern const struct nvkm_engn_func gk104_engn_ce;
index e5b9b1fc386679b92d99775999be50bbb9796ac8..f2c90c7dda7d3a818b12f8e8b519a0f1dc5c5fb0 100644 (file)
@@ -459,7 +459,6 @@ tu102_fifo = {
        .fault.hubclient = gv100_fifo_fault_hubclient,
        .fault.gpcclient = gv100_fifo_fault_gpcclient,
        .engine_id = gk104_fifo_engine_id,
-       .id_engine = gk104_fifo_id_engine,
        .uevent_init = gk104_fifo_uevent_init,
        .uevent_fini = gk104_fifo_uevent_fini,
        .recover_chan = tu102_fifo_recover_chan,
index 42b49043deefb59a26e89a99eddb4d7a90e48ab1..6f920e0e1008d663d8a2bfd70924d04444ae28bb 100644 (file)
@@ -22,6 +22,7 @@
 #define nvkm_uchan(p) container_of((p), struct nvkm_uchan, object)
 #include "cgrp.h"
 #include "chan.h"
+#include "runl.h"
 
 #include <core/oproxy.h>
 
@@ -89,14 +90,43 @@ static int
 nvkm_uchan_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *oclass)
 {
        struct nvkm_chan *chan = nvkm_uchan(object)->chan;
+       struct nvkm_engn *engn;
        int ret;
 
-       ret = chan->object.func->sclass(&chan->object, index, oclass);
-       if (ret)
-               return ret;
+       nvkm_runl_foreach_engn(engn, chan->cgrp->runl) {
+               struct nvkm_engine *engine = engn->engine;
+               int c = 0;
+
+               oclass->engine = engine;
+               oclass->base.oclass = 0;
+
+               if (engine->func->fifo.sclass) {
+                       ret = engine->func->fifo.sclass(oclass, index);
+                       if (oclass->base.oclass) {
+                               if (!oclass->base.ctor)
+                                       oclass->base.ctor = nvkm_object_new;
+                               oclass->ctor = nvkm_uchan_object_new;
+                               return 0;
+                       }
+
+                       index -= ret;
+                       continue;
+               }
+
+               while (engine->func->sclass[c].oclass) {
+                       if (c++ == index) {
+                               oclass->base = engine->func->sclass[index];
+                               if (!oclass->base.ctor)
+                                       oclass->base.ctor = nvkm_object_new;
+                               oclass->ctor = nvkm_uchan_object_new;
+                               return 0;
+                       }
+               }
+
+               index -= c;
+       }
 
-       oclass->ctor = nvkm_uchan_object_new;
-       return 0;
+       return -EINVAL;
 }
 
 static int