nv40_graph.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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_grctx.h"
  30. static int nv40_graph_register(struct drm_device *);
  31. static void nv40_graph_isr(struct drm_device *);
  32. struct nouveau_channel *
  33. nv40_graph_channel(struct drm_device *dev)
  34. {
  35. struct drm_nouveau_private *dev_priv = dev->dev_private;
  36. uint32_t inst;
  37. int i;
  38. inst = nv_rd32(dev, NV40_PGRAPH_CTXCTL_CUR);
  39. if (!(inst & NV40_PGRAPH_CTXCTL_CUR_LOADED))
  40. return NULL;
  41. inst = (inst & NV40_PGRAPH_CTXCTL_CUR_INSTANCE) << 4;
  42. for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
  43. struct nouveau_channel *chan = dev_priv->channels.ptr[i];
  44. if (chan && chan->ramin_grctx &&
  45. chan->ramin_grctx->pinst == inst)
  46. return chan;
  47. }
  48. return NULL;
  49. }
  50. int
  51. nv40_graph_create_context(struct nouveau_channel *chan)
  52. {
  53. struct drm_device *dev = chan->dev;
  54. struct drm_nouveau_private *dev_priv = dev->dev_private;
  55. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  56. struct nouveau_grctx ctx = {};
  57. unsigned long flags;
  58. int ret;
  59. ret = nouveau_gpuobj_new(dev, chan, pgraph->grctx_size, 16,
  60. NVOBJ_FLAG_ZERO_ALLOC, &chan->ramin_grctx);
  61. if (ret)
  62. return ret;
  63. /* Initialise default context values */
  64. ctx.dev = chan->dev;
  65. ctx.mode = NOUVEAU_GRCTX_VALS;
  66. ctx.data = chan->ramin_grctx;
  67. nv40_grctx_init(&ctx);
  68. nv_wo32(chan->ramin_grctx, 0, chan->ramin_grctx->pinst);
  69. /* init grctx pointer in ramfc, and on PFIFO if channel is
  70. * already active there
  71. */
  72. spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
  73. nv_wo32(chan->ramfc, 0x38, chan->ramin_grctx->pinst >> 4);
  74. nv_mask(dev, 0x002500, 0x00000001, 0x00000000);
  75. if ((nv_rd32(dev, 0x003204) & 0x0000001f) == chan->id)
  76. nv_wr32(dev, 0x0032e0, chan->ramin_grctx->pinst >> 4);
  77. nv_mask(dev, 0x002500, 0x00000001, 0x00000001);
  78. spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
  79. return 0;
  80. }
  81. void
  82. nv40_graph_destroy_context(struct nouveau_channel *chan)
  83. {
  84. struct drm_device *dev = chan->dev;
  85. struct drm_nouveau_private *dev_priv = dev->dev_private;
  86. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  87. unsigned long flags;
  88. spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
  89. pgraph->fifo_access(dev, false);
  90. /* Unload the context if it's the currently active one */
  91. if (pgraph->channel(dev) == chan)
  92. pgraph->unload_context(dev);
  93. pgraph->fifo_access(dev, true);
  94. spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
  95. /* Free the context resources */
  96. nouveau_gpuobj_ref(NULL, &chan->ramin_grctx);
  97. }
  98. static int
  99. nv40_graph_transfer_context(struct drm_device *dev, uint32_t inst, int save)
  100. {
  101. uint32_t old_cp, tv = 1000, tmp;
  102. int i;
  103. old_cp = nv_rd32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER);
  104. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, inst);
  105. tmp = nv_rd32(dev, NV40_PGRAPH_CTXCTL_0310);
  106. tmp |= save ? NV40_PGRAPH_CTXCTL_0310_XFER_SAVE :
  107. NV40_PGRAPH_CTXCTL_0310_XFER_LOAD;
  108. nv_wr32(dev, NV40_PGRAPH_CTXCTL_0310, tmp);
  109. tmp = nv_rd32(dev, NV40_PGRAPH_CTXCTL_0304);
  110. tmp |= NV40_PGRAPH_CTXCTL_0304_XFER_CTX;
  111. nv_wr32(dev, NV40_PGRAPH_CTXCTL_0304, tmp);
  112. nouveau_wait_for_idle(dev);
  113. for (i = 0; i < tv; i++) {
  114. if (nv_rd32(dev, NV40_PGRAPH_CTXCTL_030C) == 0)
  115. break;
  116. }
  117. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, old_cp);
  118. if (i == tv) {
  119. uint32_t ucstat = nv_rd32(dev, NV40_PGRAPH_CTXCTL_UCODE_STAT);
  120. NV_ERROR(dev, "Failed: Instance=0x%08x Save=%d\n", inst, save);
  121. NV_ERROR(dev, "IP: 0x%02x, Opcode: 0x%08x\n",
  122. ucstat >> NV40_PGRAPH_CTXCTL_UCODE_STAT_IP_SHIFT,
  123. ucstat & NV40_PGRAPH_CTXCTL_UCODE_STAT_OP_MASK);
  124. NV_ERROR(dev, "0x40030C = 0x%08x\n",
  125. nv_rd32(dev, NV40_PGRAPH_CTXCTL_030C));
  126. return -EBUSY;
  127. }
  128. return 0;
  129. }
  130. /* Restore the context for a specific channel into PGRAPH */
  131. int
  132. nv40_graph_load_context(struct nouveau_channel *chan)
  133. {
  134. struct drm_device *dev = chan->dev;
  135. uint32_t inst;
  136. int ret;
  137. if (!chan->ramin_grctx)
  138. return -EINVAL;
  139. inst = chan->ramin_grctx->pinst >> 4;
  140. ret = nv40_graph_transfer_context(dev, inst, 0);
  141. if (ret)
  142. return ret;
  143. /* 0x40032C, no idea of it's exact function. Could simply be a
  144. * record of the currently active PGRAPH context. It's currently
  145. * unknown as to what bit 24 does. The nv ddx has it set, so we will
  146. * set it here too.
  147. */
  148. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, inst);
  149. nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR,
  150. (inst & NV40_PGRAPH_CTXCTL_CUR_INSTANCE) |
  151. NV40_PGRAPH_CTXCTL_CUR_LOADED);
  152. /* 0x32E0 records the instance address of the active FIFO's PGRAPH
  153. * context. If at any time this doesn't match 0x40032C, you will
  154. * recieve PGRAPH_INTR_CONTEXT_SWITCH
  155. */
  156. nv_wr32(dev, NV40_PFIFO_GRCTX_INSTANCE, inst);
  157. return 0;
  158. }
  159. int
  160. nv40_graph_unload_context(struct drm_device *dev)
  161. {
  162. uint32_t inst;
  163. int ret;
  164. inst = nv_rd32(dev, NV40_PGRAPH_CTXCTL_CUR);
  165. if (!(inst & NV40_PGRAPH_CTXCTL_CUR_LOADED))
  166. return 0;
  167. inst &= NV40_PGRAPH_CTXCTL_CUR_INSTANCE;
  168. ret = nv40_graph_transfer_context(dev, inst, 1);
  169. nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, inst);
  170. return ret;
  171. }
  172. void
  173. nv40_graph_set_tile_region(struct drm_device *dev, int i)
  174. {
  175. struct drm_nouveau_private *dev_priv = dev->dev_private;
  176. struct nouveau_tile_reg *tile = &dev_priv->tile.reg[i];
  177. switch (dev_priv->chipset) {
  178. case 0x44:
  179. case 0x4a:
  180. case 0x4e:
  181. nv_wr32(dev, NV20_PGRAPH_TSIZE(i), tile->pitch);
  182. nv_wr32(dev, NV20_PGRAPH_TLIMIT(i), tile->limit);
  183. nv_wr32(dev, NV20_PGRAPH_TILE(i), tile->addr);
  184. break;
  185. case 0x46:
  186. case 0x47:
  187. case 0x49:
  188. case 0x4b:
  189. nv_wr32(dev, NV47_PGRAPH_TSIZE(i), tile->pitch);
  190. nv_wr32(dev, NV47_PGRAPH_TLIMIT(i), tile->limit);
  191. nv_wr32(dev, NV47_PGRAPH_TILE(i), tile->addr);
  192. nv_wr32(dev, NV40_PGRAPH_TSIZE1(i), tile->pitch);
  193. nv_wr32(dev, NV40_PGRAPH_TLIMIT1(i), tile->limit);
  194. nv_wr32(dev, NV40_PGRAPH_TILE1(i), tile->addr);
  195. break;
  196. default:
  197. nv_wr32(dev, NV20_PGRAPH_TSIZE(i), tile->pitch);
  198. nv_wr32(dev, NV20_PGRAPH_TLIMIT(i), tile->limit);
  199. nv_wr32(dev, NV20_PGRAPH_TILE(i), tile->addr);
  200. nv_wr32(dev, NV40_PGRAPH_TSIZE1(i), tile->pitch);
  201. nv_wr32(dev, NV40_PGRAPH_TLIMIT1(i), tile->limit);
  202. nv_wr32(dev, NV40_PGRAPH_TILE1(i), tile->addr);
  203. break;
  204. }
  205. }
  206. /*
  207. * G70 0x47
  208. * G71 0x49
  209. * NV45 0x48
  210. * G72[M] 0x46
  211. * G73 0x4b
  212. * C51_G7X 0x4c
  213. * C51 0x4e
  214. */
  215. int
  216. nv40_graph_init(struct drm_device *dev)
  217. {
  218. struct drm_nouveau_private *dev_priv =
  219. (struct drm_nouveau_private *)dev->dev_private;
  220. struct nouveau_fb_engine *pfb = &dev_priv->engine.fb;
  221. struct nouveau_grctx ctx = {};
  222. uint32_t vramsz, *cp;
  223. int ret, i, j;
  224. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) &
  225. ~NV_PMC_ENABLE_PGRAPH);
  226. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) |
  227. NV_PMC_ENABLE_PGRAPH);
  228. cp = kmalloc(sizeof(*cp) * 256, GFP_KERNEL);
  229. if (!cp)
  230. return -ENOMEM;
  231. ctx.dev = dev;
  232. ctx.mode = NOUVEAU_GRCTX_PROG;
  233. ctx.data = cp;
  234. ctx.ctxprog_max = 256;
  235. nv40_grctx_init(&ctx);
  236. dev_priv->engine.graph.grctx_size = ctx.ctxvals_pos * 4;
  237. nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
  238. for (i = 0; i < ctx.ctxprog_len; i++)
  239. nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, cp[i]);
  240. kfree(cp);
  241. ret = nv40_graph_register(dev);
  242. if (ret)
  243. return ret;
  244. /* No context present currently */
  245. nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0x00000000);
  246. nouveau_irq_register(dev, 12, nv40_graph_isr);
  247. nv_wr32(dev, NV03_PGRAPH_INTR , 0xFFFFFFFF);
  248. nv_wr32(dev, NV40_PGRAPH_INTR_EN, 0xFFFFFFFF);
  249. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0xFFFFFFFF);
  250. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x00000000);
  251. nv_wr32(dev, NV04_PGRAPH_DEBUG_1, 0x401287c0);
  252. nv_wr32(dev, NV04_PGRAPH_DEBUG_3, 0xe0de8055);
  253. nv_wr32(dev, NV10_PGRAPH_DEBUG_4, 0x00008000);
  254. nv_wr32(dev, NV04_PGRAPH_LIMIT_VIOL_PIX, 0x00be3c5f);
  255. nv_wr32(dev, NV10_PGRAPH_CTX_CONTROL, 0x10010100);
  256. nv_wr32(dev, NV10_PGRAPH_STATE , 0xFFFFFFFF);
  257. j = nv_rd32(dev, 0x1540) & 0xff;
  258. if (j) {
  259. for (i = 0; !(j & 1); j >>= 1, i++)
  260. ;
  261. nv_wr32(dev, 0x405000, i);
  262. }
  263. if (dev_priv->chipset == 0x40) {
  264. nv_wr32(dev, 0x4009b0, 0x83280fff);
  265. nv_wr32(dev, 0x4009b4, 0x000000a0);
  266. } else {
  267. nv_wr32(dev, 0x400820, 0x83280eff);
  268. nv_wr32(dev, 0x400824, 0x000000a0);
  269. }
  270. switch (dev_priv->chipset) {
  271. case 0x40:
  272. case 0x45:
  273. nv_wr32(dev, 0x4009b8, 0x0078e366);
  274. nv_wr32(dev, 0x4009bc, 0x0000014c);
  275. break;
  276. case 0x41:
  277. case 0x42: /* pciid also 0x00Cx */
  278. /* case 0x0120: XXX (pciid) */
  279. nv_wr32(dev, 0x400828, 0x007596ff);
  280. nv_wr32(dev, 0x40082c, 0x00000108);
  281. break;
  282. case 0x43:
  283. nv_wr32(dev, 0x400828, 0x0072cb77);
  284. nv_wr32(dev, 0x40082c, 0x00000108);
  285. break;
  286. case 0x44:
  287. case 0x46: /* G72 */
  288. case 0x4a:
  289. case 0x4c: /* G7x-based C51 */
  290. case 0x4e:
  291. nv_wr32(dev, 0x400860, 0);
  292. nv_wr32(dev, 0x400864, 0);
  293. break;
  294. case 0x47: /* G70 */
  295. case 0x49: /* G71 */
  296. case 0x4b: /* G73 */
  297. nv_wr32(dev, 0x400828, 0x07830610);
  298. nv_wr32(dev, 0x40082c, 0x0000016A);
  299. break;
  300. default:
  301. break;
  302. }
  303. nv_wr32(dev, 0x400b38, 0x2ffff800);
  304. nv_wr32(dev, 0x400b3c, 0x00006000);
  305. /* Tiling related stuff. */
  306. switch (dev_priv->chipset) {
  307. case 0x44:
  308. case 0x4a:
  309. nv_wr32(dev, 0x400bc4, 0x1003d888);
  310. nv_wr32(dev, 0x400bbc, 0xb7a7b500);
  311. break;
  312. case 0x46:
  313. nv_wr32(dev, 0x400bc4, 0x0000e024);
  314. nv_wr32(dev, 0x400bbc, 0xb7a7b520);
  315. break;
  316. case 0x4c:
  317. case 0x4e:
  318. case 0x67:
  319. nv_wr32(dev, 0x400bc4, 0x1003d888);
  320. nv_wr32(dev, 0x400bbc, 0xb7a7b540);
  321. break;
  322. default:
  323. break;
  324. }
  325. /* Turn all the tiling regions off. */
  326. for (i = 0; i < pfb->num_tiles; i++)
  327. nv40_graph_set_tile_region(dev, i);
  328. /* begin RAM config */
  329. vramsz = pci_resource_len(dev->pdev, 0) - 1;
  330. switch (dev_priv->chipset) {
  331. case 0x40:
  332. nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
  333. nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
  334. nv_wr32(dev, 0x4069A4, nv_rd32(dev, NV04_PFB_CFG0));
  335. nv_wr32(dev, 0x4069A8, nv_rd32(dev, NV04_PFB_CFG1));
  336. nv_wr32(dev, 0x400820, 0);
  337. nv_wr32(dev, 0x400824, 0);
  338. nv_wr32(dev, 0x400864, vramsz);
  339. nv_wr32(dev, 0x400868, vramsz);
  340. break;
  341. default:
  342. switch (dev_priv->chipset) {
  343. case 0x46:
  344. case 0x47:
  345. case 0x49:
  346. case 0x4b:
  347. nv_wr32(dev, 0x400DF0, nv_rd32(dev, NV04_PFB_CFG0));
  348. nv_wr32(dev, 0x400DF4, nv_rd32(dev, NV04_PFB_CFG1));
  349. break;
  350. default:
  351. nv_wr32(dev, 0x4009F0, nv_rd32(dev, NV04_PFB_CFG0));
  352. nv_wr32(dev, 0x4009F4, nv_rd32(dev, NV04_PFB_CFG1));
  353. break;
  354. }
  355. nv_wr32(dev, 0x4069F0, nv_rd32(dev, NV04_PFB_CFG0));
  356. nv_wr32(dev, 0x4069F4, nv_rd32(dev, NV04_PFB_CFG1));
  357. nv_wr32(dev, 0x400840, 0);
  358. nv_wr32(dev, 0x400844, 0);
  359. nv_wr32(dev, 0x4008A0, vramsz);
  360. nv_wr32(dev, 0x4008A4, vramsz);
  361. break;
  362. }
  363. return 0;
  364. }
  365. void nv40_graph_takedown(struct drm_device *dev)
  366. {
  367. nouveau_irq_unregister(dev, 12);
  368. }
  369. static int
  370. nv40_graph_register(struct drm_device *dev)
  371. {
  372. struct drm_nouveau_private *dev_priv = dev->dev_private;
  373. if (dev_priv->engine.graph.registered)
  374. return 0;
  375. NVOBJ_CLASS(dev, 0x506e, SW); /* nvsw */
  376. NVOBJ_CLASS(dev, 0x0030, GR); /* null */
  377. NVOBJ_CLASS(dev, 0x0039, GR); /* m2mf */
  378. NVOBJ_CLASS(dev, 0x004a, GR); /* gdirect */
  379. NVOBJ_CLASS(dev, 0x009f, GR); /* imageblit (nv12) */
  380. NVOBJ_CLASS(dev, 0x008a, GR); /* ifc */
  381. NVOBJ_CLASS(dev, 0x0089, GR); /* sifm */
  382. NVOBJ_CLASS(dev, 0x3089, GR); /* sifm (nv40) */
  383. NVOBJ_CLASS(dev, 0x0062, GR); /* surf2d */
  384. NVOBJ_CLASS(dev, 0x3062, GR); /* surf2d (nv40) */
  385. NVOBJ_CLASS(dev, 0x0043, GR); /* rop */
  386. NVOBJ_CLASS(dev, 0x0012, GR); /* beta1 */
  387. NVOBJ_CLASS(dev, 0x0072, GR); /* beta4 */
  388. NVOBJ_CLASS(dev, 0x0019, GR); /* cliprect */
  389. NVOBJ_CLASS(dev, 0x0044, GR); /* pattern */
  390. NVOBJ_CLASS(dev, 0x309e, GR); /* swzsurf */
  391. /* curie */
  392. if (dev_priv->chipset >= 0x60 ||
  393. 0x00005450 & (1 << (dev_priv->chipset & 0x0f)))
  394. NVOBJ_CLASS(dev, 0x4497, GR);
  395. else
  396. NVOBJ_CLASS(dev, 0x4097, GR);
  397. /* nvsw */
  398. NVOBJ_CLASS(dev, 0x506e, SW);
  399. NVOBJ_MTHD (dev, 0x506e, 0x0500, nv04_graph_mthd_page_flip);
  400. dev_priv->engine.graph.registered = true;
  401. return 0;
  402. }
  403. static int
  404. nv40_graph_isr_chid(struct drm_device *dev, u32 inst)
  405. {
  406. struct drm_nouveau_private *dev_priv = dev->dev_private;
  407. struct nouveau_channel *chan;
  408. unsigned long flags;
  409. int i;
  410. spin_lock_irqsave(&dev_priv->channels.lock, flags);
  411. for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
  412. chan = dev_priv->channels.ptr[i];
  413. if (!chan || !chan->ramin_grctx)
  414. continue;
  415. if (inst == chan->ramin_grctx->pinst)
  416. break;
  417. }
  418. spin_unlock_irqrestore(&dev_priv->channels.lock, flags);
  419. return i;
  420. }
  421. static void
  422. nv40_graph_isr(struct drm_device *dev)
  423. {
  424. u32 stat;
  425. while ((stat = nv_rd32(dev, NV03_PGRAPH_INTR))) {
  426. u32 nsource = nv_rd32(dev, NV03_PGRAPH_NSOURCE);
  427. u32 nstatus = nv_rd32(dev, NV03_PGRAPH_NSTATUS);
  428. u32 inst = (nv_rd32(dev, 0x40032c) & 0x000fffff) << 4;
  429. u32 chid = nv40_graph_isr_chid(dev, inst);
  430. u32 addr = nv_rd32(dev, NV04_PGRAPH_TRAPPED_ADDR);
  431. u32 subc = (addr & 0x00070000) >> 16;
  432. u32 mthd = (addr & 0x00001ffc);
  433. u32 data = nv_rd32(dev, NV04_PGRAPH_TRAPPED_DATA);
  434. u32 class = nv_rd32(dev, 0x400160 + subc * 4) & 0xffff;
  435. u32 show = stat;
  436. if (stat & NV_PGRAPH_INTR_ERROR) {
  437. if (nsource & NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD) {
  438. if (!nouveau_gpuobj_mthd_call2(dev, chid, class, mthd, data))
  439. show &= ~NV_PGRAPH_INTR_ERROR;
  440. } else
  441. if (nsource & NV03_PGRAPH_NSOURCE_DMA_VTX_PROTECTION) {
  442. nv_mask(dev, 0x402000, 0, 0);
  443. }
  444. }
  445. nv_wr32(dev, NV03_PGRAPH_INTR, stat);
  446. nv_wr32(dev, NV04_PGRAPH_FIFO, 0x00000001);
  447. if (show && nouveau_ratelimit()) {
  448. NV_INFO(dev, "PGRAPH -");
  449. nouveau_bitfield_print(nv10_graph_intr, show);
  450. printk(" nsource:");
  451. nouveau_bitfield_print(nv04_graph_nsource, nsource);
  452. printk(" nstatus:");
  453. nouveau_bitfield_print(nv10_graph_nstatus, nstatus);
  454. printk("\n");
  455. NV_INFO(dev, "PGRAPH - ch %d (0x%08x) subc %d "
  456. "class 0x%04x mthd 0x%04x data 0x%08x\n",
  457. chid, inst, subc, class, mthd, data);
  458. }
  459. }
  460. }