drm/nouveau/fifo: add id_engine hook
authorBen Skeggs <bskeggs@redhat.com>
Tue, 9 Feb 2021 03:06:35 +0000 (13:06 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 11 Feb 2021 01:49:57 +0000 (11:49 +1000)
Will be used by common code in subsequent commits to lookup driver
engine state from HW engine ID.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
drivers/gpu/drm/nouveau/nvkm/engine/fifo/g84.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/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/priv.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/tu102.c

index db7da93..c0a7d0f 100644 (file)
@@ -38,6 +38,52 @@ g84_fifo_uevent_init(struct nvkm_fifo *fifo)
        nvkm_mask(device, 0x002140, 0x40000000, 0x40000000);
 }
 
+static 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);
+}
+
 static int
 g84_fifo_engine_id(struct nvkm_fifo *base, struct nvkm_engine *engine)
 {
@@ -67,6 +113,7 @@ 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 7fe80a8..9713f4b 100644 (file)
@@ -105,23 +105,26 @@ gf100_fifo_runlist_insert(struct gf100_fifo *fifo, struct gf100_fifo_chan *chan)
        mutex_unlock(&fifo->base.mutex);
 }
 
-static inline struct nvkm_engine *
-gf100_fifo_engine(struct gf100_fifo *fifo, u32 engn)
+static struct nvkm_engine *
+gf100_fifo_id_engine(struct nvkm_fifo *fifo, int engi)
 {
-       struct nvkm_device *device = fifo->base.engine.subdev.device;
-
-       switch (engn) {
-       case 0: engn = NVKM_ENGINE_GR; break;
-       case 1: engn = NVKM_ENGINE_MSVLD; break;
-       case 2: engn = NVKM_ENGINE_MSPPP; break;
-       case 3: engn = NVKM_ENGINE_MSPDEC; break;
-       case 4: engn = NVKM_ENGINE_CE0; break;
-       case 5: engn = NVKM_ENGINE_CE1; break;
+       enum nvkm_subdev_type type;
+       int inst;
+
+       switch (engi) {
+       case GF100_FIFO_ENGN_GR    : type = NVKM_ENGINE_GR    ; inst = 0; break;
+       case GF100_FIFO_ENGN_MSPDEC: type = NVKM_ENGINE_MSPDEC; inst = 0; break;
+       case GF100_FIFO_ENGN_MSPPP : type = NVKM_ENGINE_MSPPP ; inst = 0; break;
+       case GF100_FIFO_ENGN_MSVLD : type = NVKM_ENGINE_MSVLD ; inst = 0; break;
+       case GF100_FIFO_ENGN_CE0   : type = NVKM_ENGINE_CE    ; inst = 0; break;
+       case GF100_FIFO_ENGN_CE1   : type = NVKM_ENGINE_CE    ; inst = 1; break;
+       case GF100_FIFO_ENGN_SW    : type = NVKM_ENGINE_SW    ; inst = 0; break;
        default:
+               WARN_ON(1);
                return NULL;
        }
 
-       return nvkm_device_engine(device, engn, 0);
+       return nvkm_device_engine(fifo->engine.subdev.device, type, inst);
 }
 
 static int
@@ -337,7 +340,7 @@ gf100_fifo_intr_sched_ctxsw(struct gf100_fifo *fifo)
                if (busy && unk0 && unk1) {
                        list_for_each_entry(chan, &fifo->chan, head) {
                                if (chan->base.chid == chid) {
-                                       engine = gf100_fifo_engine(fifo, engn);
+                                       engine = gf100_fifo_id_engine(&fifo->base, engn);
                                        if (!engine)
                                                break;
                                        gf100_fifo_recover(fifo, engine, chan);
@@ -676,6 +679,7 @@ gf100_fifo = {
        .intr = gf100_fifo_intr,
        .fault = gf100_fifo_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,
        .chan = {
index a8ddb1b..c9efa6a 100644 (file)
@@ -258,6 +258,12 @@ gk104_fifo_pbdma = {
        .init = gk104_fifo_pbdma_init,
 };
 
+struct nvkm_engine *
+gk104_fifo_id_engine(struct nvkm_fifo *base, int engi)
+{
+       return gk104_fifo(base)->engine[engi].engine;
+}
+
 int
 gk104_fifo_engine_id(struct nvkm_fifo *base, struct nvkm_engine *engine)
 {
@@ -1037,6 +1043,7 @@ gk104_fifo_ = {
        .intr = gk104_fifo_intr,
        .fault = gk104_fifo_fault,
        .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 a3e79fb..c6730c1 100644 (file)
@@ -94,6 +94,24 @@ __releases(fifo->base.lock)
        spin_unlock_irqrestore(&fifo->base.lock, flags);
 }
 
+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)
 {
@@ -364,6 +382,7 @@ 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,
        .chan = {
index c2053cc..f8887f0 100644 (file)
@@ -44,6 +44,7 @@ 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,
        .chan = {
index 44e61f6..3f94c7b 100644 (file)
@@ -82,6 +82,7 @@ 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,
        .chan = {
index 309d9fd..f9ea468 100644 (file)
@@ -113,6 +113,7 @@ 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,
        .chan = {
index 6b99c48..be94156 100644 (file)
@@ -132,6 +132,7 @@ 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,
        .chan = {
index e3e218f..8992728 100644 (file)
@@ -24,6 +24,7 @@ struct nvkm_fifo_func {
        void (*intr)(struct nvkm_fifo *);
        void (*fault)(struct nvkm_fifo *, struct nvkm_fault_data *);
        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 *);
@@ -37,10 +38,12 @@ struct nvkm_fifo_func {
 
 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 *);
 
 void gf100_fifo_intr_fault(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);
 #endif
index 6076a01..1bc6b25 100644 (file)
@@ -457,6 +457,7 @@ tu102_fifo_ = {
        .intr = tu102_fifo_intr,
        .fault = tu102_fifo_fault,
        .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,