xref: /linux/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm20b.c (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1a032fb9dSAlexandre Courbot /*
2a032fb9dSAlexandre Courbot  * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
3a032fb9dSAlexandre Courbot  *
4a032fb9dSAlexandre Courbot  * Permission is hereby granted, free of charge, to any person obtaining a
5a032fb9dSAlexandre Courbot  * copy of this software and associated documentation files (the "Software"),
6a032fb9dSAlexandre Courbot  * to deal in the Software without restriction, including without limitation
7a032fb9dSAlexandre Courbot  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8a032fb9dSAlexandre Courbot  * and/or sell copies of the Software, and to permit persons to whom the
9a032fb9dSAlexandre Courbot  * Software is furnished to do so, subject to the following conditions:
10a032fb9dSAlexandre Courbot  *
11a032fb9dSAlexandre Courbot  * The above copyright notice and this permission notice shall be included in
12a032fb9dSAlexandre Courbot  * all copies or substantial portions of the Software.
13a032fb9dSAlexandre Courbot  *
14a032fb9dSAlexandre Courbot  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15a032fb9dSAlexandre Courbot  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16a032fb9dSAlexandre Courbot  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17a032fb9dSAlexandre Courbot  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18a032fb9dSAlexandre Courbot  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19a032fb9dSAlexandre Courbot  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20a032fb9dSAlexandre Courbot  * DEALINGS IN THE SOFTWARE.
21a032fb9dSAlexandre Courbot  */
22a032fb9dSAlexandre Courbot #include "ctxgf100.h"
23a032fb9dSAlexandre Courbot 
24a032fb9dSAlexandre Courbot static void
gm20b_grctx_generate_main(struct gf100_gr_chan * chan)25*78a43c7eSBen Skeggs gm20b_grctx_generate_main(struct gf100_gr_chan *chan)
26a032fb9dSAlexandre Courbot {
27d05095b5SBen Skeggs 	struct gf100_gr *gr = chan->gr;
28276836d4SBen Skeggs 	struct nvkm_device *device = gr->base.engine.subdev.device;
2927f3d6cfSBen Skeggs 	const struct gf100_grctx_func *grctx = gr->func->grctx;
30933ad445SBen Skeggs 	u32 idle_timeout;
31a032fb9dSAlexandre Courbot 	int i, tmp;
32a032fb9dSAlexandre Courbot 
330033f15bSBen Skeggs 	gf100_gr_mmio(gr, gr->sw_ctx);
34a032fb9dSAlexandre Courbot 
35bfee3f3dSBen Skeggs 	gf100_gr_wait_idle(gr);
36a032fb9dSAlexandre Courbot 
37933ad445SBen Skeggs 	idle_timeout = nvkm_mask(device, 0x404154, 0xffffffff, 0x00000000);
38a032fb9dSAlexandre Courbot 
39*78a43c7eSBen Skeggs 	grctx->attrib_cb(chan, chan->attrib_cb->addr, grctx->attrib_cb_size(gr));
40*78a43c7eSBen Skeggs 	grctx->attrib(chan);
41a032fb9dSAlexandre Courbot 
4227f3d6cfSBen Skeggs 	grctx->unkn(gr);
43a032fb9dSAlexandre Courbot 
44fc740f54SBen Skeggs 	gf100_grctx_generate_floorsweep(gr);
45a032fb9dSAlexandre Courbot 
46a032fb9dSAlexandre Courbot 	for (i = 0; i < 8; i++)
47276836d4SBen Skeggs 		nvkm_wr32(device, 0x4064d0 + (i * 0x04), 0x00000000);
48a032fb9dSAlexandre Courbot 
49276836d4SBen Skeggs 	nvkm_wr32(device, 0x405b00, (gr->tpc_total << 8) | gr->gpc_nr);
50a032fb9dSAlexandre Courbot 
51276836d4SBen Skeggs 	nvkm_wr32(device, 0x408908, nvkm_rd32(device, 0x410108) | 0x80000000);
52a032fb9dSAlexandre Courbot 
53bfee3f3dSBen Skeggs 	for (tmp = 0, i = 0; i < gr->gpc_nr; i++)
54bfee3f3dSBen Skeggs 		tmp |= ((1 << gr->tpc_nr[i]) - 1) << (i * 4);
55276836d4SBen Skeggs 	nvkm_wr32(device, 0x4041c4, tmp);
56a032fb9dSAlexandre Courbot 
57fc360764SBen Skeggs 	gm200_grctx_generate_smid_config(gr);
58a032fb9dSAlexandre Courbot 
59bfee3f3dSBen Skeggs 	gf100_gr_wait_idle(gr);
60a032fb9dSAlexandre Courbot 
61933ad445SBen Skeggs 	nvkm_wr32(device, 0x404154, idle_timeout);
62bfee3f3dSBen Skeggs 	gf100_gr_wait_idle(gr);
63a032fb9dSAlexandre Courbot 
640033f15bSBen Skeggs 	gf100_gr_mthd(gr, gr->method);
65bfee3f3dSBen Skeggs 	gf100_gr_wait_idle(gr);
66a032fb9dSAlexandre Courbot 
670033f15bSBen Skeggs 	gf100_gr_icmd(gr, gr->bundle);
68d05095b5SBen Skeggs 	grctx->pagepool(chan, chan->pagepool->addr);
6995f78acdSBen Skeggs 	grctx->bundle(chan, chan->bundle_cb->addr, grctx->bundle_size);
70a032fb9dSAlexandre Courbot }
71a032fb9dSAlexandre Courbot 
7227f3d6cfSBen Skeggs const struct gf100_grctx_func
7327f3d6cfSBen Skeggs gm20b_grctx = {
74a032fb9dSAlexandre Courbot 	.main  = gm20b_grctx_generate_main,
75a032fb9dSAlexandre Courbot 	.unkn  = gk104_grctx_generate_unkn,
76a032fb9dSAlexandre Courbot 	.bundle = gm107_grctx_generate_bundle,
77a032fb9dSAlexandre Courbot 	.bundle_size = 0x1800,
78a032fb9dSAlexandre Courbot 	.bundle_min_gpm_fifo_depth = 0x182,
79a032fb9dSAlexandre Courbot 	.bundle_token_limit = 0x1c0,
80a032fb9dSAlexandre Courbot 	.pagepool = gm107_grctx_generate_pagepool,
81a032fb9dSAlexandre Courbot 	.pagepool_size = 0x8000,
82*78a43c7eSBen Skeggs 	.attrib_cb_size = gf100_grctx_generate_attrib_cb_size,
83*78a43c7eSBen Skeggs 	.attrib_cb = gm107_grctx_generate_attrib_cb,
84a032fb9dSAlexandre Courbot 	.attrib = gm107_grctx_generate_attrib,
85a032fb9dSAlexandre Courbot 	.attrib_nr_max = 0x600,
86a032fb9dSAlexandre Courbot 	.attrib_nr = 0x400,
87a032fb9dSAlexandre Courbot 	.alpha_nr_max = 0xc00,
88a032fb9dSAlexandre Courbot 	.alpha_nr = 0x800,
89fc740f54SBen Skeggs 	.sm_id = gm107_grctx_generate_sm_id,
90ff209c23SBen Skeggs 	.rop_mapping = gf117_grctx_generate_rop_mapping,
9127f3d6cfSBen Skeggs };
92