nv40_graph.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. /*
  2. * Copyright (C) 2007 Ben Skeggs.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the
  14. * next paragraph) shall be included in all copies or substantial
  15. * portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  21. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. */
  26. #include "drmP.h"
  27. #include "drm.h"
  28. #include "nouveau_drv.h"
  29. #include "nouveau_grctx.h"
  30. #include "nouveau_ramht.h"
  31. struct nv40_graph_engine {
  32. struct nouveau_exec_engine base;
  33. u32 grctx_size;
  34. };
  35. static struct nouveau_channel *
  36. nv40_graph_channel(struct drm_device *dev)
  37. {
  38. struct drm_nouveau_private *dev_priv = dev->dev_private;
  39. struct nouveau_gpuobj *grctx;
  40. uint32_t inst;
  41. int i;
  42. inst = nv_rd32(dev, NV40_PGRAPH_CTXCTL_CUR);
  43. if (!(inst & NV40_PGRAPH_CTXCTL_CUR_LOADED))
  44. return NULL;
  45. inst = (inst & NV40_PGRAPH_CTXCTL_CUR_INSTANCE) << 4;
  46. for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
  47. if (!dev_priv->channels.ptr[i])
  48. continue;
  49. grctx = dev_priv->channels.ptr[i]->engctx[NVOBJ_ENGINE_GR];
  50. if (grctx && grctx->pinst == inst)
  51. return dev_priv->channels.ptr[i];
  52. }
  53. return NULL;
  54. }
  55. static int
  56. nv40_graph_transfer_context(struct drm_device *dev, uint32_t inst, int save)
  57. {
  58. uint32_t old_cp, tv = 1000, tmp;
  59. int i;
  60. old_cp = nv_rd32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER);
  61. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, inst);
  62. tmp = nv_rd32(dev, NV40_PGRAPH_CTXCTL_0310);
  63. tmp |= save ? NV40_PGRAPH_CTXCTL_0310_XFER_SAVE :
  64. NV40_PGRAPH_CTXCTL_0310_XFER_LOAD;
  65. nv_wr32(dev, NV40_PGRAPH_CTXCTL_0310, tmp);
  66. tmp = nv_rd32(dev, NV40_PGRAPH_CTXCTL_0304);
  67. tmp |= NV40_PGRAPH_CTXCTL_0304_XFER_CTX;
  68. nv_wr32(dev, NV40_PGRAPH_CTXCTL_0304, tmp);
  69. nouveau_wait_for_idle(dev);
  70. for (i = 0; i < tv; i++) {
  71. if (nv_rd32(dev, NV40_PGRAPH_CTXCTL_030C) == 0)
  72. break;
  73. }
  74. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, old_cp);
  75. if (i == tv) {
  76. uint32_t ucstat = nv_rd32(dev, NV40_PGRAPH_CTXCTL_UCODE_STAT);
  77. NV_ERROR(dev, "Failed: Instance=0x%08x Save=%d\n", inst, save);
  78. NV_ERROR(dev, "IP: 0x%02x, Opcode: 0x%08x\n",
  79. ucstat >> NV40_PGRAPH_CTXCTL_UCODE_STAT_IP_SHIFT,
  80. ucstat & NV40_PGRAPH_CTXCTL_UCODE_STAT_OP_MASK);
  81. NV_ERROR(dev, "0x40030C = 0x%08x\n",
  82. nv_rd32(dev, NV40_PGRAPH_CTXCTL_030C));
  83. return -EBUSY;
  84. }
  85. return 0;
  86. }
  87. static int
  88. nv40_graph_unload_context(struct drm_device *dev)
  89. {
  90. uint32_t inst;
  91. int ret;
  92. inst = nv_rd32(dev, NV40_PGRAPH_CTXCTL_CUR);
  93. if (!(inst & NV40_PGRAPH_CTXCTL_CUR_LOADED))
  94. return 0;
  95. inst &= NV40_PGRAPH_CTXCTL_CUR_INSTANCE;
  96. ret = nv40_graph_transfer_context(dev, inst, 1);
  97. nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, inst);
  98. return ret;
  99. }
  100. static int
  101. nv40_graph_context_new(struct nouveau_channel *chan, int engine)
  102. {
  103. struct nv40_graph_engine *pgraph = nv_engine(chan->dev, engine);
  104. struct drm_device *dev = chan->dev;
  105. struct drm_nouveau_private *dev_priv = dev->dev_private;
  106. struct nouveau_gpuobj *grctx = NULL;
  107. struct nouveau_grctx ctx = {};
  108. unsigned long flags;
  109. int ret;
  110. ret = nouveau_gpuobj_new(dev, NULL, pgraph->grctx_size, 16,
  111. NVOBJ_FLAG_ZERO_ALLOC, &grctx);
  112. if (ret)
  113. return ret;
  114. /* Initialise default context values */
  115. ctx.dev = chan->dev;
  116. ctx.mode = NOUVEAU_GRCTX_VALS;
  117. ctx.data = grctx;
  118. nv40_grctx_init(&ctx);
  119. nv_wo32(grctx, 0, grctx->vinst);
  120. /* init grctx pointer in ramfc, and on PFIFO if channel is
  121. * already active there
  122. */
  123. spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
  124. nv_wo32(chan->ramfc, 0x38, grctx->vinst >> 4);
  125. nv_mask(dev, 0x002500, 0x00000001, 0x00000000);
  126. if ((nv_rd32(dev, 0x003204) & 0x0000001f) == chan->id)
  127. nv_wr32(dev, 0x0032e0, grctx->vinst >> 4);
  128. nv_mask(dev, 0x002500, 0x00000001, 0x00000001);
  129. spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
  130. chan->engctx[engine] = grctx;
  131. return 0;
  132. }
  133. static void
  134. nv40_graph_context_del(struct nouveau_channel *chan, int engine)
  135. {
  136. struct nouveau_gpuobj *grctx = chan->engctx[engine];
  137. struct drm_device *dev = chan->dev;
  138. struct drm_nouveau_private *dev_priv = dev->dev_private;
  139. unsigned long flags;
  140. spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
  141. nv04_graph_fifo_access(dev, false);
  142. /* Unload the context if it's the currently active one */
  143. if (nv40_graph_channel(dev) == chan)
  144. nv40_graph_unload_context(dev);
  145. nv04_graph_fifo_access(dev, true);
  146. spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
  147. /* Free the context resources */
  148. nouveau_gpuobj_ref(NULL, &grctx);
  149. chan->engctx[engine] = NULL;
  150. }
  151. int
  152. nv40_graph_object_new(struct nouveau_channel *chan, int engine,
  153. u32 handle, u16 class)
  154. {
  155. struct drm_device *dev = chan->dev;
  156. struct nouveau_gpuobj *obj = NULL;
  157. int ret;
  158. ret = nouveau_gpuobj_new(dev, chan, 20, 16, NVOBJ_FLAG_ZERO_FREE, &obj);
  159. if (ret)
  160. return ret;
  161. obj->engine = 1;
  162. obj->class = class;
  163. nv_wo32(obj, 0x00, class);
  164. nv_wo32(obj, 0x04, 0x00000000);
  165. #ifdef __BIG_ENDIAN
  166. nv_wo32(obj, 0x08, 0x01000000);
  167. #endif
  168. nv_wo32(obj, 0x0c, 0x00000000);
  169. nv_wo32(obj, 0x10, 0x00000000);
  170. ret = nouveau_ramht_insert(chan, handle, obj);
  171. nouveau_gpuobj_ref(NULL, &obj);
  172. return ret;
  173. }
  174. void
  175. nv40_graph_set_tile_region(struct drm_device *dev, int i)
  176. {
  177. struct drm_nouveau_private *dev_priv = dev->dev_private;
  178. struct nouveau_tile_reg *tile = &dev_priv->tile.reg[i];
  179. switch (dev_priv->chipset) {
  180. case 0x40:
  181. case 0x41: /* guess */
  182. case 0x42:
  183. case 0x43:
  184. case 0x45: /* guess */
  185. case 0x4e:
  186. nv_wr32(dev, NV20_PGRAPH_TSIZE(i), tile->pitch);
  187. nv_wr32(dev, NV20_PGRAPH_TLIMIT(i), tile->limit);
  188. nv_wr32(dev, NV20_PGRAPH_TILE(i), tile->addr);
  189. nv_wr32(dev, NV40_PGRAPH_TSIZE1(i), tile->pitch);
  190. nv_wr32(dev, NV40_PGRAPH_TLIMIT1(i), tile->limit);
  191. nv_wr32(dev, NV40_PGRAPH_TILE1(i), tile->addr);
  192. break;
  193. case 0x44:
  194. case 0x4a:
  195. nv_wr32(dev, NV20_PGRAPH_TSIZE(i), tile->pitch);
  196. nv_wr32(dev, NV20_PGRAPH_TLIMIT(i), tile->limit);
  197. nv_wr32(dev, NV20_PGRAPH_TILE(i), tile->addr);
  198. break;
  199. case 0x46:
  200. case 0x47:
  201. case 0x49:
  202. case 0x4b:
  203. case 0x4c:
  204. case 0x67:
  205. default:
  206. nv_wr32(dev, NV47_PGRAPH_TSIZE(i), tile->pitch);
  207. nv_wr32(dev, NV47_PGRAPH_TLIMIT(i), tile->limit);
  208. nv_wr32(dev, NV47_PGRAPH_TILE(i), tile->addr);
  209. nv_wr32(dev, NV40_PGRAPH_TSIZE1(i), tile->pitch);
  210. nv_wr32(dev, NV40_PGRAPH_TLIMIT1(i), tile->limit);
  211. nv_wr32(dev, NV40_PGRAPH_TILE1(i), tile->addr);
  212. break;
  213. }
  214. }
  215. /*
  216. * G70 0x47
  217. * G71 0x49
  218. * NV45 0x48
  219. * G72[M] 0x46
  220. * G73 0x4b
  221. * C51_G7X 0x4c
  222. * C51 0x4e
  223. */
  224. int
  225. nv40_graph_init(struct drm_device *dev, int engine)
  226. {
  227. struct nv40_graph_engine *pgraph = nv_engine(dev, engine);
  228. struct drm_nouveau_private *dev_priv = dev->dev_private;
  229. struct nouveau_fb_engine *pfb = &dev_priv->engine.fb;
  230. struct nouveau_grctx ctx = {};
  231. uint32_t vramsz, *cp;
  232. int i, j;
  233. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) &
  234. ~NV_PMC_ENABLE_PGRAPH);
  235. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) |
  236. NV_PMC_ENABLE_PGRAPH);
  237. cp = kmalloc(sizeof(*cp) * 256, GFP_KERNEL);
  238. if (!cp)
  239. return -ENOMEM;
  240. ctx.dev = dev;
  241. ctx.mode = NOUVEAU_GRCTX_PROG;
  242. ctx.data = cp;
  243. ctx.ctxprog_max = 256;
  244. nv40_grctx_init(&ctx);
  245. pgraph->grctx_size = ctx.ctxvals_pos * 4;
  246. nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
  247. for (i = 0; i < ctx.ctxprog_len; i++)
  248. nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, cp[i]);
  249. kfree(cp);
  250. /* No context present currently */
  251. nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0x00000000);
  252. nv_wr32(dev, NV03_PGRAPH_INTR , 0xFFFFFFFF);
  253. nv_wr32(dev, NV40_PGRAPH_INTR_EN, 0xFFFFFFFF);
  254. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0xFFFFFFFF);
  255. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x00000000);
  256. nv_wr32(dev, NV04_PGRAPH_DEBUG_1, 0x401287c0);
  257. nv_wr32(dev, NV04_PGRAPH_DEBUG_3, 0xe0de8055);
  258. nv_wr32(dev, NV10_PGRAPH_DEBUG_4, 0x00008000);
  259. nv_wr32(dev, NV04_PGRAPH_LIMIT_VIOL_PIX, 0x00be3c5f);
  260. nv_wr32(dev, NV10_PGRAPH_CTX_CONTROL, 0x10010100);
  261. nv_wr32(dev, NV10_PGRAPH_STATE , 0xFFFFFFFF);
  262. j = nv_rd32(dev, 0x1540) & 0xff;
  263. if (j) {
  264. for (i = 0; !(j & 1); j >>= 1, i++)
  265. ;
  266. nv_wr32(dev, 0x405000, i);
  267. }
  268. if (dev_priv->chipset == 0x40) {
  269. nv_wr32(dev, 0x4009b0, 0x83280fff);
  270. nv_wr32(dev, 0x4009b4, 0x000000a0);
  271. } else {
  272. nv_wr32(dev, 0x400820, 0x83280eff);
  273. nv_wr32(dev, 0x400824, 0x000000a0);
  274. }
  275. switch (dev_priv->chipset) {
  276. case 0x40:
  277. case 0x45:
  278. nv_wr32(dev, 0x4009b8, 0x0078e366);
  279. nv_wr32(dev, 0x4009bc, 0x0000014c);
  280. break;
  281. case 0x41:
  282. case 0x42: /* pciid also 0x00Cx */
  283. /* case 0x0120: XXX (pciid) */
  284. nv_wr32(dev, 0x400828, 0x007596ff);
  285. nv_wr32(dev, 0x40082c, 0x00000108);
  286. break;
  287. case 0x43:
  288. nv_wr32(dev, 0x400828, 0x0072cb77);
  289. nv_wr32(dev, 0x40082c, 0x00000108);
  290. break;
  291. case 0x44:
  292. case 0x46: /* G72 */
  293. case 0x4a:
  294. case 0x4c: /* G7x-based C51 */
  295. case 0x4e:
  296. nv_wr32(dev, 0x400860, 0);
  297. nv_wr32(dev, 0x400864, 0);
  298. break;
  299. case 0x47: /* G70 */
  300. case 0x49: /* G71 */
  301. case 0x4b: /* G73 */
  302. nv_wr32(dev, 0x400828, 0x07830610);
  303. nv_wr32(dev, 0x40082c, 0x0000016A);
  304. break;
  305. default:
  306. break;
  307. }
  308. nv_wr32(dev, 0x400b38, 0x2ffff800);
  309. nv_wr32(dev, 0x400b3c, 0x00006000);
  310. /* Tiling related stuff. */
  311. switch (dev_priv->chipset) {
  312. case 0x44:
  313. case 0x4a:
  314. nv_wr32(dev, 0x400bc4, 0x1003d888);
  315. nv_wr32(dev, 0x400bbc, 0xb7a7b500);
  316. break;
  317. case 0x46:
  318. nv_wr32(dev, 0x400bc4, 0x0000e024);
  319. nv_wr32(dev, 0x400bbc, 0xb7a7b520);
  320. break;
  321. case 0x4c:
  322. case 0x4e:
  323. case 0x67:
  324. nv_wr32(dev, 0x400bc4, 0x1003d888);
  325. nv_wr32(dev, 0x400bbc, 0xb7a7b540);
  326. break;
  327. default:
  328. break;
  329. }
  330. /* Turn all the tiling regions off. */
  331. for (i = 0; i < pfb->num_tiles; i++)
  332. nv40_graph_set_tile_region(dev, i);
  333. /* begin RAM config */
  334. vramsz = pci_resource_len(dev->pdev, 0) - 1;
  335. switch (dev_priv->chipset) {
  336. case 0x40:
  337. nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
  338. nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
  339. nv_wr32(dev, 0x4069A4, nv_rd32(dev, NV04_PFB_CFG0));
  340. nv_wr32(dev, 0x4069A8, nv_rd32(dev, NV04_PFB_CFG1));
  341. nv_wr32(dev, 0x400820, 0);
  342. nv_wr32(dev, 0x400824, 0);
  343. nv_wr32(dev, 0x400864, vramsz);
  344. nv_wr32(dev, 0x400868, vramsz);
  345. break;
  346. default:
  347. switch (dev_priv->chipset) {
  348. case 0x41:
  349. case 0x42:
  350. case 0x43:
  351. case 0x45:
  352. case 0x4e:
  353. case 0x44:
  354. case 0x4a:
  355. nv_wr32(dev, 0x4009F0, nv_rd32(dev, NV04_PFB_CFG0));
  356. nv_wr32(dev, 0x4009F4, nv_rd32(dev, NV04_PFB_CFG1));
  357. break;
  358. default:
  359. nv_wr32(dev, 0x400DF0, nv_rd32(dev, NV04_PFB_CFG0));
  360. nv_wr32(dev, 0x400DF4, nv_rd32(dev, NV04_PFB_CFG1));
  361. break;
  362. }
  363. nv_wr32(dev, 0x4069F0, nv_rd32(dev, NV04_PFB_CFG0));
  364. nv_wr32(dev, 0x4069F4, nv_rd32(dev, NV04_PFB_CFG1));
  365. nv_wr32(dev, 0x400840, 0);
  366. nv_wr32(dev, 0x400844, 0);
  367. nv_wr32(dev, 0x4008A0, vramsz);
  368. nv_wr32(dev, 0x4008A4, vramsz);
  369. break;
  370. }
  371. return 0;
  372. }
  373. static int
  374. nv40_graph_fini(struct drm_device *dev, int engine)
  375. {
  376. nv40_graph_unload_context(dev);
  377. return 0;
  378. }
  379. static int
  380. nv40_graph_isr_chid(struct drm_device *dev, u32 inst)
  381. {
  382. struct drm_nouveau_private *dev_priv = dev->dev_private;
  383. struct nouveau_gpuobj *grctx;
  384. unsigned long flags;
  385. int i;
  386. spin_lock_irqsave(&dev_priv->channels.lock, flags);
  387. for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
  388. if (!dev_priv->channels.ptr[i])
  389. continue;
  390. grctx = dev_priv->channels.ptr[i]->engctx[NVOBJ_ENGINE_GR];
  391. if (grctx && grctx->pinst == inst)
  392. break;
  393. }
  394. spin_unlock_irqrestore(&dev_priv->channels.lock, flags);
  395. return i;
  396. }
  397. static void
  398. nv40_graph_isr(struct drm_device *dev)
  399. {
  400. u32 stat;
  401. while ((stat = nv_rd32(dev, NV03_PGRAPH_INTR))) {
  402. u32 nsource = nv_rd32(dev, NV03_PGRAPH_NSOURCE);
  403. u32 nstatus = nv_rd32(dev, NV03_PGRAPH_NSTATUS);
  404. u32 inst = (nv_rd32(dev, 0x40032c) & 0x000fffff) << 4;
  405. u32 chid = nv40_graph_isr_chid(dev, inst);
  406. u32 addr = nv_rd32(dev, NV04_PGRAPH_TRAPPED_ADDR);
  407. u32 subc = (addr & 0x00070000) >> 16;
  408. u32 mthd = (addr & 0x00001ffc);
  409. u32 data = nv_rd32(dev, NV04_PGRAPH_TRAPPED_DATA);
  410. u32 class = nv_rd32(dev, 0x400160 + subc * 4) & 0xffff;
  411. u32 show = stat;
  412. if (stat & NV_PGRAPH_INTR_ERROR) {
  413. if (nsource & NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD) {
  414. if (!nouveau_gpuobj_mthd_call2(dev, chid, class, mthd, data))
  415. show &= ~NV_PGRAPH_INTR_ERROR;
  416. } else
  417. if (nsource & NV03_PGRAPH_NSOURCE_DMA_VTX_PROTECTION) {
  418. nv_mask(dev, 0x402000, 0, 0);
  419. }
  420. }
  421. nv_wr32(dev, NV03_PGRAPH_INTR, stat);
  422. nv_wr32(dev, NV04_PGRAPH_FIFO, 0x00000001);
  423. if (show && nouveau_ratelimit()) {
  424. NV_INFO(dev, "PGRAPH -");
  425. nouveau_bitfield_print(nv10_graph_intr, show);
  426. printk(" nsource:");
  427. nouveau_bitfield_print(nv04_graph_nsource, nsource);
  428. printk(" nstatus:");
  429. nouveau_bitfield_print(nv10_graph_nstatus, nstatus);
  430. printk("\n");
  431. NV_INFO(dev, "PGRAPH - ch %d (0x%08x) subc %d "
  432. "class 0x%04x mthd 0x%04x data 0x%08x\n",
  433. chid, inst, subc, class, mthd, data);
  434. }
  435. }
  436. }
  437. static void
  438. nv40_graph_destroy(struct drm_device *dev, int engine)
  439. {
  440. struct nv40_graph_engine *pgraph = nv_engine(dev, engine);
  441. nouveau_irq_unregister(dev, 12);
  442. NVOBJ_ENGINE_DEL(dev, GR);
  443. kfree(pgraph);
  444. }
  445. int
  446. nv40_graph_create(struct drm_device *dev)
  447. {
  448. struct nv40_graph_engine *pgraph;
  449. pgraph = kzalloc(sizeof(*pgraph), GFP_KERNEL);
  450. if (!pgraph)
  451. return -ENOMEM;
  452. pgraph->base.destroy = nv40_graph_destroy;
  453. pgraph->base.init = nv40_graph_init;
  454. pgraph->base.fini = nv40_graph_fini;
  455. pgraph->base.context_new = nv40_graph_context_new;
  456. pgraph->base.context_del = nv40_graph_context_del;
  457. pgraph->base.object_new = nv40_graph_object_new;
  458. NVOBJ_ENGINE_ADD(dev, GR, &pgraph->base);
  459. nouveau_irq_register(dev, 12, nv40_graph_isr);
  460. NVOBJ_CLASS(dev, 0x506e, SW); /* nvsw */
  461. NVOBJ_CLASS(dev, 0x0030, GR); /* null */
  462. NVOBJ_CLASS(dev, 0x0039, GR); /* m2mf */
  463. NVOBJ_CLASS(dev, 0x004a, GR); /* gdirect */
  464. NVOBJ_CLASS(dev, 0x009f, GR); /* imageblit (nv12) */
  465. NVOBJ_CLASS(dev, 0x008a, GR); /* ifc */
  466. NVOBJ_CLASS(dev, 0x0089, GR); /* sifm */
  467. NVOBJ_CLASS(dev, 0x3089, GR); /* sifm (nv40) */
  468. NVOBJ_CLASS(dev, 0x0062, GR); /* surf2d */
  469. NVOBJ_CLASS(dev, 0x3062, GR); /* surf2d (nv40) */
  470. NVOBJ_CLASS(dev, 0x0043, GR); /* rop */
  471. NVOBJ_CLASS(dev, 0x0012, GR); /* beta1 */
  472. NVOBJ_CLASS(dev, 0x0072, GR); /* beta4 */
  473. NVOBJ_CLASS(dev, 0x0019, GR); /* cliprect */
  474. NVOBJ_CLASS(dev, 0x0044, GR); /* pattern */
  475. NVOBJ_CLASS(dev, 0x309e, GR); /* swzsurf */
  476. /* curie */
  477. if (nv44_graph_class(dev))
  478. NVOBJ_CLASS(dev, 0x4497, GR);
  479. else
  480. NVOBJ_CLASS(dev, 0x4097, GR);
  481. /* nvsw */
  482. NVOBJ_CLASS(dev, 0x506e, SW);
  483. NVOBJ_MTHD (dev, 0x506e, 0x0500, nv04_graph_mthd_page_flip);
  484. return 0;
  485. }