nv50_graph.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. /*
  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. #include "drmP.h"
  27. #include "drm.h"
  28. #include "nouveau_drv.h"
  29. #include "nouveau_ramht.h"
  30. #include "nouveau_grctx.h"
  31. #include "nouveau_dma.h"
  32. #include "nouveau_vm.h"
  33. #include "nv50_evo.h"
  34. static int nv50_graph_register(struct drm_device *);
  35. static void nv50_graph_isr(struct drm_device *);
  36. static void
  37. nv50_graph_init_reset(struct drm_device *dev)
  38. {
  39. uint32_t pmc_e = NV_PMC_ENABLE_PGRAPH | (1 << 21);
  40. NV_DEBUG(dev, "\n");
  41. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) & ~pmc_e);
  42. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) | pmc_e);
  43. }
  44. static void
  45. nv50_graph_init_intr(struct drm_device *dev)
  46. {
  47. NV_DEBUG(dev, "\n");
  48. nouveau_irq_register(dev, 12, nv50_graph_isr);
  49. nv_wr32(dev, NV03_PGRAPH_INTR, 0xffffffff);
  50. nv_wr32(dev, 0x400138, 0xffffffff);
  51. nv_wr32(dev, NV40_PGRAPH_INTR_EN, 0xffffffff);
  52. }
  53. static void
  54. nv50_graph_init_regs__nv(struct drm_device *dev)
  55. {
  56. struct drm_nouveau_private *dev_priv = dev->dev_private;
  57. uint32_t units = nv_rd32(dev, 0x1540);
  58. int i;
  59. NV_DEBUG(dev, "\n");
  60. nv_wr32(dev, 0x400804, 0xc0000000);
  61. nv_wr32(dev, 0x406800, 0xc0000000);
  62. nv_wr32(dev, 0x400c04, 0xc0000000);
  63. nv_wr32(dev, 0x401800, 0xc0000000);
  64. nv_wr32(dev, 0x405018, 0xc0000000);
  65. nv_wr32(dev, 0x402000, 0xc0000000);
  66. for (i = 0; i < 16; i++) {
  67. if (units & 1 << i) {
  68. if (dev_priv->chipset < 0xa0) {
  69. nv_wr32(dev, 0x408900 + (i << 12), 0xc0000000);
  70. nv_wr32(dev, 0x408e08 + (i << 12), 0xc0000000);
  71. nv_wr32(dev, 0x408314 + (i << 12), 0xc0000000);
  72. } else {
  73. nv_wr32(dev, 0x408600 + (i << 11), 0xc0000000);
  74. nv_wr32(dev, 0x408708 + (i << 11), 0xc0000000);
  75. nv_wr32(dev, 0x40831c + (i << 11), 0xc0000000);
  76. }
  77. }
  78. }
  79. nv_wr32(dev, 0x400108, 0xffffffff);
  80. nv_wr32(dev, 0x400824, 0x00004000);
  81. nv_wr32(dev, 0x400500, 0x00010001);
  82. }
  83. static void
  84. nv50_graph_init_zcull(struct drm_device *dev)
  85. {
  86. struct drm_nouveau_private *dev_priv = dev->dev_private;
  87. int i;
  88. NV_DEBUG(dev, "\n");
  89. switch (dev_priv->chipset & 0xf0) {
  90. case 0x50:
  91. case 0x80:
  92. case 0x90:
  93. nv_wr32(dev, 0x402ca8, 0x00000800);
  94. break;
  95. case 0xa0:
  96. default:
  97. nv_wr32(dev, 0x402cc0, 0x00000000);
  98. if (dev_priv->chipset == 0xa0 ||
  99. dev_priv->chipset == 0xaa ||
  100. dev_priv->chipset == 0xac) {
  101. nv_wr32(dev, 0x402ca8, 0x00000802);
  102. } else {
  103. nv_wr32(dev, 0x402cc0, 0x00000000);
  104. nv_wr32(dev, 0x402ca8, 0x00000002);
  105. }
  106. break;
  107. }
  108. /* zero out zcull regions */
  109. for (i = 0; i < 8; i++) {
  110. nv_wr32(dev, 0x402c20 + (i * 8), 0x00000000);
  111. nv_wr32(dev, 0x402c24 + (i * 8), 0x00000000);
  112. nv_wr32(dev, 0x402c28 + (i * 8), 0x00000000);
  113. nv_wr32(dev, 0x402c2c + (i * 8), 0x00000000);
  114. }
  115. }
  116. static int
  117. nv50_graph_init_ctxctl(struct drm_device *dev)
  118. {
  119. struct drm_nouveau_private *dev_priv = dev->dev_private;
  120. struct nouveau_grctx ctx = {};
  121. uint32_t *cp;
  122. int i;
  123. NV_DEBUG(dev, "\n");
  124. cp = kmalloc(512 * 4, GFP_KERNEL);
  125. if (!cp) {
  126. NV_ERROR(dev, "failed to allocate ctxprog\n");
  127. dev_priv->engine.graph.accel_blocked = true;
  128. return 0;
  129. }
  130. ctx.dev = dev;
  131. ctx.mode = NOUVEAU_GRCTX_PROG;
  132. ctx.data = cp;
  133. ctx.ctxprog_max = 512;
  134. if (!nv50_grctx_init(&ctx)) {
  135. dev_priv->engine.graph.grctx_size = ctx.ctxvals_pos * 4;
  136. nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
  137. for (i = 0; i < ctx.ctxprog_len; i++)
  138. nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, cp[i]);
  139. } else {
  140. dev_priv->engine.graph.accel_blocked = true;
  141. }
  142. kfree(cp);
  143. nv_wr32(dev, 0x40008c, 0x00000004); /* HW_CTX_SWITCH_ENABLED */
  144. nv_wr32(dev, 0x400320, 4);
  145. nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0);
  146. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, 0);
  147. return 0;
  148. }
  149. int
  150. nv50_graph_init(struct drm_device *dev)
  151. {
  152. int ret;
  153. NV_DEBUG(dev, "\n");
  154. nv50_graph_init_reset(dev);
  155. nv50_graph_init_regs__nv(dev);
  156. nv50_graph_init_zcull(dev);
  157. ret = nv50_graph_init_ctxctl(dev);
  158. if (ret)
  159. return ret;
  160. ret = nv50_graph_register(dev);
  161. if (ret)
  162. return ret;
  163. nv50_graph_init_intr(dev);
  164. return 0;
  165. }
  166. void
  167. nv50_graph_takedown(struct drm_device *dev)
  168. {
  169. NV_DEBUG(dev, "\n");
  170. nv_wr32(dev, 0x40013c, 0x00000000);
  171. nouveau_irq_unregister(dev, 12);
  172. }
  173. void
  174. nv50_graph_fifo_access(struct drm_device *dev, bool enabled)
  175. {
  176. const uint32_t mask = 0x00010001;
  177. if (enabled)
  178. nv_wr32(dev, 0x400500, nv_rd32(dev, 0x400500) | mask);
  179. else
  180. nv_wr32(dev, 0x400500, nv_rd32(dev, 0x400500) & ~mask);
  181. }
  182. struct nouveau_channel *
  183. nv50_graph_channel(struct drm_device *dev)
  184. {
  185. struct drm_nouveau_private *dev_priv = dev->dev_private;
  186. uint32_t inst;
  187. int i;
  188. /* Be sure we're not in the middle of a context switch or bad things
  189. * will happen, such as unloading the wrong pgraph context.
  190. */
  191. if (!nv_wait(dev, 0x400300, 0x00000001, 0x00000000))
  192. NV_ERROR(dev, "Ctxprog is still running\n");
  193. inst = nv_rd32(dev, NV50_PGRAPH_CTXCTL_CUR);
  194. if (!(inst & NV50_PGRAPH_CTXCTL_CUR_LOADED))
  195. return NULL;
  196. inst = (inst & NV50_PGRAPH_CTXCTL_CUR_INSTANCE) << 12;
  197. for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
  198. struct nouveau_channel *chan = dev_priv->channels.ptr[i];
  199. if (chan && chan->ramin && chan->ramin->vinst == inst)
  200. return chan;
  201. }
  202. return NULL;
  203. }
  204. int
  205. nv50_graph_create_context(struct nouveau_channel *chan)
  206. {
  207. struct drm_device *dev = chan->dev;
  208. struct drm_nouveau_private *dev_priv = dev->dev_private;
  209. struct nouveau_gpuobj *ramin = chan->ramin;
  210. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  211. struct nouveau_grctx ctx = {};
  212. int hdr, ret;
  213. NV_DEBUG(dev, "ch%d\n", chan->id);
  214. ret = nouveau_gpuobj_new(dev, chan, pgraph->grctx_size, 0,
  215. NVOBJ_FLAG_ZERO_ALLOC |
  216. NVOBJ_FLAG_ZERO_FREE, &chan->ramin_grctx);
  217. if (ret)
  218. return ret;
  219. hdr = (dev_priv->chipset == 0x50) ? 0x200 : 0x20;
  220. nv_wo32(ramin, hdr + 0x00, 0x00190002);
  221. nv_wo32(ramin, hdr + 0x04, chan->ramin_grctx->vinst +
  222. pgraph->grctx_size - 1);
  223. nv_wo32(ramin, hdr + 0x08, chan->ramin_grctx->vinst);
  224. nv_wo32(ramin, hdr + 0x0c, 0);
  225. nv_wo32(ramin, hdr + 0x10, 0);
  226. nv_wo32(ramin, hdr + 0x14, 0x00010000);
  227. ctx.dev = chan->dev;
  228. ctx.mode = NOUVEAU_GRCTX_VALS;
  229. ctx.data = chan->ramin_grctx;
  230. nv50_grctx_init(&ctx);
  231. nv_wo32(chan->ramin_grctx, 0x00000, chan->ramin->vinst >> 12);
  232. dev_priv->engine.instmem.flush(dev);
  233. atomic_inc(&chan->vm->pgraph_refs);
  234. return 0;
  235. }
  236. void
  237. nv50_graph_destroy_context(struct nouveau_channel *chan)
  238. {
  239. struct drm_device *dev = chan->dev;
  240. struct drm_nouveau_private *dev_priv = dev->dev_private;
  241. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  242. struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
  243. int i, hdr = (dev_priv->chipset == 0x50) ? 0x200 : 0x20;
  244. unsigned long flags;
  245. NV_DEBUG(dev, "ch%d\n", chan->id);
  246. if (!chan->ramin)
  247. return;
  248. spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
  249. pfifo->reassign(dev, false);
  250. pgraph->fifo_access(dev, false);
  251. if (pgraph->channel(dev) == chan)
  252. pgraph->unload_context(dev);
  253. for (i = hdr; i < hdr + 24; i += 4)
  254. nv_wo32(chan->ramin, i, 0);
  255. dev_priv->engine.instmem.flush(dev);
  256. pgraph->fifo_access(dev, true);
  257. pfifo->reassign(dev, true);
  258. spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
  259. nouveau_gpuobj_ref(NULL, &chan->ramin_grctx);
  260. atomic_dec(&chan->vm->pgraph_refs);
  261. }
  262. static int
  263. nv50_graph_do_load_context(struct drm_device *dev, uint32_t inst)
  264. {
  265. uint32_t fifo = nv_rd32(dev, 0x400500);
  266. nv_wr32(dev, 0x400500, fifo & ~1);
  267. nv_wr32(dev, 0x400784, inst);
  268. nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) | 0x40);
  269. nv_wr32(dev, 0x400320, nv_rd32(dev, 0x400320) | 0x11);
  270. nv_wr32(dev, 0x400040, 0xffffffff);
  271. (void)nv_rd32(dev, 0x400040);
  272. nv_wr32(dev, 0x400040, 0x00000000);
  273. nv_wr32(dev, 0x400304, nv_rd32(dev, 0x400304) | 1);
  274. if (nouveau_wait_for_idle(dev))
  275. nv_wr32(dev, 0x40032c, inst | (1<<31));
  276. nv_wr32(dev, 0x400500, fifo);
  277. return 0;
  278. }
  279. int
  280. nv50_graph_load_context(struct nouveau_channel *chan)
  281. {
  282. uint32_t inst = chan->ramin->vinst >> 12;
  283. NV_DEBUG(chan->dev, "ch%d\n", chan->id);
  284. return nv50_graph_do_load_context(chan->dev, inst);
  285. }
  286. int
  287. nv50_graph_unload_context(struct drm_device *dev)
  288. {
  289. uint32_t inst;
  290. inst = nv_rd32(dev, NV50_PGRAPH_CTXCTL_CUR);
  291. if (!(inst & NV50_PGRAPH_CTXCTL_CUR_LOADED))
  292. return 0;
  293. inst &= NV50_PGRAPH_CTXCTL_CUR_INSTANCE;
  294. nouveau_wait_for_idle(dev);
  295. nv_wr32(dev, 0x400784, inst);
  296. nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) | 0x20);
  297. nv_wr32(dev, 0x400304, nv_rd32(dev, 0x400304) | 0x01);
  298. nouveau_wait_for_idle(dev);
  299. nv_wr32(dev, NV50_PGRAPH_CTXCTL_CUR, inst);
  300. return 0;
  301. }
  302. static void
  303. nv50_graph_context_switch(struct drm_device *dev)
  304. {
  305. uint32_t inst;
  306. nv50_graph_unload_context(dev);
  307. inst = nv_rd32(dev, NV50_PGRAPH_CTXCTL_NEXT);
  308. inst &= NV50_PGRAPH_CTXCTL_NEXT_INSTANCE;
  309. nv50_graph_do_load_context(dev, inst);
  310. nv_wr32(dev, NV40_PGRAPH_INTR_EN, nv_rd32(dev,
  311. NV40_PGRAPH_INTR_EN) | NV_PGRAPH_INTR_CONTEXT_SWITCH);
  312. }
  313. static int
  314. nv50_graph_nvsw_dma_vblsem(struct nouveau_channel *chan,
  315. u32 class, u32 mthd, u32 data)
  316. {
  317. struct nouveau_gpuobj *gpuobj;
  318. gpuobj = nouveau_ramht_find(chan, data);
  319. if (!gpuobj)
  320. return -ENOENT;
  321. if (nouveau_notifier_offset(gpuobj, NULL))
  322. return -EINVAL;
  323. chan->nvsw.vblsem = gpuobj;
  324. chan->nvsw.vblsem_offset = ~0;
  325. return 0;
  326. }
  327. static int
  328. nv50_graph_nvsw_vblsem_offset(struct nouveau_channel *chan,
  329. u32 class, u32 mthd, u32 data)
  330. {
  331. if (nouveau_notifier_offset(chan->nvsw.vblsem, &data))
  332. return -ERANGE;
  333. chan->nvsw.vblsem_offset = data >> 2;
  334. return 0;
  335. }
  336. static int
  337. nv50_graph_nvsw_vblsem_release_val(struct nouveau_channel *chan,
  338. u32 class, u32 mthd, u32 data)
  339. {
  340. chan->nvsw.vblsem_rval = data;
  341. return 0;
  342. }
  343. static int
  344. nv50_graph_nvsw_vblsem_release(struct nouveau_channel *chan,
  345. u32 class, u32 mthd, u32 data)
  346. {
  347. struct drm_device *dev = chan->dev;
  348. struct drm_nouveau_private *dev_priv = dev->dev_private;
  349. if (!chan->nvsw.vblsem || chan->nvsw.vblsem_offset == ~0 || data > 1)
  350. return -EINVAL;
  351. drm_vblank_get(dev, data);
  352. chan->nvsw.vblsem_head = data;
  353. list_add(&chan->nvsw.vbl_wait, &dev_priv->vbl_waiting);
  354. return 0;
  355. }
  356. static int
  357. nv50_graph_nvsw_mthd_page_flip(struct nouveau_channel *chan,
  358. u32 class, u32 mthd, u32 data)
  359. {
  360. nouveau_finish_page_flip(chan, NULL);
  361. return 0;
  362. }
  363. static int
  364. nv50_graph_register(struct drm_device *dev)
  365. {
  366. struct drm_nouveau_private *dev_priv = dev->dev_private;
  367. if (dev_priv->engine.graph.registered)
  368. return 0;
  369. NVOBJ_CLASS(dev, 0x506e, SW); /* nvsw */
  370. NVOBJ_MTHD (dev, 0x506e, 0x018c, nv50_graph_nvsw_dma_vblsem);
  371. NVOBJ_MTHD (dev, 0x506e, 0x0400, nv50_graph_nvsw_vblsem_offset);
  372. NVOBJ_MTHD (dev, 0x506e, 0x0404, nv50_graph_nvsw_vblsem_release_val);
  373. NVOBJ_MTHD (dev, 0x506e, 0x0408, nv50_graph_nvsw_vblsem_release);
  374. NVOBJ_MTHD (dev, 0x506e, 0x0500, nv50_graph_nvsw_mthd_page_flip);
  375. NVOBJ_CLASS(dev, 0x0030, GR); /* null */
  376. NVOBJ_CLASS(dev, 0x5039, GR); /* m2mf */
  377. NVOBJ_CLASS(dev, 0x502d, GR); /* 2d */
  378. /* tesla */
  379. if (dev_priv->chipset == 0x50)
  380. NVOBJ_CLASS(dev, 0x5097, GR); /* tesla (nv50) */
  381. else
  382. if (dev_priv->chipset < 0xa0)
  383. NVOBJ_CLASS(dev, 0x8297, GR); /* tesla (nv8x/nv9x) */
  384. else {
  385. switch (dev_priv->chipset) {
  386. case 0xa0:
  387. case 0xaa:
  388. case 0xac:
  389. NVOBJ_CLASS(dev, 0x8397, GR);
  390. break;
  391. case 0xa3:
  392. case 0xa5:
  393. case 0xa8:
  394. NVOBJ_CLASS(dev, 0x8597, GR);
  395. break;
  396. case 0xaf:
  397. NVOBJ_CLASS(dev, 0x8697, GR);
  398. break;
  399. }
  400. }
  401. /* compute */
  402. NVOBJ_CLASS(dev, 0x50c0, GR);
  403. if (dev_priv->chipset > 0xa0 &&
  404. dev_priv->chipset != 0xaa &&
  405. dev_priv->chipset != 0xac)
  406. NVOBJ_CLASS(dev, 0x85c0, GR);
  407. dev_priv->engine.graph.registered = true;
  408. return 0;
  409. }
  410. void
  411. nv50_graph_tlb_flush(struct drm_device *dev)
  412. {
  413. nv50_vm_flush_engine(dev, 0);
  414. }
  415. void
  416. nv86_graph_tlb_flush(struct drm_device *dev)
  417. {
  418. struct drm_nouveau_private *dev_priv = dev->dev_private;
  419. struct nouveau_timer_engine *ptimer = &dev_priv->engine.timer;
  420. bool idle, timeout = false;
  421. unsigned long flags;
  422. u64 start;
  423. u32 tmp;
  424. spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
  425. nv_mask(dev, 0x400500, 0x00000001, 0x00000000);
  426. start = ptimer->read(dev);
  427. do {
  428. idle = true;
  429. for (tmp = nv_rd32(dev, 0x400380); tmp && idle; tmp >>= 3) {
  430. if ((tmp & 7) == 1)
  431. idle = false;
  432. }
  433. for (tmp = nv_rd32(dev, 0x400384); tmp && idle; tmp >>= 3) {
  434. if ((tmp & 7) == 1)
  435. idle = false;
  436. }
  437. for (tmp = nv_rd32(dev, 0x400388); tmp && idle; tmp >>= 3) {
  438. if ((tmp & 7) == 1)
  439. idle = false;
  440. }
  441. } while (!idle && !(timeout = ptimer->read(dev) - start > 2000000000));
  442. if (timeout) {
  443. NV_ERROR(dev, "PGRAPH TLB flush idle timeout fail: "
  444. "0x%08x 0x%08x 0x%08x 0x%08x\n",
  445. nv_rd32(dev, 0x400700), nv_rd32(dev, 0x400380),
  446. nv_rd32(dev, 0x400384), nv_rd32(dev, 0x400388));
  447. }
  448. nv50_vm_flush_engine(dev, 0);
  449. nv_mask(dev, 0x400500, 0x00000001, 0x00000001);
  450. spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
  451. }
  452. static struct nouveau_enum nv50_mp_exec_error_names[] =
  453. {
  454. { 3, "STACK_UNDERFLOW", NULL },
  455. { 4, "QUADON_ACTIVE", NULL },
  456. { 8, "TIMEOUT", NULL },
  457. { 0x10, "INVALID_OPCODE", NULL },
  458. { 0x40, "BREAKPOINT", NULL },
  459. {}
  460. };
  461. static struct nouveau_bitfield nv50_graph_trap_m2mf[] = {
  462. { 0x00000001, "NOTIFY" },
  463. { 0x00000002, "IN" },
  464. { 0x00000004, "OUT" },
  465. {}
  466. };
  467. static struct nouveau_bitfield nv50_graph_trap_vfetch[] = {
  468. { 0x00000001, "FAULT" },
  469. {}
  470. };
  471. static struct nouveau_bitfield nv50_graph_trap_strmout[] = {
  472. { 0x00000001, "FAULT" },
  473. {}
  474. };
  475. static struct nouveau_bitfield nv50_graph_trap_ccache[] = {
  476. { 0x00000001, "FAULT" },
  477. {}
  478. };
  479. /* There must be a *lot* of these. Will take some time to gather them up. */
  480. struct nouveau_enum nv50_data_error_names[] = {
  481. { 0x00000003, "INVALID_QUERY_OR_TEXTURE", NULL },
  482. { 0x00000004, "INVALID_VALUE", NULL },
  483. { 0x00000005, "INVALID_ENUM", NULL },
  484. { 0x00000008, "INVALID_OBJECT", NULL },
  485. { 0x00000009, "READ_ONLY_OBJECT", NULL },
  486. { 0x0000000a, "SUPERVISOR_OBJECT", NULL },
  487. { 0x0000000b, "INVALID_ADDRESS_ALIGNMENT", NULL },
  488. { 0x0000000c, "INVALID_BITFIELD", NULL },
  489. { 0x0000000d, "BEGIN_END_ACTIVE", NULL },
  490. { 0x0000000e, "SEMANTIC_COLOR_BACK_OVER_LIMIT", NULL },
  491. { 0x0000000f, "VIEWPORT_ID_NEEDS_GP", NULL },
  492. { 0x00000010, "RT_DOUBLE_BIND", NULL },
  493. { 0x00000011, "RT_TYPES_MISMATCH", NULL },
  494. { 0x00000012, "RT_LINEAR_WITH_ZETA", NULL },
  495. { 0x00000015, "FP_TOO_FEW_REGS", NULL },
  496. { 0x00000016, "ZETA_FORMAT_CSAA_MISMATCH", NULL },
  497. { 0x00000017, "RT_LINEAR_WITH_MSAA", NULL },
  498. { 0x00000018, "FP_INTERPOLANT_START_OVER_LIMIT", NULL },
  499. { 0x00000019, "SEMANTIC_LAYER_OVER_LIMIT", NULL },
  500. { 0x0000001a, "RT_INVALID_ALIGNMENT", NULL },
  501. { 0x0000001b, "SAMPLER_OVER_LIMIT", NULL },
  502. { 0x0000001c, "TEXTURE_OVER_LIMIT", NULL },
  503. { 0x0000001e, "GP_TOO_MANY_OUTPUTS", NULL },
  504. { 0x0000001f, "RT_BPP128_WITH_MS8", NULL },
  505. { 0x00000021, "Z_OUT_OF_BOUNDS", NULL },
  506. { 0x00000023, "XY_OUT_OF_BOUNDS", NULL },
  507. { 0x00000027, "CP_MORE_PARAMS_THAN_SHARED", NULL },
  508. { 0x00000028, "CP_NO_REG_SPACE_STRIPED", NULL },
  509. { 0x00000029, "CP_NO_REG_SPACE_PACKED", NULL },
  510. { 0x0000002a, "CP_NOT_ENOUGH_WARPS", NULL },
  511. { 0x0000002b, "CP_BLOCK_SIZE_MISMATCH", NULL },
  512. { 0x0000002c, "CP_NOT_ENOUGH_LOCAL_WARPS", NULL },
  513. { 0x0000002d, "CP_NOT_ENOUGH_STACK_WARPS", NULL },
  514. { 0x0000002e, "CP_NO_BLOCKDIM_LATCH", NULL },
  515. { 0x00000031, "ENG2D_FORMAT_MISMATCH", NULL },
  516. { 0x0000003f, "PRIMITIVE_ID_NEEDS_GP", NULL },
  517. { 0x00000044, "SEMANTIC_VIEWPORT_OVER_LIMIT", NULL },
  518. { 0x00000045, "SEMANTIC_COLOR_FRONT_OVER_LIMIT", NULL },
  519. { 0x00000046, "LAYER_ID_NEEDS_GP", NULL },
  520. { 0x00000047, "SEMANTIC_CLIP_OVER_LIMIT", NULL },
  521. { 0x00000048, "SEMANTIC_PTSZ_OVER_LIMIT", NULL },
  522. {}
  523. };
  524. static struct nouveau_bitfield nv50_graph_intr[] = {
  525. { 0x00000001, "NOTIFY" },
  526. { 0x00000002, "COMPUTE_QUERY" },
  527. { 0x00000010, "ILLEGAL_MTHD" },
  528. { 0x00000020, "ILLEGAL_CLASS" },
  529. { 0x00000040, "DOUBLE_NOTIFY" },
  530. { 0x00001000, "CONTEXT_SWITCH" },
  531. { 0x00010000, "BUFFER_NOTIFY" },
  532. { 0x00100000, "DATA_ERROR" },
  533. { 0x00200000, "TRAP" },
  534. { 0x01000000, "SINGLE_STEP" },
  535. {}
  536. };
  537. static void
  538. nv50_pgraph_mp_trap(struct drm_device *dev, int tpid, int display)
  539. {
  540. struct drm_nouveau_private *dev_priv = dev->dev_private;
  541. uint32_t units = nv_rd32(dev, 0x1540);
  542. uint32_t addr, mp10, status, pc, oplow, ophigh;
  543. int i;
  544. int mps = 0;
  545. for (i = 0; i < 4; i++) {
  546. if (!(units & 1 << (i+24)))
  547. continue;
  548. if (dev_priv->chipset < 0xa0)
  549. addr = 0x408200 + (tpid << 12) + (i << 7);
  550. else
  551. addr = 0x408100 + (tpid << 11) + (i << 7);
  552. mp10 = nv_rd32(dev, addr + 0x10);
  553. status = nv_rd32(dev, addr + 0x14);
  554. if (!status)
  555. continue;
  556. if (display) {
  557. nv_rd32(dev, addr + 0x20);
  558. pc = nv_rd32(dev, addr + 0x24);
  559. oplow = nv_rd32(dev, addr + 0x70);
  560. ophigh= nv_rd32(dev, addr + 0x74);
  561. NV_INFO(dev, "PGRAPH_TRAP_MP_EXEC - "
  562. "TP %d MP %d: ", tpid, i);
  563. nouveau_enum_print(nv50_mp_exec_error_names, status);
  564. printk(" at %06x warp %d, opcode %08x %08x\n",
  565. pc&0xffffff, pc >> 24,
  566. oplow, ophigh);
  567. }
  568. nv_wr32(dev, addr + 0x10, mp10);
  569. nv_wr32(dev, addr + 0x14, 0);
  570. mps++;
  571. }
  572. if (!mps && display)
  573. NV_INFO(dev, "PGRAPH_TRAP_MP_EXEC - TP %d: "
  574. "No MPs claiming errors?\n", tpid);
  575. }
  576. static void
  577. nv50_pgraph_tp_trap(struct drm_device *dev, int type, uint32_t ustatus_old,
  578. uint32_t ustatus_new, int display, const char *name)
  579. {
  580. struct drm_nouveau_private *dev_priv = dev->dev_private;
  581. int tps = 0;
  582. uint32_t units = nv_rd32(dev, 0x1540);
  583. int i, r;
  584. uint32_t ustatus_addr, ustatus;
  585. for (i = 0; i < 16; i++) {
  586. if (!(units & (1 << i)))
  587. continue;
  588. if (dev_priv->chipset < 0xa0)
  589. ustatus_addr = ustatus_old + (i << 12);
  590. else
  591. ustatus_addr = ustatus_new + (i << 11);
  592. ustatus = nv_rd32(dev, ustatus_addr) & 0x7fffffff;
  593. if (!ustatus)
  594. continue;
  595. tps++;
  596. switch (type) {
  597. case 6: /* texture error... unknown for now */
  598. if (display) {
  599. NV_ERROR(dev, "magic set %d:\n", i);
  600. for (r = ustatus_addr + 4; r <= ustatus_addr + 0x10; r += 4)
  601. NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
  602. nv_rd32(dev, r));
  603. }
  604. break;
  605. case 7: /* MP error */
  606. if (ustatus & 0x00010000) {
  607. nv50_pgraph_mp_trap(dev, i, display);
  608. ustatus &= ~0x00010000;
  609. }
  610. break;
  611. case 8: /* TPDMA error */
  612. {
  613. uint32_t e0c = nv_rd32(dev, ustatus_addr + 4);
  614. uint32_t e10 = nv_rd32(dev, ustatus_addr + 8);
  615. uint32_t e14 = nv_rd32(dev, ustatus_addr + 0xc);
  616. uint32_t e18 = nv_rd32(dev, ustatus_addr + 0x10);
  617. uint32_t e1c = nv_rd32(dev, ustatus_addr + 0x14);
  618. uint32_t e20 = nv_rd32(dev, ustatus_addr + 0x18);
  619. uint32_t e24 = nv_rd32(dev, ustatus_addr + 0x1c);
  620. /* 2d engine destination */
  621. if (ustatus & 0x00000010) {
  622. if (display) {
  623. NV_INFO(dev, "PGRAPH_TRAP_TPDMA_2D - TP %d - Unknown fault at address %02x%08x\n",
  624. i, e14, e10);
  625. NV_INFO(dev, "PGRAPH_TRAP_TPDMA_2D - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
  626. i, e0c, e18, e1c, e20, e24);
  627. }
  628. ustatus &= ~0x00000010;
  629. }
  630. /* Render target */
  631. if (ustatus & 0x00000040) {
  632. if (display) {
  633. NV_INFO(dev, "PGRAPH_TRAP_TPDMA_RT - TP %d - Unknown fault at address %02x%08x\n",
  634. i, e14, e10);
  635. NV_INFO(dev, "PGRAPH_TRAP_TPDMA_RT - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
  636. i, e0c, e18, e1c, e20, e24);
  637. }
  638. ustatus &= ~0x00000040;
  639. }
  640. /* CUDA memory: l[], g[] or stack. */
  641. if (ustatus & 0x00000080) {
  642. if (display) {
  643. if (e18 & 0x80000000) {
  644. /* g[] read fault? */
  645. NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Global read fault at address %02x%08x\n",
  646. i, e14, e10 | ((e18 >> 24) & 0x1f));
  647. e18 &= ~0x1f000000;
  648. } else if (e18 & 0xc) {
  649. /* g[] write fault? */
  650. NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Global write fault at address %02x%08x\n",
  651. i, e14, e10 | ((e18 >> 7) & 0x1f));
  652. e18 &= ~0x00000f80;
  653. } else {
  654. NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Unknown CUDA fault at address %02x%08x\n",
  655. i, e14, e10);
  656. }
  657. NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
  658. i, e0c, e18, e1c, e20, e24);
  659. }
  660. ustatus &= ~0x00000080;
  661. }
  662. }
  663. break;
  664. }
  665. if (ustatus) {
  666. if (display)
  667. NV_INFO(dev, "%s - TP%d: Unhandled ustatus 0x%08x\n", name, i, ustatus);
  668. }
  669. nv_wr32(dev, ustatus_addr, 0xc0000000);
  670. }
  671. if (!tps && display)
  672. NV_INFO(dev, "%s - No TPs claiming errors?\n", name);
  673. }
  674. static int
  675. nv50_pgraph_trap_handler(struct drm_device *dev, u32 display, u64 inst, u32 chid)
  676. {
  677. u32 status = nv_rd32(dev, 0x400108);
  678. u32 ustatus;
  679. if (!status && display) {
  680. NV_INFO(dev, "PGRAPH - TRAP: no units reporting traps?\n");
  681. return 1;
  682. }
  683. /* DISPATCH: Relays commands to other units and handles NOTIFY,
  684. * COND, QUERY. If you get a trap from it, the command is still stuck
  685. * in DISPATCH and you need to do something about it. */
  686. if (status & 0x001) {
  687. ustatus = nv_rd32(dev, 0x400804) & 0x7fffffff;
  688. if (!ustatus && display) {
  689. NV_INFO(dev, "PGRAPH_TRAP_DISPATCH - no ustatus?\n");
  690. }
  691. nv_wr32(dev, 0x400500, 0x00000000);
  692. /* Known to be triggered by screwed up NOTIFY and COND... */
  693. if (ustatus & 0x00000001) {
  694. u32 addr = nv_rd32(dev, 0x400808);
  695. u32 subc = (addr & 0x00070000) >> 16;
  696. u32 mthd = (addr & 0x00001ffc);
  697. u32 datal = nv_rd32(dev, 0x40080c);
  698. u32 datah = nv_rd32(dev, 0x400810);
  699. u32 class = nv_rd32(dev, 0x400814);
  700. u32 r848 = nv_rd32(dev, 0x400848);
  701. NV_INFO(dev, "PGRAPH - TRAP DISPATCH_FAULT\n");
  702. if (display && (addr & 0x80000000)) {
  703. NV_INFO(dev, "PGRAPH - ch %d (0x%010llx) "
  704. "subc %d class 0x%04x mthd 0x%04x "
  705. "data 0x%08x%08x "
  706. "400808 0x%08x 400848 0x%08x\n",
  707. chid, inst, subc, class, mthd, datah,
  708. datal, addr, r848);
  709. } else
  710. if (display) {
  711. NV_INFO(dev, "PGRAPH - no stuck command?\n");
  712. }
  713. nv_wr32(dev, 0x400808, 0);
  714. nv_wr32(dev, 0x4008e8, nv_rd32(dev, 0x4008e8) & 3);
  715. nv_wr32(dev, 0x400848, 0);
  716. ustatus &= ~0x00000001;
  717. }
  718. if (ustatus & 0x00000002) {
  719. u32 addr = nv_rd32(dev, 0x40084c);
  720. u32 subc = (addr & 0x00070000) >> 16;
  721. u32 mthd = (addr & 0x00001ffc);
  722. u32 data = nv_rd32(dev, 0x40085c);
  723. u32 class = nv_rd32(dev, 0x400814);
  724. NV_INFO(dev, "PGRAPH - TRAP DISPATCH_QUERY\n");
  725. if (display && (addr & 0x80000000)) {
  726. NV_INFO(dev, "PGRAPH - ch %d (0x%010llx) "
  727. "subc %d class 0x%04x mthd 0x%04x "
  728. "data 0x%08x 40084c 0x%08x\n",
  729. chid, inst, subc, class, mthd,
  730. data, addr);
  731. } else
  732. if (display) {
  733. NV_INFO(dev, "PGRAPH - no stuck command?\n");
  734. }
  735. nv_wr32(dev, 0x40084c, 0);
  736. ustatus &= ~0x00000002;
  737. }
  738. if (ustatus && display) {
  739. NV_INFO(dev, "PGRAPH - TRAP_DISPATCH (unknown "
  740. "0x%08x)\n", ustatus);
  741. }
  742. nv_wr32(dev, 0x400804, 0xc0000000);
  743. nv_wr32(dev, 0x400108, 0x001);
  744. status &= ~0x001;
  745. if (!status)
  746. return 0;
  747. }
  748. /* M2MF: Memory to memory copy engine. */
  749. if (status & 0x002) {
  750. u32 ustatus = nv_rd32(dev, 0x406800) & 0x7fffffff;
  751. if (display) {
  752. NV_INFO(dev, "PGRAPH - TRAP_M2MF");
  753. nouveau_bitfield_print(nv50_graph_trap_m2mf, ustatus);
  754. printk("\n");
  755. NV_INFO(dev, "PGRAPH - TRAP_M2MF %08x %08x %08x %08x\n",
  756. nv_rd32(dev, 0x406804), nv_rd32(dev, 0x406808),
  757. nv_rd32(dev, 0x40680c), nv_rd32(dev, 0x406810));
  758. }
  759. /* No sane way found yet -- just reset the bugger. */
  760. nv_wr32(dev, 0x400040, 2);
  761. nv_wr32(dev, 0x400040, 0);
  762. nv_wr32(dev, 0x406800, 0xc0000000);
  763. nv_wr32(dev, 0x400108, 0x002);
  764. status &= ~0x002;
  765. }
  766. /* VFETCH: Fetches data from vertex buffers. */
  767. if (status & 0x004) {
  768. u32 ustatus = nv_rd32(dev, 0x400c04) & 0x7fffffff;
  769. if (display) {
  770. NV_INFO(dev, "PGRAPH - TRAP_VFETCH");
  771. nouveau_bitfield_print(nv50_graph_trap_vfetch, ustatus);
  772. printk("\n");
  773. NV_INFO(dev, "PGRAPH - TRAP_VFETCH %08x %08x %08x %08x\n",
  774. nv_rd32(dev, 0x400c00), nv_rd32(dev, 0x400c08),
  775. nv_rd32(dev, 0x400c0c), nv_rd32(dev, 0x400c10));
  776. }
  777. nv_wr32(dev, 0x400c04, 0xc0000000);
  778. nv_wr32(dev, 0x400108, 0x004);
  779. status &= ~0x004;
  780. }
  781. /* STRMOUT: DirectX streamout / OpenGL transform feedback. */
  782. if (status & 0x008) {
  783. ustatus = nv_rd32(dev, 0x401800) & 0x7fffffff;
  784. if (display) {
  785. NV_INFO(dev, "PGRAPH - TRAP_STRMOUT");
  786. nouveau_bitfield_print(nv50_graph_trap_strmout, ustatus);
  787. printk("\n");
  788. NV_INFO(dev, "PGRAPH - TRAP_STRMOUT %08x %08x %08x %08x\n",
  789. nv_rd32(dev, 0x401804), nv_rd32(dev, 0x401808),
  790. nv_rd32(dev, 0x40180c), nv_rd32(dev, 0x401810));
  791. }
  792. /* No sane way found yet -- just reset the bugger. */
  793. nv_wr32(dev, 0x400040, 0x80);
  794. nv_wr32(dev, 0x400040, 0);
  795. nv_wr32(dev, 0x401800, 0xc0000000);
  796. nv_wr32(dev, 0x400108, 0x008);
  797. status &= ~0x008;
  798. }
  799. /* CCACHE: Handles code and c[] caches and fills them. */
  800. if (status & 0x010) {
  801. ustatus = nv_rd32(dev, 0x405018) & 0x7fffffff;
  802. if (display) {
  803. NV_INFO(dev, "PGRAPH - TRAP_CCACHE");
  804. nouveau_bitfield_print(nv50_graph_trap_ccache, ustatus);
  805. printk("\n");
  806. NV_INFO(dev, "PGRAPH - TRAP_CCACHE %08x %08x %08x %08x"
  807. " %08x %08x %08x\n",
  808. nv_rd32(dev, 0x405000), nv_rd32(dev, 0x405004),
  809. nv_rd32(dev, 0x405008), nv_rd32(dev, 0x40500c),
  810. nv_rd32(dev, 0x405010), nv_rd32(dev, 0x405014),
  811. nv_rd32(dev, 0x40501c));
  812. }
  813. nv_wr32(dev, 0x405018, 0xc0000000);
  814. nv_wr32(dev, 0x400108, 0x010);
  815. status &= ~0x010;
  816. }
  817. /* Unknown, not seen yet... 0x402000 is the only trap status reg
  818. * remaining, so try to handle it anyway. Perhaps related to that
  819. * unknown DMA slot on tesla? */
  820. if (status & 0x20) {
  821. ustatus = nv_rd32(dev, 0x402000) & 0x7fffffff;
  822. if (display)
  823. NV_INFO(dev, "PGRAPH - TRAP_UNKC04 0x%08x\n", ustatus);
  824. nv_wr32(dev, 0x402000, 0xc0000000);
  825. /* no status modifiction on purpose */
  826. }
  827. /* TEXTURE: CUDA texturing units */
  828. if (status & 0x040) {
  829. nv50_pgraph_tp_trap(dev, 6, 0x408900, 0x408600, display,
  830. "PGRAPH - TRAP_TEXTURE");
  831. nv_wr32(dev, 0x400108, 0x040);
  832. status &= ~0x040;
  833. }
  834. /* MP: CUDA execution engines. */
  835. if (status & 0x080) {
  836. nv50_pgraph_tp_trap(dev, 7, 0x408314, 0x40831c, display,
  837. "PGRAPH - TRAP_MP");
  838. nv_wr32(dev, 0x400108, 0x080);
  839. status &= ~0x080;
  840. }
  841. /* TPDMA: Handles TP-initiated uncached memory accesses:
  842. * l[], g[], stack, 2d surfaces, render targets. */
  843. if (status & 0x100) {
  844. nv50_pgraph_tp_trap(dev, 8, 0x408e08, 0x408708, display,
  845. "PGRAPH - TRAP_TPDMA");
  846. nv_wr32(dev, 0x400108, 0x100);
  847. status &= ~0x100;
  848. }
  849. if (status) {
  850. if (display)
  851. NV_INFO(dev, "PGRAPH - TRAP: unknown 0x%08x\n", status);
  852. nv_wr32(dev, 0x400108, status);
  853. }
  854. return 1;
  855. }
  856. static int
  857. nv50_graph_isr_chid(struct drm_device *dev, u64 inst)
  858. {
  859. struct drm_nouveau_private *dev_priv = dev->dev_private;
  860. struct nouveau_channel *chan;
  861. unsigned long flags;
  862. int i;
  863. spin_lock_irqsave(&dev_priv->channels.lock, flags);
  864. for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
  865. chan = dev_priv->channels.ptr[i];
  866. if (!chan || !chan->ramin)
  867. continue;
  868. if (inst == chan->ramin->vinst)
  869. break;
  870. }
  871. spin_unlock_irqrestore(&dev_priv->channels.lock, flags);
  872. return i;
  873. }
  874. static void
  875. nv50_graph_isr(struct drm_device *dev)
  876. {
  877. u32 stat;
  878. while ((stat = nv_rd32(dev, 0x400100))) {
  879. u64 inst = (u64)(nv_rd32(dev, 0x40032c) & 0x0fffffff) << 12;
  880. u32 chid = nv50_graph_isr_chid(dev, inst);
  881. u32 addr = nv_rd32(dev, NV04_PGRAPH_TRAPPED_ADDR);
  882. u32 subc = (addr & 0x00070000) >> 16;
  883. u32 mthd = (addr & 0x00001ffc);
  884. u32 data = nv_rd32(dev, NV04_PGRAPH_TRAPPED_DATA);
  885. u32 class = nv_rd32(dev, 0x400814);
  886. u32 show = stat;
  887. if (stat & 0x00000010) {
  888. if (!nouveau_gpuobj_mthd_call2(dev, chid, class,
  889. mthd, data))
  890. show &= ~0x00000010;
  891. }
  892. if (stat & 0x00001000) {
  893. nv_wr32(dev, 0x400500, 0x00000000);
  894. nv_wr32(dev, 0x400100, 0x00001000);
  895. nv_mask(dev, 0x40013c, 0x00001000, 0x00000000);
  896. nv50_graph_context_switch(dev);
  897. stat &= ~0x00001000;
  898. show &= ~0x00001000;
  899. }
  900. show = (show && nouveau_ratelimit()) ? show : 0;
  901. if (show & 0x00100000) {
  902. u32 ecode = nv_rd32(dev, 0x400110);
  903. NV_INFO(dev, "PGRAPH - DATA_ERROR ");
  904. nouveau_enum_print(nv50_data_error_names, ecode);
  905. printk("\n");
  906. }
  907. if (stat & 0x00200000) {
  908. if (!nv50_pgraph_trap_handler(dev, show, inst, chid))
  909. show &= ~0x00200000;
  910. }
  911. nv_wr32(dev, 0x400100, stat);
  912. nv_wr32(dev, 0x400500, 0x00010001);
  913. if (show) {
  914. NV_INFO(dev, "PGRAPH -");
  915. nouveau_bitfield_print(nv50_graph_intr, show);
  916. printk("\n");
  917. NV_INFO(dev, "PGRAPH - ch %d (0x%010llx) subc %d "
  918. "class 0x%04x mthd 0x%04x data 0x%08x\n",
  919. chid, inst, subc, class, mthd, data);
  920. nv50_fb_vm_trap(dev, 1);
  921. }
  922. }
  923. if (nv_rd32(dev, 0x400824) & (1 << 31))
  924. nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) & ~(1 << 31));
  925. }