nv50_graph.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  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. nv84_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. { 3, "STACK_UNDERFLOW", NULL },
  454. { 4, "QUADON_ACTIVE", NULL },
  455. { 8, "TIMEOUT", NULL },
  456. { 0x10, "INVALID_OPCODE", NULL },
  457. { 0x40, "BREAKPOINT", NULL },
  458. {}
  459. };
  460. static struct nouveau_bitfield nv50_graph_trap_m2mf[] = {
  461. { 0x00000001, "NOTIFY" },
  462. { 0x00000002, "IN" },
  463. { 0x00000004, "OUT" },
  464. {}
  465. };
  466. static struct nouveau_bitfield nv50_graph_trap_vfetch[] = {
  467. { 0x00000001, "FAULT" },
  468. {}
  469. };
  470. static struct nouveau_bitfield nv50_graph_trap_strmout[] = {
  471. { 0x00000001, "FAULT" },
  472. {}
  473. };
  474. static struct nouveau_bitfield nv50_graph_trap_ccache[] = {
  475. { 0x00000001, "FAULT" },
  476. {}
  477. };
  478. /* There must be a *lot* of these. Will take some time to gather them up. */
  479. struct nouveau_enum nv50_data_error_names[] = {
  480. { 0x00000003, "INVALID_QUERY_OR_TEXTURE", NULL },
  481. { 0x00000004, "INVALID_VALUE", NULL },
  482. { 0x00000005, "INVALID_ENUM", NULL },
  483. { 0x00000008, "INVALID_OBJECT", NULL },
  484. { 0x00000009, "READ_ONLY_OBJECT", NULL },
  485. { 0x0000000a, "SUPERVISOR_OBJECT", NULL },
  486. { 0x0000000b, "INVALID_ADDRESS_ALIGNMENT", NULL },
  487. { 0x0000000c, "INVALID_BITFIELD", NULL },
  488. { 0x0000000d, "BEGIN_END_ACTIVE", NULL },
  489. { 0x0000000e, "SEMANTIC_COLOR_BACK_OVER_LIMIT", NULL },
  490. { 0x0000000f, "VIEWPORT_ID_NEEDS_GP", NULL },
  491. { 0x00000010, "RT_DOUBLE_BIND", NULL },
  492. { 0x00000011, "RT_TYPES_MISMATCH", NULL },
  493. { 0x00000012, "RT_LINEAR_WITH_ZETA", NULL },
  494. { 0x00000015, "FP_TOO_FEW_REGS", NULL },
  495. { 0x00000016, "ZETA_FORMAT_CSAA_MISMATCH", NULL },
  496. { 0x00000017, "RT_LINEAR_WITH_MSAA", NULL },
  497. { 0x00000018, "FP_INTERPOLANT_START_OVER_LIMIT", NULL },
  498. { 0x00000019, "SEMANTIC_LAYER_OVER_LIMIT", NULL },
  499. { 0x0000001a, "RT_INVALID_ALIGNMENT", NULL },
  500. { 0x0000001b, "SAMPLER_OVER_LIMIT", NULL },
  501. { 0x0000001c, "TEXTURE_OVER_LIMIT", NULL },
  502. { 0x0000001e, "GP_TOO_MANY_OUTPUTS", NULL },
  503. { 0x0000001f, "RT_BPP128_WITH_MS8", NULL },
  504. { 0x00000021, "Z_OUT_OF_BOUNDS", NULL },
  505. { 0x00000023, "XY_OUT_OF_BOUNDS", NULL },
  506. { 0x00000027, "CP_MORE_PARAMS_THAN_SHARED", NULL },
  507. { 0x00000028, "CP_NO_REG_SPACE_STRIPED", NULL },
  508. { 0x00000029, "CP_NO_REG_SPACE_PACKED", NULL },
  509. { 0x0000002a, "CP_NOT_ENOUGH_WARPS", NULL },
  510. { 0x0000002b, "CP_BLOCK_SIZE_MISMATCH", NULL },
  511. { 0x0000002c, "CP_NOT_ENOUGH_LOCAL_WARPS", NULL },
  512. { 0x0000002d, "CP_NOT_ENOUGH_STACK_WARPS", NULL },
  513. { 0x0000002e, "CP_NO_BLOCKDIM_LATCH", NULL },
  514. { 0x00000031, "ENG2D_FORMAT_MISMATCH", NULL },
  515. { 0x0000003f, "PRIMITIVE_ID_NEEDS_GP", NULL },
  516. { 0x00000044, "SEMANTIC_VIEWPORT_OVER_LIMIT", NULL },
  517. { 0x00000045, "SEMANTIC_COLOR_FRONT_OVER_LIMIT", NULL },
  518. { 0x00000046, "LAYER_ID_NEEDS_GP", NULL },
  519. { 0x00000047, "SEMANTIC_CLIP_OVER_LIMIT", NULL },
  520. { 0x00000048, "SEMANTIC_PTSZ_OVER_LIMIT", NULL },
  521. {}
  522. };
  523. static struct nouveau_bitfield nv50_graph_intr[] = {
  524. { 0x00000001, "NOTIFY" },
  525. { 0x00000002, "COMPUTE_QUERY" },
  526. { 0x00000010, "ILLEGAL_MTHD" },
  527. { 0x00000020, "ILLEGAL_CLASS" },
  528. { 0x00000040, "DOUBLE_NOTIFY" },
  529. { 0x00001000, "CONTEXT_SWITCH" },
  530. { 0x00010000, "BUFFER_NOTIFY" },
  531. { 0x00100000, "DATA_ERROR" },
  532. { 0x00200000, "TRAP" },
  533. { 0x01000000, "SINGLE_STEP" },
  534. {}
  535. };
  536. static void
  537. nv50_pgraph_mp_trap(struct drm_device *dev, int tpid, int display)
  538. {
  539. struct drm_nouveau_private *dev_priv = dev->dev_private;
  540. uint32_t units = nv_rd32(dev, 0x1540);
  541. uint32_t addr, mp10, status, pc, oplow, ophigh;
  542. int i;
  543. int mps = 0;
  544. for (i = 0; i < 4; i++) {
  545. if (!(units & 1 << (i+24)))
  546. continue;
  547. if (dev_priv->chipset < 0xa0)
  548. addr = 0x408200 + (tpid << 12) + (i << 7);
  549. else
  550. addr = 0x408100 + (tpid << 11) + (i << 7);
  551. mp10 = nv_rd32(dev, addr + 0x10);
  552. status = nv_rd32(dev, addr + 0x14);
  553. if (!status)
  554. continue;
  555. if (display) {
  556. nv_rd32(dev, addr + 0x20);
  557. pc = nv_rd32(dev, addr + 0x24);
  558. oplow = nv_rd32(dev, addr + 0x70);
  559. ophigh= nv_rd32(dev, addr + 0x74);
  560. NV_INFO(dev, "PGRAPH_TRAP_MP_EXEC - "
  561. "TP %d MP %d: ", tpid, i);
  562. nouveau_enum_print(nv50_mp_exec_error_names, status);
  563. printk(" at %06x warp %d, opcode %08x %08x\n",
  564. pc&0xffffff, pc >> 24,
  565. oplow, ophigh);
  566. }
  567. nv_wr32(dev, addr + 0x10, mp10);
  568. nv_wr32(dev, addr + 0x14, 0);
  569. mps++;
  570. }
  571. if (!mps && display)
  572. NV_INFO(dev, "PGRAPH_TRAP_MP_EXEC - TP %d: "
  573. "No MPs claiming errors?\n", tpid);
  574. }
  575. static void
  576. nv50_pgraph_tp_trap(struct drm_device *dev, int type, uint32_t ustatus_old,
  577. uint32_t ustatus_new, int display, const char *name)
  578. {
  579. struct drm_nouveau_private *dev_priv = dev->dev_private;
  580. int tps = 0;
  581. uint32_t units = nv_rd32(dev, 0x1540);
  582. int i, r;
  583. uint32_t ustatus_addr, ustatus;
  584. for (i = 0; i < 16; i++) {
  585. if (!(units & (1 << i)))
  586. continue;
  587. if (dev_priv->chipset < 0xa0)
  588. ustatus_addr = ustatus_old + (i << 12);
  589. else
  590. ustatus_addr = ustatus_new + (i << 11);
  591. ustatus = nv_rd32(dev, ustatus_addr) & 0x7fffffff;
  592. if (!ustatus)
  593. continue;
  594. tps++;
  595. switch (type) {
  596. case 6: /* texture error... unknown for now */
  597. if (display) {
  598. NV_ERROR(dev, "magic set %d:\n", i);
  599. for (r = ustatus_addr + 4; r <= ustatus_addr + 0x10; r += 4)
  600. NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
  601. nv_rd32(dev, r));
  602. }
  603. break;
  604. case 7: /* MP error */
  605. if (ustatus & 0x00010000) {
  606. nv50_pgraph_mp_trap(dev, i, display);
  607. ustatus &= ~0x00010000;
  608. }
  609. break;
  610. case 8: /* TPDMA error */
  611. {
  612. uint32_t e0c = nv_rd32(dev, ustatus_addr + 4);
  613. uint32_t e10 = nv_rd32(dev, ustatus_addr + 8);
  614. uint32_t e14 = nv_rd32(dev, ustatus_addr + 0xc);
  615. uint32_t e18 = nv_rd32(dev, ustatus_addr + 0x10);
  616. uint32_t e1c = nv_rd32(dev, ustatus_addr + 0x14);
  617. uint32_t e20 = nv_rd32(dev, ustatus_addr + 0x18);
  618. uint32_t e24 = nv_rd32(dev, ustatus_addr + 0x1c);
  619. /* 2d engine destination */
  620. if (ustatus & 0x00000010) {
  621. if (display) {
  622. NV_INFO(dev, "PGRAPH_TRAP_TPDMA_2D - TP %d - Unknown fault at address %02x%08x\n",
  623. i, e14, e10);
  624. NV_INFO(dev, "PGRAPH_TRAP_TPDMA_2D - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
  625. i, e0c, e18, e1c, e20, e24);
  626. }
  627. ustatus &= ~0x00000010;
  628. }
  629. /* Render target */
  630. if (ustatus & 0x00000040) {
  631. if (display) {
  632. NV_INFO(dev, "PGRAPH_TRAP_TPDMA_RT - TP %d - Unknown fault at address %02x%08x\n",
  633. i, e14, e10);
  634. NV_INFO(dev, "PGRAPH_TRAP_TPDMA_RT - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
  635. i, e0c, e18, e1c, e20, e24);
  636. }
  637. ustatus &= ~0x00000040;
  638. }
  639. /* CUDA memory: l[], g[] or stack. */
  640. if (ustatus & 0x00000080) {
  641. if (display) {
  642. if (e18 & 0x80000000) {
  643. /* g[] read fault? */
  644. NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Global read fault at address %02x%08x\n",
  645. i, e14, e10 | ((e18 >> 24) & 0x1f));
  646. e18 &= ~0x1f000000;
  647. } else if (e18 & 0xc) {
  648. /* g[] write fault? */
  649. NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Global write fault at address %02x%08x\n",
  650. i, e14, e10 | ((e18 >> 7) & 0x1f));
  651. e18 &= ~0x00000f80;
  652. } else {
  653. NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Unknown CUDA fault at address %02x%08x\n",
  654. i, e14, e10);
  655. }
  656. NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
  657. i, e0c, e18, e1c, e20, e24);
  658. }
  659. ustatus &= ~0x00000080;
  660. }
  661. }
  662. break;
  663. }
  664. if (ustatus) {
  665. if (display)
  666. NV_INFO(dev, "%s - TP%d: Unhandled ustatus 0x%08x\n", name, i, ustatus);
  667. }
  668. nv_wr32(dev, ustatus_addr, 0xc0000000);
  669. }
  670. if (!tps && display)
  671. NV_INFO(dev, "%s - No TPs claiming errors?\n", name);
  672. }
  673. static int
  674. nv50_pgraph_trap_handler(struct drm_device *dev, u32 display, u64 inst, u32 chid)
  675. {
  676. u32 status = nv_rd32(dev, 0x400108);
  677. u32 ustatus;
  678. if (!status && display) {
  679. NV_INFO(dev, "PGRAPH - TRAP: no units reporting traps?\n");
  680. return 1;
  681. }
  682. /* DISPATCH: Relays commands to other units and handles NOTIFY,
  683. * COND, QUERY. If you get a trap from it, the command is still stuck
  684. * in DISPATCH and you need to do something about it. */
  685. if (status & 0x001) {
  686. ustatus = nv_rd32(dev, 0x400804) & 0x7fffffff;
  687. if (!ustatus && display) {
  688. NV_INFO(dev, "PGRAPH_TRAP_DISPATCH - no ustatus?\n");
  689. }
  690. nv_wr32(dev, 0x400500, 0x00000000);
  691. /* Known to be triggered by screwed up NOTIFY and COND... */
  692. if (ustatus & 0x00000001) {
  693. u32 addr = nv_rd32(dev, 0x400808);
  694. u32 subc = (addr & 0x00070000) >> 16;
  695. u32 mthd = (addr & 0x00001ffc);
  696. u32 datal = nv_rd32(dev, 0x40080c);
  697. u32 datah = nv_rd32(dev, 0x400810);
  698. u32 class = nv_rd32(dev, 0x400814);
  699. u32 r848 = nv_rd32(dev, 0x400848);
  700. NV_INFO(dev, "PGRAPH - TRAP DISPATCH_FAULT\n");
  701. if (display && (addr & 0x80000000)) {
  702. NV_INFO(dev, "PGRAPH - ch %d (0x%010llx) "
  703. "subc %d class 0x%04x mthd 0x%04x "
  704. "data 0x%08x%08x "
  705. "400808 0x%08x 400848 0x%08x\n",
  706. chid, inst, subc, class, mthd, datah,
  707. datal, addr, r848);
  708. } else
  709. if (display) {
  710. NV_INFO(dev, "PGRAPH - no stuck command?\n");
  711. }
  712. nv_wr32(dev, 0x400808, 0);
  713. nv_wr32(dev, 0x4008e8, nv_rd32(dev, 0x4008e8) & 3);
  714. nv_wr32(dev, 0x400848, 0);
  715. ustatus &= ~0x00000001;
  716. }
  717. if (ustatus & 0x00000002) {
  718. u32 addr = nv_rd32(dev, 0x40084c);
  719. u32 subc = (addr & 0x00070000) >> 16;
  720. u32 mthd = (addr & 0x00001ffc);
  721. u32 data = nv_rd32(dev, 0x40085c);
  722. u32 class = nv_rd32(dev, 0x400814);
  723. NV_INFO(dev, "PGRAPH - TRAP DISPATCH_QUERY\n");
  724. if (display && (addr & 0x80000000)) {
  725. NV_INFO(dev, "PGRAPH - ch %d (0x%010llx) "
  726. "subc %d class 0x%04x mthd 0x%04x "
  727. "data 0x%08x 40084c 0x%08x\n",
  728. chid, inst, subc, class, mthd,
  729. data, addr);
  730. } else
  731. if (display) {
  732. NV_INFO(dev, "PGRAPH - no stuck command?\n");
  733. }
  734. nv_wr32(dev, 0x40084c, 0);
  735. ustatus &= ~0x00000002;
  736. }
  737. if (ustatus && display) {
  738. NV_INFO(dev, "PGRAPH - TRAP_DISPATCH (unknown "
  739. "0x%08x)\n", ustatus);
  740. }
  741. nv_wr32(dev, 0x400804, 0xc0000000);
  742. nv_wr32(dev, 0x400108, 0x001);
  743. status &= ~0x001;
  744. if (!status)
  745. return 0;
  746. }
  747. /* M2MF: Memory to memory copy engine. */
  748. if (status & 0x002) {
  749. u32 ustatus = nv_rd32(dev, 0x406800) & 0x7fffffff;
  750. if (display) {
  751. NV_INFO(dev, "PGRAPH - TRAP_M2MF");
  752. nouveau_bitfield_print(nv50_graph_trap_m2mf, ustatus);
  753. printk("\n");
  754. NV_INFO(dev, "PGRAPH - TRAP_M2MF %08x %08x %08x %08x\n",
  755. nv_rd32(dev, 0x406804), nv_rd32(dev, 0x406808),
  756. nv_rd32(dev, 0x40680c), nv_rd32(dev, 0x406810));
  757. }
  758. /* No sane way found yet -- just reset the bugger. */
  759. nv_wr32(dev, 0x400040, 2);
  760. nv_wr32(dev, 0x400040, 0);
  761. nv_wr32(dev, 0x406800, 0xc0000000);
  762. nv_wr32(dev, 0x400108, 0x002);
  763. status &= ~0x002;
  764. }
  765. /* VFETCH: Fetches data from vertex buffers. */
  766. if (status & 0x004) {
  767. u32 ustatus = nv_rd32(dev, 0x400c04) & 0x7fffffff;
  768. if (display) {
  769. NV_INFO(dev, "PGRAPH - TRAP_VFETCH");
  770. nouveau_bitfield_print(nv50_graph_trap_vfetch, ustatus);
  771. printk("\n");
  772. NV_INFO(dev, "PGRAPH - TRAP_VFETCH %08x %08x %08x %08x\n",
  773. nv_rd32(dev, 0x400c00), nv_rd32(dev, 0x400c08),
  774. nv_rd32(dev, 0x400c0c), nv_rd32(dev, 0x400c10));
  775. }
  776. nv_wr32(dev, 0x400c04, 0xc0000000);
  777. nv_wr32(dev, 0x400108, 0x004);
  778. status &= ~0x004;
  779. }
  780. /* STRMOUT: DirectX streamout / OpenGL transform feedback. */
  781. if (status & 0x008) {
  782. ustatus = nv_rd32(dev, 0x401800) & 0x7fffffff;
  783. if (display) {
  784. NV_INFO(dev, "PGRAPH - TRAP_STRMOUT");
  785. nouveau_bitfield_print(nv50_graph_trap_strmout, ustatus);
  786. printk("\n");
  787. NV_INFO(dev, "PGRAPH - TRAP_STRMOUT %08x %08x %08x %08x\n",
  788. nv_rd32(dev, 0x401804), nv_rd32(dev, 0x401808),
  789. nv_rd32(dev, 0x40180c), nv_rd32(dev, 0x401810));
  790. }
  791. /* No sane way found yet -- just reset the bugger. */
  792. nv_wr32(dev, 0x400040, 0x80);
  793. nv_wr32(dev, 0x400040, 0);
  794. nv_wr32(dev, 0x401800, 0xc0000000);
  795. nv_wr32(dev, 0x400108, 0x008);
  796. status &= ~0x008;
  797. }
  798. /* CCACHE: Handles code and c[] caches and fills them. */
  799. if (status & 0x010) {
  800. ustatus = nv_rd32(dev, 0x405018) & 0x7fffffff;
  801. if (display) {
  802. NV_INFO(dev, "PGRAPH - TRAP_CCACHE");
  803. nouveau_bitfield_print(nv50_graph_trap_ccache, ustatus);
  804. printk("\n");
  805. NV_INFO(dev, "PGRAPH - TRAP_CCACHE %08x %08x %08x %08x"
  806. " %08x %08x %08x\n",
  807. nv_rd32(dev, 0x405000), nv_rd32(dev, 0x405004),
  808. nv_rd32(dev, 0x405008), nv_rd32(dev, 0x40500c),
  809. nv_rd32(dev, 0x405010), nv_rd32(dev, 0x405014),
  810. nv_rd32(dev, 0x40501c));
  811. }
  812. nv_wr32(dev, 0x405018, 0xc0000000);
  813. nv_wr32(dev, 0x400108, 0x010);
  814. status &= ~0x010;
  815. }
  816. /* Unknown, not seen yet... 0x402000 is the only trap status reg
  817. * remaining, so try to handle it anyway. Perhaps related to that
  818. * unknown DMA slot on tesla? */
  819. if (status & 0x20) {
  820. ustatus = nv_rd32(dev, 0x402000) & 0x7fffffff;
  821. if (display)
  822. NV_INFO(dev, "PGRAPH - TRAP_UNKC04 0x%08x\n", ustatus);
  823. nv_wr32(dev, 0x402000, 0xc0000000);
  824. /* no status modifiction on purpose */
  825. }
  826. /* TEXTURE: CUDA texturing units */
  827. if (status & 0x040) {
  828. nv50_pgraph_tp_trap(dev, 6, 0x408900, 0x408600, display,
  829. "PGRAPH - TRAP_TEXTURE");
  830. nv_wr32(dev, 0x400108, 0x040);
  831. status &= ~0x040;
  832. }
  833. /* MP: CUDA execution engines. */
  834. if (status & 0x080) {
  835. nv50_pgraph_tp_trap(dev, 7, 0x408314, 0x40831c, display,
  836. "PGRAPH - TRAP_MP");
  837. nv_wr32(dev, 0x400108, 0x080);
  838. status &= ~0x080;
  839. }
  840. /* TPDMA: Handles TP-initiated uncached memory accesses:
  841. * l[], g[], stack, 2d surfaces, render targets. */
  842. if (status & 0x100) {
  843. nv50_pgraph_tp_trap(dev, 8, 0x408e08, 0x408708, display,
  844. "PGRAPH - TRAP_TPDMA");
  845. nv_wr32(dev, 0x400108, 0x100);
  846. status &= ~0x100;
  847. }
  848. if (status) {
  849. if (display)
  850. NV_INFO(dev, "PGRAPH - TRAP: unknown 0x%08x\n", status);
  851. nv_wr32(dev, 0x400108, status);
  852. }
  853. return 1;
  854. }
  855. static int
  856. nv50_graph_isr_chid(struct drm_device *dev, u64 inst)
  857. {
  858. struct drm_nouveau_private *dev_priv = dev->dev_private;
  859. struct nouveau_channel *chan;
  860. unsigned long flags;
  861. int i;
  862. spin_lock_irqsave(&dev_priv->channels.lock, flags);
  863. for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
  864. chan = dev_priv->channels.ptr[i];
  865. if (!chan || !chan->ramin)
  866. continue;
  867. if (inst == chan->ramin->vinst)
  868. break;
  869. }
  870. spin_unlock_irqrestore(&dev_priv->channels.lock, flags);
  871. return i;
  872. }
  873. static void
  874. nv50_graph_isr(struct drm_device *dev)
  875. {
  876. u32 stat;
  877. while ((stat = nv_rd32(dev, 0x400100))) {
  878. u64 inst = (u64)(nv_rd32(dev, 0x40032c) & 0x0fffffff) << 12;
  879. u32 chid = nv50_graph_isr_chid(dev, inst);
  880. u32 addr = nv_rd32(dev, NV04_PGRAPH_TRAPPED_ADDR);
  881. u32 subc = (addr & 0x00070000) >> 16;
  882. u32 mthd = (addr & 0x00001ffc);
  883. u32 data = nv_rd32(dev, NV04_PGRAPH_TRAPPED_DATA);
  884. u32 class = nv_rd32(dev, 0x400814);
  885. u32 show = stat;
  886. if (stat & 0x00000010) {
  887. if (!nouveau_gpuobj_mthd_call2(dev, chid, class,
  888. mthd, data))
  889. show &= ~0x00000010;
  890. }
  891. if (stat & 0x00001000) {
  892. nv_wr32(dev, 0x400500, 0x00000000);
  893. nv_wr32(dev, 0x400100, 0x00001000);
  894. nv_mask(dev, 0x40013c, 0x00001000, 0x00000000);
  895. nv50_graph_context_switch(dev);
  896. stat &= ~0x00001000;
  897. show &= ~0x00001000;
  898. }
  899. show = (show && nouveau_ratelimit()) ? show : 0;
  900. if (show & 0x00100000) {
  901. u32 ecode = nv_rd32(dev, 0x400110);
  902. NV_INFO(dev, "PGRAPH - DATA_ERROR ");
  903. nouveau_enum_print(nv50_data_error_names, ecode);
  904. printk("\n");
  905. }
  906. if (stat & 0x00200000) {
  907. if (!nv50_pgraph_trap_handler(dev, show, inst, chid))
  908. show &= ~0x00200000;
  909. }
  910. nv_wr32(dev, 0x400100, stat);
  911. nv_wr32(dev, 0x400500, 0x00010001);
  912. if (show) {
  913. NV_INFO(dev, "PGRAPH -");
  914. nouveau_bitfield_print(nv50_graph_intr, show);
  915. printk("\n");
  916. NV_INFO(dev, "PGRAPH - ch %d (0x%010llx) subc %d "
  917. "class 0x%04x mthd 0x%04x data 0x%08x\n",
  918. chid, inst, subc, class, mthd, data);
  919. nv50_fb_vm_trap(dev, 1);
  920. }
  921. }
  922. if (nv_rd32(dev, 0x400824) & (1 << 31))
  923. nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) & ~(1 << 31));
  924. }