]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgp102.c
drm/nouveau/gr/gp107: initial support
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / nouveau / nvkm / engine / gr / ctxgp102.c
CommitLineData
424321be
BS
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
b2c4ef70 32void
424321be
BS
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};