xref: /openbmc/linux/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gv100.c (revision acff941535639a1d244ad9a20dbf3266d39915ed)
1 /*
2  * Copyright 2018 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 #include "chan.h"
23 #include "cgrp.h"
24 #include "runl.h"
25 #include "runq.h"
26 
27 #include "gk104.h"
28 #include "changk104.h"
29 
30 #include <core/gpuobj.h>
31 
32 #include <nvif/class.h>
33 
34 static u32
35 gv100_chan_doorbell_handle(struct nvkm_chan *chan)
36 {
37 	return chan->id;
38 }
39 
40 static const struct nvkm_chan_func
41 gv100_chan = {
42 	.bind = gk104_chan_bind_inst,
43 	.unbind = gk104_chan_unbind,
44 	.start = gk104_chan_start,
45 	.stop = gk104_chan_stop,
46 	.preempt = gk110_chan_preempt,
47 	.doorbell_handle = gv100_chan_doorbell_handle,
48 };
49 
50 const struct nvkm_engn_func
51 gv100_engn = {
52 };
53 
54 const struct nvkm_engn_func
55 gv100_engn_ce = {
56 };
57 
58 const struct nvkm_runq_func
59 gv100_runq = {
60 	.init = gk208_runq_init,
61 	.intr = gk104_runq_intr,
62 	.intr_0_names = gk104_runq_intr_0_names,
63 };
64 
65 void
66 gv100_fifo_runlist_chan(struct gk104_fifo_chan *chan,
67 			struct nvkm_memory *memory, u32 offset)
68 {
69 	struct nvkm_memory *usermem = chan->fifo->user.mem;
70 	const u64 user = nvkm_memory_addr(usermem) + (chan->base.chid * 0x200);
71 	const u64 inst = chan->base.inst->addr;
72 
73 	nvkm_wo32(memory, offset + 0x0, lower_32_bits(user));
74 	nvkm_wo32(memory, offset + 0x4, upper_32_bits(user));
75 	nvkm_wo32(memory, offset + 0x8, lower_32_bits(inst) | chan->base.chid);
76 	nvkm_wo32(memory, offset + 0xc, upper_32_bits(inst));
77 }
78 
79 void
80 gv100_fifo_runlist_cgrp(struct nvkm_fifo_cgrp *cgrp,
81 			struct nvkm_memory *memory, u32 offset)
82 {
83 	nvkm_wo32(memory, offset + 0x0, (128 << 24) | (3 << 16) | 0x00000001);
84 	nvkm_wo32(memory, offset + 0x4, cgrp->chan_nr);
85 	nvkm_wo32(memory, offset + 0x8, cgrp->id);
86 	nvkm_wo32(memory, offset + 0xc, 0x00000000);
87 }
88 
89 static const struct gk104_fifo_runlist_func
90 gv100_fifo_runlist = {
91 	.size = 16,
92 	.cgrp = gv100_fifo_runlist_cgrp,
93 	.chan = gv100_fifo_runlist_chan,
94 	.commit = gk104_fifo_runlist_commit,
95 };
96 
97 static const struct nvkm_runl_func
98 gv100_runl = {
99 	.wait = nv50_runl_wait,
100 	.pending = gk104_runl_pending,
101 	.block = gk104_runl_block,
102 	.allow = gk104_runl_allow,
103 	.preempt_pending = gf100_runl_preempt_pending,
104 };
105 
106 const struct nvkm_enum
107 gv100_fifo_mmu_fault_gpcclient[] = {
108 	{ 0x00, "T1_0" },
109 	{ 0x01, "T1_1" },
110 	{ 0x02, "T1_2" },
111 	{ 0x03, "T1_3" },
112 	{ 0x04, "T1_4" },
113 	{ 0x05, "T1_5" },
114 	{ 0x06, "T1_6" },
115 	{ 0x07, "T1_7" },
116 	{ 0x08, "PE_0" },
117 	{ 0x09, "PE_1" },
118 	{ 0x0a, "PE_2" },
119 	{ 0x0b, "PE_3" },
120 	{ 0x0c, "PE_4" },
121 	{ 0x0d, "PE_5" },
122 	{ 0x0e, "PE_6" },
123 	{ 0x0f, "PE_7" },
124 	{ 0x10, "RAST" },
125 	{ 0x11, "GCC" },
126 	{ 0x12, "GPCCS" },
127 	{ 0x13, "PROP_0" },
128 	{ 0x14, "PROP_1" },
129 	{ 0x15, "PROP_2" },
130 	{ 0x16, "PROP_3" },
131 	{ 0x17, "GPM" },
132 	{ 0x18, "LTP_UTLB_0" },
133 	{ 0x19, "LTP_UTLB_1" },
134 	{ 0x1a, "LTP_UTLB_2" },
135 	{ 0x1b, "LTP_UTLB_3" },
136 	{ 0x1c, "LTP_UTLB_4" },
137 	{ 0x1d, "LTP_UTLB_5" },
138 	{ 0x1e, "LTP_UTLB_6" },
139 	{ 0x1f, "LTP_UTLB_7" },
140 	{ 0x20, "RGG_UTLB" },
141 	{ 0x21, "T1_8" },
142 	{ 0x22, "T1_9" },
143 	{ 0x23, "T1_10" },
144 	{ 0x24, "T1_11" },
145 	{ 0x25, "T1_12" },
146 	{ 0x26, "T1_13" },
147 	{ 0x27, "T1_14" },
148 	{ 0x28, "T1_15" },
149 	{ 0x29, "TPCCS_0" },
150 	{ 0x2a, "TPCCS_1" },
151 	{ 0x2b, "TPCCS_2" },
152 	{ 0x2c, "TPCCS_3" },
153 	{ 0x2d, "TPCCS_4" },
154 	{ 0x2e, "TPCCS_5" },
155 	{ 0x2f, "TPCCS_6" },
156 	{ 0x30, "TPCCS_7" },
157 	{ 0x31, "PE_8" },
158 	{ 0x32, "PE_9" },
159 	{ 0x33, "TPCCS_8" },
160 	{ 0x34, "TPCCS_9" },
161 	{ 0x35, "T1_16" },
162 	{ 0x36, "T1_17" },
163 	{ 0x37, "T1_18" },
164 	{ 0x38, "T1_19" },
165 	{ 0x39, "PE_10" },
166 	{ 0x3a, "PE_11" },
167 	{ 0x3b, "TPCCS_10" },
168 	{ 0x3c, "TPCCS_11" },
169 	{ 0x3d, "T1_20" },
170 	{ 0x3e, "T1_21" },
171 	{ 0x3f, "T1_22" },
172 	{ 0x40, "T1_23" },
173 	{ 0x41, "PE_12" },
174 	{ 0x42, "PE_13" },
175 	{ 0x43, "TPCCS_12" },
176 	{ 0x44, "TPCCS_13" },
177 	{ 0x45, "T1_24" },
178 	{ 0x46, "T1_25" },
179 	{ 0x47, "T1_26" },
180 	{ 0x48, "T1_27" },
181 	{ 0x49, "PE_14" },
182 	{ 0x4a, "PE_15" },
183 	{ 0x4b, "TPCCS_14" },
184 	{ 0x4c, "TPCCS_15" },
185 	{ 0x4d, "T1_28" },
186 	{ 0x4e, "T1_29" },
187 	{ 0x4f, "T1_30" },
188 	{ 0x50, "T1_31" },
189 	{ 0x51, "PE_16" },
190 	{ 0x52, "PE_17" },
191 	{ 0x53, "TPCCS_16" },
192 	{ 0x54, "TPCCS_17" },
193 	{ 0x55, "T1_32" },
194 	{ 0x56, "T1_33" },
195 	{ 0x57, "T1_34" },
196 	{ 0x58, "T1_35" },
197 	{ 0x59, "PE_18" },
198 	{ 0x5a, "PE_19" },
199 	{ 0x5b, "TPCCS_18" },
200 	{ 0x5c, "TPCCS_19" },
201 	{ 0x5d, "T1_36" },
202 	{ 0x5e, "T1_37" },
203 	{ 0x5f, "T1_38" },
204 	{ 0x60, "T1_39" },
205 	{}
206 };
207 
208 const struct nvkm_enum
209 gv100_fifo_mmu_fault_hubclient[] = {
210 	{ 0x00, "VIP" },
211 	{ 0x01, "CE0" },
212 	{ 0x02, "CE1" },
213 	{ 0x03, "DNISO" },
214 	{ 0x04, "FE" },
215 	{ 0x05, "FECS" },
216 	{ 0x06, "HOST" },
217 	{ 0x07, "HOST_CPU" },
218 	{ 0x08, "HOST_CPU_NB" },
219 	{ 0x09, "ISO" },
220 	{ 0x0a, "MMU" },
221 	{ 0x0b, "NVDEC" },
222 	{ 0x0d, "NVENC1" },
223 	{ 0x0e, "NISO" },
224 	{ 0x0f, "P2P" },
225 	{ 0x10, "PD" },
226 	{ 0x11, "PERF" },
227 	{ 0x12, "PMU" },
228 	{ 0x13, "RASTERTWOD" },
229 	{ 0x14, "SCC" },
230 	{ 0x15, "SCC_NB" },
231 	{ 0x16, "SEC" },
232 	{ 0x17, "SSYNC" },
233 	{ 0x18, "CE2" },
234 	{ 0x19, "XV" },
235 	{ 0x1a, "MMU_NB" },
236 	{ 0x1b, "NVENC0" },
237 	{ 0x1c, "DFALCON" },
238 	{ 0x1d, "SKED" },
239 	{ 0x1e, "AFALCON" },
240 	{ 0x1f, "DONT_CARE" },
241 	{ 0x20, "HSCE0" },
242 	{ 0x21, "HSCE1" },
243 	{ 0x22, "HSCE2" },
244 	{ 0x23, "HSCE3" },
245 	{ 0x24, "HSCE4" },
246 	{ 0x25, "HSCE5" },
247 	{ 0x26, "HSCE6" },
248 	{ 0x27, "HSCE7" },
249 	{ 0x28, "HSCE8" },
250 	{ 0x29, "HSCE9" },
251 	{ 0x2a, "HSHUB" },
252 	{ 0x2b, "PTP_X0" },
253 	{ 0x2c, "PTP_X1" },
254 	{ 0x2d, "PTP_X2" },
255 	{ 0x2e, "PTP_X3" },
256 	{ 0x2f, "PTP_X4" },
257 	{ 0x30, "PTP_X5" },
258 	{ 0x31, "PTP_X6" },
259 	{ 0x32, "PTP_X7" },
260 	{ 0x33, "NVENC2" },
261 	{ 0x34, "VPR_SCRUBBER0" },
262 	{ 0x35, "VPR_SCRUBBER1" },
263 	{ 0x36, "DWBIF" },
264 	{ 0x37, "FBFALCON" },
265 	{ 0x38, "CE_SHIM" },
266 	{ 0x39, "GSP" },
267 	{}
268 };
269 
270 const struct nvkm_enum
271 gv100_fifo_mmu_fault_reason[] = {
272 	{ 0x00, "PDE" },
273 	{ 0x01, "PDE_SIZE" },
274 	{ 0x02, "PTE" },
275 	{ 0x03, "VA_LIMIT_VIOLATION" },
276 	{ 0x04, "UNBOUND_INST_BLOCK" },
277 	{ 0x05, "PRIV_VIOLATION" },
278 	{ 0x06, "RO_VIOLATION" },
279 	{ 0x07, "WO_VIOLATION" },
280 	{ 0x08, "PITCH_MASK_VIOLATION" },
281 	{ 0x09, "WORK_CREATION" },
282 	{ 0x0a, "UNSUPPORTED_APERTURE" },
283 	{ 0x0b, "COMPRESSION_FAILURE" },
284 	{ 0x0c, "UNSUPPORTED_KIND" },
285 	{ 0x0d, "REGION_VIOLATION" },
286 	{ 0x0e, "POISONED" },
287 	{ 0x0f, "ATOMIC_VIOLATION" },
288 	{}
289 };
290 
291 static const struct nvkm_enum
292 gv100_fifo_mmu_fault_engine[] = {
293 	{ 0x01, "DISPLAY" },
294 	{ 0x03, "PTP" },
295 	{ 0x04, "BAR1", NULL, NVKM_SUBDEV_BAR },
296 	{ 0x05, "BAR2", NULL, NVKM_SUBDEV_INSTMEM },
297 	{ 0x06, "PWR_PMU" },
298 	{ 0x08, "IFB", NULL, NVKM_ENGINE_IFB },
299 	{ 0x09, "PERF" },
300 	{ 0x1f, "PHYSICAL" },
301 	{ 0x20, "HOST0" },
302 	{ 0x21, "HOST1" },
303 	{ 0x22, "HOST2" },
304 	{ 0x23, "HOST3" },
305 	{ 0x24, "HOST4" },
306 	{ 0x25, "HOST5" },
307 	{ 0x26, "HOST6" },
308 	{ 0x27, "HOST7" },
309 	{ 0x28, "HOST8" },
310 	{ 0x29, "HOST9" },
311 	{ 0x2a, "HOST10" },
312 	{ 0x2b, "HOST11" },
313 	{ 0x2c, "HOST12" },
314 	{ 0x2d, "HOST13" },
315 	{}
316 };
317 
318 const struct nvkm_enum
319 gv100_fifo_mmu_fault_access[] = {
320 	{ 0x0, "VIRT_READ" },
321 	{ 0x1, "VIRT_WRITE" },
322 	{ 0x2, "VIRT_ATOMIC" },
323 	{ 0x3, "VIRT_PREFETCH" },
324 	{ 0x4, "VIRT_ATOMIC_WEAK" },
325 	{ 0x8, "PHYS_READ" },
326 	{ 0x9, "PHYS_WRITE" },
327 	{ 0xa, "PHYS_ATOMIC" },
328 	{ 0xb, "PHYS_PREFETCH" },
329 	{}
330 };
331 
332 static const struct nvkm_fifo_func_mmu_fault
333 gv100_fifo_mmu_fault = {
334 	.recover = gf100_fifo_mmu_fault_recover,
335 	.access = gv100_fifo_mmu_fault_access,
336 	.engine = gv100_fifo_mmu_fault_engine,
337 	.reason = gv100_fifo_mmu_fault_reason,
338 	.hubclient = gv100_fifo_mmu_fault_hubclient,
339 	.gpcclient = gv100_fifo_mmu_fault_gpcclient,
340 };
341 
342 static const struct nvkm_fifo_func
343 gv100_fifo = {
344 	.dtor = gk104_fifo_dtor,
345 	.oneinit = gk104_fifo_oneinit,
346 	.chid_nr = gm200_fifo_chid_nr,
347 	.chid_ctor = gk110_fifo_chid_ctor,
348 	.runq_nr = gm200_fifo_runq_nr,
349 	.runl_ctor = gk104_fifo_runl_ctor,
350 	.init = gk104_fifo_init,
351 	.init_pbdmas = gk104_fifo_init_pbdmas,
352 	.fini = gk104_fifo_fini,
353 	.intr = gk104_fifo_intr,
354 	.mmu_fault = &gv100_fifo_mmu_fault,
355 	.engine_id = gk104_fifo_engine_id,
356 	.recover_chan = gk104_fifo_recover_chan,
357 	.runlist = &gv100_fifo_runlist,
358 	.nonstall = &gf100_fifo_nonstall,
359 	.runl = &gv100_runl,
360 	.runq = &gv100_runq,
361 	.engn = &gv100_engn,
362 	.engn_ce = &gv100_engn_ce,
363 	.cgrp = {{ 0, 0, KEPLER_CHANNEL_GROUP_A  }, &gk110_cgrp, .force = true },
364 	.chan = {{ 0, 0,  VOLTA_CHANNEL_GPFIFO_A }, &gv100_chan, .ctor = gv100_fifo_gpfifo_new },
365 };
366 
367 int
368 gv100_fifo_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
369 	       struct nvkm_fifo **pfifo)
370 {
371 	return gk104_fifo_new_(&gv100_fifo, device, type, inst, 0, pfifo);
372 }
373