xref: /linux/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gp100.c (revision acff941535639a1d244ad9a20dbf3266d39915ed)
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
23  */
24 #include "runl.h"
25 #include "gk104.h"
26 #include "changk104.h"
27 
28 #include <subdev/fault.h>
29 
30 #include <nvif/class.h>
31 
32 static const struct nvkm_runl_func
33 gp100_runl = {
34 	.wait = nv50_runl_wait,
35 	.pending = gk104_runl_pending,
36 	.block = gk104_runl_block,
37 	.allow = gk104_runl_allow,
38 	.preempt_pending = gf100_runl_preempt_pending,
39 };
40 
41 static const struct nvkm_enum
42 gp100_fifo_mmu_fault_engine[] = {
43 	{ 0x01, "DISPLAY" },
44 	{ 0x03, "IFB", NULL, NVKM_ENGINE_IFB },
45 	{ 0x04, "BAR1", NULL, NVKM_SUBDEV_BAR },
46 	{ 0x05, "BAR2", NULL, NVKM_SUBDEV_INSTMEM },
47 	{ 0x06, "HOST0" },
48 	{ 0x07, "HOST1" },
49 	{ 0x08, "HOST2" },
50 	{ 0x09, "HOST3" },
51 	{ 0x0a, "HOST4" },
52 	{ 0x0b, "HOST5" },
53 	{ 0x0c, "HOST6" },
54 	{ 0x0d, "HOST7" },
55 	{ 0x0e, "HOST8" },
56 	{ 0x0f, "HOST9" },
57 	{ 0x10, "HOST10" },
58 	{ 0x13, "PERF" },
59 	{ 0x17, "PMU" },
60 	{ 0x18, "PTP" },
61 	{ 0x1f, "PHYSICAL" },
62 	{}
63 };
64 
65 static const struct nvkm_fifo_func_mmu_fault
66 gp100_fifo_mmu_fault = {
67 	.recover = gf100_fifo_mmu_fault_recover,
68 	.access = gf100_fifo_mmu_fault_access,
69 	.engine = gp100_fifo_mmu_fault_engine,
70 	.reason = gk104_fifo_mmu_fault_reason,
71 	.hubclient = gk104_fifo_mmu_fault_hubclient,
72 	.gpcclient = gk104_fifo_mmu_fault_gpcclient,
73 };
74 
75 static void
76 gp100_fifo_intr_mmu_fault_unit(struct nvkm_fifo *fifo, int unit)
77 {
78 	struct nvkm_device *device = fifo->engine.subdev.device;
79 	u32 inst = nvkm_rd32(device, 0x002800 + (unit * 0x10));
80 	u32 valo = nvkm_rd32(device, 0x002804 + (unit * 0x10));
81 	u32 vahi = nvkm_rd32(device, 0x002808 + (unit * 0x10));
82 	u32 type = nvkm_rd32(device, 0x00280c + (unit * 0x10));
83 	struct nvkm_fault_data info;
84 
85 	info.inst   =  (u64)inst << 12;
86 	info.addr   = ((u64)vahi << 32) | valo;
87 	info.time   = 0;
88 	info.engine = unit;
89 	info.valid  = 1;
90 	info.gpc    = (type & 0x1f000000) >> 24;
91 	info.hub    = (type & 0x00100000) >> 20;
92 	info.access = (type & 0x00070000) >> 16;
93 	info.client = (type & 0x00007f00) >> 8;
94 	info.reason = (type & 0x0000001f);
95 
96 	nvkm_fifo_fault(fifo, &info);
97 }
98 
99 static const struct nvkm_fifo_func
100 gp100_fifo = {
101 	.dtor = gk104_fifo_dtor,
102 	.oneinit = gk104_fifo_oneinit,
103 	.chid_nr = gm200_fifo_chid_nr,
104 	.chid_ctor = gk110_fifo_chid_ctor,
105 	.runq_nr = gm200_fifo_runq_nr,
106 	.runl_ctor = gk104_fifo_runl_ctor,
107 	.init = gk104_fifo_init,
108 	.init_pbdmas = gk104_fifo_init_pbdmas,
109 	.fini = gk104_fifo_fini,
110 	.intr = gk104_fifo_intr,
111 	.intr_mmu_fault_unit = gp100_fifo_intr_mmu_fault_unit,
112 	.mmu_fault = &gp100_fifo_mmu_fault,
113 	.engine_id = gk104_fifo_engine_id,
114 	.recover_chan = gk104_fifo_recover_chan,
115 	.runlist = &gm107_fifo_runlist,
116 	.nonstall = &gf100_fifo_nonstall,
117 	.runl = &gp100_runl,
118 	.runq = &gk208_runq,
119 	.engn = &gk104_engn,
120 	.engn_ce = &gk104_engn_ce,
121 	.cgrp = {{ 0, 0, KEPLER_CHANNEL_GROUP_A  }, &gk110_cgrp, .force = true },
122 	.chan = {{ 0, 0, PASCAL_CHANNEL_GPFIFO_A }, &gm107_chan, .ctor = &gk104_fifo_gpfifo_new },
123 };
124 
125 int
126 gp100_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
127 	       struct nvkm_fifo **pfifo)
128 {
129 	return gk104_fifo_new_(&gp100_fifo, device, type, inst, 0, pfifo);
130 }
131