drm/nouveau/fifo/gk110-: support writing channel group runlist entries
authorBen Skeggs <bskeggs@redhat.com>
Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 18 May 2018 05:01:22 +0000 (15:01 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
12 files changed:
drivers/gpu/drm/nouveau/nvkm/engine/fifo/cgrp.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/fifo/changk104.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h
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/gm20b.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gp100.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gp10b.c

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/cgrp.h b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/cgrp.h
new file mode 100644 (file)
index 0000000..d0ac60b
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef __NVKM_FIFO_CGRP_H__
+#define __NVKM_FIFO_CGRP_H__
+#include "priv.h"
+
+struct nvkm_fifo_cgrp {
+       int id;
+       struct list_head head;
+       struct list_head chan;
+       int chan_nr;
+};
+#endif
index 08b4415f0e24e09ceb989d93fbc8e856831f38a2..391e864c2a4a93997e0f70bf228e240cf3a5e23c 100644 (file)
@@ -10,6 +10,7 @@ struct gk104_fifo_chan {
        struct gk104_fifo *fifo;
        int runl;
 
+       struct nvkm_fifo_cgrp *cgrp;
        struct list_head head;
        bool killed;
 
index 2b8e0d3d2d96c7f3a86f7cacbc4e002d6dfa4d1d..bc87f18c3092849983ca5b70a177307f16b9116c 100644 (file)
@@ -22,6 +22,7 @@
  * Authors: Ben Skeggs
  */
 #include "gk104.h"
+#include "cgrp.h"
 #include "changk104.h"
 
 #include <core/client.h>
@@ -145,6 +146,7 @@ gk104_fifo_runlist_commit(struct gk104_fifo *fifo, int runl)
        struct nvkm_subdev *subdev = &fifo->base.engine.subdev;
        struct nvkm_device *device = subdev->device;
        struct nvkm_memory *mem;
+       struct nvkm_fifo_cgrp *cgrp;
        int nr = 0;
        int target;
 
@@ -156,6 +158,13 @@ gk104_fifo_runlist_commit(struct gk104_fifo *fifo, int runl)
        list_for_each_entry(chan, &fifo->runlist[runl].chan, head) {
                func->chan(chan, mem, nr++ * func->size);
        }
+
+       list_for_each_entry(cgrp, &fifo->runlist[runl].cgrp, head) {
+               func->cgrp(cgrp, mem, nr++ * func->size);
+               list_for_each_entry(chan, &cgrp->chan, head) {
+                       func->chan(chan, mem, nr++ * func->size);
+               }
+       }
        nvkm_done(mem);
 
        switch (nvkm_memory_target(mem)) {
@@ -182,16 +191,28 @@ unlock:
 void
 gk104_fifo_runlist_remove(struct gk104_fifo *fifo, struct gk104_fifo_chan *chan)
 {
+       struct nvkm_fifo_cgrp *cgrp = chan->cgrp;
        mutex_lock(&fifo->base.engine.subdev.mutex);
-       list_del_init(&chan->head);
+       if (!list_empty(&chan->head)) {
+               list_del_init(&chan->head);
+               if (cgrp && !--cgrp->chan_nr)
+                       list_del_init(&cgrp->head);
+       }
        mutex_unlock(&fifo->base.engine.subdev.mutex);
 }
 
 void
 gk104_fifo_runlist_insert(struct gk104_fifo *fifo, struct gk104_fifo_chan *chan)
 {
+       struct nvkm_fifo_cgrp *cgrp = chan->cgrp;
        mutex_lock(&fifo->base.engine.subdev.mutex);
-       list_add_tail(&chan->head, &fifo->runlist[chan->runl].chan);
+       if (cgrp) {
+               if (!cgrp->chan_nr++)
+                       list_add_tail(&cgrp->head, &fifo->runlist[chan->runl].cgrp);
+               list_add_tail(&chan->head, &cgrp->chan);
+       } else {
+               list_add_tail(&chan->head, &fifo->runlist[chan->runl].chan);
+       }
        mutex_unlock(&fifo->base.engine.subdev.mutex);
 }
 
@@ -898,6 +919,7 @@ gk104_fifo_oneinit(struct nvkm_fifo *base)
                }
 
                init_waitqueue_head(&fifo->runlist[i].wait);
+               INIT_LIST_HEAD(&fifo->runlist[i].cgrp);
                INIT_LIST_HEAD(&fifo->runlist[i].chan);
        }
 
index c32ea45f945648de376a2f514966108c7c2fed72..dfb3da84c9d1ce7ad5c033e270e811a171efa453 100644 (file)
@@ -3,6 +3,7 @@
 #define __GK104_FIFO_H__
 #define gk104_fifo(p) container_of((p), struct gk104_fifo, base)
 #include "priv.h"
+struct nvkm_fifo_cgrp;
 
 #include <core/enum.h>
 #include <subdev/mmu.h>
@@ -31,6 +32,7 @@ struct gk104_fifo {
                struct nvkm_memory *mem[2];
                int next;
                wait_queue_head_t wait;
+               struct list_head cgrp;
                struct list_head chan;
                u32 engm;
        } runlist[16];
@@ -53,6 +55,8 @@ struct gk104_fifo_func {
 
        const struct gk104_fifo_runlist_func {
                u8 size;
+               void (*cgrp)(struct nvkm_fifo_cgrp *,
+                            struct nvkm_memory *, u32 offset);
                void (*chan)(struct gk104_fifo_chan *,
                             struct nvkm_memory *, u32 offset);
        } *runlist;
@@ -71,7 +75,6 @@ void gk104_fifo_runlist_remove(struct gk104_fifo *, struct gk104_fifo_chan *);
 void gk104_fifo_runlist_commit(struct gk104_fifo *, int runl);
 
 extern const struct nvkm_enum gk104_fifo_fault_access[];
-
 extern const struct nvkm_enum gk104_fifo_fault_engine[];
 extern const struct nvkm_enum gk104_fifo_fault_reason[];
 extern const struct nvkm_enum gk104_fifo_fault_hubclient[];
@@ -80,6 +83,10 @@ extern const struct gk104_fifo_runlist_func gk104_fifo_runlist;
 void gk104_fifo_runlist_chan(struct gk104_fifo_chan *,
                             struct nvkm_memory *, u32);
 
+extern const struct gk104_fifo_runlist_func gk110_fifo_runlist;
+void gk110_fifo_runlist_cgrp(struct nvkm_fifo_cgrp *,
+                            struct nvkm_memory *, u32);
+
 extern const struct nvkm_enum gm107_fifo_fault_engine[];
 extern const struct nvkm_enum gp100_fifo_fault_engine[];
 #endif
index f7e160479558292793cdbee8f091081d5bb4216e..ac7655a130fbdf0c78857c54593fb969db166068 100644 (file)
  * Authors: Ben Skeggs
  */
 #include "gk104.h"
+#include "cgrp.h"
 #include "changk104.h"
 
+#include <core/memory.h>
+
 #include <nvif/class.h>
 
+void
+gk110_fifo_runlist_cgrp(struct nvkm_fifo_cgrp *cgrp,
+                       struct nvkm_memory *memory, u32 offset)
+{
+       nvkm_wo32(memory, offset + 0, (cgrp->chan_nr << 26) | (128 << 18) |
+                                     (3 << 14) | 0x00002000 | cgrp->id);
+       nvkm_wo32(memory, offset + 4, 0x00000000);
+}
+
+const struct gk104_fifo_runlist_func
+gk110_fifo_runlist = {
+       .size = 8,
+       .cgrp = gk110_fifo_runlist_cgrp,
+       .chan = gk104_fifo_runlist_chan,
+};
+
 static const struct gk104_fifo_func
 gk110_fifo = {
        .fault.access = gk104_fifo_fault_access,
@@ -33,7 +52,7 @@ gk110_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .runlist = &gk104_fifo_runlist,
+       .runlist = &gk110_fifo_runlist,
        .chan = {{0,0,KEPLER_CHANNEL_GPFIFO_B}, gk104_fifo_gpfifo_new },
 };
 
index ff936ab6bf87074390fbebb494c236448d4f57ba..b7385cd70b25ebc55b16b962b2f3fe51cc4d21d7 100644 (file)
@@ -33,7 +33,7 @@ gk208_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .runlist = &gk104_fifo_runlist,
+       .runlist = &gk110_fifo_runlist,
        .chan = {{0,0,KEPLER_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
index cb78d4df91822bb8f152fcef710789442504fea9..15cc80c02649fe9c44bc2b8da2852e555359ac17 100644 (file)
@@ -31,7 +31,7 @@ gk20a_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .runlist = &gk104_fifo_runlist,
+       .runlist = &gk110_fifo_runlist,
        .chan = {{0,0,KEPLER_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
index f749d93a51c1870a419f3fba77cf511710815bcb..99b89f6ae34bb4f9eb5f1dd89dbd87564eb4eb40 100644 (file)
@@ -56,7 +56,7 @@ gm107_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .runlist = &gk104_fifo_runlist,
+       .runlist = &gk110_fifo_runlist,
        .chan = {{0,0,KEPLER_CHANNEL_GPFIFO_B}, gk104_fifo_gpfifo_new },
 };
 
index 3b97bd48697d3b14341bc2eab34dec850b825553..16fd8de135a7b45ad727b87936718531f247ad01 100644 (file)
@@ -33,7 +33,7 @@ gm200_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .runlist = &gk104_fifo_runlist,
+       .runlist = &gk110_fifo_runlist,
        .chan = {{0,0,MAXWELL_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
index c7e11a40f016d1baf08cc83b436ea45a1a5ee433..bfa5fa5bc5e525c65921fb245f0264e3fc42c21e 100644 (file)
@@ -31,7 +31,7 @@ gm20b_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .runlist = &gk104_fifo_runlist,
+       .runlist = &gk110_fifo_runlist,
        .chan = {{0,0,MAXWELL_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
index 5c0cc40f7e3e0848e657187fcbc799176c2b748e..c2852943fc3c1b1bac8770a2cd4e9eba96f8f383 100644 (file)
@@ -57,7 +57,7 @@ gp100_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .runlist = &gk104_fifo_runlist,
+       .runlist = &gk110_fifo_runlist,
        .chan = {{0,0,PASCAL_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };
 
index fe3a8fad86208fbaaf94dc70025b0cc31f4c86d1..29a4029694deffcc6e2aeddd87a757e81d59aa68 100644 (file)
@@ -31,7 +31,7 @@ gp10b_fifo = {
        .fault.reason = gk104_fifo_fault_reason,
        .fault.hubclient = gk104_fifo_fault_hubclient,
        .fault.gpcclient = gk104_fifo_fault_gpcclient,
-       .runlist = &gk104_fifo_runlist,
+       .runlist = &gk110_fifo_runlist,
        .chan = {{0,0,PASCAL_CHANNEL_GPFIFO_A}, gk104_fifo_gpfifo_new },
 };