nv50_graph.c 30 KB

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