]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
drm/nouveau/gr/gf100-: calculate and use sm mapping table
authorBen Skeggs <bskeggs@redhat.com>
Tue, 8 May 2018 10:39:47 +0000 (20:39 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 18 May 2018 05:01:26 +0000 (15:01 +1000)
There's a number of places that require this data, so let's separate out
the calculations to ensure they remain consistent.

This is incorrect for GM200 and newer, but will produce the same results
as we did before.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
23 files changed:
drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm200.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgp100.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf104.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf108.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf110.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf117.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf119.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gk104.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gk110b.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gk208.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gm107.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gm200.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gm20b.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gp100.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gp102.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gp104.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gp107.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gp10b.c

index 949e1216b8ba338426f987a85283cc79229fba92..c2dcc01379c9eedcb5d7f2f9168f4da1ddac1778 100644 (file)
@@ -1092,23 +1092,18 @@ gf100_grctx_generate_r4060a8(struct gf100_gr *gr)
        struct nvkm_device *device = gr->base.engine.subdev.device;
        const u8 gpcmax = nvkm_rd32(device, 0x022430);
        const u8 tpcmax = nvkm_rd32(device, 0x022434) * gpcmax;
-       u8 tpcnr[GPC_MAX], data[TPC_MAX];
-       int gpc, tpc, i;
-
-       memcpy(tpcnr, gr->tpc_nr, sizeof(gr->tpc_nr));
-       memset(data, 0x1f, sizeof(data));
-
-       gpc = -1;
-       for (tpc = 0; tpc < gr->tpc_total; tpc++) {
-               do {
-                       gpc = (gpc + 1) % gr->gpc_nr;
-               } while (!tpcnr[gpc]);
-               tpcnr[gpc]--;
-               data[tpc] = gpc;
-       }
+       int i, j, sm = 0;
+       u32 data;
 
-       for (i = 0; i < DIV_ROUND_UP(tpcmax, 4); i++)
-               nvkm_wr32(device, 0x4060a8 + (i * 4), ((u32 *)data)[i]);
+       for (i = 0; i < DIV_ROUND_UP(tpcmax, 4); i++) {
+               for (data = 0, j = 0; j < 4; j++) {
+                       if (sm < gr->sm_nr)
+                               data |= gr->sm[sm++].gpc << (j * 8);
+                       else
+                               data |= 0x1f << (j * 8);
+               }
+               nvkm_wr32(device, 0x4060a8 + (i * 4), data);
+       }
 }
 
 void
@@ -1326,16 +1321,13 @@ gf100_grctx_generate_floorsweep(struct gf100_gr *gr)
 {
        struct nvkm_device *device = gr->base.engine.subdev.device;
        const struct gf100_grctx_func *func = gr->func->grctx;
-       int tpc, gpc, sm, i, j;
+       int gpc, sm, i, j;
        u32 data;
 
-       for (tpc = 0, sm = 0; tpc < gr->tpc_max; tpc++) {
-               for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
-                       if (tpc < gr->tpc_nr[gpc])
-                               func->sm_id(gr, gpc, tpc, sm++);
-                       if (func->tpc_nr)
-                               func->tpc_nr(gr, gpc);
-               }
+       for (sm = 0; sm < gr->sm_nr; sm++) {
+               func->sm_id(gr, gr->sm[sm].gpc, gr->sm[sm].tpc, sm);
+               if (func->tpc_nr)
+                       func->tpc_nr(gr, gr->sm[sm].gpc);
        }
 
        for (gpc = 0, i = 0; i < 4; i++) {
index 7107ec4297783a1a8228fed2a1383563ce29d719..013d05a0f0f64908a6551853cff34db821858667 100644 (file)
@@ -49,23 +49,13 @@ gm200_grctx_generate_smid_config(struct gf100_gr *gr)
        const u32 dist_nr = DIV_ROUND_UP(gr->tpc_total, 4);
        u32 dist[TPC_MAX / 4] = {};
        u32 gpcs[GPC_MAX] = {};
-       u8  tpcnr[GPC_MAX];
-       int tpc, gpc, i;
+       u8  sm, i;
 
-       memcpy(tpcnr, gr->tpc_nr, sizeof(gr->tpc_nr));
-
-       /* won't result in the same distribution as the binary driver where
-        * some of the gpcs have more tpcs than others, but this shall do
-        * for the moment.  the code for earlier gpus has this issue too.
-        */
-       for (gpc = -1, i = 0; i < gr->tpc_total; i++) {
-               do {
-                       gpc = (gpc + 1) % gr->gpc_nr;
-               } while(!tpcnr[gpc]);
-               tpc = gr->tpc_nr[gpc] - tpcnr[gpc]--;
-
-               dist[i / 4] |= ((gpc << 4) | tpc) << ((i % 4) * 8);
-               gpcs[gpc] |= i << (tpc * 8);
+       for (sm = 0; sm < gr->sm_nr; sm++) {
+               const u8 gpc = gr->sm[sm].gpc;
+               const u8 tpc = gr->sm[sm].tpc;
+               dist[sm / 4] |= ((gpc << 4) | tpc) << ((sm % 4) * 8);
+               gpcs[gpc] |= sm << (tpc * 8);
        }
 
        for (i = 0; i < dist_nr; i++)
index af6330c73872362e801df06569a354f0c42ae9b0..2344fd8086f72c1d54bc7b0789c4e97ea1c16f31 100644 (file)
@@ -95,23 +95,13 @@ gp100_grctx_generate_smid_config(struct gf100_gr *gr)
        struct nvkm_device *device = gr->base.engine.subdev.device;
        const u32 dist_nr = DIV_ROUND_UP(gr->tpc_total, 4);
        u32 dist[TPC_MAX / 4] = {}, gpcs[16] = {};
-       u8  tpcnr[GPC_MAX];
-       int tpc, gpc, i;
+       u8  sm, i;
 
-       memcpy(tpcnr, gr->tpc_nr, sizeof(gr->tpc_nr));
-
-       /* won't result in the same distribution as the binary driver where
-        * some of the gpcs have more tpcs than others, but this shall do
-        * for the moment.  the code for earlier gpus has this issue too.
-        */
-       for (gpc = -1, i = 0; i < gr->tpc_total; i++) {
-               do {
-                       gpc = (gpc + 1) % gr->gpc_nr;
-               } while(!tpcnr[gpc]);
-               tpc = gr->tpc_nr[gpc] - tpcnr[gpc]--;
-
-               dist[i / 4] |= ((gpc << 4) | tpc) << ((i % 4) * 8);
-               gpcs[gpc + (gr->func->gpc_nr * (tpc / 4))] |= i << (tpc * 8);
+       for (sm = 0; sm < gr->sm_nr; sm++) {
+               const u8 gpc = gr->sm[sm].gpc;
+               const u8 tpc = gr->sm[sm].tpc;
+               dist[sm / 4] |= ((gpc << 4) | tpc) << ((sm % 4) * 8);
+               gpcs[gpc + (gr->func->gpc_nr * (tpc / 4))] |= sm << ((tpc % 4) * 8);
        }
 
        for (i = 0; i < dist_nr; i++)
index f6d884156b75493ea591d4b15fe75774944f526c..b2070c87c91ce28c05969c747377b789df5c60a1 100644 (file)
@@ -1652,6 +1652,21 @@ gf100_gr_init_ctxctl(struct gf100_gr *gr)
        return ret;
 }
 
+void
+gf100_gr_oneinit_sm_id(struct gf100_gr *gr)
+{
+       int tpc, gpc;
+       for (tpc = 0; tpc < gr->tpc_max; tpc++) {
+               for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
+                       if (tpc < gr->tpc_nr[gpc]) {
+                               gr->sm[gr->sm_nr].gpc = gpc;
+                               gr->sm[gr->sm_nr].tpc = tpc;
+                               gr->sm_nr++;
+                       }
+               }
+       }
+}
+
 void
 gf100_gr_oneinit_tiles(struct gf100_gr *gr)
 {
@@ -1769,6 +1784,7 @@ gf100_gr_oneinit(struct nvkm_gr *base)
 
        memset(gr->tile, 0xff, sizeof(gr->tile));
        gr->func->oneinit_tiles(gr);
+       gr->func->oneinit_sm_id(gr);
        return 0;
 }
 
@@ -2204,6 +2220,7 @@ gf100_gr_gpccs_ucode = {
 static const struct gf100_gr_func
 gf100_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gf100_gr_init_gpc_mmu,
        .init_vsc_stream_master = gf100_gr_init_vsc_stream_master,
index 53a173e023b4c671e00ce8a100cbfad5b23bad7b..55dedd87fc38001d8338905d5deb27bb12fd270d 100644 (file)
@@ -110,6 +110,12 @@ struct gf100_gr {
        u8 screen_tile_row_offset;
        u8 tile[TPC_MAX];
 
+       struct {
+               u8 gpc;
+               u8 tpc;
+       } sm[TPC_MAX];
+       u8 sm_nr;
+
        struct gf100_gr_data mmio_data[4];
        struct gf100_gr_mmio mmio_list[4096/8];
        u32  size;
@@ -125,6 +131,7 @@ void *gf100_gr_dtor(struct nvkm_gr *);
 struct gf100_gr_func {
        void (*dtor)(struct gf100_gr *);
        void (*oneinit_tiles)(struct gf100_gr *);
+       void (*oneinit_sm_id)(struct gf100_gr *);
        int (*init)(struct gf100_gr *);
        void (*init_gpc_mmu)(struct gf100_gr *);
        void (*init_r405a14)(struct gf100_gr *);
@@ -167,6 +174,7 @@ struct gf100_gr_func {
 
 int gf100_gr_rops(struct gf100_gr *);
 void gf100_gr_oneinit_tiles(struct gf100_gr *);
+void gf100_gr_oneinit_sm_id(struct gf100_gr *);
 int gf100_gr_init(struct gf100_gr *);
 void gf100_gr_init_vsc_stream_master(struct gf100_gr *);
 void gf100_gr_init_zcull(struct gf100_gr *);
@@ -195,6 +203,7 @@ void gm107_gr_init_400054(struct gf100_gr *);
 int gk20a_gr_init(struct gf100_gr *);
 
 void gm200_gr_oneinit_tiles(struct gf100_gr *);
+void gm200_gr_oneinit_sm_id(struct gf100_gr *);
 int gm200_gr_rops(struct gf100_gr *);
 void gm200_gr_init_num_active_ltcs(struct gf100_gr *);
 void gm200_gr_init_ds_hww_esr_2(struct gf100_gr *);
index 8b49b8fe6d2cf8720750290b5228b589c5179c75..1d8e16a571360dee7e3b5005f26957802ac663f4 100644 (file)
@@ -115,6 +115,7 @@ gf104_gr_pack_mmio[] = {
 static const struct gf100_gr_func
 gf104_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gf100_gr_init_gpc_mmu,
        .init_vsc_stream_master = gf100_gr_init_vsc_stream_master,
index 6432aeba0a148843263603992ff2d123d7166947..a5a74df4edffd42b1e7bb2b495e641e3bc0416cb 100644 (file)
@@ -112,6 +112,7 @@ gf108_gr_init_r405a14(struct gf100_gr *gr)
 static const struct gf100_gr_func
 gf108_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gf100_gr_init_gpc_mmu,
        .init_r405a14 = gf108_gr_init_r405a14,
index 4e007c945233c57229ecd8ad05221ed3c30bac4c..45fada09900983bedc037f7b5853fc4bdada9f06 100644 (file)
@@ -87,6 +87,7 @@ gf110_gr_pack_mmio[] = {
 static const struct gf100_gr_func
 gf110_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gf100_gr_init_gpc_mmu,
        .init_vsc_stream_master = gf100_gr_init_vsc_stream_master,
index d6831b41df39f76fe2f8553ab4979ce48ed26667..5ee167d0f5aa991e84d3a9d22c3bdd26a8ff1bee 100644 (file)
@@ -151,6 +151,7 @@ gf117_gr_init_zcull(struct gf100_gr *gr)
 static const struct gf100_gr_func
 gf117_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gf100_gr_init_gpc_mmu,
        .init_vsc_stream_master = gf100_gr_init_vsc_stream_master,
index f0f10a4d8a26b1c515762d9f0b7f31db90db0c8d..2096552fc537c346ae43c454dacc4b2e272dc417 100644 (file)
@@ -178,6 +178,7 @@ gf119_gr_pack_mmio[] = {
 static const struct gf100_gr_func
 gf119_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gf100_gr_init_gpc_mmu,
        .init_vsc_stream_master = gf100_gr_init_vsc_stream_master,
index d57fb5ff1fe94a669f01c174f92e05ecfe720dfe..cce250a85ba6053f7594165a5f1e06cd781d1586 100644 (file)
@@ -449,6 +449,7 @@ gk104_gr_gpccs_ucode = {
 static const struct gf100_gr_func
 gk104_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gf100_gr_init_gpc_mmu,
        .init_vsc_stream_master = gk104_gr_init_vsc_stream_master,
index 41997ebda7193b2521732fbcdade8dfe76f0285d..558b497692abe9f7b312680cdf5b6c938e3a031c 100644 (file)
@@ -351,6 +351,7 @@ gk110_gr_init_419eb4(struct gf100_gr *gr)
 static const struct gf100_gr_func
 gk110_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gf100_gr_init_gpc_mmu,
        .init_vsc_stream_master = gk104_gr_init_vsc_stream_master,
index b7a6479c6ec223d7e92b4ec66030b8bab73eca5f..c8c48a26f4355c5a4484939d0cafa2a3f7801e2f 100644 (file)
@@ -103,6 +103,7 @@ gk110b_gr_pack_mmio[] = {
 static const struct gf100_gr_func
 gk110b_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gf100_gr_init_gpc_mmu,
        .init_vsc_stream_master = gk104_gr_init_vsc_stream_master,
index 5f1e71abe50424b84173d5582454bf6a6f9298f5..477a7dea79f5f8ca5ff823c7789fce1270e83f42 100644 (file)
@@ -162,6 +162,7 @@ gk208_gr_gpccs_ucode = {
 static const struct gf100_gr_func
 gk208_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gf100_gr_init_gpc_mmu,
        .init_vsc_stream_master = gk104_gr_init_vsc_stream_master,
index ab4e5380eba2d9ac94a6d0d7d83c21981bda5114..11a32fa01586cfcd47f7e98b13a20f3d57536936 100644 (file)
@@ -283,6 +283,7 @@ gk20a_gr_init(struct gf100_gr *gr)
 static const struct gf100_gr_func
 gk20a_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gk20a_gr_init,
        .init_zcull = gf117_gr_init_zcull,
        .init_rop_active_fbps = gk104_gr_init_rop_active_fbps,
index 98f74fe7007d0f611661d790ce0a5836b55515ae..a6937f8c3cfdf457593ef28a1ec1d086f200ee71 100644 (file)
@@ -392,6 +392,7 @@ gm107_gr_gpccs_ucode = {
 static const struct gf100_gr_func
 gm107_gr = {
        .oneinit_tiles = gf100_gr_oneinit_tiles,
+       .oneinit_sm_id = gf100_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gm107_gr_init_gpc_mmu,
        .init_bios = gm107_gr_init_bios,
index 3e017fdd23ed90bde3f2c37ff67801e04fc2e4c1..8966d2a7235caadd70aada3ee5c237d29a1e471d 100644 (file)
@@ -92,6 +92,13 @@ gm200_gr_tile_map_2_8[] = {
        0, 1, 1, 0, 0, 1, 1, 0,
 };
 
+void
+gm200_gr_oneinit_sm_id(struct gf100_gr *gr)
+{
+       /*XXX: There's a different algorithm here I've not yet figured out. */
+       gf100_gr_oneinit_sm_id(gr);
+}
+
 void
 gm200_gr_oneinit_tiles(struct gf100_gr *gr)
 {
@@ -158,6 +165,7 @@ gm200_gr_new_(const struct gf100_gr_func *func, struct nvkm_device *device,
 static const struct gf100_gr_func
 gm200_gr = {
        .oneinit_tiles = gm200_gr_oneinit_tiles,
+       .oneinit_sm_id = gm200_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gm200_gr_init_gpc_mmu,
        .init_bios = gm107_gr_init_bios,
index 29d3b9445cf632906041a31b04b53cb769e13bb2..afa1c6e3223077f69456c77571ae2222b80fdf4d 100644 (file)
@@ -65,6 +65,7 @@ gm20b_gr_set_hww_esr_report_mask(struct gf100_gr *gr)
 static const struct gf100_gr_func
 gm20b_gr = {
        .oneinit_tiles = gm200_gr_oneinit_tiles,
+       .oneinit_sm_id = gm200_gr_oneinit_sm_id,
        .init = gk20a_gr_init,
        .init_zcull = gf117_gr_init_zcull,
        .init_gpc_mmu = gm20b_gr_init_gpc_mmu,
index 70d0aa2c1076b51292387f67de57ba34789bdb55..1d9d8760e13e08b0fb1a5ca154231c370dd11040 100644 (file)
@@ -65,6 +65,7 @@ gp100_gr_init_rop_active_fbps(struct gf100_gr *gr)
 static const struct gf100_gr_func
 gp100_gr = {
        .oneinit_tiles = gm200_gr_oneinit_tiles,
+       .oneinit_sm_id = gm200_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gm200_gr_init_gpc_mmu,
        .init_vsc_stream_master = gk104_gr_init_vsc_stream_master,
index 71bfe2d8c3f61519884fd72c8d690683c4461102..2d9a2c3ec261310408824a33bd56ccbd3127c4e2 100644 (file)
@@ -43,6 +43,7 @@ gp102_gr_init_swdx_pes_mask(struct gf100_gr *gr)
 static const struct gf100_gr_func
 gp102_gr = {
        .oneinit_tiles = gm200_gr_oneinit_tiles,
+       .oneinit_sm_id = gm200_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gm200_gr_init_gpc_mmu,
        .init_vsc_stream_master = gk104_gr_init_vsc_stream_master,
index 234c970bb0dc9a8bf48cc94d8fe73c5745f8903c..e466ae460d3ceea883103ef73fd6c276c74ecb37 100644 (file)
@@ -27,6 +27,7 @@
 static const struct gf100_gr_func
 gp104_gr = {
        .oneinit_tiles = gm200_gr_oneinit_tiles,
+       .oneinit_sm_id = gm200_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gm200_gr_init_gpc_mmu,
        .init_vsc_stream_master = gk104_gr_init_vsc_stream_master,
index 6c5724017c71962b5fe48b08c9324760bf08de77..2fa046a1da608910de0347100efadd2055d965c1 100644 (file)
@@ -29,6 +29,7 @@
 static const struct gf100_gr_func
 gp107_gr = {
        .oneinit_tiles = gm200_gr_oneinit_tiles,
+       .oneinit_sm_id = gm200_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gm200_gr_init_gpc_mmu,
        .init_vsc_stream_master = gk104_gr_init_vsc_stream_master,
index aaaa2844ec2016ca960395662d843034e9f32457..0a01a306da2a6076ac1a729d4fab7b62ece3ffa3 100644 (file)
@@ -28,6 +28,7 @@
 static const struct gf100_gr_func
 gp10b_gr = {
        .oneinit_tiles = gm200_gr_oneinit_tiles,
+       .oneinit_sm_id = gm200_gr_oneinit_sm_id,
        .init = gf100_gr_init,
        .init_gpc_mmu = gm200_gr_init_gpc_mmu,
        .init_vsc_stream_master = gk104_gr_init_vsc_stream_master,