2 * Copyright (C) 2007 Ben Skeggs.
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:
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.
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.
29 #include "nouveau_drv.h"
30 #include "nouveau_fifo.h"
31 #include "nouveau_ramht.h"
32 #include "nouveau_dma.h"
33 #include "nouveau_vm.h"
36 struct nv50_graph_engine
{
37 struct nouveau_exec_engine base
;
44 nv50_graph_init(struct drm_device
*dev
, int engine
)
46 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
47 struct nv50_graph_engine
*pgraph
= nv_engine(dev
, engine
);
48 u32 units
= nv_rd32(dev
, 0x001540);
54 nv_mask(dev
, 0x000200, 0x00201000, 0x00000000);
55 nv_mask(dev
, 0x000200, 0x00201000, 0x00201000);
56 nv_wr32(dev
, 0x40008c, 0x00000004); /* HW_CTX_SWITCH_ENABLED */
58 /* reset/enable traps and interrupts */
59 nv_wr32(dev
, 0x400804, 0xc0000000);
60 nv_wr32(dev
, 0x406800, 0xc0000000);
61 nv_wr32(dev
, 0x400c04, 0xc0000000);
62 nv_wr32(dev
, 0x401800, 0xc0000000);
63 nv_wr32(dev
, 0x405018, 0xc0000000);
64 nv_wr32(dev
, 0x402000, 0xc0000000);
65 for (i
= 0; i
< 16; i
++) {
66 if (!(units
& (1 << i
)))
69 if (dev_priv
->chipset
< 0xa0) {
70 nv_wr32(dev
, 0x408900 + (i
<< 12), 0xc0000000);
71 nv_wr32(dev
, 0x408e08 + (i
<< 12), 0xc0000000);
72 nv_wr32(dev
, 0x408314 + (i
<< 12), 0xc0000000);
74 nv_wr32(dev
, 0x408600 + (i
<< 11), 0xc0000000);
75 nv_wr32(dev
, 0x408708 + (i
<< 11), 0xc0000000);
76 nv_wr32(dev
, 0x40831c + (i
<< 11), 0xc0000000);
80 nv_wr32(dev
, 0x400108, 0xffffffff);
81 nv_wr32(dev
, 0x400138, 0xffffffff);
82 nv_wr32(dev
, 0x400100, 0xffffffff);
83 nv_wr32(dev
, 0x40013c, 0xffffffff);
84 nv_wr32(dev
, 0x400500, 0x00010001);
86 /* upload context program, initialise ctxctl defaults */
87 nv_wr32(dev
, 0x400324, 0x00000000);
88 for (i
= 0; i
< pgraph
->ctxprog_size
; i
++)
89 nv_wr32(dev
, 0x400328, pgraph
->ctxprog
[i
]);
90 nv_wr32(dev
, 0x400824, 0x00000000);
91 nv_wr32(dev
, 0x400828, 0x00000000);
92 nv_wr32(dev
, 0x40082c, 0x00000000);
93 nv_wr32(dev
, 0x400830, 0x00000000);
94 nv_wr32(dev
, 0x400724, 0x00000000);
95 nv_wr32(dev
, 0x40032c, 0x00000000);
96 nv_wr32(dev
, 0x400320, 4); /* CTXCTL_CMD = NEWCTXDMA */
98 /* some unknown zcull magic */
99 switch (dev_priv
->chipset
& 0xf0) {
103 nv_wr32(dev
, 0x402ca8, 0x00000800);
107 nv_wr32(dev
, 0x402cc0, 0x00000000);
108 if (dev_priv
->chipset
== 0xa0 ||
109 dev_priv
->chipset
== 0xaa ||
110 dev_priv
->chipset
== 0xac) {
111 nv_wr32(dev
, 0x402ca8, 0x00000802);
113 nv_wr32(dev
, 0x402cc0, 0x00000000);
114 nv_wr32(dev
, 0x402ca8, 0x00000002);
120 /* zero out zcull regions */
121 for (i
= 0; i
< 8; i
++) {
122 nv_wr32(dev
, 0x402c20 + (i
* 8), 0x00000000);
123 nv_wr32(dev
, 0x402c24 + (i
* 8), 0x00000000);
124 nv_wr32(dev
, 0x402c28 + (i
* 8), 0x00000000);
125 nv_wr32(dev
, 0x402c2c + (i
* 8), 0x00000000);
132 nv50_graph_fini(struct drm_device
*dev
, int engine
, bool suspend
)
134 nv_wr32(dev
, 0x40013c, 0x00000000);
139 nv50_graph_context_new(struct nouveau_channel
*chan
, int engine
)
141 struct drm_device
*dev
= chan
->dev
;
142 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
143 struct nouveau_gpuobj
*ramin
= chan
->ramin
;
144 struct nouveau_gpuobj
*grctx
= NULL
;
145 struct nv50_graph_engine
*pgraph
= nv_engine(dev
, engine
);
148 NV_DEBUG(dev
, "ch%d\n", chan
->id
);
150 ret
= nouveau_gpuobj_new(dev
, NULL
, pgraph
->grctx_size
, 0,
151 NVOBJ_FLAG_ZERO_ALLOC
|
152 NVOBJ_FLAG_ZERO_FREE
, &grctx
);
156 hdr
= (dev_priv
->chipset
== 0x50) ? 0x200 : 0x20;
157 nv_wo32(ramin
, hdr
+ 0x00, 0x00190002);
158 nv_wo32(ramin
, hdr
+ 0x04, grctx
->vinst
+ grctx
->size
- 1);
159 nv_wo32(ramin
, hdr
+ 0x08, grctx
->vinst
);
160 nv_wo32(ramin
, hdr
+ 0x0c, 0);
161 nv_wo32(ramin
, hdr
+ 0x10, 0);
162 nv_wo32(ramin
, hdr
+ 0x14, 0x00010000);
164 nv50_grctx_fill(dev
, grctx
);
165 nv_wo32(grctx
, 0x00000, chan
->ramin
->vinst
>> 12);
167 dev_priv
->engine
.instmem
.flush(dev
);
169 atomic_inc(&chan
->vm
->engref
[NVOBJ_ENGINE_GR
]);
170 chan
->engctx
[NVOBJ_ENGINE_GR
] = grctx
;
175 nv50_graph_context_del(struct nouveau_channel
*chan
, int engine
)
177 struct nouveau_gpuobj
*grctx
= chan
->engctx
[engine
];
178 struct drm_device
*dev
= chan
->dev
;
179 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
180 int i
, hdr
= (dev_priv
->chipset
== 0x50) ? 0x200 : 0x20;
182 for (i
= hdr
; i
< hdr
+ 24; i
+= 4)
183 nv_wo32(chan
->ramin
, i
, 0);
184 dev_priv
->engine
.instmem
.flush(dev
);
186 atomic_dec(&chan
->vm
->engref
[engine
]);
187 nouveau_gpuobj_ref(NULL
, &grctx
);
188 chan
->engctx
[engine
] = NULL
;
192 nv50_graph_object_new(struct nouveau_channel
*chan
, int engine
,
193 u32 handle
, u16
class)
195 struct drm_device
*dev
= chan
->dev
;
196 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
197 struct nouveau_gpuobj
*obj
= NULL
;
200 ret
= nouveau_gpuobj_new(dev
, chan
, 16, 16, NVOBJ_FLAG_ZERO_FREE
, &obj
);
206 nv_wo32(obj
, 0x00, class);
207 nv_wo32(obj
, 0x04, 0x00000000);
208 nv_wo32(obj
, 0x08, 0x00000000);
209 nv_wo32(obj
, 0x0c, 0x00000000);
210 dev_priv
->engine
.instmem
.flush(dev
);
212 ret
= nouveau_ramht_insert(chan
, handle
, obj
);
213 nouveau_gpuobj_ref(NULL
, &obj
);
218 nv50_graph_tlb_flush(struct drm_device
*dev
, int engine
)
220 nv50_vm_flush_engine(dev
, 0);
224 nv84_graph_tlb_flush(struct drm_device
*dev
, int engine
)
226 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
227 struct nouveau_timer_engine
*ptimer
= &dev_priv
->engine
.timer
;
228 bool idle
, timeout
= false;
233 spin_lock_irqsave(&dev_priv
->context_switch_lock
, flags
);
234 nv_mask(dev
, 0x400500, 0x00000001, 0x00000000);
236 start
= ptimer
->read(dev
);
240 for (tmp
= nv_rd32(dev
, 0x400380); tmp
&& idle
; tmp
>>= 3) {
245 for (tmp
= nv_rd32(dev
, 0x400384); tmp
&& idle
; tmp
>>= 3) {
250 for (tmp
= nv_rd32(dev
, 0x400388); tmp
&& idle
; tmp
>>= 3) {
254 } while (!idle
&& !(timeout
= ptimer
->read(dev
) - start
> 2000000000));
257 NV_ERROR(dev
, "PGRAPH TLB flush idle timeout fail: "
258 "0x%08x 0x%08x 0x%08x 0x%08x\n",
259 nv_rd32(dev
, 0x400700), nv_rd32(dev
, 0x400380),
260 nv_rd32(dev
, 0x400384), nv_rd32(dev
, 0x400388));
263 nv50_vm_flush_engine(dev
, 0);
265 nv_mask(dev
, 0x400500, 0x00000001, 0x00000001);
266 spin_unlock_irqrestore(&dev_priv
->context_switch_lock
, flags
);
269 static struct nouveau_enum nv50_mp_exec_error_names
[] = {
270 { 3, "STACK_UNDERFLOW", NULL
},
271 { 4, "QUADON_ACTIVE", NULL
},
272 { 8, "TIMEOUT", NULL
},
273 { 0x10, "INVALID_OPCODE", NULL
},
274 { 0x40, "BREAKPOINT", NULL
},
278 static struct nouveau_bitfield nv50_graph_trap_m2mf
[] = {
279 { 0x00000001, "NOTIFY" },
280 { 0x00000002, "IN" },
281 { 0x00000004, "OUT" },
285 static struct nouveau_bitfield nv50_graph_trap_vfetch
[] = {
286 { 0x00000001, "FAULT" },
290 static struct nouveau_bitfield nv50_graph_trap_strmout
[] = {
291 { 0x00000001, "FAULT" },
295 static struct nouveau_bitfield nv50_graph_trap_ccache
[] = {
296 { 0x00000001, "FAULT" },
300 /* There must be a *lot* of these. Will take some time to gather them up. */
301 struct nouveau_enum nv50_data_error_names
[] = {
302 { 0x00000003, "INVALID_OPERATION", NULL
},
303 { 0x00000004, "INVALID_VALUE", NULL
},
304 { 0x00000005, "INVALID_ENUM", NULL
},
305 { 0x00000008, "INVALID_OBJECT", NULL
},
306 { 0x00000009, "READ_ONLY_OBJECT", NULL
},
307 { 0x0000000a, "SUPERVISOR_OBJECT", NULL
},
308 { 0x0000000b, "INVALID_ADDRESS_ALIGNMENT", NULL
},
309 { 0x0000000c, "INVALID_BITFIELD", NULL
},
310 { 0x0000000d, "BEGIN_END_ACTIVE", NULL
},
311 { 0x0000000e, "SEMANTIC_COLOR_BACK_OVER_LIMIT", NULL
},
312 { 0x0000000f, "VIEWPORT_ID_NEEDS_GP", NULL
},
313 { 0x00000010, "RT_DOUBLE_BIND", NULL
},
314 { 0x00000011, "RT_TYPES_MISMATCH", NULL
},
315 { 0x00000012, "RT_LINEAR_WITH_ZETA", NULL
},
316 { 0x00000015, "FP_TOO_FEW_REGS", NULL
},
317 { 0x00000016, "ZETA_FORMAT_CSAA_MISMATCH", NULL
},
318 { 0x00000017, "RT_LINEAR_WITH_MSAA", NULL
},
319 { 0x00000018, "FP_INTERPOLANT_START_OVER_LIMIT", NULL
},
320 { 0x00000019, "SEMANTIC_LAYER_OVER_LIMIT", NULL
},
321 { 0x0000001a, "RT_INVALID_ALIGNMENT", NULL
},
322 { 0x0000001b, "SAMPLER_OVER_LIMIT", NULL
},
323 { 0x0000001c, "TEXTURE_OVER_LIMIT", NULL
},
324 { 0x0000001e, "GP_TOO_MANY_OUTPUTS", NULL
},
325 { 0x0000001f, "RT_BPP128_WITH_MS8", NULL
},
326 { 0x00000021, "Z_OUT_OF_BOUNDS", NULL
},
327 { 0x00000023, "XY_OUT_OF_BOUNDS", NULL
},
328 { 0x00000024, "VP_ZERO_INPUTS", NULL
},
329 { 0x00000027, "CP_MORE_PARAMS_THAN_SHARED", NULL
},
330 { 0x00000028, "CP_NO_REG_SPACE_STRIPED", NULL
},
331 { 0x00000029, "CP_NO_REG_SPACE_PACKED", NULL
},
332 { 0x0000002a, "CP_NOT_ENOUGH_WARPS", NULL
},
333 { 0x0000002b, "CP_BLOCK_SIZE_MISMATCH", NULL
},
334 { 0x0000002c, "CP_NOT_ENOUGH_LOCAL_WARPS", NULL
},
335 { 0x0000002d, "CP_NOT_ENOUGH_STACK_WARPS", NULL
},
336 { 0x0000002e, "CP_NO_BLOCKDIM_LATCH", NULL
},
337 { 0x00000031, "ENG2D_FORMAT_MISMATCH", NULL
},
338 { 0x0000003f, "PRIMITIVE_ID_NEEDS_GP", NULL
},
339 { 0x00000044, "SEMANTIC_VIEWPORT_OVER_LIMIT", NULL
},
340 { 0x00000045, "SEMANTIC_COLOR_FRONT_OVER_LIMIT", NULL
},
341 { 0x00000046, "LAYER_ID_NEEDS_GP", NULL
},
342 { 0x00000047, "SEMANTIC_CLIP_OVER_LIMIT", NULL
},
343 { 0x00000048, "SEMANTIC_PTSZ_OVER_LIMIT", NULL
},
347 static struct nouveau_bitfield nv50_graph_intr
[] = {
348 { 0x00000001, "NOTIFY" },
349 { 0x00000002, "COMPUTE_QUERY" },
350 { 0x00000010, "ILLEGAL_MTHD" },
351 { 0x00000020, "ILLEGAL_CLASS" },
352 { 0x00000040, "DOUBLE_NOTIFY" },
353 { 0x00001000, "CONTEXT_SWITCH" },
354 { 0x00010000, "BUFFER_NOTIFY" },
355 { 0x00100000, "DATA_ERROR" },
356 { 0x00200000, "TRAP" },
357 { 0x01000000, "SINGLE_STEP" },
362 nv50_pgraph_mp_trap(struct drm_device
*dev
, int tpid
, int display
)
364 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
365 uint32_t units
= nv_rd32(dev
, 0x1540);
366 uint32_t addr
, mp10
, status
, pc
, oplow
, ophigh
;
369 for (i
= 0; i
< 4; i
++) {
370 if (!(units
& 1 << (i
+24)))
372 if (dev_priv
->chipset
< 0xa0)
373 addr
= 0x408200 + (tpid
<< 12) + (i
<< 7);
375 addr
= 0x408100 + (tpid
<< 11) + (i
<< 7);
376 mp10
= nv_rd32(dev
, addr
+ 0x10);
377 status
= nv_rd32(dev
, addr
+ 0x14);
381 nv_rd32(dev
, addr
+ 0x20);
382 pc
= nv_rd32(dev
, addr
+ 0x24);
383 oplow
= nv_rd32(dev
, addr
+ 0x70);
384 ophigh
= nv_rd32(dev
, addr
+ 0x74);
385 NV_INFO(dev
, "PGRAPH_TRAP_MP_EXEC - "
386 "TP %d MP %d: ", tpid
, i
);
387 nouveau_enum_print(nv50_mp_exec_error_names
, status
);
388 printk(" at %06x warp %d, opcode %08x %08x\n",
389 pc
&0xffffff, pc
>> 24,
392 nv_wr32(dev
, addr
+ 0x10, mp10
);
393 nv_wr32(dev
, addr
+ 0x14, 0);
397 NV_INFO(dev
, "PGRAPH_TRAP_MP_EXEC - TP %d: "
398 "No MPs claiming errors?\n", tpid
);
402 nv50_pgraph_tp_trap(struct drm_device
*dev
, int type
, uint32_t ustatus_old
,
403 uint32_t ustatus_new
, int display
, const char *name
)
405 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
407 uint32_t units
= nv_rd32(dev
, 0x1540);
409 uint32_t ustatus_addr
, ustatus
;
410 for (i
= 0; i
< 16; i
++) {
411 if (!(units
& (1 << i
)))
413 if (dev_priv
->chipset
< 0xa0)
414 ustatus_addr
= ustatus_old
+ (i
<< 12);
416 ustatus_addr
= ustatus_new
+ (i
<< 11);
417 ustatus
= nv_rd32(dev
, ustatus_addr
) & 0x7fffffff;
422 case 6: /* texture error... unknown for now */
424 NV_ERROR(dev
, "magic set %d:\n", i
);
425 for (r
= ustatus_addr
+ 4; r
<= ustatus_addr
+ 0x10; r
+= 4)
426 NV_ERROR(dev
, "\t0x%08x: 0x%08x\n", r
,
430 case 7: /* MP error */
431 if (ustatus
& 0x04030000) {
432 nv50_pgraph_mp_trap(dev
, i
, display
);
433 ustatus
&= ~0x04030000;
436 case 8: /* TPDMA error */
438 uint32_t e0c
= nv_rd32(dev
, ustatus_addr
+ 4);
439 uint32_t e10
= nv_rd32(dev
, ustatus_addr
+ 8);
440 uint32_t e14
= nv_rd32(dev
, ustatus_addr
+ 0xc);
441 uint32_t e18
= nv_rd32(dev
, ustatus_addr
+ 0x10);
442 uint32_t e1c
= nv_rd32(dev
, ustatus_addr
+ 0x14);
443 uint32_t e20
= nv_rd32(dev
, ustatus_addr
+ 0x18);
444 uint32_t e24
= nv_rd32(dev
, ustatus_addr
+ 0x1c);
445 /* 2d engine destination */
446 if (ustatus
& 0x00000010) {
448 NV_INFO(dev
, "PGRAPH_TRAP_TPDMA_2D - TP %d - Unknown fault at address %02x%08x\n",
450 NV_INFO(dev
, "PGRAPH_TRAP_TPDMA_2D - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
451 i
, e0c
, e18
, e1c
, e20
, e24
);
453 ustatus
&= ~0x00000010;
456 if (ustatus
& 0x00000040) {
458 NV_INFO(dev
, "PGRAPH_TRAP_TPDMA_RT - TP %d - Unknown fault at address %02x%08x\n",
460 NV_INFO(dev
, "PGRAPH_TRAP_TPDMA_RT - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
461 i
, e0c
, e18
, e1c
, e20
, e24
);
463 ustatus
&= ~0x00000040;
465 /* CUDA memory: l[], g[] or stack. */
466 if (ustatus
& 0x00000080) {
468 if (e18
& 0x80000000) {
469 /* g[] read fault? */
470 NV_INFO(dev
, "PGRAPH_TRAP_TPDMA - TP %d - Global read fault at address %02x%08x\n",
471 i
, e14
, e10
| ((e18
>> 24) & 0x1f));
473 } else if (e18
& 0xc) {
474 /* g[] write fault? */
475 NV_INFO(dev
, "PGRAPH_TRAP_TPDMA - TP %d - Global write fault at address %02x%08x\n",
476 i
, e14
, e10
| ((e18
>> 7) & 0x1f));
479 NV_INFO(dev
, "PGRAPH_TRAP_TPDMA - TP %d - Unknown CUDA fault at address %02x%08x\n",
482 NV_INFO(dev
, "PGRAPH_TRAP_TPDMA - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
483 i
, e0c
, e18
, e1c
, e20
, e24
);
485 ustatus
&= ~0x00000080;
492 NV_INFO(dev
, "%s - TP%d: Unhandled ustatus 0x%08x\n", name
, i
, ustatus
);
494 nv_wr32(dev
, ustatus_addr
, 0xc0000000);
498 NV_INFO(dev
, "%s - No TPs claiming errors?\n", name
);
502 nv50_pgraph_trap_handler(struct drm_device
*dev
, u32 display
, u64 inst
, u32 chid
)
504 u32 status
= nv_rd32(dev
, 0x400108);
507 if (!status
&& display
) {
508 NV_INFO(dev
, "PGRAPH - TRAP: no units reporting traps?\n");
512 /* DISPATCH: Relays commands to other units and handles NOTIFY,
513 * COND, QUERY. If you get a trap from it, the command is still stuck
514 * in DISPATCH and you need to do something about it. */
515 if (status
& 0x001) {
516 ustatus
= nv_rd32(dev
, 0x400804) & 0x7fffffff;
517 if (!ustatus
&& display
) {
518 NV_INFO(dev
, "PGRAPH_TRAP_DISPATCH - no ustatus?\n");
521 nv_wr32(dev
, 0x400500, 0x00000000);
523 /* Known to be triggered by screwed up NOTIFY and COND... */
524 if (ustatus
& 0x00000001) {
525 u32 addr
= nv_rd32(dev
, 0x400808);
526 u32 subc
= (addr
& 0x00070000) >> 16;
527 u32 mthd
= (addr
& 0x00001ffc);
528 u32 datal
= nv_rd32(dev
, 0x40080c);
529 u32 datah
= nv_rd32(dev
, 0x400810);
530 u32
class = nv_rd32(dev
, 0x400814);
531 u32 r848
= nv_rd32(dev
, 0x400848);
533 NV_INFO(dev
, "PGRAPH - TRAP DISPATCH_FAULT\n");
534 if (display
&& (addr
& 0x80000000)) {
535 NV_INFO(dev
, "PGRAPH - ch %d (0x%010llx) "
536 "subc %d class 0x%04x mthd 0x%04x "
538 "400808 0x%08x 400848 0x%08x\n",
539 chid
, inst
, subc
, class, mthd
, datah
,
543 NV_INFO(dev
, "PGRAPH - no stuck command?\n");
546 nv_wr32(dev
, 0x400808, 0);
547 nv_wr32(dev
, 0x4008e8, nv_rd32(dev
, 0x4008e8) & 3);
548 nv_wr32(dev
, 0x400848, 0);
549 ustatus
&= ~0x00000001;
552 if (ustatus
& 0x00000002) {
553 u32 addr
= nv_rd32(dev
, 0x40084c);
554 u32 subc
= (addr
& 0x00070000) >> 16;
555 u32 mthd
= (addr
& 0x00001ffc);
556 u32 data
= nv_rd32(dev
, 0x40085c);
557 u32
class = nv_rd32(dev
, 0x400814);
559 NV_INFO(dev
, "PGRAPH - TRAP DISPATCH_QUERY\n");
560 if (display
&& (addr
& 0x80000000)) {
561 NV_INFO(dev
, "PGRAPH - ch %d (0x%010llx) "
562 "subc %d class 0x%04x mthd 0x%04x "
563 "data 0x%08x 40084c 0x%08x\n",
564 chid
, inst
, subc
, class, mthd
,
568 NV_INFO(dev
, "PGRAPH - no stuck command?\n");
571 nv_wr32(dev
, 0x40084c, 0);
572 ustatus
&= ~0x00000002;
575 if (ustatus
&& display
) {
576 NV_INFO(dev
, "PGRAPH - TRAP_DISPATCH (unknown "
577 "0x%08x)\n", ustatus
);
580 nv_wr32(dev
, 0x400804, 0xc0000000);
581 nv_wr32(dev
, 0x400108, 0x001);
587 /* M2MF: Memory to memory copy engine. */
588 if (status
& 0x002) {
589 u32 ustatus
= nv_rd32(dev
, 0x406800) & 0x7fffffff;
591 NV_INFO(dev
, "PGRAPH - TRAP_M2MF");
592 nouveau_bitfield_print(nv50_graph_trap_m2mf
, ustatus
);
594 NV_INFO(dev
, "PGRAPH - TRAP_M2MF %08x %08x %08x %08x\n",
595 nv_rd32(dev
, 0x406804), nv_rd32(dev
, 0x406808),
596 nv_rd32(dev
, 0x40680c), nv_rd32(dev
, 0x406810));
600 /* No sane way found yet -- just reset the bugger. */
601 nv_wr32(dev
, 0x400040, 2);
602 nv_wr32(dev
, 0x400040, 0);
603 nv_wr32(dev
, 0x406800, 0xc0000000);
604 nv_wr32(dev
, 0x400108, 0x002);
608 /* VFETCH: Fetches data from vertex buffers. */
609 if (status
& 0x004) {
610 u32 ustatus
= nv_rd32(dev
, 0x400c04) & 0x7fffffff;
612 NV_INFO(dev
, "PGRAPH - TRAP_VFETCH");
613 nouveau_bitfield_print(nv50_graph_trap_vfetch
, ustatus
);
615 NV_INFO(dev
, "PGRAPH - TRAP_VFETCH %08x %08x %08x %08x\n",
616 nv_rd32(dev
, 0x400c00), nv_rd32(dev
, 0x400c08),
617 nv_rd32(dev
, 0x400c0c), nv_rd32(dev
, 0x400c10));
620 nv_wr32(dev
, 0x400c04, 0xc0000000);
621 nv_wr32(dev
, 0x400108, 0x004);
625 /* STRMOUT: DirectX streamout / OpenGL transform feedback. */
626 if (status
& 0x008) {
627 ustatus
= nv_rd32(dev
, 0x401800) & 0x7fffffff;
629 NV_INFO(dev
, "PGRAPH - TRAP_STRMOUT");
630 nouveau_bitfield_print(nv50_graph_trap_strmout
, ustatus
);
632 NV_INFO(dev
, "PGRAPH - TRAP_STRMOUT %08x %08x %08x %08x\n",
633 nv_rd32(dev
, 0x401804), nv_rd32(dev
, 0x401808),
634 nv_rd32(dev
, 0x40180c), nv_rd32(dev
, 0x401810));
638 /* No sane way found yet -- just reset the bugger. */
639 nv_wr32(dev
, 0x400040, 0x80);
640 nv_wr32(dev
, 0x400040, 0);
641 nv_wr32(dev
, 0x401800, 0xc0000000);
642 nv_wr32(dev
, 0x400108, 0x008);
646 /* CCACHE: Handles code and c[] caches and fills them. */
647 if (status
& 0x010) {
648 ustatus
= nv_rd32(dev
, 0x405018) & 0x7fffffff;
650 NV_INFO(dev
, "PGRAPH - TRAP_CCACHE");
651 nouveau_bitfield_print(nv50_graph_trap_ccache
, ustatus
);
653 NV_INFO(dev
, "PGRAPH - TRAP_CCACHE %08x %08x %08x %08x"
655 nv_rd32(dev
, 0x405000), nv_rd32(dev
, 0x405004),
656 nv_rd32(dev
, 0x405008), nv_rd32(dev
, 0x40500c),
657 nv_rd32(dev
, 0x405010), nv_rd32(dev
, 0x405014),
658 nv_rd32(dev
, 0x40501c));
662 nv_wr32(dev
, 0x405018, 0xc0000000);
663 nv_wr32(dev
, 0x400108, 0x010);
667 /* Unknown, not seen yet... 0x402000 is the only trap status reg
668 * remaining, so try to handle it anyway. Perhaps related to that
669 * unknown DMA slot on tesla? */
671 ustatus
= nv_rd32(dev
, 0x402000) & 0x7fffffff;
673 NV_INFO(dev
, "PGRAPH - TRAP_UNKC04 0x%08x\n", ustatus
);
674 nv_wr32(dev
, 0x402000, 0xc0000000);
675 /* no status modifiction on purpose */
678 /* TEXTURE: CUDA texturing units */
679 if (status
& 0x040) {
680 nv50_pgraph_tp_trap(dev
, 6, 0x408900, 0x408600, display
,
681 "PGRAPH - TRAP_TEXTURE");
682 nv_wr32(dev
, 0x400108, 0x040);
686 /* MP: CUDA execution engines. */
687 if (status
& 0x080) {
688 nv50_pgraph_tp_trap(dev
, 7, 0x408314, 0x40831c, display
,
690 nv_wr32(dev
, 0x400108, 0x080);
694 /* TPDMA: Handles TP-initiated uncached memory accesses:
695 * l[], g[], stack, 2d surfaces, render targets. */
696 if (status
& 0x100) {
697 nv50_pgraph_tp_trap(dev
, 8, 0x408e08, 0x408708, display
,
698 "PGRAPH - TRAP_TPDMA");
699 nv_wr32(dev
, 0x400108, 0x100);
705 NV_INFO(dev
, "PGRAPH - TRAP: unknown 0x%08x\n", status
);
706 nv_wr32(dev
, 0x400108, status
);
713 nv50_graph_isr_chid(struct drm_device
*dev
, u64 inst
)
715 struct nouveau_fifo_priv
*pfifo
= nv_engine(dev
, NVOBJ_ENGINE_FIFO
);
716 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
717 struct nouveau_channel
*chan
;
721 spin_lock_irqsave(&dev_priv
->channels
.lock
, flags
);
722 for (i
= 0; i
< pfifo
->channels
; i
++) {
723 chan
= dev_priv
->channels
.ptr
[i
];
724 if (!chan
|| !chan
->ramin
)
727 if (inst
== chan
->ramin
->vinst
)
730 spin_unlock_irqrestore(&dev_priv
->channels
.lock
, flags
);
735 nv50_graph_isr(struct drm_device
*dev
)
739 while ((stat
= nv_rd32(dev
, 0x400100))) {
740 u64 inst
= (u64
)(nv_rd32(dev
, 0x40032c) & 0x0fffffff) << 12;
741 u32 chid
= nv50_graph_isr_chid(dev
, inst
);
742 u32 addr
= nv_rd32(dev
, NV04_PGRAPH_TRAPPED_ADDR
);
743 u32 subc
= (addr
& 0x00070000) >> 16;
744 u32 mthd
= (addr
& 0x00001ffc);
745 u32 data
= nv_rd32(dev
, NV04_PGRAPH_TRAPPED_DATA
);
746 u32
class = nv_rd32(dev
, 0x400814);
749 if (stat
& 0x00000010) {
750 if (!nouveau_gpuobj_mthd_call2(dev
, chid
, class,
755 show
= (show
&& nouveau_ratelimit()) ? show
: 0;
757 if (show
& 0x00100000) {
758 u32 ecode
= nv_rd32(dev
, 0x400110);
759 NV_INFO(dev
, "PGRAPH - DATA_ERROR ");
760 nouveau_enum_print(nv50_data_error_names
, ecode
);
764 if (stat
& 0x00200000) {
765 if (!nv50_pgraph_trap_handler(dev
, show
, inst
, chid
))
769 nv_wr32(dev
, 0x400100, stat
);
770 nv_wr32(dev
, 0x400500, 0x00010001);
773 NV_INFO(dev
, "PGRAPH -");
774 nouveau_bitfield_print(nv50_graph_intr
, show
);
776 NV_INFO(dev
, "PGRAPH - ch %d (0x%010llx) subc %d "
777 "class 0x%04x mthd 0x%04x data 0x%08x\n",
778 chid
, inst
, subc
, class, mthd
, data
);
779 nv50_fb_vm_trap(dev
, 1);
783 if (nv_rd32(dev
, 0x400824) & (1 << 31))
784 nv_wr32(dev
, 0x400824, nv_rd32(dev
, 0x400824) & ~(1 << 31));
788 nv50_graph_destroy(struct drm_device
*dev
, int engine
)
790 struct nv50_graph_engine
*pgraph
= nv_engine(dev
, engine
);
792 NVOBJ_ENGINE_DEL(dev
, GR
);
794 nouveau_irq_unregister(dev
, 12);
799 nv50_graph_create(struct drm_device
*dev
)
801 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
802 struct nv50_graph_engine
*pgraph
;
805 pgraph
= kzalloc(sizeof(*pgraph
),GFP_KERNEL
);
809 ret
= nv50_grctx_init(dev
, pgraph
->ctxprog
, ARRAY_SIZE(pgraph
->ctxprog
),
810 &pgraph
->ctxprog_size
,
811 &pgraph
->grctx_size
);
813 NV_ERROR(dev
, "PGRAPH: ctxprog build failed\n");
818 pgraph
->base
.destroy
= nv50_graph_destroy
;
819 pgraph
->base
.init
= nv50_graph_init
;
820 pgraph
->base
.fini
= nv50_graph_fini
;
821 pgraph
->base
.context_new
= nv50_graph_context_new
;
822 pgraph
->base
.context_del
= nv50_graph_context_del
;
823 pgraph
->base
.object_new
= nv50_graph_object_new
;
824 if (dev_priv
->chipset
== 0x50 || dev_priv
->chipset
== 0xac)
825 pgraph
->base
.tlb_flush
= nv50_graph_tlb_flush
;
827 pgraph
->base
.tlb_flush
= nv84_graph_tlb_flush
;
829 nouveau_irq_register(dev
, 12, nv50_graph_isr
);
831 NVOBJ_ENGINE_ADD(dev
, GR
, &pgraph
->base
);
832 NVOBJ_CLASS(dev
, 0x0030, GR
); /* null */
833 NVOBJ_CLASS(dev
, 0x5039, GR
); /* m2mf */
834 NVOBJ_CLASS(dev
, 0x502d, GR
); /* 2d */
837 if (dev_priv
->chipset
== 0x50)
838 NVOBJ_CLASS(dev
, 0x5097, GR
); /* tesla (nv50) */
840 if (dev_priv
->chipset
< 0xa0)
841 NVOBJ_CLASS(dev
, 0x8297, GR
); /* tesla (nv8x/nv9x) */
843 switch (dev_priv
->chipset
) {
847 NVOBJ_CLASS(dev
, 0x8397, GR
);
852 NVOBJ_CLASS(dev
, 0x8597, GR
);
855 NVOBJ_CLASS(dev
, 0x8697, GR
);
861 NVOBJ_CLASS(dev
, 0x50c0, GR
);
862 if (dev_priv
->chipset
> 0xa0 &&
863 dev_priv
->chipset
!= 0xaa &&
864 dev_priv
->chipset
!= 0xac)
865 NVOBJ_CLASS(dev
, 0x85c0, GR
);