aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2016-11-30 00:48:00 -0500
committerBen Skeggs <bskeggs@redhat.com>2017-03-07 02:05:16 -0500
commit424321befd2102dc1609e3ae280a28eab61c522b (patch)
treede97abbb3421e4bfc473c7e369c597f2e5ac240f
parent4eb3390e345e4dc5b17673f64660098eaa21522d (diff)
drm/nouveau/gr/gp102: initial support
Differences from GP100: - 3 PPCs/GPC. - Another random reg to calculate/write. - Attrib CB setup a little different. - PascalB - PascalComputeB Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/class.h2
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.h4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgp100.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgp102.c98
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gp100.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gp102.c66
9 files changed, 183 insertions, 4 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvif/class.h b/drivers/gpu/drm/nouveau/include/nvif/class.h
index 3a2c0137d4b4..d08da82ba7ed 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/class.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/class.h
@@ -125,6 +125,7 @@
125#define MAXWELL_B /* cl9097.h */ 0x0000b197 125#define MAXWELL_B /* cl9097.h */ 0x0000b197
126 126
127#define PASCAL_A /* cl9097.h */ 0x0000c097 127#define PASCAL_A /* cl9097.h */ 0x0000c097
128#define PASCAL_B /* cl9097.h */ 0x0000c197
128 129
129#define NV74_BSP 0x000074b0 130#define NV74_BSP 0x000074b0
130 131
@@ -163,6 +164,7 @@
163#define MAXWELL_COMPUTE_A 0x0000b0c0 164#define MAXWELL_COMPUTE_A 0x0000b0c0
164#define MAXWELL_COMPUTE_B 0x0000b1c0 165#define MAXWELL_COMPUTE_B 0x0000b1c0
165#define PASCAL_COMPUTE_A 0x0000c0c0 166#define PASCAL_COMPUTE_A 0x0000c0c0
167#define PASCAL_COMPUTE_B 0x0000c1c0
166 168
167#define NV74_CIPHER 0x000074c1 169#define NV74_CIPHER 0x000074c1
168#endif 170#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h
index 89cf99307828..0a636833e0eb 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h
@@ -43,4 +43,5 @@ int gm107_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
43int gm200_gr_new(struct nvkm_device *, int, struct nvkm_gr **); 43int gm200_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
44int gm20b_gr_new(struct nvkm_device *, int, struct nvkm_gr **); 44int gm20b_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
45int gp100_gr_new(struct nvkm_device *, int, struct nvkm_gr **); 45int gp100_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
46int gp102_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
46#endif 47#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild
index f1c494182248..2938ad5aca40 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild
@@ -32,6 +32,7 @@ nvkm-y += nvkm/engine/gr/gm107.o
32nvkm-y += nvkm/engine/gr/gm200.o 32nvkm-y += nvkm/engine/gr/gm200.o
33nvkm-y += nvkm/engine/gr/gm20b.o 33nvkm-y += nvkm/engine/gr/gm20b.o
34nvkm-y += nvkm/engine/gr/gp100.o 34nvkm-y += nvkm/engine/gr/gp100.o
35nvkm-y += nvkm/engine/gr/gp102.o
35 36
36nvkm-y += nvkm/engine/gr/ctxnv40.o 37nvkm-y += nvkm/engine/gr/ctxnv40.o
37nvkm-y += nvkm/engine/gr/ctxnv50.o 38nvkm-y += nvkm/engine/gr/ctxnv50.o
@@ -50,3 +51,4 @@ nvkm-y += nvkm/engine/gr/ctxgm107.o
50nvkm-y += nvkm/engine/gr/ctxgm200.o 51nvkm-y += nvkm/engine/gr/ctxgm200.o
51nvkm-y += nvkm/engine/gr/ctxgm20b.o 52nvkm-y += nvkm/engine/gr/ctxgm20b.o
52nvkm-y += nvkm/engine/gr/ctxgp100.o 53nvkm-y += nvkm/engine/gr/ctxgp100.o
54nvkm-y += nvkm/engine/gr/ctxgp102.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.h b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.h
index 52048b5a5274..0ae032fa2909 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.h
@@ -102,6 +102,10 @@ void gm200_grctx_generate_405b60(struct gf100_gr *);
102extern const struct gf100_grctx_func gm20b_grctx; 102extern const struct gf100_grctx_func gm20b_grctx;
103 103
104extern const struct gf100_grctx_func gp100_grctx; 104extern const struct gf100_grctx_func gp100_grctx;
105void gp100_grctx_generate_main(struct gf100_gr *, struct gf100_grctx *);
106void gp100_grctx_generate_pagepool(struct gf100_grctx *);
107
108extern const struct gf100_grctx_func gp102_grctx;
105 109
106/* context init value lists */ 110/* context init value lists */
107 111
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgp100.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgp100.c
index 3d1ae7ddf7dd..7833bc777a29 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgp100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgp100.c
@@ -29,7 +29,7 @@
29 * PGRAPH context implementation 29 * PGRAPH context implementation
30 ******************************************************************************/ 30 ******************************************************************************/
31 31
32static void 32void
33gp100_grctx_generate_pagepool(struct gf100_grctx *info) 33gp100_grctx_generate_pagepool(struct gf100_grctx *info)
34{ 34{
35 const struct gf100_grctx_func *grctx = info->gr->func->grctx; 35 const struct gf100_grctx_func *grctx = info->gr->func->grctx;
@@ -123,7 +123,7 @@ gp100_grctx_generate_405b60(struct gf100_gr *gr)
123 nvkm_wr32(device, 0x405ba0 + (i * 4), gpcs[i]); 123 nvkm_wr32(device, 0x405ba0 + (i * 4), gpcs[i]);
124} 124}
125 125
126static void 126void
127gp100_grctx_generate_main(struct gf100_gr *gr, struct gf100_grctx *info) 127gp100_grctx_generate_main(struct gf100_gr *gr, struct gf100_grctx *info)
128{ 128{
129 struct nvkm_device *device = gr->base.engine.subdev.device; 129 struct nvkm_device *device = gr->base.engine.subdev.device;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgp102.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgp102.c
new file mode 100644
index 000000000000..ee26d64af73a
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgp102.c
@@ -0,0 +1,98 @@
1/*
2 * Copyright 2016 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
23 */
24#include "ctxgf100.h"
25
26#include <subdev/fb.h>
27
28/*******************************************************************************
29 * PGRAPH context implementation
30 ******************************************************************************/
31
32static void
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};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
index db6ee3b06841..1d2101af2a87 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
@@ -124,6 +124,7 @@ struct gf100_gr_func {
124 void (*init_gpc_mmu)(struct gf100_gr *); 124 void (*init_gpc_mmu)(struct gf100_gr *);
125 void (*init_rop_active_fbps)(struct gf100_gr *); 125 void (*init_rop_active_fbps)(struct gf100_gr *);
126 void (*init_ppc_exceptions)(struct gf100_gr *); 126 void (*init_ppc_exceptions)(struct gf100_gr *);
127 void (*init_swdx_pes_mask)(struct gf100_gr *);
127 void (*set_hww_esr_report_mask)(struct gf100_gr *); 128 void (*set_hww_esr_report_mask)(struct gf100_gr *);
128 const struct gf100_gr_pack *mmio; 129 const struct gf100_gr_pack *mmio;
129 struct { 130 struct {
@@ -150,6 +151,9 @@ int gk20a_gr_init(struct gf100_gr *);
150int gm200_gr_init(struct gf100_gr *); 151int gm200_gr_init(struct gf100_gr *);
151int gm200_gr_rops(struct gf100_gr *); 152int gm200_gr_rops(struct gf100_gr *);
152 153
154int gp100_gr_init(struct gf100_gr *);
155void gp100_gr_init_rop_active_fbps(struct gf100_gr *);
156
153#define gf100_gr_chan(p) container_of((p), struct gf100_gr_chan, object) 157#define gf100_gr_chan(p) container_of((p), struct gf100_gr_chan, object)
154 158
155struct gf100_gr_chan { 159struct gf100_gr_chan {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gp100.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gp100.c
index 26ad79def0ff..94ed7debb714 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gp100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gp100.c
@@ -30,7 +30,7 @@
30 * PGRAPH engine/subdev functions 30 * PGRAPH engine/subdev functions
31 ******************************************************************************/ 31 ******************************************************************************/
32 32
33static void 33void
34gp100_gr_init_rop_active_fbps(struct gf100_gr *gr) 34gp100_gr_init_rop_active_fbps(struct gf100_gr *gr)
35{ 35{
36 struct nvkm_device *device = gr->base.engine.subdev.device; 36 struct nvkm_device *device = gr->base.engine.subdev.device;
@@ -40,7 +40,7 @@ gp100_gr_init_rop_active_fbps(struct gf100_gr *gr)
40 nvkm_mask(device, 0x408958, 0x0000000f, fbp_count); /* crop */ 40 nvkm_mask(device, 0x408958, 0x0000000f, fbp_count); /* crop */
41} 41}
42 42
43static int 43int
44gp100_gr_init(struct gf100_gr *gr) 44gp100_gr_init(struct gf100_gr *gr)
45{ 45{
46 struct nvkm_device *device = gr->base.engine.subdev.device; 46 struct nvkm_device *device = gr->base.engine.subdev.device;
@@ -85,6 +85,8 @@ gp100_gr_init(struct gf100_gr *gr)
85 nvkm_wr32(device, GPC_BCAST(0x033c), nvkm_rd32(device, 0x100804)); 85 nvkm_wr32(device, GPC_BCAST(0x033c), nvkm_rd32(device, 0x100804));
86 86
87 gr->func->init_rop_active_fbps(gr); 87 gr->func->init_rop_active_fbps(gr);
88 if (gr->func->init_swdx_pes_mask)
89 gr->func->init_swdx_pes_mask(gr);
88 90
89 nvkm_wr32(device, 0x400500, 0x00010001); 91 nvkm_wr32(device, 0x400500, 0x00010001);
90 nvkm_wr32(device, 0x400100, 0xffffffff); 92 nvkm_wr32(device, 0x400100, 0xffffffff);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gp102.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gp102.c
new file mode 100644
index 000000000000..1d5117a16299
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gp102.c
@@ -0,0 +1,66 @@
1/*
2 * Copyright 2016 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
23 */
24#include "gf100.h"
25#include "ctxgf100.h"
26
27#include <nvif/class.h>
28
29static void
30gp102_gr_init_swdx_pes_mask(struct gf100_gr *gr)
31{
32 struct nvkm_device *device = gr->base.engine.subdev.device;
33 u32 mask = 0, data, gpc;
34
35 for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
36 data = nvkm_rd32(device, GPC_UNIT(gpc, 0x0c50)) & 0x0000000f;
37 mask |= data << (gpc * 4);
38 }
39
40 nvkm_wr32(device, 0x4181d0, mask);
41}
42
43static const struct gf100_gr_func
44gp102_gr = {
45 .init = gp100_gr_init,
46 .init_gpc_mmu = gm200_gr_init_gpc_mmu,
47 .init_rop_active_fbps = gp100_gr_init_rop_active_fbps,
48 .init_ppc_exceptions = gk104_gr_init_ppc_exceptions,
49 .init_swdx_pes_mask = gp102_gr_init_swdx_pes_mask,
50 .rops = gm200_gr_rops,
51 .ppc_nr = 3,
52 .grctx = &gp102_grctx,
53 .sclass = {
54 { -1, -1, FERMI_TWOD_A },
55 { -1, -1, KEPLER_INLINE_TO_MEMORY_B },
56 { -1, -1, PASCAL_B, &gf100_fermi },
57 { -1, -1, PASCAL_COMPUTE_B },
58 {}
59 }
60};
61
62int
63gp102_gr_new(struct nvkm_device *device, int index, struct nvkm_gr **pgr)
64{
65 return gm200_gr_new_(&gp102_gr, device, index, pgr);
66}