aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2014-08-09 14:10:30 -0400
committerBen Skeggs <bskeggs@redhat.com>2014-08-09 15:28:16 -0400
commit67cfbfdfec9fade9886ff23717023e3149926a49 (patch)
tree0776a33c94770d9bf4996dfff868e4c7eed97182
parentb81146b03bfaa62218ea334d0c39ad1bc21f42e6 (diff)
drm/gf100-/gr: unhardcode attribute cb config
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxgk110b.c7
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxgk20a.c5
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxgm107.c66
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnv108.c30
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc0.c38
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc0.h13
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c54
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc4.c3
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc8.c3
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c63
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c5
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnve4.c31
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnvf0.c47
13 files changed, 199 insertions, 166 deletions
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxgk110b.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxgk110b.c
index 11bf8b3a45df..6b903c9ee0fb 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxgk110b.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxgk110b.c
@@ -82,7 +82,7 @@ gk110b_grctx_oclass = &(struct nvc0_grctx_oclass) {
82 .wr32 = _nouveau_graph_context_wr32, 82 .wr32 = _nouveau_graph_context_wr32,
83 }, 83 },
84 .main = nve4_grctx_generate_main, 84 .main = nve4_grctx_generate_main,
85 .mods = nvf0_grctx_generate_mods, 85 .mods = nve4_grctx_generate_mods,
86 .unkn = nve4_grctx_generate_unkn, 86 .unkn = nve4_grctx_generate_unkn,
87 .hub = nvf0_grctx_pack_hub, 87 .hub = nvf0_grctx_pack_hub,
88 .gpc = nvf0_grctx_pack_gpc, 88 .gpc = nvf0_grctx_pack_gpc,
@@ -97,4 +97,9 @@ gk110b_grctx_oclass = &(struct nvc0_grctx_oclass) {
97 .bundle_token_limit = 0x600, 97 .bundle_token_limit = 0x600,
98 .pagepool = nve4_grctx_generate_pagepool, 98 .pagepool = nve4_grctx_generate_pagepool,
99 .pagepool_size = 0x8000, 99 .pagepool_size = 0x8000,
100 .attrib = nvd7_grctx_generate_attrib,
101 .attrib_nr_max = 0x324,
102 .attrib_nr = 0x218,
103 .alpha_nr_max = 0x7ff,
104 .alpha_nr = 0x648,
100}.base; 105}.base;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxgk20a.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxgk20a.c
index c560f486dcfb..f336fe38a32a 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxgk20a.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxgk20a.c
@@ -56,4 +56,9 @@ gk20a_grctx_oclass = &(struct nvc0_grctx_oclass) {
56 .bundle_token_limit = 0x100, 56 .bundle_token_limit = 0x100,
57 .pagepool = nve4_grctx_generate_pagepool, 57 .pagepool = nve4_grctx_generate_pagepool,
58 .pagepool_size = 0x8000, 58 .pagepool_size = 0x8000,
59 .attrib = nvd7_grctx_generate_attrib,
60 .attrib_nr_max = 0x240,
61 .attrib_nr = 0x240,
62 .alpha_nr_max = 0x648 + (0x648 / 2),
63 .alpha_nr = 0x648,
59}.base; 64}.base;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxgm107.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxgm107.c
index 5f4d60e0ea07..dfd92fa5f374 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxgm107.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxgm107.c
@@ -891,29 +891,47 @@ gm107_grctx_generate_pagepool(struct nvc0_grctx *info)
891} 891}
892 892
893static void 893static void
894gm107_grctx_generate_attrib(struct nvc0_grctx *info)
895{
896 struct nvc0_graph_priv *priv = info->priv;
897 const struct nvc0_grctx_oclass *impl = (void *)nvc0_grctx_impl(priv);
898 const u32 alpha = impl->alpha_nr;
899 const u32 attrib = impl->attrib_nr;
900 const u32 size = 0x20 * (impl->attrib_nr_max + impl->alpha_nr_max);
901 const u32 access = NV_MEM_ACCESS_RW;
902 const int s = 12;
903 const int b = mmio_vram(info, size * priv->tpc_total, (1 << s), access);
904 const int max_batches = 0xffff;
905 u32 bo = 0;
906 u32 ao = bo + impl->attrib_nr_max * priv->tpc_total;
907 int gpc, ppc, n = 0;
908
909 mmio_refn(info, 0x418810, 0x80000000, s, b);
910 mmio_refn(info, 0x419848, 0x10000000, s, b);
911 mmio_refn(info, 0x419c2c, 0x10000000, s, b);
912 mmio_wr32(info, 0x405830, (attrib << 16) | alpha);
913 mmio_wr32(info, 0x4064c4, ((alpha / 4) << 16) | max_batches);
914
915 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
916 for (ppc = 0; ppc < priv->ppc_nr[gpc]; ppc++, n++) {
917 const u32 as = alpha * priv->ppc_tpc_nr[gpc][ppc];
918 const u32 bs = attrib * priv->ppc_tpc_nr[gpc][ppc];
919 const u32 u = 0x418ea0 + (n * 0x04);
920 const u32 o = PPC_UNIT(gpc, ppc, 0);
921 mmio_wr32(info, o + 0xc0, bs);
922 mmio_wr32(info, o + 0xf4, bo);
923 bo += impl->attrib_nr_max * priv->ppc_tpc_nr[gpc][ppc];
924 mmio_wr32(info, o + 0xe4, as);
925 mmio_wr32(info, o + 0xf8, ao);
926 ao += impl->alpha_nr_max * priv->ppc_tpc_nr[gpc][ppc];
927 mmio_wr32(info, u, (0x715 /*XXX*/ << 16) | bs);
928 }
929 }
930}
931
932void
894gm107_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info) 933gm107_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
895{ 934{
896 mmio_data(0x200000, 0x1000, NV_MEM_ACCESS_RW);
897
898 mmio_list(0x418810, 0x80000000, 12, 2);
899 mmio_list(0x419848, 0x10000000, 12, 2);
900 mmio_list(0x419c2c, 0x10000000, 12, 2);
901
902 mmio_list(0x405830, 0x0aa01000, 0, 0);
903 mmio_list(0x4064c4, 0x0400ffff, 0, 0);
904
905 /*XXX*/
906 mmio_list(0x5030c0, 0x00001540, 0, 0);
907 mmio_list(0x5030f4, 0x00000000, 0, 0);
908 mmio_list(0x5030e4, 0x00002000, 0, 0);
909 mmio_list(0x5030f8, 0x00003fc0, 0, 0);
910 mmio_list(0x418ea0, 0x07151540, 0, 0);
911
912 mmio_list(0x5032c0, 0x00001540, 0, 0);
913 mmio_list(0x5032f4, 0x00001fe0, 0, 0);
914 mmio_list(0x5032e4, 0x00002000, 0, 0);
915 mmio_list(0x5032f8, 0x00006fc0, 0, 0);
916 mmio_list(0x418ea4, 0x07151540, 0, 0);
917} 935}
918 936
919static void 937static void
@@ -952,6 +970,7 @@ gm107_grctx_generate_main(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
952 970
953 oclass->bundle(info); 971 oclass->bundle(info);
954 oclass->pagepool(info); 972 oclass->pagepool(info);
973 oclass->attrib(info);
955 oclass->mods(priv, info); 974 oclass->mods(priv, info);
956 oclass->unkn(priv); 975 oclass->unkn(priv);
957 976
@@ -1012,4 +1031,9 @@ gm107_grctx_oclass = &(struct nvc0_grctx_oclass) {
1012 .bundle_token_limit = 0x2c0, 1031 .bundle_token_limit = 0x2c0,
1013 .pagepool = gm107_grctx_generate_pagepool, 1032 .pagepool = gm107_grctx_generate_pagepool,
1014 .pagepool_size = 0x8000, 1033 .pagepool_size = 0x8000,
1034 .attrib = gm107_grctx_generate_attrib,
1035 .attrib_nr_max = 0xff0,
1036 .attrib_nr = 0xaa0,
1037 .alpha_nr_max = 0x1800,
1038 .alpha_nr = 0x1000,
1015}.base; 1039}.base;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv108.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv108.c
index c3487c42e5d6..f32241800f8e 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv108.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv108.c
@@ -534,31 +534,6 @@ nv108_grctx_pack_ppc[] = {
534static void 534static void
535nv108_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info) 535nv108_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
536{ 536{
537 u32 magic[GPC_MAX][2];
538 u32 offset;
539 int gpc;
540
541 mmio_data(0x060000, 0x1000, NV_MEM_ACCESS_RW);
542 mmio_list(0x418810, 0x80000000, 12, 2);
543 mmio_list(0x419848, 0x10000000, 12, 2);
544
545 mmio_list(0x405830, 0x02180648, 0, 0);
546 mmio_list(0x4064c4, 0x0192ffff, 0, 0);
547
548 for (gpc = 0, offset = 0; gpc < priv->gpc_nr; gpc++) {
549 u16 magic0 = 0x0218 * priv->tpc_nr[gpc];
550 u16 magic1 = 0x0648 * priv->tpc_nr[gpc];
551 magic[gpc][0] = 0x10000000 | (magic0 << 16) | offset;
552 magic[gpc][1] = 0x00000000 | (magic1 << 16);
553 offset += 0x0324 * priv->tpc_nr[gpc];
554 }
555
556 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
557 mmio_list(GPC_UNIT(gpc, 0x30c0), magic[gpc][0], 0, 0);
558 mmio_list(GPC_UNIT(gpc, 0x30e4), magic[gpc][1] | offset, 0, 0);
559 offset += 0x07ff * priv->tpc_nr[gpc];
560 }
561
562 mmio_list(0x17e91c, 0x0b040a0b, 0, 0); 537 mmio_list(0x17e91c, 0x0b040a0b, 0, 0);
563 mmio_list(0x17e920, 0x00090d08, 0, 0); 538 mmio_list(0x17e920, 0x00090d08, 0, 0);
564} 539}
@@ -590,4 +565,9 @@ nv108_grctx_oclass = &(struct nvc0_grctx_oclass) {
590 .bundle_token_limit = 0x200, 565 .bundle_token_limit = 0x200,
591 .pagepool = nve4_grctx_generate_pagepool, 566 .pagepool = nve4_grctx_generate_pagepool,
592 .pagepool_size = 0x8000, 567 .pagepool_size = 0x8000,
568 .attrib = nvd7_grctx_generate_attrib,
569 .attrib_nr_max = 0x324,
570 .attrib_nr = 0x218,
571 .alpha_nr_max = 0x7ff,
572 .alpha_nr = 0x648,
593}.base; 573}.base;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc0.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc0.c
index 8dd3a5b56cd3..46905a48f00a 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc0.c
@@ -1047,28 +1047,38 @@ nvc0_grctx_generate_pagepool(struct nvc0_grctx *info)
1047} 1047}
1048 1048
1049void 1049void
1050nvc0_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info) 1050nvc0_grctx_generate_attrib(struct nvc0_grctx *info)
1051{ 1051{
1052 struct nvc0_graph_priv *priv = info->priv;
1053 const struct nvc0_grctx_oclass *impl = nvc0_grctx_impl(priv);
1054 const u32 attrib = impl->attrib_nr;
1055 const u32 size = 0x20 * (impl->attrib_nr_max + impl->alpha_nr_max);
1056 const u32 access = NV_MEM_ACCESS_RW;
1057 const int s = 12;
1058 const int b = mmio_vram(info, size * priv->tpc_total, (1 << s), access);
1052 int gpc, tpc; 1059 int gpc, tpc;
1053 u32 offset; 1060 u32 bo = 0;
1054
1055 mmio_data(0x060000, 0x1000, NV_MEM_ACCESS_RW);
1056 1061
1057 mmio_list(0x418810, 0x80000000, 12, 2); 1062 mmio_refn(info, 0x418810, 0x80000000, s, b);
1058 mmio_list(0x419848, 0x10000000, 12, 2); 1063 mmio_refn(info, 0x419848, 0x10000000, s, b);
1064 mmio_wr32(info, 0x405830, (attrib << 16));
1059 1065
1060 mmio_list(0x405830, 0x02180000, 0, 0); 1066 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
1061
1062 for (gpc = 0, offset = 0; gpc < priv->gpc_nr; gpc++) {
1063 for (tpc = 0; tpc < priv->tpc_nr[gpc]; tpc++) { 1067 for (tpc = 0; tpc < priv->tpc_nr[gpc]; tpc++) {
1064 u32 addr = TPC_UNIT(gpc, tpc, 0x0520); 1068 const u32 o = TPC_UNIT(gpc, tpc, 0x0520);
1065 mmio_list(addr, 0x02180000 | offset, 0, 0); 1069 mmio_skip(info, o, (attrib << 16) | ++bo);
1066 offset += 0x0324; 1070 mmio_wr32(info, o, (attrib << 16) | --bo);
1071 bo += impl->attrib_nr_max;
1067 } 1072 }
1068 } 1073 }
1069} 1074}
1070 1075
1071void 1076void
1077nvc0_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
1078{
1079}
1080
1081void
1072nvc0_grctx_generate_unkn(struct nvc0_graph_priv *priv) 1082nvc0_grctx_generate_unkn(struct nvc0_graph_priv *priv)
1073{ 1083{
1074} 1084}
@@ -1236,6 +1246,7 @@ nvc0_grctx_generate_main(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
1236 1246
1237 oclass->bundle(info); 1247 oclass->bundle(info);
1238 oclass->pagepool(info); 1248 oclass->pagepool(info);
1249 oclass->attrib(info);
1239 oclass->mods(priv, info); 1250 oclass->mods(priv, info);
1240 oclass->unkn(priv); 1251 oclass->unkn(priv);
1241 1252
@@ -1376,4 +1387,7 @@ nvc0_grctx_oclass = &(struct nvc0_grctx_oclass) {
1376 .bundle_size = 0x1800, 1387 .bundle_size = 0x1800,
1377 .pagepool = nvc0_grctx_generate_pagepool, 1388 .pagepool = nvc0_grctx_generate_pagepool,
1378 .pagepool_size = 0x8000, 1389 .pagepool_size = 0x8000,
1390 .attrib = nvc0_grctx_generate_attrib,
1391 .attrib_nr_max = 0x324,
1392 .attrib_nr = 0x218,
1379}.base; 1393}.base;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc0.h b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc0.h
index 6387a160ac18..fe3fcb99c69c 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc0.h
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc0.h
@@ -47,6 +47,12 @@ struct nvc0_grctx_oclass {
47 /* pagepool */ 47 /* pagepool */
48 void (*pagepool)(struct nvc0_grctx *); 48 void (*pagepool)(struct nvc0_grctx *);
49 u32 pagepool_size; 49 u32 pagepool_size;
50 /* attribute(/alpha) circular buffer */
51 void (*attrib)(struct nvc0_grctx *);
52 u32 attrib_nr_max;
53 u32 attrib_nr;
54 u32 alpha_nr_max;
55 u32 alpha_nr;
50}; 56};
51 57
52static inline const struct nvc0_grctx_oclass * 58static inline const struct nvc0_grctx_oclass *
@@ -60,6 +66,7 @@ int nvc0_grctx_generate(struct nvc0_graph_priv *);
60void nvc0_grctx_generate_main(struct nvc0_graph_priv *, struct nvc0_grctx *); 66void nvc0_grctx_generate_main(struct nvc0_graph_priv *, struct nvc0_grctx *);
61void nvc0_grctx_generate_bundle(struct nvc0_grctx *); 67void nvc0_grctx_generate_bundle(struct nvc0_grctx *);
62void nvc0_grctx_generate_pagepool(struct nvc0_grctx *); 68void nvc0_grctx_generate_pagepool(struct nvc0_grctx *);
69void nvc0_grctx_generate_attrib(struct nvc0_grctx *);
63void nvc0_grctx_generate_mods(struct nvc0_graph_priv *, struct nvc0_grctx *); 70void nvc0_grctx_generate_mods(struct nvc0_graph_priv *, struct nvc0_grctx *);
64void nvc0_grctx_generate_unkn(struct nvc0_graph_priv *); 71void nvc0_grctx_generate_unkn(struct nvc0_graph_priv *);
65void nvc0_grctx_generate_tpcid(struct nvc0_graph_priv *); 72void nvc0_grctx_generate_tpcid(struct nvc0_graph_priv *);
@@ -69,12 +76,16 @@ void nvc0_grctx_generate_r418bb8(struct nvc0_graph_priv *);
69void nvc0_grctx_generate_r406800(struct nvc0_graph_priv *); 76void nvc0_grctx_generate_r406800(struct nvc0_graph_priv *);
70 77
71extern struct nouveau_oclass *nvc1_grctx_oclass; 78extern struct nouveau_oclass *nvc1_grctx_oclass;
79void nvc1_grctx_generate_attrib(struct nvc0_grctx *);
72void nvc1_grctx_generate_mods(struct nvc0_graph_priv *, struct nvc0_grctx *); 80void nvc1_grctx_generate_mods(struct nvc0_graph_priv *, struct nvc0_grctx *);
73void nvc1_grctx_generate_unkn(struct nvc0_graph_priv *); 81void nvc1_grctx_generate_unkn(struct nvc0_graph_priv *);
74 82
75extern struct nouveau_oclass *nvc4_grctx_oclass; 83extern struct nouveau_oclass *nvc4_grctx_oclass;
76extern struct nouveau_oclass *nvc8_grctx_oclass; 84extern struct nouveau_oclass *nvc8_grctx_oclass;
85
77extern struct nouveau_oclass *nvd7_grctx_oclass; 86extern struct nouveau_oclass *nvd7_grctx_oclass;
87void nvd7_grctx_generate_attrib(struct nvc0_grctx *);
88
78extern struct nouveau_oclass *nvd9_grctx_oclass; 89extern struct nouveau_oclass *nvd9_grctx_oclass;
79 90
80extern struct nouveau_oclass *nve4_grctx_oclass; 91extern struct nouveau_oclass *nve4_grctx_oclass;
@@ -86,8 +97,6 @@ void nve4_grctx_generate_mods(struct nvc0_graph_priv *, struct nvc0_grctx *);
86void nve4_grctx_generate_unkn(struct nvc0_graph_priv *); 97void nve4_grctx_generate_unkn(struct nvc0_graph_priv *);
87void nve4_grctx_generate_r418bb8(struct nvc0_graph_priv *); 98void nve4_grctx_generate_r418bb8(struct nvc0_graph_priv *);
88 99
89void nvf0_grctx_generate_mods(struct nvc0_graph_priv *, struct nvc0_grctx *);
90
91extern struct nouveau_oclass *nvf0_grctx_oclass; 100extern struct nouveau_oclass *nvf0_grctx_oclass;
92extern struct nouveau_oclass *gk110b_grctx_oclass; 101extern struct nouveau_oclass *gk110b_grctx_oclass;
93extern struct nouveau_oclass *nv108_grctx_oclass; 102extern struct nouveau_oclass *nv108_grctx_oclass;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c
index f174204c18ab..d9b8f981096f 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c
@@ -727,33 +727,48 @@ nvc1_grctx_pack_tpc[] = {
727 ******************************************************************************/ 727 ******************************************************************************/
728 728
729void 729void
730nvc1_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info) 730nvc1_grctx_generate_attrib(struct nvc0_grctx *info)
731{ 731{
732 struct nvc0_graph_priv *priv = info->priv;
733 const struct nvc0_grctx_oclass *impl = nvc0_grctx_impl(priv);
734 const u32 alpha = impl->alpha_nr;
735 const u32 beta = impl->attrib_nr;
736 const u32 size = 0x20 * (impl->attrib_nr_max + impl->alpha_nr_max);
737 const u32 access = NV_MEM_ACCESS_RW;
738 const int s = 12;
739 const int b = mmio_vram(info, size * priv->tpc_total, (1 << s), access);
740 const int timeslice_mode = 1;
741 const int max_batches = 0xffff;
742 u32 bo = 0;
743 u32 ao = bo + impl->attrib_nr_max * priv->tpc_total;
732 int gpc, tpc; 744 int gpc, tpc;
733 u32 offset;
734
735 mmio_data(0x060000, 0x1000, NV_MEM_ACCESS_RW);
736 mmio_list(0x418810, 0x80000000, 12, 2);
737 mmio_list(0x419848, 0x10000000, 12, 2);
738 745
739 mmio_list(0x405830, 0x02180218, 0, 0); 746 mmio_refn(info, 0x418810, 0x80000000, s, b);
740 mmio_list(0x4064c4, 0x0086ffff, 0, 0); 747 mmio_refn(info, 0x419848, 0x10000000, s, b);
748 mmio_wr32(info, 0x405830, (beta << 16) | alpha);
749 mmio_wr32(info, 0x4064c4, ((alpha / 4) << 16) | max_batches);
741 750
742 for (gpc = 0, offset = 0; gpc < priv->gpc_nr; gpc++) { 751 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
743 for (tpc = 0; tpc < priv->tpc_nr[gpc]; tpc++) { 752 for (tpc = 0; tpc < priv->tpc_nr[gpc]; tpc++) {
744 u32 addr = TPC_UNIT(gpc, tpc, 0x0520); 753 const u32 a = alpha;
745 mmio_list(addr, 0x12180000 | offset, 0, 0); 754 const u32 b = beta;
746 offset += 0x0324; 755 const u32 t = timeslice_mode;
747 } 756 const u32 o = TPC_UNIT(gpc, tpc, 0x500);
748 for (tpc = 0; tpc < priv->tpc_nr[gpc]; tpc++) { 757 mmio_skip(info, o + 0x20, (t << 28) | (b << 16) | ++bo);
749 u32 addr = TPC_UNIT(gpc, tpc, 0x0544); 758 mmio_wr32(info, o + 0x20, (t << 28) | (b << 16) | --bo);
750 mmio_list(addr, 0x02180000 | offset, 0, 0); 759 bo += impl->attrib_nr_max;
751 offset += 0x0324; 760 mmio_wr32(info, o + 0x44, (a << 16) | ao);
761 ao += impl->alpha_nr_max;
752 } 762 }
753 } 763 }
754} 764}
755 765
756void 766void
767nvc1_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
768{
769}
770
771void
757nvc1_grctx_generate_unkn(struct nvc0_graph_priv *priv) 772nvc1_grctx_generate_unkn(struct nvc0_graph_priv *priv)
758{ 773{
759 nv_mask(priv, 0x418c6c, 0x00000001, 0x00000001); 774 nv_mask(priv, 0x418c6c, 0x00000001, 0x00000001);
@@ -788,4 +803,9 @@ nvc1_grctx_oclass = &(struct nvc0_grctx_oclass) {
788 .bundle_size = 0x1800, 803 .bundle_size = 0x1800,
789 .pagepool = nvc0_grctx_generate_pagepool, 804 .pagepool = nvc0_grctx_generate_pagepool,
790 .pagepool_size = 0x8000, 805 .pagepool_size = 0x8000,
806 .attrib = nvc1_grctx_generate_attrib,
807 .attrib_nr_max = 0x324,
808 .attrib_nr = 0x218,
809 .alpha_nr_max = 0x324,
810 .alpha_nr = 0x218,
791}.base; 811}.base;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc4.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc4.c
index ec7f32a6a0f9..8d84dff9fe1f 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc4.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc4.c
@@ -104,4 +104,7 @@ nvc4_grctx_oclass = &(struct nvc0_grctx_oclass) {
104 .bundle_size = 0x1800, 104 .bundle_size = 0x1800,
105 .pagepool = nvc0_grctx_generate_pagepool, 105 .pagepool = nvc0_grctx_generate_pagepool,
106 .pagepool_size = 0x8000, 106 .pagepool_size = 0x8000,
107 .attrib = nvc0_grctx_generate_attrib,
108 .attrib_nr_max = 0x324,
109 .attrib_nr = 0x218,
107}.base; 110}.base;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc8.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc8.c
index de0586829ce1..93f9b60ef871 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc8.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc8.c
@@ -355,4 +355,7 @@ nvc8_grctx_oclass = &(struct nvc0_grctx_oclass) {
355 .bundle_size = 0x1800, 355 .bundle_size = 0x1800,
356 .pagepool = nvc0_grctx_generate_pagepool, 356 .pagepool = nvc0_grctx_generate_pagepool,
357 .pagepool_size = 0x8000, 357 .pagepool_size = 0x8000,
358 .attrib = nvc0_grctx_generate_attrib,
359 .attrib_nr_max = 0x324,
360 .attrib_nr = 0x218,
358}.base; 361}.base;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c
index ce016ac225a9..05b76538a06f 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c
@@ -177,33 +177,46 @@ nvd7_grctx_pack_ppc[] = {
177 * PGRAPH context implementation 177 * PGRAPH context implementation
178 ******************************************************************************/ 178 ******************************************************************************/
179 179
180static void 180void
181nvd7_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info) 181nvd7_grctx_generate_attrib(struct nvc0_grctx *info)
182{ 182{
183 u32 magic[GPC_MAX][2]; 183 struct nvc0_graph_priv *priv = info->priv;
184 u32 offset; 184 const struct nvc0_grctx_oclass *impl = nvc0_grctx_impl(priv);
185 int gpc; 185 const u32 alpha = impl->alpha_nr;
186 const u32 beta = impl->attrib_nr;
187 const u32 size = 0x20 * (impl->attrib_nr_max + impl->alpha_nr_max);
188 const u32 access = NV_MEM_ACCESS_RW;
189 const int s = 12;
190 const int b = mmio_vram(info, size * priv->tpc_total, (1 << s), access);
191 const int timeslice_mode = 1;
192 const int max_batches = 0xffff;
193 u32 bo = 0;
194 u32 ao = bo + impl->attrib_nr_max * priv->tpc_total;
195 int gpc, ppc;
186 196
187 mmio_data(0x060000, 0x1000, NV_MEM_ACCESS_RW); 197 mmio_refn(info, 0x418810, 0x80000000, s, b);
188 mmio_list(0x418810, 0x80000000, 12, 2); 198 mmio_refn(info, 0x419848, 0x10000000, s, b);
189 mmio_list(0x419848, 0x10000000, 12, 2); 199 mmio_wr32(info, 0x405830, (beta << 16) | alpha);
190 200 mmio_wr32(info, 0x4064c4, ((alpha / 4) << 16) | max_batches);
191 mmio_list(0x405830, 0x02180324, 0, 0);
192 mmio_list(0x4064c4, 0x00c9ffff, 0, 0);
193
194 for (gpc = 0, offset = 0; gpc < priv->gpc_nr; gpc++) {
195 u16 magic0 = 0x0218 * priv->tpc_nr[gpc];
196 u16 magic1 = 0x0324 * priv->tpc_nr[gpc];
197 magic[gpc][0] = 0x10000000 | (magic0 << 16) | offset;
198 magic[gpc][1] = 0x00000000 | (magic1 << 16);
199 offset += 0x0324 * priv->tpc_nr[gpc];
200 }
201 201
202 for (gpc = 0; gpc < priv->gpc_nr; gpc++) { 202 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
203 mmio_list(GPC_UNIT(gpc, 0x30c0), magic[gpc][0], 0, 0); 203 for (ppc = 0; ppc < priv->ppc_nr[gpc]; ppc++) {
204 mmio_list(GPC_UNIT(gpc, 0x30e4), magic[gpc][1] | offset, 0, 0); 204 const u32 a = alpha * priv->ppc_tpc_nr[gpc][ppc];
205 offset += 0x07ff * priv->tpc_nr[gpc]; 205 const u32 b = beta * priv->ppc_tpc_nr[gpc][ppc];
206 const u32 t = timeslice_mode;
207 const u32 o = PPC_UNIT(gpc, ppc, 0);
208 mmio_skip(info, o + 0xc0, (t << 28) | (b << 16) | ++bo);
209 mmio_wr32(info, o + 0xc0, (t << 28) | (b << 16) | --bo);
210 bo += impl->attrib_nr_max * priv->ppc_tpc_nr[gpc][ppc];
211 mmio_wr32(info, o + 0xe4, (a << 16) | ao);
212 ao += impl->alpha_nr_max * priv->ppc_tpc_nr[gpc][ppc];
213 }
206 } 214 }
215}
216
217static void
218nvd7_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
219{
207 mmio_list(0x17e91c, 0x03060609, 0, 0); /* different from kepler */ 220 mmio_list(0x17e91c, 0x03060609, 0, 0); /* different from kepler */
208} 221}
209 222
@@ -225,6 +238,7 @@ nvd7_grctx_generate_main(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
225 238
226 oclass->bundle(info); 239 oclass->bundle(info);
227 oclass->pagepool(info); 240 oclass->pagepool(info);
241 oclass->attrib(info);
228 oclass->mods(priv, info); 242 oclass->mods(priv, info);
229 oclass->unkn(priv); 243 oclass->unkn(priv);
230 244
@@ -268,4 +282,9 @@ nvd7_grctx_oclass = &(struct nvc0_grctx_oclass) {
268 .bundle_size = 0x1800, 282 .bundle_size = 0x1800,
269 .pagepool = nvc0_grctx_generate_pagepool, 283 .pagepool = nvc0_grctx_generate_pagepool,
270 .pagepool_size = 0x8000, 284 .pagepool_size = 0x8000,
285 .attrib = nvd7_grctx_generate_attrib,
286 .attrib_nr_max = 0x324,
287 .attrib_nr = 0x218,
288 .alpha_nr_max = 0x7ff,
289 .alpha_nr = 0x324,
271}.base; 290}.base;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c
index b2b0f7085ea7..e5808a82ba4d 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c
@@ -523,4 +523,9 @@ nvd9_grctx_oclass = &(struct nvc0_grctx_oclass) {
523 .bundle_size = 0x1800, 523 .bundle_size = 0x1800,
524 .pagepool = nvc0_grctx_generate_pagepool, 524 .pagepool = nvc0_grctx_generate_pagepool,
525 .pagepool_size = 0x8000, 525 .pagepool_size = 0x8000,
526 .attrib = nvc1_grctx_generate_attrib,
527 .attrib_nr_max = 0x324,
528 .attrib_nr = 0x218,
529 .alpha_nr_max = 0x324,
530 .alpha_nr = 0x218,
526}.base; 531}.base;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnve4.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnve4.c
index 9dfb60d8e5a8..22de56b39a88 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnve4.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnve4.c
@@ -872,31 +872,6 @@ nve4_grctx_generate_pagepool(struct nvc0_grctx *info)
872void 872void
873nve4_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info) 873nve4_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
874{ 874{
875 u32 magic[GPC_MAX][2];
876 u32 offset;
877 int gpc;
878
879 mmio_data(0x060000, 0x1000, NV_MEM_ACCESS_RW);
880 mmio_list(0x418810, 0x80000000, 12, 2);
881 mmio_list(0x419848, 0x10000000, 12, 2);
882
883 mmio_list(0x405830, 0x02180648, 0, 0);
884 mmio_list(0x4064c4, 0x0192ffff, 0, 0);
885
886 for (gpc = 0, offset = 0; gpc < priv->gpc_nr; gpc++) {
887 u16 magic0 = 0x0218 * priv->tpc_nr[gpc];
888 u16 magic1 = 0x0648 * priv->tpc_nr[gpc];
889 magic[gpc][0] = 0x10000000 | (magic0 << 16) | offset;
890 magic[gpc][1] = 0x00000000 | (magic1 << 16);
891 offset += 0x0324 * priv->tpc_nr[gpc];
892 }
893
894 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
895 mmio_list(GPC_UNIT(gpc, 0x30c0), magic[gpc][0], 0, 0);
896 mmio_list(GPC_UNIT(gpc, 0x30e4), magic[gpc][1] | offset, 0, 0);
897 offset += 0x07ff * priv->tpc_nr[gpc];
898 }
899
900 mmio_list(0x17e91c, 0x06060609, 0, 0); 875 mmio_list(0x17e91c, 0x06060609, 0, 0);
901 mmio_list(0x17e920, 0x00090a05, 0, 0); 876 mmio_list(0x17e920, 0x00090a05, 0, 0);
902} 877}
@@ -988,6 +963,7 @@ nve4_grctx_generate_main(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
988 963
989 oclass->bundle(info); 964 oclass->bundle(info);
990 oclass->pagepool(info); 965 oclass->pagepool(info);
966 oclass->attrib(info);
991 oclass->mods(priv, info); 967 oclass->mods(priv, info);
992 oclass->unkn(priv); 968 oclass->unkn(priv);
993 969
@@ -1045,4 +1021,9 @@ nve4_grctx_oclass = &(struct nvc0_grctx_oclass) {
1045 .bundle_token_limit = 0x600, 1021 .bundle_token_limit = 0x600,
1046 .pagepool = nve4_grctx_generate_pagepool, 1022 .pagepool = nve4_grctx_generate_pagepool,
1047 .pagepool_size = 0x8000, 1023 .pagepool_size = 0x8000,
1024 .attrib = nvd7_grctx_generate_attrib,
1025 .attrib_nr_max = 0x324,
1026 .attrib_nr = 0x218,
1027 .alpha_nr_max = 0x7ff,
1028 .alpha_nr = 0x648,
1048}.base; 1029}.base;
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvf0.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvf0.c
index e25ec47defa8..4400b1dcd73e 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvf0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvf0.c
@@ -809,46 +809,6 @@ nvf0_grctx_pack_ppc[] = {
809 * PGRAPH context implementation 809 * PGRAPH context implementation
810 ******************************************************************************/ 810 ******************************************************************************/
811 811
812void
813nvf0_grctx_generate_mods(struct nvc0_graph_priv *priv, struct nvc0_grctx *info)
814{
815 u32 magic[GPC_MAX][4];
816 u32 offset;
817 int gpc;
818
819 mmio_data(0x060000, 0x1000, NV_MEM_ACCESS_RW);
820 mmio_list(0x418810, 0x80000000, 12, 2);
821 mmio_list(0x419848, 0x10000000, 12, 2);
822
823 mmio_list(0x405830, 0x02180648, 0, 0);
824 mmio_list(0x4064c4, 0x0192ffff, 0, 0);
825
826 for (gpc = 0, offset = 0; gpc < priv->gpc_nr; gpc++) {
827 u16 magic0 = 0x0218 * (priv->tpc_nr[gpc] - 1);
828 u16 magic1 = 0x0648 * (priv->tpc_nr[gpc] - 1);
829 u16 magic2 = 0x0218;
830 u16 magic3 = 0x0648;
831 magic[gpc][0] = 0x10000000 | (magic0 << 16) | offset;
832 magic[gpc][1] = 0x00000000 | (magic1 << 16);
833 offset += 0x0324 * (priv->tpc_nr[gpc] - 1);
834 magic[gpc][2] = 0x10000000 | (magic2 << 16) | offset;
835 magic[gpc][3] = 0x00000000 | (magic3 << 16);
836 offset += 0x0324;
837 }
838
839 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
840 mmio_list(GPC_UNIT(gpc, 0x30c0), magic[gpc][0], 0, 0);
841 mmio_list(GPC_UNIT(gpc, 0x30e4), magic[gpc][1] | offset, 0, 0);
842 offset += 0x07ff * (priv->tpc_nr[gpc] - 1);
843 mmio_list(GPC_UNIT(gpc, 0x32c0), magic[gpc][2], 0, 0);
844 mmio_list(GPC_UNIT(gpc, 0x32e4), magic[gpc][3] | offset, 0, 0);
845 offset += 0x07ff;
846 }
847
848 mmio_list(0x17e91c, 0x06060609, 0, 0);
849 mmio_list(0x17e920, 0x00090a05, 0, 0);
850}
851
852struct nouveau_oclass * 812struct nouveau_oclass *
853nvf0_grctx_oclass = &(struct nvc0_grctx_oclass) { 813nvf0_grctx_oclass = &(struct nvc0_grctx_oclass) {
854 .base.handle = NV_ENGCTX(GR, 0xf0), 814 .base.handle = NV_ENGCTX(GR, 0xf0),
@@ -861,7 +821,7 @@ nvf0_grctx_oclass = &(struct nvc0_grctx_oclass) {
861 .wr32 = _nouveau_graph_context_wr32, 821 .wr32 = _nouveau_graph_context_wr32,
862 }, 822 },
863 .main = nve4_grctx_generate_main, 823 .main = nve4_grctx_generate_main,
864 .mods = nvf0_grctx_generate_mods, 824 .mods = nve4_grctx_generate_mods,
865 .unkn = nve4_grctx_generate_unkn, 825 .unkn = nve4_grctx_generate_unkn,
866 .hub = nvf0_grctx_pack_hub, 826 .hub = nvf0_grctx_pack_hub,
867 .gpc = nvf0_grctx_pack_gpc, 827 .gpc = nvf0_grctx_pack_gpc,
@@ -876,4 +836,9 @@ nvf0_grctx_oclass = &(struct nvc0_grctx_oclass) {
876 .bundle_token_limit = 0x7c0, 836 .bundle_token_limit = 0x7c0,
877 .pagepool = nve4_grctx_generate_pagepool, 837 .pagepool = nve4_grctx_generate_pagepool,
878 .pagepool_size = 0x8000, 838 .pagepool_size = 0x8000,
839 .attrib = nvd7_grctx_generate_attrib,
840 .attrib_nr_max = 0x324,
841 .attrib_nr = 0x218,
842 .alpha_nr_max = 0x7ff,
843 .alpha_nr = 0x648,
879}.base; 844}.base;