34 nvc0_graph_sclass[] = {
43 nvc1_graph_sclass[] = {
53 nvc8_graph_sclass[] = {
84 *pobject = nv_object(chan);
105 0, &chan->
data[i].mem);
124 data |= info >> mmio->
shift;
132 for (i = 0; i < priv->
size; i += 4)
133 nv_wo32(chan, i, priv->
data[i / 4]);
136 nv_wo32(chan, 0x00, chan->
mmio_nr / 2);
137 nv_wo32(chan, 0x04, chan->
mmio_vma.offset >> 8);
139 nv_wo32(chan, 0xf4, 0);
140 nv_wo32(chan, 0xf8, 0);
141 nv_wo32(chan, 0x10, chan->
mmio_nr / 2);
144 nv_wo32(chan, 0x1c, 1);
145 nv_wo32(chan, 0x20, 0);
146 nv_wo32(chan, 0x28, 0);
147 nv_wo32(chan, 0x2c, 0);
161 nouveau_gpuobj_ref(
NULL, &chan->
data[i].mem);
165 nouveau_gpuobj_ref(
NULL, &chan->
mmio);
171 nvc0_graph_cclass = {
189 nv_error(priv,
"%06x - done 0x%08x\n", base,
190 nv_rd32(priv, base + 0x400));
191 nv_error(priv,
"%06x - stat 0x%08x 0x%08x 0x%08x 0x%08x\n", base,
192 nv_rd32(priv, base + 0x800), nv_rd32(priv, base + 0x804),
193 nv_rd32(priv, base + 0x808), nv_rd32(priv, base + 0x80c));
194 nv_error(priv,
"%06x - stat 0x%08x 0x%08x 0x%08x 0x%08x\n", base,
195 nv_rd32(priv, base + 0x810), nv_rd32(priv, base + 0x814),
196 nv_rd32(priv, base + 0x818), nv_rd32(priv, base + 0x81c));
202 u32 gpcnr = nv_rd32(priv, 0x409604) & 0xffff;
205 nvc0_graph_ctxctl_debug_unit(priv, 0x409000);
206 for (gpc = 0; gpc < gpcnr; gpc++)
207 nvc0_graph_ctxctl_debug_unit(priv, 0x502000 + (gpc * 0x8000));
213 u32 ustat = nv_rd32(priv, 0x409c18);
215 if (ustat & 0x00000001)
216 nv_error(priv,
"CTXCTRL ucode error\n");
217 if (ustat & 0x00080000)
218 nv_error(priv,
"CTXCTRL watchdog timeout\n");
219 if (ustat & ~0x00080001)
220 nv_error(priv,
"CTXCTRL 0x%08x\n", ustat);
223 nv_wr32(priv, 0x409c20, ustat);
231 if (stat & 0x00000001) {
233 nv_error(priv,
"GPC%d/TPC%d/TEX: 0x%08x\n", gpc, tpc, trap);
234 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x0224), 0xc0000000);
235 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x0508), 0x00000001);
239 if (stat & 0x00000002) {
240 u32 trap0 = nv_rd32(priv,
TPC_UNIT(gpc, tpc, 0x0644));
241 u32 trap1 = nv_rd32(priv,
TPC_UNIT(gpc, tpc, 0x064c));
242 nv_error(priv,
"GPC%d/TPC%d/MP: 0x%08x 0x%08x\n",
243 gpc, tpc, trap0, trap1);
244 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x0644), 0x001ffffe);
245 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x064c), 0x0000000f);
246 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x0508), 0x00000002);
250 if (stat & 0x00000004) {
251 u32 trap = nv_rd32(priv,
TPC_UNIT(gpc, tpc, 0x0084));
252 nv_error(priv,
"GPC%d/TPC%d/POLY: 0x%08x\n", gpc, tpc, trap);
253 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x0084), 0xc0000000);
254 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x0508), 0x00000004);
258 if (stat & 0x00000008) {
259 u32 trap = nv_rd32(priv,
TPC_UNIT(gpc, tpc, 0x048c));
260 nv_error(priv,
"GPC%d/TPC%d/L1C: 0x%08x\n", gpc, tpc, trap);
261 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x048c), 0xc0000000);
262 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x0508), 0x00000008);
267 nv_error(priv,
"GPC%d/TPC%d/0x%08x: unknown\n", gpc, tpc, stat);
268 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x0508), stat);
278 if (stat & 0x00000001) {
280 nv_error(priv,
"GPC%d/PROP: 0x%08x\n", gpc, trap);
281 nv_wr32(priv,
GPC_UNIT(gpc, 0x0420), 0xc0000000);
282 nv_wr32(priv,
GPC_UNIT(gpc, 0x2c90), 0x00000001);
286 if (stat & 0x00000002) {
288 nv_error(priv,
"GPC%d/ZCULL: 0x%08x\n", gpc, trap);
289 nv_wr32(priv,
GPC_UNIT(gpc, 0x0900), 0xc0000000);
290 nv_wr32(priv,
GPC_UNIT(gpc, 0x2c90), 0x00000002);
294 if (stat & 0x00000004) {
296 nv_error(priv,
"GPC%d/CCACHE: 0x%08x\n", gpc, trap);
297 nv_wr32(priv,
GPC_UNIT(gpc, 0x1028), 0xc0000000);
298 nv_wr32(priv,
GPC_UNIT(gpc, 0x2c90), 0x00000004);
302 if (stat & 0x00000008) {
304 nv_error(priv,
"GPC%d/ESETUP: 0x%08x\n", gpc, trap);
305 nv_wr32(priv,
GPC_UNIT(gpc, 0x0824), 0xc0000000);
306 nv_wr32(priv,
GPC_UNIT(gpc, 0x2c90), 0x00000008);
310 for (tpc = 0; tpc < priv->
tpc_nr[gpc]; tpc++) {
313 nvc0_graph_trap_tpc(priv, gpc, tpc);
314 nv_wr32(priv,
GPC_UNIT(gpc, 0x2c90), mask);
320 nv_error(priv,
"GPC%d/0x%08x: unknown\n", gpc, stat);
321 nv_wr32(priv,
GPC_UNIT(gpc, 0x2c90), stat);
328 u32 trap = nv_rd32(priv, 0x400108);
331 if (trap & 0x00000001) {
332 u32 stat = nv_rd32(priv, 0x404000);
333 nv_error(priv,
"DISPATCH 0x%08x\n", stat);
334 nv_wr32(priv, 0x404000, 0xc0000000);
335 nv_wr32(priv, 0x400108, 0x00000001);
339 if (trap & 0x00000002) {
340 u32 stat = nv_rd32(priv, 0x404600);
341 nv_error(priv,
"M2MF 0x%08x\n", stat);
342 nv_wr32(priv, 0x404600, 0xc0000000);
343 nv_wr32(priv, 0x400108, 0x00000002);
347 if (trap & 0x00000008) {
348 u32 stat = nv_rd32(priv, 0x408030);
349 nv_error(priv,
"CCACHE 0x%08x\n", stat);
350 nv_wr32(priv, 0x408030, 0xc0000000);
351 nv_wr32(priv, 0x400108, 0x00000008);
355 if (trap & 0x00000010) {
356 u32 stat = nv_rd32(priv, 0x405840);
357 nv_error(priv,
"SHADER 0x%08x\n", stat);
358 nv_wr32(priv, 0x405840, 0xc0000000);
359 nv_wr32(priv, 0x400108, 0x00000010);
363 if (trap & 0x00000040) {
364 u32 stat = nv_rd32(priv, 0x40601c);
365 nv_error(priv,
"UNK6 0x%08x\n", stat);
366 nv_wr32(priv, 0x40601c, 0xc0000000);
367 nv_wr32(priv, 0x400108, 0x00000040);
371 if (trap & 0x00000080) {
372 u32 stat = nv_rd32(priv, 0x404490);
373 nv_error(priv,
"MACRO 0x%08x\n", stat);
374 nv_wr32(priv, 0x404490, 0xc0000000);
375 nv_wr32(priv, 0x400108, 0x00000080);
379 if (trap & 0x01000000) {
380 u32 stat = nv_rd32(priv, 0x400118);
381 for (gpc = 0; stat && gpc < priv->
gpc_nr; gpc++) {
382 u32 mask = 0x00000001 << gpc;
384 nvc0_graph_trap_gpc(priv, gpc);
385 nv_wr32(priv, 0x400118, mask);
389 nv_wr32(priv, 0x400108, 0x01000000);
393 if (trap & 0x02000000) {
394 for (rop = 0; rop < priv->
rop_nr; rop++) {
397 nv_error(priv,
"ROP%d 0x%08x 0x%08x\n",
399 nv_wr32(priv,
ROP_UNIT(rop, 0x070), 0xc0000000);
400 nv_wr32(priv,
ROP_UNIT(rop, 0x144), 0xc0000000);
402 nv_wr32(priv, 0x400108, 0x02000000);
407 nv_error(priv,
"TRAP UNHANDLED 0x%08x\n", trap);
408 nv_wr32(priv, 0x400108, trap);
420 u64 inst = nv_rd32(priv, 0x409b00) & 0x0fffffff;
421 u32 stat = nv_rd32(priv, 0x400100);
422 u32 addr = nv_rd32(priv, 0x400704);
423 u32 mthd = (addr & 0x00003ffc);
424 u32 subc = (addr & 0x00070000) >> 16;
425 u32 data = nv_rd32(priv, 0x400708);
426 u32 code = nv_rd32(priv, 0x400110);
427 u32 class = nv_rd32(priv, 0x404200 + (subc * 4));
431 chid = pfifo->
chid(pfifo, engctx);
433 if (stat & 0x00000010) {
435 if (!handle || nv_call(handle->
object, mthd, data)) {
436 nv_error(priv,
"ILLEGAL_MTHD ch %d [0x%010llx] "
437 "subc %d class 0x%04x mthd 0x%04x "
439 chid, inst << 12, subc,
class, mthd, data);
442 nv_wr32(priv, 0x400100, 0x00000010);
446 if (stat & 0x00000020) {
447 nv_error(priv,
"ILLEGAL_CLASS ch %d [0x%010llx] subc %d "
448 "class 0x%04x mthd 0x%04x data 0x%08x\n",
449 chid, inst << 12, subc,
class, mthd, data);
450 nv_wr32(priv, 0x400100, 0x00000020);
454 if (stat & 0x00100000) {
457 printk(
"] ch %d [0x%010llx] subc %d class 0x%04x "
458 "mthd 0x%04x data 0x%08x\n",
459 chid, inst << 12, subc,
class, mthd, data);
460 nv_wr32(priv, 0x400100, 0x00100000);
464 if (stat & 0x00200000) {
465 nv_error(priv,
"TRAP ch %d [0x%010llx]\n", chid, inst << 12);
466 nvc0_graph_trap_intr(priv);
467 nv_wr32(priv, 0x400100, 0x00200000);
471 if (stat & 0x00080000) {
472 nvc0_graph_ctxctl_isr(priv);
473 nv_wr32(priv, 0x400100, 0x00080000);
478 nv_error(priv,
"unknown stat 0x%08x\n", stat);
479 nv_wr32(priv, 0x400100, stat);
482 nv_wr32(priv, 0x400500, 0x00010001);
498 snprintf(f,
sizeof(f),
"nouveau/%s", fwname);
501 nv_error(priv,
"failed to load %s\n", fwname);
531 *pobject = nv_object(priv);
535 nv_subdev(priv)->unit = 0x18001000;
536 nv_subdev(priv)->intr = nvc0_graph_intr;
537 nv_engine(priv)->cclass = &nvc0_graph_cclass;
540 nv_info(priv,
"using external firmware\n");
549 switch (nvc0_graph_class(priv)) {
551 nv_engine(priv)->sclass = nvc0_graph_sclass;
554 nv_engine(priv)->sclass = nvc1_graph_sclass;
557 nv_engine(priv)->sclass = nvc8_graph_sclass;
569 for (i = 0; i < 0x1000; i += 4) {
574 priv->
rop_nr = (nv_rd32(priv, 0x409604) & 0x001f0000) >> 16;
575 priv->
gpc_nr = nv_rd32(priv, 0x409604) & 0x0000001f;
576 for (i = 0; i < priv->
gpc_nr; i++) {
582 switch (nv_device(priv)->
chipset) {
637 nvc0_graph_dtor_fw(&priv->
fuc409c);
638 nvc0_graph_dtor_fw(&priv->
fuc409d);
639 nvc0_graph_dtor_fw(&priv->
fuc41ac);
640 nvc0_graph_dtor_fw(&priv->
fuc41ad);
653 nv_wr32(priv,
GPC_BCAST(0x0880), 0x00000000);
654 nv_wr32(priv,
GPC_BCAST(0x08a4), 0x00000000);
655 for (i = 0; i < 4; i++)
656 nv_wr32(priv,
GPC_BCAST(0x0888) + (i * 4), 0x00000000);
664 nv_wr32(priv, 0x400080, 0x003083c2);
665 nv_wr32(priv, 0x400088, 0x00006fe7);
666 nv_wr32(priv, 0x40008c, 0x00000000);
667 nv_wr32(priv, 0x400090, 0x00000030);
668 nv_wr32(priv, 0x40013c, 0x013901f7);
669 nv_wr32(priv, 0x400140, 0x00000100);
670 nv_wr32(priv, 0x400144, 0x00000000);
671 nv_wr32(priv, 0x400148, 0x00000110);
672 nv_wr32(priv, 0x400138, 0x00000000);
673 nv_wr32(priv, 0x400130, 0x00000000);
674 nv_wr32(priv, 0x400134, 0x00000000);
675 nv_wr32(priv, 0x400124, 0x00000002);
686 nv_wr32(priv,
TPC_UNIT(0, 0, 0x5c), 1);
697 memset(data, 0x00,
sizeof(data));
699 for (i = 0, gpc = -1; i < priv->
tpc_total; i++) {
701 gpc = (gpc + 1) % priv->
gpc_nr;
702 }
while (!tpcnr[gpc]);
703 tpc = priv->
tpc_nr[gpc] - tpcnr[gpc]--;
705 data[i / 8] |= tpc << ((i % 8) * 4);
708 nv_wr32(priv,
GPC_BCAST(0x0980), data[0]);
709 nv_wr32(priv,
GPC_BCAST(0x0984), data[1]);
710 nv_wr32(priv,
GPC_BCAST(0x0988), data[2]);
711 nv_wr32(priv,
GPC_BCAST(0x098c), data[3]);
713 for (gpc = 0; gpc < priv->
gpc_nr; gpc++) {
717 nv_wr32(priv,
GPC_UNIT(gpc, 0x0918), magicgpc918);
720 nv_wr32(priv,
GPC_BCAST(0x1bd4), magicgpc918);
721 nv_wr32(priv,
GPC_BCAST(0x08ac), nv_rd32(priv, 0x100800));
727 nv_wr32(priv, 0x409c24, 0x000f0000);
728 nv_wr32(priv, 0x404000, 0xc0000000);
729 nv_wr32(priv, 0x404600, 0xc0000000);
730 nv_wr32(priv, 0x408030, 0xc0000000);
731 nv_wr32(priv, 0x40601c, 0xc0000000);
732 nv_wr32(priv, 0x404490, 0xc0000000);
733 nv_wr32(priv, 0x406018, 0xc0000000);
734 nv_wr32(priv, 0x405840, 0xc0000000);
735 nv_wr32(priv, 0x405844, 0x00ffffff);
736 nv_mask(priv, 0x419cc0, 0x00000008, 0x00000008);
737 nv_mask(priv, 0x419eb4, 0x00001000, 0x00001000);
745 for (gpc = 0; gpc < priv->
gpc_nr; gpc++) {
746 nv_wr32(priv,
GPC_UNIT(gpc, 0x0420), 0xc0000000);
747 nv_wr32(priv,
GPC_UNIT(gpc, 0x0900), 0xc0000000);
748 nv_wr32(priv,
GPC_UNIT(gpc, 0x1028), 0xc0000000);
749 nv_wr32(priv,
GPC_UNIT(gpc, 0x0824), 0xc0000000);
750 for (tpc = 0; tpc < priv->
tpc_nr[gpc]; tpc++) {
751 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x508), 0xffffffff);
752 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x50c), 0xffffffff);
753 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x224), 0xc0000000);
754 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x48c), 0xc0000000);
755 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x084), 0xc0000000);
756 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x644), 0x001ffffe);
757 nv_wr32(priv,
TPC_UNIT(gpc, tpc, 0x64c), 0x0000000f);
759 nv_wr32(priv,
GPC_UNIT(gpc, 0x2c90), 0xffffffff);
760 nv_wr32(priv,
GPC_UNIT(gpc, 0x2c94), 0xffffffff);
769 for (rop = 0; rop < priv->
rop_nr; rop++) {
770 nv_wr32(priv,
ROP_UNIT(rop, 0x144), 0xc0000000);
771 nv_wr32(priv,
ROP_UNIT(rop, 0x070), 0xc0000000);
772 nv_wr32(priv,
ROP_UNIT(rop, 0x204), 0xffffffff);
773 nv_wr32(priv,
ROP_UNIT(rop, 0x208), 0xffffffff);
783 nv_wr32(priv, fuc_base + 0x01c0, 0x01000000);
784 for (i = 0; i < data->
size / 4; i++)
785 nv_wr32(priv, fuc_base + 0x01c4, data->
data[i]);
787 nv_wr32(priv, fuc_base + 0x0180, 0x01000000);
788 for (i = 0; i < code->
size / 4; i++) {
790 nv_wr32(priv, fuc_base + 0x0188, i >> 6);
791 nv_wr32(priv, fuc_base + 0x0184, code->
data[i]);
803 r000260 = nv_mask(priv, 0x000260, 0x00000001, 0x00000000);
808 nv_wr32(priv, 0x000260, r000260);
811 nv_wr32(priv, 0x409840, 0xffffffff);
812 nv_wr32(priv, 0x41a10c, 0x00000000);
813 nv_wr32(priv, 0x40910c, 0x00000000);
814 nv_wr32(priv, 0x41a100, 0x00000002);
815 nv_wr32(priv, 0x409100, 0x00000002);
816 if (!
nv_wait(priv, 0x409800, 0x00000001, 0x00000001))
817 nv_info(priv,
"0x409800 wait failed\n");
819 nv_wr32(priv, 0x409840, 0xffffffff);
820 nv_wr32(priv, 0x409500, 0x7fffffff);
821 nv_wr32(priv, 0x409504, 0x00000021);
823 nv_wr32(priv, 0x409840, 0xffffffff);
824 nv_wr32(priv, 0x409500, 0x00000000);
825 nv_wr32(priv, 0x409504, 0x00000010);
826 if (!
nv_wait_ne(priv, 0x409800, 0xffffffff, 0x00000000)) {
827 nv_error(priv,
"fuc09 req 0x10 timeout\n");
830 priv->
size = nv_rd32(priv, 0x409800);
832 nv_wr32(priv, 0x409840, 0xffffffff);
833 nv_wr32(priv, 0x409500, 0x00000000);
834 nv_wr32(priv, 0x409504, 0x00000016);
835 if (!
nv_wait_ne(priv, 0x409800, 0xffffffff, 0x00000000)) {
836 nv_error(priv,
"fuc09 req 0x16 timeout\n");
840 nv_wr32(priv, 0x409840, 0xffffffff);
841 nv_wr32(priv, 0x409500, 0x00000000);
842 nv_wr32(priv, 0x409504, 0x00000025);
843 if (!
nv_wait_ne(priv, 0x409800, 0xffffffff, 0x00000000)) {
844 nv_error(priv,
"fuc09 req 0x25 timeout\n");
851 nv_error(priv,
"failed to construct context\n");
860 r000260 = nv_mask(priv, 0x000260, 0x00000001, 0x00000000);
861 nv_wr32(priv, 0x4091c0, 0x01000000);
865 nv_wr32(priv, 0x409180, 0x01000000);
868 nv_wr32(priv, 0x409188, i >> 6);
873 nv_wr32(priv, 0x41a1c0, 0x01000000);
877 nv_wr32(priv, 0x41a180, 0x01000000);
880 nv_wr32(priv, 0x41a188, i >> 6);
883 nv_wr32(priv, 0x000260, r000260);
886 nv_wr32(priv, 0x409800, nv_device(priv)->
chipset);
887 nv_wr32(priv, 0x40910c, 0x00000000);
888 nv_wr32(priv, 0x409100, 0x00000002);
889 if (!
nv_wait(priv, 0x409800, 0x80000000, 0x80000000)) {
890 nv_error(priv,
"HUB_INIT timed out\n");
895 priv->
size = nv_rd32(priv, 0x409804);
899 nv_error(priv,
"failed to construct context\n");
917 nvc0_graph_init_obj418880(priv);
918 nvc0_graph_init_regs(priv);
920 nvc0_graph_init_gpc_0(priv);
923 nv_wr32(priv, 0x400500, 0x00010001);
924 nv_wr32(priv, 0x400100, 0xffffffff);
925 nv_wr32(priv, 0x40013c, 0xffffffff);
927 nvc0_graph_init_units(priv);
928 nvc0_graph_init_gpc_1(priv);
929 nvc0_graph_init_rop(priv);
931 nv_wr32(priv, 0x400108, 0xffffffff);
932 nv_wr32(priv, 0x400138, 0xffffffff);
933 nv_wr32(priv, 0x400118, 0xffffffff);
934 nv_wr32(priv, 0x400130, 0xffffffff);
935 nv_wr32(priv, 0x40011c, 0xffffffff);
936 nv_wr32(priv, 0x400134, 0xffffffff);
937 nv_wr32(priv, 0x400054, 0x34ce3464);
939 ret = nvc0_graph_init_ctxctl(priv);
950 .ctor = nvc0_graph_ctor,
952 .init = nvc0_graph_init,