drm/nouveau/fifo/gm200-: read pbdma count more directly
authorBen Skeggs <bskeggs@redhat.com>
Tue, 11 Dec 2018 04:50:02 +0000 (14:50 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 11 Dec 2018 05:37:48 +0000 (15:37 +1000)
The trick we used (and still use for older GPUs) doesn't work on Turing.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
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/gk208.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
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gv100.c

index 79e0b58c5de7e5cff453ae864b902b85432a5efb..1053fe7964661ce809b4ab78e87ec04049d9180f 100644 (file)
@@ -256,8 +256,18 @@ gk104_fifo_pbdma_init(struct gk104_fifo *fifo)
        nvkm_wr32(device, 0x000204, (1 << fifo->pbdma_nr) - 1);
 }
 
+int
+gk104_fifo_pbdma_nr(struct gk104_fifo *fifo)
+{
+       struct nvkm_device *device = fifo->base.engine.subdev.device;
+       /* Determine number of PBDMAs by checking valid enable bits. */
+       nvkm_wr32(device, 0x000204, 0xffffffff);
+       return hweight32(nvkm_rd32(device, 0x000204));
+}
+
 const struct gk104_fifo_pbdma_func
 gk104_fifo_pbdma = {
+       .nr = gk104_fifo_pbdma_nr,
        .init = gk104_fifo_pbdma_init,
 };
 
@@ -925,9 +935,7 @@ gk104_fifo_oneinit(struct nvkm_fifo *base)
        enum nvkm_devidx engidx;
        u32 *map;
 
-       /* Determine number of PBDMAs by checking valid enable bits. */
-       nvkm_wr32(device, 0x000204, 0xffffffff);
-       fifo->pbdma_nr = hweight32(nvkm_rd32(device, 0x000204));
+       fifo->pbdma_nr = fifo->func->pbdma->nr(fifo);
        nvkm_debug(subdev, "%d PBDMA(s)\n", fifo->pbdma_nr);
 
        /* Read PBDMA->runlist(s) mapping from HW. */
index 61d7eee516afa1eb2962c3d31e25251172f544eb..e7c5793569b88ab7d1f08a90393f7660e69793a7 100644 (file)
@@ -46,6 +46,7 @@ struct gk104_fifo {
 
 struct gk104_fifo_func {
        const struct gk104_fifo_pbdma_func {
+               int (*nr)(struct gk104_fifo *);
                void (*init)(struct gk104_fifo *);
                void (*init_timeout)(struct gk104_fifo *);
        } *pbdma;
@@ -89,6 +90,7 @@ void gk104_fifo_runlist_remove(struct gk104_fifo *, struct gk104_fifo_chan *);
 void gk104_fifo_runlist_update(struct gk104_fifo *, int runl);
 
 extern const struct gk104_fifo_pbdma_func gk104_fifo_pbdma;
+int gk104_fifo_pbdma_nr(struct gk104_fifo *);
 void gk104_fifo_pbdma_init(struct gk104_fifo *);
 extern const struct nvkm_enum gk104_fifo_fault_access[];
 extern const struct nvkm_enum gk104_fifo_fault_engine[];
@@ -111,5 +113,8 @@ void gk208_fifo_pbdma_init_timeout(struct gk104_fifo *);
 extern const struct nvkm_enum gm107_fifo_fault_engine[];
 extern const struct gk104_fifo_runlist_func gm107_fifo_runlist;
 
+extern const struct gk104_fifo_pbdma_func gm200_fifo_pbdma;
+int gm200_fifo_pbdma_nr(struct gk104_fifo *);
+
 extern const struct nvkm_enum gp100_fifo_fault_engine[];
 #endif
index 45952292c4363db30a2f85a9753a3be853246fc0..9553fb4af601f033e37b6bdc8878bf9fa6e9f727 100644 (file)
@@ -38,6 +38,7 @@ gk208_fifo_pbdma_init_timeout(struct gk104_fifo *fifo)
 
 const struct gk104_fifo_pbdma_func
 gk208_fifo_pbdma = {
+       .nr = gk104_fifo_pbdma_nr,
        .init = gk104_fifo_pbdma_init,
        .init_timeout = gk208_fifo_pbdma_init_timeout,
 };
index 488d8250ad4cdec67d44559006cde8e897d0a34f..b96c1c5d6577f0a12a1494077fef43d76ba23cfe 100644 (file)
 
 #include <nvif/class.h>
 
+int
+gm200_fifo_pbdma_nr(struct gk104_fifo *fifo)
+{
+       struct nvkm_device *device = fifo->base.engine.subdev.device;
+       return nvkm_rd32(device, 0x002004) & 0x000000ff;
+}
+
+const struct gk104_fifo_pbdma_func
+gm200_fifo_pbdma = {
+       .nr = gm200_fifo_pbdma_nr,
+       .init = gk104_fifo_pbdma_init,
+       .init_timeout = gk208_fifo_pbdma_init_timeout,
+};
+
 static const struct gk104_fifo_func
 gm200_fifo = {
-       .pbdma = &gk208_fifo_pbdma,
+       .pbdma = &gm200_fifo_pbdma,
        .fault.access = gk104_fifo_fault_access,
        .fault.engine = gm107_fifo_fault_engine,
        .fault.reason = gk104_fifo_fault_reason,
index 5a05ad009b8afe919f8f2421ab09562b57fcd3a9..a49539b9e4ec328f24d7d3b1e4aa798b19ae92c2 100644 (file)
@@ -26,7 +26,7 @@
 
 static const struct gk104_fifo_func
 gm20b_fifo = {
-       .pbdma = &gk208_fifo_pbdma,
+       .pbdma = &gm200_fifo_pbdma,
        .fault.access = gk104_fifo_fault_access,
        .fault.engine = gm107_fifo_fault_engine,
        .fault.reason = gk104_fifo_fault_reason,
index 838fa90c3cac9fa7b5dd184179be41302afd1a19..54377e0f6a88fb1957beca80c28e062dab08009c 100644 (file)
@@ -52,7 +52,7 @@ gp100_fifo_fault_engine[] = {
 
 static const struct gk104_fifo_func
 gp100_fifo = {
-       .pbdma = &gk208_fifo_pbdma,
+       .pbdma = &gm200_fifo_pbdma,
        .fault.access = gk104_fifo_fault_access,
        .fault.engine = gp100_fifo_fault_engine,
        .fault.reason = gk104_fifo_fault_reason,
index 080209de93f1b9e457cb50334415c57216c41fea..778ba7e46fb36f1d10ea48d9c651df2a2bd7520a 100644 (file)
@@ -26,7 +26,7 @@
 
 static const struct gk104_fifo_func
 gp10b_fifo = {
-       .pbdma = &gk208_fifo_pbdma,
+       .pbdma = &gm200_fifo_pbdma,
        .fault.access = gk104_fifo_fault_access,
        .fault.engine = gp100_fifo_fault_engine,
        .fault.reason = gk104_fifo_fault_reason,
index ded6493e98097a3f491bf1795e4ff27906012230..98cf4408385097137157cbfbe4893c3a23a2a331 100644 (file)
@@ -288,7 +288,7 @@ gv100_fifo_fault_access[] = {
 
 static const struct gk104_fifo_func
 gv100_fifo = {
-       .pbdma = &gk208_fifo_pbdma,
+       .pbdma = &gm200_fifo_pbdma,
        .fault.access = gv100_fifo_fault_access,
        .fault.engine = gv100_fifo_fault_engine,
        .fault.reason = gv100_fifo_fault_reason,