nv50_graph.c 30 KB

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