1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include "ctxgf100.h"
25
26#include <subdev/fb.h>
27
28
29
30
31
32void
33gp102_grctx_generate_attrib(struct gf100_grctx *info)
34{
35 struct gf100_gr *gr = info->gr;
36 const struct gf100_grctx_func *grctx = gr->func->grctx;
37 const u32 alpha = grctx->alpha_nr;
38 const u32 attrib = grctx->attrib_nr;
39 const u32 pertpc = 0x20 * (grctx->attrib_nr_max + grctx->alpha_nr_max);
40 const u32 size = roundup(gr->tpc_total * pertpc, 0x80);
41 const u32 access = NV_MEM_ACCESS_RW;
42 const int s = 12;
43 const int b = mmio_vram(info, size, (1 << s), access);
44 const int max_batches = 0xffff;
45 u32 ao = 0;
46 u32 bo = ao + grctx->alpha_nr_max * gr->tpc_total;
47 int gpc, ppc, n = 0;
48
49 mmio_refn(info, 0x418810, 0x80000000, s, b);
50 mmio_refn(info, 0x419848, 0x10000000, s, b);
51 mmio_refn(info, 0x419c2c, 0x10000000, s, b);
52 mmio_refn(info, 0x419b00, 0x00000000, s, b);
53 mmio_wr32(info, 0x419b04, 0x80000000 | size >> 7);
54 mmio_wr32(info, 0x405830, attrib);
55 mmio_wr32(info, 0x40585c, alpha);
56 mmio_wr32(info, 0x4064c4, ((alpha / 4) << 16) | max_batches);
57
58 for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
59 for (ppc = 0; ppc < gr->ppc_nr[gpc]; ppc++, n++) {
60 const u32 as = alpha * gr->ppc_tpc_nr[gpc][ppc];
61 const u32 bs = attrib * gr->ppc_tpc_nr[gpc][ppc];
62 const u32 u = 0x418ea0 + (n * 0x04);
63 const u32 o = PPC_UNIT(gpc, ppc, 0);
64 const u32 p = GPC_UNIT(gpc, 0xc44 + (ppc * 4));
65 if (!(gr->ppc_mask[gpc] & (1 << ppc)))
66 continue;
67 mmio_wr32(info, o + 0xc0, bs);
68 mmio_wr32(info, p, bs);
69 mmio_wr32(info, o + 0xf4, bo);
70 mmio_wr32(info, o + 0xf0, bs);
71 bo += grctx->attrib_nr_max * gr->ppc_tpc_nr[gpc][ppc];
72 mmio_wr32(info, o + 0xe4, as);
73 mmio_wr32(info, o + 0xf8, ao);
74 ao += grctx->alpha_nr_max * gr->ppc_tpc_nr[gpc][ppc];
75 mmio_wr32(info, u, bs);
76 }
77 }
78
79 mmio_wr32(info, 0x4181e4, 0x00000100);
80 mmio_wr32(info, 0x41befc, 0x00000100);
81}
82
83const struct gf100_grctx_func
84gp102_grctx = {
85 .main = gp100_grctx_generate_main,
86 .unkn = gk104_grctx_generate_unkn,
87 .bundle = gm107_grctx_generate_bundle,
88 .bundle_size = 0x3000,
89 .bundle_min_gpm_fifo_depth = 0x180,
90 .bundle_token_limit = 0x900,
91 .pagepool = gp100_grctx_generate_pagepool,
92 .pagepool_size = 0x20000,
93 .attrib = gp102_grctx_generate_attrib,
94 .attrib_nr_max = 0x5d4,
95 .attrib_nr = 0x320,
96 .alpha_nr_max = 0xc00,
97 .alpha_nr = 0x800,
98};
99