blob: f5fd1b296d27ae24a3a11dc140593376ef01dd7b [file] [log] [blame]
Ben Skeggs6ee73862009-12-11 19:24:15 +10001/*
2 * Copyright (C) 2007 Ben Skeggs.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 */
26
27#include "drmP.h"
28#include "drm.h"
29#include "nouveau_drv.h"
Ben Skeggsa8eaebc2010-09-01 15:24:31 +100030#include "nouveau_ramht.h"
Marcin Kościelnickid5f3c902010-02-25 00:54:02 +000031#include "nouveau_grctx.h"
Francisco Jerez332b2422010-10-20 23:35:40 +020032#include "nouveau_dma.h"
Ben Skeggsa11c3192010-08-27 10:00:25 +100033#include "nouveau_vm.h"
Francisco Jerez332b2422010-10-20 23:35:40 +020034#include "nv50_evo.h"
Ben Skeggs6ee73862009-12-11 19:24:15 +100035
Ben Skeggs274fec92010-11-03 13:16:18 +100036static int nv50_graph_register(struct drm_device *);
37static void nv50_graph_isr(struct drm_device *);
Ben Skeggsb8c157d2010-10-20 10:39:35 +100038
Ben Skeggs6ee73862009-12-11 19:24:15 +100039static void
40nv50_graph_init_reset(struct drm_device *dev)
41{
42 uint32_t pmc_e = NV_PMC_ENABLE_PGRAPH | (1 << 21);
43
44 NV_DEBUG(dev, "\n");
45
46 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) & ~pmc_e);
47 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) | pmc_e);
48}
49
50static void
51nv50_graph_init_intr(struct drm_device *dev)
52{
53 NV_DEBUG(dev, "\n");
54
Ben Skeggs274fec92010-11-03 13:16:18 +100055 nouveau_irq_register(dev, 12, nv50_graph_isr);
Ben Skeggs6ee73862009-12-11 19:24:15 +100056 nv_wr32(dev, NV03_PGRAPH_INTR, 0xffffffff);
57 nv_wr32(dev, 0x400138, 0xffffffff);
58 nv_wr32(dev, NV40_PGRAPH_INTR_EN, 0xffffffff);
59}
60
61static void
62nv50_graph_init_regs__nv(struct drm_device *dev)
63{
Marcin Kościelnicki304424e2010-03-01 00:18:39 +000064 struct drm_nouveau_private *dev_priv = dev->dev_private;
65 uint32_t units = nv_rd32(dev, 0x1540);
66 int i;
67
Ben Skeggs6ee73862009-12-11 19:24:15 +100068 NV_DEBUG(dev, "\n");
69
70 nv_wr32(dev, 0x400804, 0xc0000000);
71 nv_wr32(dev, 0x406800, 0xc0000000);
72 nv_wr32(dev, 0x400c04, 0xc0000000);
Marcin Kościelnicki716abaa2010-01-12 18:21:56 +000073 nv_wr32(dev, 0x401800, 0xc0000000);
Ben Skeggs6ee73862009-12-11 19:24:15 +100074 nv_wr32(dev, 0x405018, 0xc0000000);
75 nv_wr32(dev, 0x402000, 0xc0000000);
76
Marcin Kościelnicki304424e2010-03-01 00:18:39 +000077 for (i = 0; i < 16; i++) {
78 if (units & 1 << i) {
79 if (dev_priv->chipset < 0xa0) {
80 nv_wr32(dev, 0x408900 + (i << 12), 0xc0000000);
81 nv_wr32(dev, 0x408e08 + (i << 12), 0xc0000000);
82 nv_wr32(dev, 0x408314 + (i << 12), 0xc0000000);
83 } else {
84 nv_wr32(dev, 0x408600 + (i << 11), 0xc0000000);
85 nv_wr32(dev, 0x408708 + (i << 11), 0xc0000000);
86 nv_wr32(dev, 0x40831c + (i << 11), 0xc0000000);
87 }
88 }
89 }
90
Ben Skeggs6ee73862009-12-11 19:24:15 +100091 nv_wr32(dev, 0x400108, 0xffffffff);
92
93 nv_wr32(dev, 0x400824, 0x00004000);
94 nv_wr32(dev, 0x400500, 0x00010001);
95}
96
97static void
98nv50_graph_init_regs(struct drm_device *dev)
99{
100 NV_DEBUG(dev, "\n");
101
102 nv_wr32(dev, NV04_PGRAPH_DEBUG_3,
103 (1 << 2) /* HW_CONTEXT_SWITCH_ENABLED */);
104 nv_wr32(dev, 0x402ca8, 0x800);
105}
106
107static int
108nv50_graph_init_ctxctl(struct drm_device *dev)
109{
Ben Skeggs054b93e2009-12-15 22:02:47 +1000110 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggsec91db22010-07-08 11:53:19 +1000111 struct nouveau_grctx ctx = {};
112 uint32_t *cp;
113 int i;
Ben Skeggs054b93e2009-12-15 22:02:47 +1000114
Ben Skeggs6ee73862009-12-11 19:24:15 +1000115 NV_DEBUG(dev, "\n");
116
Ben Skeggsec91db22010-07-08 11:53:19 +1000117 cp = kmalloc(512 * 4, GFP_KERNEL);
118 if (!cp) {
119 NV_ERROR(dev, "failed to allocate ctxprog\n");
120 dev_priv->engine.graph.accel_blocked = true;
121 return 0;
Marcin Kościelnickid5f3c902010-02-25 00:54:02 +0000122 }
Marcin Kościelnickid5f3c902010-02-25 00:54:02 +0000123
Ben Skeggsec91db22010-07-08 11:53:19 +1000124 ctx.dev = dev;
125 ctx.mode = NOUVEAU_GRCTX_PROG;
126 ctx.data = cp;
127 ctx.ctxprog_max = 512;
128 if (!nv50_grctx_init(&ctx)) {
129 dev_priv->engine.graph.grctx_size = ctx.ctxvals_pos * 4;
130
131 nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
132 for (i = 0; i < ctx.ctxprog_len; i++)
133 nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, cp[i]);
134 } else {
135 dev_priv->engine.graph.accel_blocked = true;
Marcin Kościelnickid5f3c902010-02-25 00:54:02 +0000136 }
Ben Skeggsec91db22010-07-08 11:53:19 +1000137 kfree(cp);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000138
139 nv_wr32(dev, 0x400320, 4);
140 nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0);
141 nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, 0);
142 return 0;
143}
144
145int
146nv50_graph_init(struct drm_device *dev)
147{
148 int ret;
149
150 NV_DEBUG(dev, "\n");
151
152 nv50_graph_init_reset(dev);
153 nv50_graph_init_regs__nv(dev);
154 nv50_graph_init_regs(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000155
156 ret = nv50_graph_init_ctxctl(dev);
157 if (ret)
158 return ret;
159
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000160 ret = nv50_graph_register(dev);
161 if (ret)
162 return ret;
163 nv50_graph_init_intr(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000164 return 0;
165}
166
167void
168nv50_graph_takedown(struct drm_device *dev)
169{
170 NV_DEBUG(dev, "\n");
Ben Skeggs274fec92010-11-03 13:16:18 +1000171 nv_wr32(dev, 0x40013c, 0x00000000);
172 nouveau_irq_unregister(dev, 12);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000173}
174
175void
176nv50_graph_fifo_access(struct drm_device *dev, bool enabled)
177{
178 const uint32_t mask = 0x00010001;
179
180 if (enabled)
181 nv_wr32(dev, 0x400500, nv_rd32(dev, 0x400500) | mask);
182 else
183 nv_wr32(dev, 0x400500, nv_rd32(dev, 0x400500) & ~mask);
184}
185
186struct nouveau_channel *
187nv50_graph_channel(struct drm_device *dev)
188{
189 struct drm_nouveau_private *dev_priv = dev->dev_private;
190 uint32_t inst;
191 int i;
192
Maarten Maathuisa51a3bf2010-02-01 18:32:09 +0100193 /* Be sure we're not in the middle of a context switch or bad things
194 * will happen, such as unloading the wrong pgraph context.
195 */
Francisco Jerez4b5c1522010-09-07 17:34:44 +0200196 if (!nv_wait(dev, 0x400300, 0x00000001, 0x00000000))
Maarten Maathuisa51a3bf2010-02-01 18:32:09 +0100197 NV_ERROR(dev, "Ctxprog is still running\n");
198
Ben Skeggs6ee73862009-12-11 19:24:15 +1000199 inst = nv_rd32(dev, NV50_PGRAPH_CTXCTL_CUR);
200 if (!(inst & NV50_PGRAPH_CTXCTL_CUR_LOADED))
201 return NULL;
202 inst = (inst & NV50_PGRAPH_CTXCTL_CUR_INSTANCE) << 12;
203
204 for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
Ben Skeggscff5c132010-10-06 16:16:59 +1000205 struct nouveau_channel *chan = dev_priv->channels.ptr[i];
Ben Skeggs6ee73862009-12-11 19:24:15 +1000206
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000207 if (chan && chan->ramin && chan->ramin->vinst == inst)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000208 return chan;
209 }
210
211 return NULL;
212}
213
214int
215nv50_graph_create_context(struct nouveau_channel *chan)
216{
217 struct drm_device *dev = chan->dev;
218 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000219 struct nouveau_gpuobj *ramin = chan->ramin;
Marcin Kościelnickid5f3c902010-02-25 00:54:02 +0000220 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
Ben Skeggsec91db22010-07-08 11:53:19 +1000221 struct nouveau_grctx ctx = {};
Ben Skeggs6ee73862009-12-11 19:24:15 +1000222 int hdr, ret;
223
224 NV_DEBUG(dev, "ch%d\n", chan->id);
225
Ben Skeggs3052be22010-10-20 11:46:38 +1000226 ret = nouveau_gpuobj_new(dev, chan, pgraph->grctx_size, 0,
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000227 NVOBJ_FLAG_ZERO_ALLOC |
228 NVOBJ_FLAG_ZERO_FREE, &chan->ramin_grctx);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000229 if (ret)
230 return ret;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000231
Ben Skeggsac94a342010-07-08 15:28:48 +1000232 hdr = (dev_priv->chipset == 0x50) ? 0x200 : 0x20;
Ben Skeggsb3beb162010-09-01 15:24:29 +1000233 nv_wo32(ramin, hdr + 0x00, 0x00190002);
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000234 nv_wo32(ramin, hdr + 0x04, chan->ramin_grctx->vinst +
Ben Skeggsb3beb162010-09-01 15:24:29 +1000235 pgraph->grctx_size - 1);
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000236 nv_wo32(ramin, hdr + 0x08, chan->ramin_grctx->vinst);
Ben Skeggsb3beb162010-09-01 15:24:29 +1000237 nv_wo32(ramin, hdr + 0x0c, 0);
238 nv_wo32(ramin, hdr + 0x10, 0);
239 nv_wo32(ramin, hdr + 0x14, 0x00010000);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000240
Ben Skeggsec91db22010-07-08 11:53:19 +1000241 ctx.dev = chan->dev;
242 ctx.mode = NOUVEAU_GRCTX_VALS;
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000243 ctx.data = chan->ramin_grctx;
Ben Skeggsec91db22010-07-08 11:53:19 +1000244 nv50_grctx_init(&ctx);
245
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000246 nv_wo32(chan->ramin_grctx, 0x00000, chan->ramin->vinst >> 12);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000247
Ben Skeggsf56cb862010-07-08 11:29:10 +1000248 dev_priv->engine.instmem.flush(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000249 return 0;
250}
251
252void
253nv50_graph_destroy_context(struct nouveau_channel *chan)
254{
255 struct drm_device *dev = chan->dev;
256 struct drm_nouveau_private *dev_priv = dev->dev_private;
Francisco Jerez3945e472010-10-18 03:53:39 +0200257 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
Ben Skeggsac94a342010-07-08 15:28:48 +1000258 int i, hdr = (dev_priv->chipset == 0x50) ? 0x200 : 0x20;
Francisco Jerez3945e472010-10-18 03:53:39 +0200259 unsigned long flags;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000260
261 NV_DEBUG(dev, "ch%d\n", chan->id);
262
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000263 if (!chan->ramin)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000264 return;
265
Francisco Jerez3945e472010-10-18 03:53:39 +0200266 spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
267 pgraph->fifo_access(dev, false);
268
269 if (pgraph->channel(dev) == chan)
270 pgraph->unload_context(dev);
271
Ben Skeggs6ee73862009-12-11 19:24:15 +1000272 for (i = hdr; i < hdr + 24; i += 4)
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000273 nv_wo32(chan->ramin, i, 0);
Ben Skeggsf56cb862010-07-08 11:29:10 +1000274 dev_priv->engine.instmem.flush(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000275
Francisco Jerez3945e472010-10-18 03:53:39 +0200276 pgraph->fifo_access(dev, true);
277 spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
278
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000279 nouveau_gpuobj_ref(NULL, &chan->ramin_grctx);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000280}
281
282static int
283nv50_graph_do_load_context(struct drm_device *dev, uint32_t inst)
284{
285 uint32_t fifo = nv_rd32(dev, 0x400500);
286
287 nv_wr32(dev, 0x400500, fifo & ~1);
288 nv_wr32(dev, 0x400784, inst);
289 nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) | 0x40);
290 nv_wr32(dev, 0x400320, nv_rd32(dev, 0x400320) | 0x11);
291 nv_wr32(dev, 0x400040, 0xffffffff);
292 (void)nv_rd32(dev, 0x400040);
293 nv_wr32(dev, 0x400040, 0x00000000);
294 nv_wr32(dev, 0x400304, nv_rd32(dev, 0x400304) | 1);
295
296 if (nouveau_wait_for_idle(dev))
297 nv_wr32(dev, 0x40032c, inst | (1<<31));
298 nv_wr32(dev, 0x400500, fifo);
299
300 return 0;
301}
302
303int
304nv50_graph_load_context(struct nouveau_channel *chan)
305{
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000306 uint32_t inst = chan->ramin->vinst >> 12;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000307
308 NV_DEBUG(chan->dev, "ch%d\n", chan->id);
309 return nv50_graph_do_load_context(chan->dev, inst);
310}
311
312int
313nv50_graph_unload_context(struct drm_device *dev)
314{
Maarten Maathuisa51a3bf2010-02-01 18:32:09 +0100315 uint32_t inst;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000316
317 inst = nv_rd32(dev, NV50_PGRAPH_CTXCTL_CUR);
318 if (!(inst & NV50_PGRAPH_CTXCTL_CUR_LOADED))
319 return 0;
320 inst &= NV50_PGRAPH_CTXCTL_CUR_INSTANCE;
321
Maarten Maathuis0a90dc512010-01-11 21:18:53 +0100322 nouveau_wait_for_idle(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000323 nv_wr32(dev, 0x400784, inst);
324 nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) | 0x20);
325 nv_wr32(dev, 0x400304, nv_rd32(dev, 0x400304) | 0x01);
326 nouveau_wait_for_idle(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000327
328 nv_wr32(dev, NV50_PGRAPH_CTXCTL_CUR, inst);
329 return 0;
330}
331
Ben Skeggs274fec92010-11-03 13:16:18 +1000332static void
Ben Skeggs6ee73862009-12-11 19:24:15 +1000333nv50_graph_context_switch(struct drm_device *dev)
334{
335 uint32_t inst;
336
337 nv50_graph_unload_context(dev);
338
339 inst = nv_rd32(dev, NV50_PGRAPH_CTXCTL_NEXT);
340 inst &= NV50_PGRAPH_CTXCTL_NEXT_INSTANCE;
341 nv50_graph_do_load_context(dev, inst);
342
343 nv_wr32(dev, NV40_PGRAPH_INTR_EN, nv_rd32(dev,
344 NV40_PGRAPH_INTR_EN) | NV_PGRAPH_INTR_CONTEXT_SWITCH);
345}
346
347static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000348nv50_graph_nvsw_dma_vblsem(struct nouveau_channel *chan,
349 u32 class, u32 mthd, u32 data)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000350{
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000351 struct nouveau_gpuobj *gpuobj;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000352
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000353 gpuobj = nouveau_ramht_find(chan, data);
354 if (!gpuobj)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000355 return -ENOENT;
356
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000357 if (nouveau_notifier_offset(gpuobj, NULL))
Ben Skeggs6ee73862009-12-11 19:24:15 +1000358 return -EINVAL;
359
Ben Skeggsa8eaebc2010-09-01 15:24:31 +1000360 chan->nvsw.vblsem = gpuobj;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000361 chan->nvsw.vblsem_offset = ~0;
362 return 0;
363}
364
365static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000366nv50_graph_nvsw_vblsem_offset(struct nouveau_channel *chan,
367 u32 class, u32 mthd, u32 data)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000368{
369 if (nouveau_notifier_offset(chan->nvsw.vblsem, &data))
370 return -ERANGE;
371
372 chan->nvsw.vblsem_offset = data >> 2;
373 return 0;
374}
375
376static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000377nv50_graph_nvsw_vblsem_release_val(struct nouveau_channel *chan,
378 u32 class, u32 mthd, u32 data)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000379{
380 chan->nvsw.vblsem_rval = data;
381 return 0;
382}
383
384static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000385nv50_graph_nvsw_vblsem_release(struct nouveau_channel *chan,
386 u32 class, u32 mthd, u32 data)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000387{
388 struct drm_device *dev = chan->dev;
389 struct drm_nouveau_private *dev_priv = dev->dev_private;
390
391 if (!chan->nvsw.vblsem || chan->nvsw.vblsem_offset == ~0 || data > 1)
392 return -EINVAL;
393
Francisco Jerez042206c2010-10-21 18:19:29 +0200394 drm_vblank_get(dev, data);
Francisco Jerez1f6d2de2010-10-24 14:15:58 +0200395
396 chan->nvsw.vblsem_head = data;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000397 list_add(&chan->nvsw.vbl_wait, &dev_priv->vbl_waiting);
Francisco Jerez1f6d2de2010-10-24 14:15:58 +0200398
Ben Skeggs6ee73862009-12-11 19:24:15 +1000399 return 0;
400}
401
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000402static int
Francisco Jerez332b2422010-10-20 23:35:40 +0200403nv50_graph_nvsw_mthd_page_flip(struct nouveau_channel *chan,
404 u32 class, u32 mthd, u32 data)
405{
406 struct nouveau_page_flip_state s;
407
408 if (!nouveau_finish_page_flip(chan, &s)) {
409 /* XXX - Do something here */
410 }
411
412 return 0;
413}
414
415static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000416nv50_graph_register(struct drm_device *dev)
417{
418 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000419
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000420 if (dev_priv->engine.graph.registered)
421 return 0;
422
423 NVOBJ_CLASS(dev, 0x506e, SW); /* nvsw */
424 NVOBJ_MTHD (dev, 0x506e, 0x018c, nv50_graph_nvsw_dma_vblsem);
425 NVOBJ_MTHD (dev, 0x506e, 0x0400, nv50_graph_nvsw_vblsem_offset);
426 NVOBJ_MTHD (dev, 0x506e, 0x0404, nv50_graph_nvsw_vblsem_release_val);
427 NVOBJ_MTHD (dev, 0x506e, 0x0408, nv50_graph_nvsw_vblsem_release);
Francisco Jerez332b2422010-10-20 23:35:40 +0200428 NVOBJ_MTHD (dev, 0x506e, 0x0500, nv50_graph_nvsw_mthd_page_flip);
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000429
430 NVOBJ_CLASS(dev, 0x0030, GR); /* null */
431 NVOBJ_CLASS(dev, 0x5039, GR); /* m2mf */
432 NVOBJ_CLASS(dev, 0x502d, GR); /* 2d */
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000433
434 /* tesla */
435 if (dev_priv->chipset == 0x50)
436 NVOBJ_CLASS(dev, 0x5097, GR); /* tesla (nv50) */
437 else
438 if (dev_priv->chipset < 0xa0)
439 NVOBJ_CLASS(dev, 0x8297, GR); /* tesla (nv8x/nv9x) */
440 else {
441 switch (dev_priv->chipset) {
442 case 0xa0:
443 case 0xaa:
444 case 0xac:
445 NVOBJ_CLASS(dev, 0x8397, GR);
446 break;
447 case 0xa3:
448 case 0xa5:
449 case 0xa8:
450 NVOBJ_CLASS(dev, 0x8597, GR);
451 break;
452 case 0xaf:
453 NVOBJ_CLASS(dev, 0x8697, GR);
454 break;
455 }
456 }
457
Ben Skeggsaa2c2e82010-11-04 13:40:15 +1000458 /* compute */
Ben Skeggsa169f092010-11-05 09:40:00 +1000459 NVOBJ_CLASS(dev, 0x50c0, GR);
460 if (dev_priv->chipset > 0xa0 &&
461 dev_priv->chipset != 0xaa &&
462 dev_priv->chipset != 0xac)
Ben Skeggsaa2c2e82010-11-04 13:40:15 +1000463 NVOBJ_CLASS(dev, 0x85c0, GR);
464
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000465 dev_priv->engine.graph.registered = true;
466 return 0;
467}
Ben Skeggs56ac7472010-10-22 10:26:24 +1000468
469void
470nv50_graph_tlb_flush(struct drm_device *dev)
471{
Ben Skeggsa11c3192010-08-27 10:00:25 +1000472 nv50_vm_flush_engine(dev, 0);
Ben Skeggs56ac7472010-10-22 10:26:24 +1000473}
474
475void
476nv86_graph_tlb_flush(struct drm_device *dev)
477{
478 struct drm_nouveau_private *dev_priv = dev->dev_private;
479 struct nouveau_timer_engine *ptimer = &dev_priv->engine.timer;
480 bool idle, timeout = false;
481 unsigned long flags;
482 u64 start;
483 u32 tmp;
484
485 spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
486 nv_mask(dev, 0x400500, 0x00000001, 0x00000000);
487
488 start = ptimer->read(dev);
489 do {
490 idle = true;
491
492 for (tmp = nv_rd32(dev, 0x400380); tmp && idle; tmp >>= 3) {
493 if ((tmp & 7) == 1)
494 idle = false;
495 }
496
497 for (tmp = nv_rd32(dev, 0x400384); tmp && idle; tmp >>= 3) {
498 if ((tmp & 7) == 1)
499 idle = false;
500 }
501
502 for (tmp = nv_rd32(dev, 0x400388); tmp && idle; tmp >>= 3) {
503 if ((tmp & 7) == 1)
504 idle = false;
505 }
506 } while (!idle && !(timeout = ptimer->read(dev) - start > 2000000000));
507
508 if (timeout) {
509 NV_ERROR(dev, "PGRAPH TLB flush idle timeout fail: "
510 "0x%08x 0x%08x 0x%08x 0x%08x\n",
511 nv_rd32(dev, 0x400700), nv_rd32(dev, 0x400380),
512 nv_rd32(dev, 0x400384), nv_rd32(dev, 0x400388));
513 }
514
Ben Skeggsa11c3192010-08-27 10:00:25 +1000515 nv50_vm_flush_engine(dev, 0);
Ben Skeggs56ac7472010-10-22 10:26:24 +1000516
517 nv_mask(dev, 0x400500, 0x00000001, 0x00000001);
518 spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
519}
Ben Skeggs274fec92010-11-03 13:16:18 +1000520
521static struct nouveau_enum nv50_mp_exec_error_names[] =
522{
523 { 3, "STACK_UNDERFLOW" },
524 { 4, "QUADON_ACTIVE" },
525 { 8, "TIMEOUT" },
526 { 0x10, "INVALID_OPCODE" },
527 { 0x40, "BREAKPOINT" },
528 {}
529};
530
531static struct nouveau_bitfield nv50_graph_trap_m2mf[] = {
532 { 0x00000001, "NOTIFY" },
533 { 0x00000002, "IN" },
534 { 0x00000004, "OUT" },
535 {}
536};
537
538static struct nouveau_bitfield nv50_graph_trap_vfetch[] = {
539 { 0x00000001, "FAULT" },
540 {}
541};
542
543static struct nouveau_bitfield nv50_graph_trap_strmout[] = {
544 { 0x00000001, "FAULT" },
545 {}
546};
547
548static struct nouveau_bitfield nv50_graph_trap_ccache[] = {
549 { 0x00000001, "FAULT" },
550 {}
551};
552
553/* There must be a *lot* of these. Will take some time to gather them up. */
554static struct nouveau_enum nv50_data_error_names[] = {
555 { 4, "INVALID_VALUE" },
556 { 5, "INVALID_ENUM" },
557 { 8, "INVALID_OBJECT" },
558 { 0xc, "INVALID_BITFIELD" },
559 { 0x28, "MP_NO_REG_SPACE" },
560 { 0x2b, "MP_BLOCK_SIZE_MISMATCH" },
561 {}
562};
563
564static struct nouveau_bitfield nv50_graph_intr[] = {
565 { 0x00000001, "NOTIFY" },
566 { 0x00000002, "COMPUTE_QUERY" },
567 { 0x00000010, "ILLEGAL_MTHD" },
568 { 0x00000020, "ILLEGAL_CLASS" },
569 { 0x00000040, "DOUBLE_NOTIFY" },
570 { 0x00001000, "CONTEXT_SWITCH" },
571 { 0x00010000, "BUFFER_NOTIFY" },
572 { 0x00100000, "DATA_ERROR" },
573 { 0x00200000, "TRAP" },
574 { 0x01000000, "SINGLE_STEP" },
575 {}
576};
577
578static void
579nv50_pgraph_mp_trap(struct drm_device *dev, int tpid, int display)
580{
581 struct drm_nouveau_private *dev_priv = dev->dev_private;
582 uint32_t units = nv_rd32(dev, 0x1540);
583 uint32_t addr, mp10, status, pc, oplow, ophigh;
584 int i;
585 int mps = 0;
586 for (i = 0; i < 4; i++) {
587 if (!(units & 1 << (i+24)))
588 continue;
589 if (dev_priv->chipset < 0xa0)
590 addr = 0x408200 + (tpid << 12) + (i << 7);
591 else
592 addr = 0x408100 + (tpid << 11) + (i << 7);
593 mp10 = nv_rd32(dev, addr + 0x10);
594 status = nv_rd32(dev, addr + 0x14);
595 if (!status)
596 continue;
597 if (display) {
598 nv_rd32(dev, addr + 0x20);
599 pc = nv_rd32(dev, addr + 0x24);
600 oplow = nv_rd32(dev, addr + 0x70);
601 ophigh= nv_rd32(dev, addr + 0x74);
602 NV_INFO(dev, "PGRAPH_TRAP_MP_EXEC - "
603 "TP %d MP %d: ", tpid, i);
604 nouveau_enum_print(nv50_mp_exec_error_names, status);
605 printk(" at %06x warp %d, opcode %08x %08x\n",
606 pc&0xffffff, pc >> 24,
607 oplow, ophigh);
608 }
609 nv_wr32(dev, addr + 0x10, mp10);
610 nv_wr32(dev, addr + 0x14, 0);
611 mps++;
612 }
613 if (!mps && display)
614 NV_INFO(dev, "PGRAPH_TRAP_MP_EXEC - TP %d: "
615 "No MPs claiming errors?\n", tpid);
616}
617
618static void
619nv50_pgraph_tp_trap(struct drm_device *dev, int type, uint32_t ustatus_old,
620 uint32_t ustatus_new, int display, const char *name)
621{
622 struct drm_nouveau_private *dev_priv = dev->dev_private;
623 int tps = 0;
624 uint32_t units = nv_rd32(dev, 0x1540);
625 int i, r;
626 uint32_t ustatus_addr, ustatus;
627 for (i = 0; i < 16; i++) {
628 if (!(units & (1 << i)))
629 continue;
630 if (dev_priv->chipset < 0xa0)
631 ustatus_addr = ustatus_old + (i << 12);
632 else
633 ustatus_addr = ustatus_new + (i << 11);
634 ustatus = nv_rd32(dev, ustatus_addr) & 0x7fffffff;
635 if (!ustatus)
636 continue;
637 tps++;
638 switch (type) {
639 case 6: /* texture error... unknown for now */
640 nv50_fb_vm_trap(dev, display, name);
641 if (display) {
642 NV_ERROR(dev, "magic set %d:\n", i);
643 for (r = ustatus_addr + 4; r <= ustatus_addr + 0x10; r += 4)
644 NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
645 nv_rd32(dev, r));
646 }
647 break;
648 case 7: /* MP error */
649 if (ustatus & 0x00010000) {
650 nv50_pgraph_mp_trap(dev, i, display);
651 ustatus &= ~0x00010000;
652 }
653 break;
654 case 8: /* TPDMA error */
655 {
656 uint32_t e0c = nv_rd32(dev, ustatus_addr + 4);
657 uint32_t e10 = nv_rd32(dev, ustatus_addr + 8);
658 uint32_t e14 = nv_rd32(dev, ustatus_addr + 0xc);
659 uint32_t e18 = nv_rd32(dev, ustatus_addr + 0x10);
660 uint32_t e1c = nv_rd32(dev, ustatus_addr + 0x14);
661 uint32_t e20 = nv_rd32(dev, ustatus_addr + 0x18);
662 uint32_t e24 = nv_rd32(dev, ustatus_addr + 0x1c);
663 nv50_fb_vm_trap(dev, display, name);
664 /* 2d engine destination */
665 if (ustatus & 0x00000010) {
666 if (display) {
667 NV_INFO(dev, "PGRAPH_TRAP_TPDMA_2D - TP %d - Unknown fault at address %02x%08x\n",
668 i, e14, e10);
669 NV_INFO(dev, "PGRAPH_TRAP_TPDMA_2D - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
670 i, e0c, e18, e1c, e20, e24);
671 }
672 ustatus &= ~0x00000010;
673 }
674 /* Render target */
675 if (ustatus & 0x00000040) {
676 if (display) {
677 NV_INFO(dev, "PGRAPH_TRAP_TPDMA_RT - TP %d - Unknown fault at address %02x%08x\n",
678 i, e14, e10);
679 NV_INFO(dev, "PGRAPH_TRAP_TPDMA_RT - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
680 i, e0c, e18, e1c, e20, e24);
681 }
682 ustatus &= ~0x00000040;
683 }
684 /* CUDA memory: l[], g[] or stack. */
685 if (ustatus & 0x00000080) {
686 if (display) {
687 if (e18 & 0x80000000) {
688 /* g[] read fault? */
689 NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Global read fault at address %02x%08x\n",
690 i, e14, e10 | ((e18 >> 24) & 0x1f));
691 e18 &= ~0x1f000000;
692 } else if (e18 & 0xc) {
693 /* g[] write fault? */
694 NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Global write fault at address %02x%08x\n",
695 i, e14, e10 | ((e18 >> 7) & 0x1f));
696 e18 &= ~0x00000f80;
697 } else {
698 NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Unknown CUDA fault at address %02x%08x\n",
699 i, e14, e10);
700 }
701 NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
702 i, e0c, e18, e1c, e20, e24);
703 }
704 ustatus &= ~0x00000080;
705 }
706 }
707 break;
708 }
709 if (ustatus) {
710 if (display)
711 NV_INFO(dev, "%s - TP%d: Unhandled ustatus 0x%08x\n", name, i, ustatus);
712 }
713 nv_wr32(dev, ustatus_addr, 0xc0000000);
714 }
715
716 if (!tps && display)
717 NV_INFO(dev, "%s - No TPs claiming errors?\n", name);
718}
719
720static int
721nv50_pgraph_trap_handler(struct drm_device *dev, u32 display, u64 inst, u32 chid)
722{
723 u32 status = nv_rd32(dev, 0x400108);
724 u32 ustatus;
725
726 if (!status && display) {
727 NV_INFO(dev, "PGRAPH - TRAP: no units reporting traps?\n");
728 return 1;
729 }
730
731 /* DISPATCH: Relays commands to other units and handles NOTIFY,
732 * COND, QUERY. If you get a trap from it, the command is still stuck
733 * in DISPATCH and you need to do something about it. */
734 if (status & 0x001) {
735 ustatus = nv_rd32(dev, 0x400804) & 0x7fffffff;
736 if (!ustatus && display) {
737 NV_INFO(dev, "PGRAPH_TRAP_DISPATCH - no ustatus?\n");
738 }
739
740 nv_wr32(dev, 0x400500, 0x00000000);
741
742 /* Known to be triggered by screwed up NOTIFY and COND... */
743 if (ustatus & 0x00000001) {
744 u32 addr = nv_rd32(dev, 0x400808);
745 u32 subc = (addr & 0x00070000) >> 16;
746 u32 mthd = (addr & 0x00001ffc);
747 u32 datal = nv_rd32(dev, 0x40080c);
748 u32 datah = nv_rd32(dev, 0x400810);
749 u32 class = nv_rd32(dev, 0x400814);
750 u32 r848 = nv_rd32(dev, 0x400848);
751
752 NV_INFO(dev, "PGRAPH - TRAP DISPATCH_FAULT\n");
753 if (display && (addr & 0x80000000)) {
754 NV_INFO(dev, "PGRAPH - ch %d (0x%010llx) "
755 "subc %d class 0x%04x mthd 0x%04x "
756 "data 0x%08x%08x "
757 "400808 0x%08x 400848 0x%08x\n",
758 chid, inst, subc, class, mthd, datah,
759 datal, addr, r848);
760 } else
761 if (display) {
762 NV_INFO(dev, "PGRAPH - no stuck command?\n");
763 }
764
765 nv_wr32(dev, 0x400808, 0);
766 nv_wr32(dev, 0x4008e8, nv_rd32(dev, 0x4008e8) & 3);
767 nv_wr32(dev, 0x400848, 0);
768 ustatus &= ~0x00000001;
769 }
770
771 if (ustatus & 0x00000002) {
772 u32 addr = nv_rd32(dev, 0x40084c);
773 u32 subc = (addr & 0x00070000) >> 16;
774 u32 mthd = (addr & 0x00001ffc);
775 u32 data = nv_rd32(dev, 0x40085c);
776 u32 class = nv_rd32(dev, 0x400814);
777
778 NV_INFO(dev, "PGRAPH - TRAP DISPATCH_QUERY\n");
779 if (display && (addr & 0x80000000)) {
780 NV_INFO(dev, "PGRAPH - ch %d (0x%010llx) "
781 "subc %d class 0x%04x mthd 0x%04x "
782 "data 0x%08x 40084c 0x%08x\n",
783 chid, inst, subc, class, mthd,
784 data, addr);
785 } else
786 if (display) {
787 NV_INFO(dev, "PGRAPH - no stuck command?\n");
788 }
789
790 nv_wr32(dev, 0x40084c, 0);
791 ustatus &= ~0x00000002;
792 }
793
794 if (ustatus && display) {
795 NV_INFO(dev, "PGRAPH - TRAP_DISPATCH (unknown "
796 "0x%08x)\n", ustatus);
797 }
798
799 nv_wr32(dev, 0x400804, 0xc0000000);
800 nv_wr32(dev, 0x400108, 0x001);
801 status &= ~0x001;
802 if (!status)
803 return 0;
804 }
805
806 /* M2MF: Memory to memory copy engine. */
807 if (status & 0x002) {
808 u32 ustatus = nv_rd32(dev, 0x406800) & 0x7fffffff;
809 if (display) {
810 NV_INFO(dev, "PGRAPH - TRAP_M2MF");
811 nouveau_bitfield_print(nv50_graph_trap_m2mf, ustatus);
812 printk("\n");
813 NV_INFO(dev, "PGRAPH - TRAP_M2MF %08x %08x %08x %08x\n",
814 nv_rd32(dev, 0x406804), nv_rd32(dev, 0x406808),
815 nv_rd32(dev, 0x40680c), nv_rd32(dev, 0x406810));
816
817 }
818
819 /* No sane way found yet -- just reset the bugger. */
820 nv_wr32(dev, 0x400040, 2);
821 nv_wr32(dev, 0x400040, 0);
822 nv_wr32(dev, 0x406800, 0xc0000000);
823 nv_wr32(dev, 0x400108, 0x002);
824 status &= ~0x002;
825 }
826
827 /* VFETCH: Fetches data from vertex buffers. */
828 if (status & 0x004) {
829 u32 ustatus = nv_rd32(dev, 0x400c04) & 0x7fffffff;
830 if (display) {
831 NV_INFO(dev, "PGRAPH - TRAP_VFETCH");
832 nouveau_bitfield_print(nv50_graph_trap_vfetch, ustatus);
833 printk("\n");
834 NV_INFO(dev, "PGRAPH - TRAP_VFETCH %08x %08x %08x %08x\n",
835 nv_rd32(dev, 0x400c00), nv_rd32(dev, 0x400c08),
836 nv_rd32(dev, 0x400c0c), nv_rd32(dev, 0x400c10));
837 }
838
839 nv_wr32(dev, 0x400c04, 0xc0000000);
840 nv_wr32(dev, 0x400108, 0x004);
841 status &= ~0x004;
842 }
843
844 /* STRMOUT: DirectX streamout / OpenGL transform feedback. */
845 if (status & 0x008) {
846 ustatus = nv_rd32(dev, 0x401800) & 0x7fffffff;
847 if (display) {
848 NV_INFO(dev, "PGRAPH - TRAP_STRMOUT");
849 nouveau_bitfield_print(nv50_graph_trap_strmout, ustatus);
850 printk("\n");
851 NV_INFO(dev, "PGRAPH - TRAP_STRMOUT %08x %08x %08x %08x\n",
852 nv_rd32(dev, 0x401804), nv_rd32(dev, 0x401808),
853 nv_rd32(dev, 0x40180c), nv_rd32(dev, 0x401810));
854
855 }
856
857 /* No sane way found yet -- just reset the bugger. */
858 nv_wr32(dev, 0x400040, 0x80);
859 nv_wr32(dev, 0x400040, 0);
860 nv_wr32(dev, 0x401800, 0xc0000000);
861 nv_wr32(dev, 0x400108, 0x008);
862 status &= ~0x008;
863 }
864
865 /* CCACHE: Handles code and c[] caches and fills them. */
866 if (status & 0x010) {
867 ustatus = nv_rd32(dev, 0x405018) & 0x7fffffff;
868 if (display) {
869 NV_INFO(dev, "PGRAPH - TRAP_CCACHE");
870 nouveau_bitfield_print(nv50_graph_trap_ccache, ustatus);
871 printk("\n");
872 NV_INFO(dev, "PGRAPH - TRAP_CCACHE %08x %08x %08x %08x"
873 " %08x %08x %08x\n",
874 nv_rd32(dev, 0x405800), nv_rd32(dev, 0x405804),
875 nv_rd32(dev, 0x405808), nv_rd32(dev, 0x40580c),
876 nv_rd32(dev, 0x405810), nv_rd32(dev, 0x405814),
877 nv_rd32(dev, 0x40581c));
878
879 }
880
881 nv_wr32(dev, 0x405018, 0xc0000000);
882 nv_wr32(dev, 0x400108, 0x010);
883 status &= ~0x010;
884 }
885
886 /* Unknown, not seen yet... 0x402000 is the only trap status reg
887 * remaining, so try to handle it anyway. Perhaps related to that
888 * unknown DMA slot on tesla? */
889 if (status & 0x20) {
890 ustatus = nv_rd32(dev, 0x402000) & 0x7fffffff;
891 if (display)
892 NV_INFO(dev, "PGRAPH - TRAP_UNKC04 0x%08x\n", ustatus);
893 nv_wr32(dev, 0x402000, 0xc0000000);
894 /* no status modifiction on purpose */
895 }
896
897 /* TEXTURE: CUDA texturing units */
898 if (status & 0x040) {
899 nv50_pgraph_tp_trap(dev, 6, 0x408900, 0x408600, display,
900 "PGRAPH - TRAP_TEXTURE");
901 nv_wr32(dev, 0x400108, 0x040);
902 status &= ~0x040;
903 }
904
905 /* MP: CUDA execution engines. */
906 if (status & 0x080) {
907 nv50_pgraph_tp_trap(dev, 7, 0x408314, 0x40831c, display,
908 "PGRAPH - TRAP_MP");
909 nv_wr32(dev, 0x400108, 0x080);
910 status &= ~0x080;
911 }
912
913 /* TPDMA: Handles TP-initiated uncached memory accesses:
914 * l[], g[], stack, 2d surfaces, render targets. */
915 if (status & 0x100) {
916 nv50_pgraph_tp_trap(dev, 8, 0x408e08, 0x408708, display,
917 "PGRAPH - TRAP_TPDMA");
918 nv_wr32(dev, 0x400108, 0x100);
919 status &= ~0x100;
920 }
921
922 if (status) {
923 if (display)
924 NV_INFO(dev, "PGRAPH - TRAP: unknown 0x%08x\n", status);
925 nv_wr32(dev, 0x400108, status);
926 }
927
928 return 1;
929}
930
931static int
932nv50_graph_isr_chid(struct drm_device *dev, u64 inst)
933{
934 struct drm_nouveau_private *dev_priv = dev->dev_private;
935 struct nouveau_channel *chan;
936 unsigned long flags;
937 int i;
938
939 spin_lock_irqsave(&dev_priv->channels.lock, flags);
940 for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
941 chan = dev_priv->channels.ptr[i];
942 if (!chan || !chan->ramin)
943 continue;
944
945 if (inst == chan->ramin->vinst)
946 break;
947 }
948 spin_unlock_irqrestore(&dev_priv->channels.lock, flags);
949 return i;
950}
951
952static void
953nv50_graph_isr(struct drm_device *dev)
954{
955 u32 stat;
956
957 while ((stat = nv_rd32(dev, 0x400100))) {
958 u64 inst = (u64)(nv_rd32(dev, 0x40032c) & 0x0fffffff) << 12;
959 u32 chid = nv50_graph_isr_chid(dev, inst);
960 u32 addr = nv_rd32(dev, NV04_PGRAPH_TRAPPED_ADDR);
961 u32 subc = (addr & 0x00070000) >> 16;
962 u32 mthd = (addr & 0x00001ffc);
963 u32 data = nv_rd32(dev, NV04_PGRAPH_TRAPPED_DATA);
964 u32 class = nv_rd32(dev, 0x400814);
965 u32 show = stat;
966
967 if (stat & 0x00000010) {
968 if (!nouveau_gpuobj_mthd_call2(dev, chid, class,
969 mthd, data))
970 show &= ~0x00000010;
971 }
972
973 if (stat & 0x00001000) {
974 nv_wr32(dev, 0x400500, 0x00000000);
975 nv_wr32(dev, 0x400100, 0x00001000);
976 nv_mask(dev, 0x40013c, 0x00001000, 0x00000000);
977 nv50_graph_context_switch(dev);
978 stat &= ~0x00001000;
979 show &= ~0x00001000;
980 }
981
982 show = (show && nouveau_ratelimit()) ? show : 0;
983
984 if (show & 0x00100000) {
985 u32 ecode = nv_rd32(dev, 0x400110);
986 NV_INFO(dev, "PGRAPH - DATA_ERROR ");
987 nouveau_enum_print(nv50_data_error_names, ecode);
988 printk("\n");
989 }
990
991 if (stat & 0x00200000) {
992 if (!nv50_pgraph_trap_handler(dev, show, inst, chid))
993 show &= ~0x00200000;
994 }
995
996 nv_wr32(dev, 0x400100, stat);
997 nv_wr32(dev, 0x400500, 0x00010001);
998
999 if (show) {
1000 NV_INFO(dev, "PGRAPH -");
1001 nouveau_bitfield_print(nv50_graph_intr, show);
1002 printk("\n");
1003 NV_INFO(dev, "PGRAPH - ch %d (0x%010llx) subc %d "
1004 "class 0x%04x mthd 0x%04x data 0x%08x\n",
1005 chid, inst, subc, class, mthd, data);
1006 }
1007 }
1008
1009 if (nv_rd32(dev, 0x400824) & (1 << 31))
1010 nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) & ~(1 << 31));
1011}