nv20_graph.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. #include "drmP.h"
  2. #include "drm.h"
  3. #include "nouveau_drv.h"
  4. #include "nouveau_drm.h"
  5. /*
  6. * NV20
  7. * -----
  8. * There are 3 families :
  9. * NV20 is 0x10de:0x020*
  10. * NV25/28 is 0x10de:0x025* / 0x10de:0x028*
  11. * NV2A is 0x10de:0x02A0
  12. *
  13. * NV30
  14. * -----
  15. * There are 3 families :
  16. * NV30/31 is 0x10de:0x030* / 0x10de:0x031*
  17. * NV34 is 0x10de:0x032*
  18. * NV35/36 is 0x10de:0x033* / 0x10de:0x034*
  19. *
  20. * Not seen in the wild, no dumps (probably NV35) :
  21. * NV37 is 0x10de:0x00fc, 0x10de:0x00fd
  22. * NV38 is 0x10de:0x0333, 0x10de:0x00fe
  23. *
  24. */
  25. #define NV20_GRCTX_SIZE (3580*4)
  26. #define NV25_GRCTX_SIZE (3529*4)
  27. #define NV2A_GRCTX_SIZE (3500*4)
  28. #define NV30_31_GRCTX_SIZE (24392)
  29. #define NV34_GRCTX_SIZE (18140)
  30. #define NV35_36_GRCTX_SIZE (22396)
  31. static int nv20_graph_register(struct drm_device *);
  32. static int nv30_graph_register(struct drm_device *);
  33. static void nv20_graph_isr(struct drm_device *);
  34. static void
  35. nv20_graph_context_init(struct drm_device *dev, struct nouveau_gpuobj *ctx)
  36. {
  37. int i;
  38. nv_wo32(ctx, 0x033c, 0xffff0000);
  39. nv_wo32(ctx, 0x03a0, 0x0fff0000);
  40. nv_wo32(ctx, 0x03a4, 0x0fff0000);
  41. nv_wo32(ctx, 0x047c, 0x00000101);
  42. nv_wo32(ctx, 0x0490, 0x00000111);
  43. nv_wo32(ctx, 0x04a8, 0x44400000);
  44. for (i = 0x04d4; i <= 0x04e0; i += 4)
  45. nv_wo32(ctx, i, 0x00030303);
  46. for (i = 0x04f4; i <= 0x0500; i += 4)
  47. nv_wo32(ctx, i, 0x00080000);
  48. for (i = 0x050c; i <= 0x0518; i += 4)
  49. nv_wo32(ctx, i, 0x01012000);
  50. for (i = 0x051c; i <= 0x0528; i += 4)
  51. nv_wo32(ctx, i, 0x000105b8);
  52. for (i = 0x052c; i <= 0x0538; i += 4)
  53. nv_wo32(ctx, i, 0x00080008);
  54. for (i = 0x055c; i <= 0x0598; i += 4)
  55. nv_wo32(ctx, i, 0x07ff0000);
  56. nv_wo32(ctx, 0x05a4, 0x4b7fffff);
  57. nv_wo32(ctx, 0x05fc, 0x00000001);
  58. nv_wo32(ctx, 0x0604, 0x00004000);
  59. nv_wo32(ctx, 0x0610, 0x00000001);
  60. nv_wo32(ctx, 0x0618, 0x00040000);
  61. nv_wo32(ctx, 0x061c, 0x00010000);
  62. for (i = 0x1c1c; i <= 0x248c; i += 16) {
  63. nv_wo32(ctx, (i + 0), 0x10700ff9);
  64. nv_wo32(ctx, (i + 4), 0x0436086c);
  65. nv_wo32(ctx, (i + 8), 0x000c001b);
  66. }
  67. nv_wo32(ctx, 0x281c, 0x3f800000);
  68. nv_wo32(ctx, 0x2830, 0x3f800000);
  69. nv_wo32(ctx, 0x285c, 0x40000000);
  70. nv_wo32(ctx, 0x2860, 0x3f800000);
  71. nv_wo32(ctx, 0x2864, 0x3f000000);
  72. nv_wo32(ctx, 0x286c, 0x40000000);
  73. nv_wo32(ctx, 0x2870, 0x3f800000);
  74. nv_wo32(ctx, 0x2878, 0xbf800000);
  75. nv_wo32(ctx, 0x2880, 0xbf800000);
  76. nv_wo32(ctx, 0x34a4, 0x000fe000);
  77. nv_wo32(ctx, 0x3530, 0x000003f8);
  78. nv_wo32(ctx, 0x3540, 0x002fe000);
  79. for (i = 0x355c; i <= 0x3578; i += 4)
  80. nv_wo32(ctx, i, 0x001c527c);
  81. }
  82. static void
  83. nv25_graph_context_init(struct drm_device *dev, struct nouveau_gpuobj *ctx)
  84. {
  85. int i;
  86. nv_wo32(ctx, 0x035c, 0xffff0000);
  87. nv_wo32(ctx, 0x03c0, 0x0fff0000);
  88. nv_wo32(ctx, 0x03c4, 0x0fff0000);
  89. nv_wo32(ctx, 0x049c, 0x00000101);
  90. nv_wo32(ctx, 0x04b0, 0x00000111);
  91. nv_wo32(ctx, 0x04c8, 0x00000080);
  92. nv_wo32(ctx, 0x04cc, 0xffff0000);
  93. nv_wo32(ctx, 0x04d0, 0x00000001);
  94. nv_wo32(ctx, 0x04e4, 0x44400000);
  95. nv_wo32(ctx, 0x04fc, 0x4b800000);
  96. for (i = 0x0510; i <= 0x051c; i += 4)
  97. nv_wo32(ctx, i, 0x00030303);
  98. for (i = 0x0530; i <= 0x053c; i += 4)
  99. nv_wo32(ctx, i, 0x00080000);
  100. for (i = 0x0548; i <= 0x0554; i += 4)
  101. nv_wo32(ctx, i, 0x01012000);
  102. for (i = 0x0558; i <= 0x0564; i += 4)
  103. nv_wo32(ctx, i, 0x000105b8);
  104. for (i = 0x0568; i <= 0x0574; i += 4)
  105. nv_wo32(ctx, i, 0x00080008);
  106. for (i = 0x0598; i <= 0x05d4; i += 4)
  107. nv_wo32(ctx, i, 0x07ff0000);
  108. nv_wo32(ctx, 0x05e0, 0x4b7fffff);
  109. nv_wo32(ctx, 0x0620, 0x00000080);
  110. nv_wo32(ctx, 0x0624, 0x30201000);
  111. nv_wo32(ctx, 0x0628, 0x70605040);
  112. nv_wo32(ctx, 0x062c, 0xb0a09080);
  113. nv_wo32(ctx, 0x0630, 0xf0e0d0c0);
  114. nv_wo32(ctx, 0x0664, 0x00000001);
  115. nv_wo32(ctx, 0x066c, 0x00004000);
  116. nv_wo32(ctx, 0x0678, 0x00000001);
  117. nv_wo32(ctx, 0x0680, 0x00040000);
  118. nv_wo32(ctx, 0x0684, 0x00010000);
  119. for (i = 0x1b04; i <= 0x2374; i += 16) {
  120. nv_wo32(ctx, (i + 0), 0x10700ff9);
  121. nv_wo32(ctx, (i + 4), 0x0436086c);
  122. nv_wo32(ctx, (i + 8), 0x000c001b);
  123. }
  124. nv_wo32(ctx, 0x2704, 0x3f800000);
  125. nv_wo32(ctx, 0x2718, 0x3f800000);
  126. nv_wo32(ctx, 0x2744, 0x40000000);
  127. nv_wo32(ctx, 0x2748, 0x3f800000);
  128. nv_wo32(ctx, 0x274c, 0x3f000000);
  129. nv_wo32(ctx, 0x2754, 0x40000000);
  130. nv_wo32(ctx, 0x2758, 0x3f800000);
  131. nv_wo32(ctx, 0x2760, 0xbf800000);
  132. nv_wo32(ctx, 0x2768, 0xbf800000);
  133. nv_wo32(ctx, 0x308c, 0x000fe000);
  134. nv_wo32(ctx, 0x3108, 0x000003f8);
  135. nv_wo32(ctx, 0x3468, 0x002fe000);
  136. for (i = 0x3484; i <= 0x34a0; i += 4)
  137. nv_wo32(ctx, i, 0x001c527c);
  138. }
  139. static void
  140. nv2a_graph_context_init(struct drm_device *dev, struct nouveau_gpuobj *ctx)
  141. {
  142. int i;
  143. nv_wo32(ctx, 0x033c, 0xffff0000);
  144. nv_wo32(ctx, 0x03a0, 0x0fff0000);
  145. nv_wo32(ctx, 0x03a4, 0x0fff0000);
  146. nv_wo32(ctx, 0x047c, 0x00000101);
  147. nv_wo32(ctx, 0x0490, 0x00000111);
  148. nv_wo32(ctx, 0x04a8, 0x44400000);
  149. for (i = 0x04d4; i <= 0x04e0; i += 4)
  150. nv_wo32(ctx, i, 0x00030303);
  151. for (i = 0x04f4; i <= 0x0500; i += 4)
  152. nv_wo32(ctx, i, 0x00080000);
  153. for (i = 0x050c; i <= 0x0518; i += 4)
  154. nv_wo32(ctx, i, 0x01012000);
  155. for (i = 0x051c; i <= 0x0528; i += 4)
  156. nv_wo32(ctx, i, 0x000105b8);
  157. for (i = 0x052c; i <= 0x0538; i += 4)
  158. nv_wo32(ctx, i, 0x00080008);
  159. for (i = 0x055c; i <= 0x0598; i += 4)
  160. nv_wo32(ctx, i, 0x07ff0000);
  161. nv_wo32(ctx, 0x05a4, 0x4b7fffff);
  162. nv_wo32(ctx, 0x05fc, 0x00000001);
  163. nv_wo32(ctx, 0x0604, 0x00004000);
  164. nv_wo32(ctx, 0x0610, 0x00000001);
  165. nv_wo32(ctx, 0x0618, 0x00040000);
  166. nv_wo32(ctx, 0x061c, 0x00010000);
  167. for (i = 0x1a9c; i <= 0x22fc; i += 16) { /*XXX: check!! */
  168. nv_wo32(ctx, (i + 0), 0x10700ff9);
  169. nv_wo32(ctx, (i + 4), 0x0436086c);
  170. nv_wo32(ctx, (i + 8), 0x000c001b);
  171. }
  172. nv_wo32(ctx, 0x269c, 0x3f800000);
  173. nv_wo32(ctx, 0x26b0, 0x3f800000);
  174. nv_wo32(ctx, 0x26dc, 0x40000000);
  175. nv_wo32(ctx, 0x26e0, 0x3f800000);
  176. nv_wo32(ctx, 0x26e4, 0x3f000000);
  177. nv_wo32(ctx, 0x26ec, 0x40000000);
  178. nv_wo32(ctx, 0x26f0, 0x3f800000);
  179. nv_wo32(ctx, 0x26f8, 0xbf800000);
  180. nv_wo32(ctx, 0x2700, 0xbf800000);
  181. nv_wo32(ctx, 0x3024, 0x000fe000);
  182. nv_wo32(ctx, 0x30a0, 0x000003f8);
  183. nv_wo32(ctx, 0x33fc, 0x002fe000);
  184. for (i = 0x341c; i <= 0x3438; i += 4)
  185. nv_wo32(ctx, i, 0x001c527c);
  186. }
  187. static void
  188. nv30_31_graph_context_init(struct drm_device *dev, struct nouveau_gpuobj *ctx)
  189. {
  190. int i;
  191. nv_wo32(ctx, 0x0410, 0x00000101);
  192. nv_wo32(ctx, 0x0424, 0x00000111);
  193. nv_wo32(ctx, 0x0428, 0x00000060);
  194. nv_wo32(ctx, 0x0444, 0x00000080);
  195. nv_wo32(ctx, 0x0448, 0xffff0000);
  196. nv_wo32(ctx, 0x044c, 0x00000001);
  197. nv_wo32(ctx, 0x0460, 0x44400000);
  198. nv_wo32(ctx, 0x048c, 0xffff0000);
  199. for (i = 0x04e0; i < 0x04e8; i += 4)
  200. nv_wo32(ctx, i, 0x0fff0000);
  201. nv_wo32(ctx, 0x04ec, 0x00011100);
  202. for (i = 0x0508; i < 0x0548; i += 4)
  203. nv_wo32(ctx, i, 0x07ff0000);
  204. nv_wo32(ctx, 0x0550, 0x4b7fffff);
  205. nv_wo32(ctx, 0x058c, 0x00000080);
  206. nv_wo32(ctx, 0x0590, 0x30201000);
  207. nv_wo32(ctx, 0x0594, 0x70605040);
  208. nv_wo32(ctx, 0x0598, 0xb8a89888);
  209. nv_wo32(ctx, 0x059c, 0xf8e8d8c8);
  210. nv_wo32(ctx, 0x05b0, 0xb0000000);
  211. for (i = 0x0600; i < 0x0640; i += 4)
  212. nv_wo32(ctx, i, 0x00010588);
  213. for (i = 0x0640; i < 0x0680; i += 4)
  214. nv_wo32(ctx, i, 0x00030303);
  215. for (i = 0x06c0; i < 0x0700; i += 4)
  216. nv_wo32(ctx, i, 0x0008aae4);
  217. for (i = 0x0700; i < 0x0740; i += 4)
  218. nv_wo32(ctx, i, 0x01012000);
  219. for (i = 0x0740; i < 0x0780; i += 4)
  220. nv_wo32(ctx, i, 0x00080008);
  221. nv_wo32(ctx, 0x085c, 0x00040000);
  222. nv_wo32(ctx, 0x0860, 0x00010000);
  223. for (i = 0x0864; i < 0x0874; i += 4)
  224. nv_wo32(ctx, i, 0x00040004);
  225. for (i = 0x1f18; i <= 0x3088 ; i += 16) {
  226. nv_wo32(ctx, i + 0, 0x10700ff9);
  227. nv_wo32(ctx, i + 1, 0x0436086c);
  228. nv_wo32(ctx, i + 2, 0x000c001b);
  229. }
  230. for (i = 0x30b8; i < 0x30c8; i += 4)
  231. nv_wo32(ctx, i, 0x0000ffff);
  232. nv_wo32(ctx, 0x344c, 0x3f800000);
  233. nv_wo32(ctx, 0x3808, 0x3f800000);
  234. nv_wo32(ctx, 0x381c, 0x3f800000);
  235. nv_wo32(ctx, 0x3848, 0x40000000);
  236. nv_wo32(ctx, 0x384c, 0x3f800000);
  237. nv_wo32(ctx, 0x3850, 0x3f000000);
  238. nv_wo32(ctx, 0x3858, 0x40000000);
  239. nv_wo32(ctx, 0x385c, 0x3f800000);
  240. nv_wo32(ctx, 0x3864, 0xbf800000);
  241. nv_wo32(ctx, 0x386c, 0xbf800000);
  242. }
  243. static void
  244. nv34_graph_context_init(struct drm_device *dev, struct nouveau_gpuobj *ctx)
  245. {
  246. int i;
  247. nv_wo32(ctx, 0x040c, 0x01000101);
  248. nv_wo32(ctx, 0x0420, 0x00000111);
  249. nv_wo32(ctx, 0x0424, 0x00000060);
  250. nv_wo32(ctx, 0x0440, 0x00000080);
  251. nv_wo32(ctx, 0x0444, 0xffff0000);
  252. nv_wo32(ctx, 0x0448, 0x00000001);
  253. nv_wo32(ctx, 0x045c, 0x44400000);
  254. nv_wo32(ctx, 0x0480, 0xffff0000);
  255. for (i = 0x04d4; i < 0x04dc; i += 4)
  256. nv_wo32(ctx, i, 0x0fff0000);
  257. nv_wo32(ctx, 0x04e0, 0x00011100);
  258. for (i = 0x04fc; i < 0x053c; i += 4)
  259. nv_wo32(ctx, i, 0x07ff0000);
  260. nv_wo32(ctx, 0x0544, 0x4b7fffff);
  261. nv_wo32(ctx, 0x057c, 0x00000080);
  262. nv_wo32(ctx, 0x0580, 0x30201000);
  263. nv_wo32(ctx, 0x0584, 0x70605040);
  264. nv_wo32(ctx, 0x0588, 0xb8a89888);
  265. nv_wo32(ctx, 0x058c, 0xf8e8d8c8);
  266. nv_wo32(ctx, 0x05a0, 0xb0000000);
  267. for (i = 0x05f0; i < 0x0630; i += 4)
  268. nv_wo32(ctx, i, 0x00010588);
  269. for (i = 0x0630; i < 0x0670; i += 4)
  270. nv_wo32(ctx, i, 0x00030303);
  271. for (i = 0x06b0; i < 0x06f0; i += 4)
  272. nv_wo32(ctx, i, 0x0008aae4);
  273. for (i = 0x06f0; i < 0x0730; i += 4)
  274. nv_wo32(ctx, i, 0x01012000);
  275. for (i = 0x0730; i < 0x0770; i += 4)
  276. nv_wo32(ctx, i, 0x00080008);
  277. nv_wo32(ctx, 0x0850, 0x00040000);
  278. nv_wo32(ctx, 0x0854, 0x00010000);
  279. for (i = 0x0858; i < 0x0868; i += 4)
  280. nv_wo32(ctx, i, 0x00040004);
  281. for (i = 0x15ac; i <= 0x271c ; i += 16) {
  282. nv_wo32(ctx, i + 0, 0x10700ff9);
  283. nv_wo32(ctx, i + 1, 0x0436086c);
  284. nv_wo32(ctx, i + 2, 0x000c001b);
  285. }
  286. for (i = 0x274c; i < 0x275c; i += 4)
  287. nv_wo32(ctx, i, 0x0000ffff);
  288. nv_wo32(ctx, 0x2ae0, 0x3f800000);
  289. nv_wo32(ctx, 0x2e9c, 0x3f800000);
  290. nv_wo32(ctx, 0x2eb0, 0x3f800000);
  291. nv_wo32(ctx, 0x2edc, 0x40000000);
  292. nv_wo32(ctx, 0x2ee0, 0x3f800000);
  293. nv_wo32(ctx, 0x2ee4, 0x3f000000);
  294. nv_wo32(ctx, 0x2eec, 0x40000000);
  295. nv_wo32(ctx, 0x2ef0, 0x3f800000);
  296. nv_wo32(ctx, 0x2ef8, 0xbf800000);
  297. nv_wo32(ctx, 0x2f00, 0xbf800000);
  298. }
  299. static void
  300. nv35_36_graph_context_init(struct drm_device *dev, struct nouveau_gpuobj *ctx)
  301. {
  302. int i;
  303. nv_wo32(ctx, 0x040c, 0x00000101);
  304. nv_wo32(ctx, 0x0420, 0x00000111);
  305. nv_wo32(ctx, 0x0424, 0x00000060);
  306. nv_wo32(ctx, 0x0440, 0x00000080);
  307. nv_wo32(ctx, 0x0444, 0xffff0000);
  308. nv_wo32(ctx, 0x0448, 0x00000001);
  309. nv_wo32(ctx, 0x045c, 0x44400000);
  310. nv_wo32(ctx, 0x0488, 0xffff0000);
  311. for (i = 0x04dc; i < 0x04e4; i += 4)
  312. nv_wo32(ctx, i, 0x0fff0000);
  313. nv_wo32(ctx, 0x04e8, 0x00011100);
  314. for (i = 0x0504; i < 0x0544; i += 4)
  315. nv_wo32(ctx, i, 0x07ff0000);
  316. nv_wo32(ctx, 0x054c, 0x4b7fffff);
  317. nv_wo32(ctx, 0x0588, 0x00000080);
  318. nv_wo32(ctx, 0x058c, 0x30201000);
  319. nv_wo32(ctx, 0x0590, 0x70605040);
  320. nv_wo32(ctx, 0x0594, 0xb8a89888);
  321. nv_wo32(ctx, 0x0598, 0xf8e8d8c8);
  322. nv_wo32(ctx, 0x05ac, 0xb0000000);
  323. for (i = 0x0604; i < 0x0644; i += 4)
  324. nv_wo32(ctx, i, 0x00010588);
  325. for (i = 0x0644; i < 0x0684; i += 4)
  326. nv_wo32(ctx, i, 0x00030303);
  327. for (i = 0x06c4; i < 0x0704; i += 4)
  328. nv_wo32(ctx, i, 0x0008aae4);
  329. for (i = 0x0704; i < 0x0744; i += 4)
  330. nv_wo32(ctx, i, 0x01012000);
  331. for (i = 0x0744; i < 0x0784; i += 4)
  332. nv_wo32(ctx, i, 0x00080008);
  333. nv_wo32(ctx, 0x0860, 0x00040000);
  334. nv_wo32(ctx, 0x0864, 0x00010000);
  335. for (i = 0x0868; i < 0x0878; i += 4)
  336. nv_wo32(ctx, i, 0x00040004);
  337. for (i = 0x1f1c; i <= 0x308c ; i += 16) {
  338. nv_wo32(ctx, i + 0, 0x10700ff9);
  339. nv_wo32(ctx, i + 4, 0x0436086c);
  340. nv_wo32(ctx, i + 8, 0x000c001b);
  341. }
  342. for (i = 0x30bc; i < 0x30cc; i += 4)
  343. nv_wo32(ctx, i, 0x0000ffff);
  344. nv_wo32(ctx, 0x3450, 0x3f800000);
  345. nv_wo32(ctx, 0x380c, 0x3f800000);
  346. nv_wo32(ctx, 0x3820, 0x3f800000);
  347. nv_wo32(ctx, 0x384c, 0x40000000);
  348. nv_wo32(ctx, 0x3850, 0x3f800000);
  349. nv_wo32(ctx, 0x3854, 0x3f000000);
  350. nv_wo32(ctx, 0x385c, 0x40000000);
  351. nv_wo32(ctx, 0x3860, 0x3f800000);
  352. nv_wo32(ctx, 0x3868, 0xbf800000);
  353. nv_wo32(ctx, 0x3870, 0xbf800000);
  354. }
  355. int
  356. nv20_graph_create_context(struct nouveau_channel *chan)
  357. {
  358. struct drm_device *dev = chan->dev;
  359. struct drm_nouveau_private *dev_priv = dev->dev_private;
  360. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  361. void (*ctx_init)(struct drm_device *, struct nouveau_gpuobj *);
  362. unsigned int idoffs = 0x28;
  363. int ret;
  364. switch (dev_priv->chipset) {
  365. case 0x20:
  366. ctx_init = nv20_graph_context_init;
  367. idoffs = 0;
  368. break;
  369. case 0x25:
  370. case 0x28:
  371. ctx_init = nv25_graph_context_init;
  372. break;
  373. case 0x2a:
  374. ctx_init = nv2a_graph_context_init;
  375. idoffs = 0;
  376. break;
  377. case 0x30:
  378. case 0x31:
  379. ctx_init = nv30_31_graph_context_init;
  380. break;
  381. case 0x34:
  382. ctx_init = nv34_graph_context_init;
  383. break;
  384. case 0x35:
  385. case 0x36:
  386. ctx_init = nv35_36_graph_context_init;
  387. break;
  388. default:
  389. BUG_ON(1);
  390. }
  391. ret = nouveau_gpuobj_new(dev, chan, pgraph->grctx_size, 16,
  392. NVOBJ_FLAG_ZERO_ALLOC, &chan->ramin_grctx);
  393. if (ret)
  394. return ret;
  395. /* Initialise default context values */
  396. ctx_init(dev, chan->ramin_grctx);
  397. /* nv20: nv_wo32(dev, chan->ramin_grctx->gpuobj, 10, chan->id<<24); */
  398. nv_wo32(chan->ramin_grctx, idoffs,
  399. (chan->id << 24) | 0x1); /* CTX_USER */
  400. nv_wo32(pgraph->ctx_table, chan->id * 4, chan->ramin_grctx->pinst >> 4);
  401. return 0;
  402. }
  403. void
  404. nv20_graph_destroy_context(struct nouveau_channel *chan)
  405. {
  406. struct drm_device *dev = chan->dev;
  407. struct drm_nouveau_private *dev_priv = dev->dev_private;
  408. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  409. unsigned long flags;
  410. spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
  411. pgraph->fifo_access(dev, false);
  412. /* Unload the context if it's the currently active one */
  413. if (pgraph->channel(dev) == chan)
  414. pgraph->unload_context(dev);
  415. pgraph->fifo_access(dev, true);
  416. spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
  417. /* Free the context resources */
  418. nv_wo32(pgraph->ctx_table, chan->id * 4, 0);
  419. nouveau_gpuobj_ref(NULL, &chan->ramin_grctx);
  420. }
  421. int
  422. nv20_graph_load_context(struct nouveau_channel *chan)
  423. {
  424. struct drm_device *dev = chan->dev;
  425. uint32_t inst;
  426. if (!chan->ramin_grctx)
  427. return -EINVAL;
  428. inst = chan->ramin_grctx->pinst >> 4;
  429. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, inst);
  430. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_XFER,
  431. NV20_PGRAPH_CHANNEL_CTX_XFER_LOAD);
  432. nv_wr32(dev, NV10_PGRAPH_CTX_CONTROL, 0x10010100);
  433. nouveau_wait_for_idle(dev);
  434. return 0;
  435. }
  436. int
  437. nv20_graph_unload_context(struct drm_device *dev)
  438. {
  439. struct drm_nouveau_private *dev_priv = dev->dev_private;
  440. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  441. struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
  442. struct nouveau_channel *chan;
  443. uint32_t inst, tmp;
  444. chan = pgraph->channel(dev);
  445. if (!chan)
  446. return 0;
  447. inst = chan->ramin_grctx->pinst >> 4;
  448. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_POINTER, inst);
  449. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_XFER,
  450. NV20_PGRAPH_CHANNEL_CTX_XFER_SAVE);
  451. nouveau_wait_for_idle(dev);
  452. nv_wr32(dev, NV10_PGRAPH_CTX_CONTROL, 0x10000000);
  453. tmp = nv_rd32(dev, NV10_PGRAPH_CTX_USER) & 0x00ffffff;
  454. tmp |= (pfifo->channels - 1) << 24;
  455. nv_wr32(dev, NV10_PGRAPH_CTX_USER, tmp);
  456. return 0;
  457. }
  458. static void
  459. nv20_graph_rdi(struct drm_device *dev)
  460. {
  461. struct drm_nouveau_private *dev_priv = dev->dev_private;
  462. int i, writecount = 32;
  463. uint32_t rdi_index = 0x2c80000;
  464. if (dev_priv->chipset == 0x20) {
  465. rdi_index = 0x3d0000;
  466. writecount = 15;
  467. }
  468. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, rdi_index);
  469. for (i = 0; i < writecount; i++)
  470. nv_wr32(dev, NV10_PGRAPH_RDI_DATA, 0);
  471. nouveau_wait_for_idle(dev);
  472. }
  473. void
  474. nv20_graph_set_tile_region(struct drm_device *dev, int i)
  475. {
  476. struct drm_nouveau_private *dev_priv = dev->dev_private;
  477. struct nouveau_tile_reg *tile = &dev_priv->tile.reg[i];
  478. nv_wr32(dev, NV20_PGRAPH_TLIMIT(i), tile->limit);
  479. nv_wr32(dev, NV20_PGRAPH_TSIZE(i), tile->pitch);
  480. nv_wr32(dev, NV20_PGRAPH_TILE(i), tile->addr);
  481. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0030 + 4 * i);
  482. nv_wr32(dev, NV10_PGRAPH_RDI_DATA, tile->limit);
  483. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0050 + 4 * i);
  484. nv_wr32(dev, NV10_PGRAPH_RDI_DATA, tile->pitch);
  485. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0010 + 4 * i);
  486. nv_wr32(dev, NV10_PGRAPH_RDI_DATA, tile->addr);
  487. if (dev_priv->card_type == NV_20) {
  488. nv_wr32(dev, NV20_PGRAPH_ZCOMP(i), tile->zcomp);
  489. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00ea0090 + 4 * i);
  490. nv_wr32(dev, NV10_PGRAPH_RDI_DATA, tile->zcomp);
  491. }
  492. }
  493. int
  494. nv20_graph_init(struct drm_device *dev)
  495. {
  496. struct drm_nouveau_private *dev_priv = dev->dev_private;
  497. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  498. uint32_t tmp, vramsz;
  499. int ret, i;
  500. switch (dev_priv->chipset) {
  501. case 0x20:
  502. pgraph->grctx_size = NV20_GRCTX_SIZE;
  503. break;
  504. case 0x25:
  505. case 0x28:
  506. pgraph->grctx_size = NV25_GRCTX_SIZE;
  507. break;
  508. case 0x2a:
  509. pgraph->grctx_size = NV2A_GRCTX_SIZE;
  510. break;
  511. default:
  512. NV_ERROR(dev, "unknown chipset, disabling acceleration\n");
  513. pgraph->accel_blocked = true;
  514. return 0;
  515. }
  516. nv_wr32(dev, NV03_PMC_ENABLE,
  517. nv_rd32(dev, NV03_PMC_ENABLE) & ~NV_PMC_ENABLE_PGRAPH);
  518. nv_wr32(dev, NV03_PMC_ENABLE,
  519. nv_rd32(dev, NV03_PMC_ENABLE) | NV_PMC_ENABLE_PGRAPH);
  520. if (!pgraph->ctx_table) {
  521. /* Create Context Pointer Table */
  522. ret = nouveau_gpuobj_new(dev, NULL, 32 * 4, 16,
  523. NVOBJ_FLAG_ZERO_ALLOC,
  524. &pgraph->ctx_table);
  525. if (ret)
  526. return ret;
  527. }
  528. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_TABLE,
  529. pgraph->ctx_table->pinst >> 4);
  530. nv20_graph_rdi(dev);
  531. ret = nv20_graph_register(dev);
  532. if (ret) {
  533. nouveau_gpuobj_ref(NULL, &pgraph->ctx_table);
  534. return ret;
  535. }
  536. nouveau_irq_register(dev, 12, nv20_graph_isr);
  537. nv_wr32(dev, NV03_PGRAPH_INTR , 0xFFFFFFFF);
  538. nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0xFFFFFFFF);
  539. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0xFFFFFFFF);
  540. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x00000000);
  541. nv_wr32(dev, NV04_PGRAPH_DEBUG_1, 0x00118700);
  542. nv_wr32(dev, NV04_PGRAPH_DEBUG_3, 0xF3CE0475); /* 0x4 = auto ctx switch */
  543. nv_wr32(dev, NV10_PGRAPH_DEBUG_4, 0x00000000);
  544. nv_wr32(dev, 0x40009C , 0x00000040);
  545. if (dev_priv->chipset >= 0x25) {
  546. nv_wr32(dev, 0x400890, 0x00a8cfff);
  547. nv_wr32(dev, 0x400610, 0x304B1FB6);
  548. nv_wr32(dev, 0x400B80, 0x1cbd3883);
  549. nv_wr32(dev, 0x400B84, 0x44000000);
  550. nv_wr32(dev, 0x400098, 0x40000080);
  551. nv_wr32(dev, 0x400B88, 0x000000ff);
  552. } else {
  553. nv_wr32(dev, 0x400880, 0x0008c7df);
  554. nv_wr32(dev, 0x400094, 0x00000005);
  555. nv_wr32(dev, 0x400B80, 0x45eae20e);
  556. nv_wr32(dev, 0x400B84, 0x24000000);
  557. nv_wr32(dev, 0x400098, 0x00000040);
  558. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00E00038);
  559. nv_wr32(dev, NV10_PGRAPH_RDI_DATA , 0x00000030);
  560. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00E10038);
  561. nv_wr32(dev, NV10_PGRAPH_RDI_DATA , 0x00000030);
  562. }
  563. /* Turn all the tiling regions off. */
  564. for (i = 0; i < NV10_PFB_TILE__SIZE; i++)
  565. nv20_graph_set_tile_region(dev, i);
  566. nv_wr32(dev, 0x4009a0, nv_rd32(dev, 0x100324));
  567. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA000C);
  568. nv_wr32(dev, NV10_PGRAPH_RDI_DATA, nv_rd32(dev, 0x100324));
  569. nv_wr32(dev, NV10_PGRAPH_CTX_CONTROL, 0x10000100);
  570. nv_wr32(dev, NV10_PGRAPH_STATE , 0xFFFFFFFF);
  571. tmp = nv_rd32(dev, NV10_PGRAPH_SURFACE) & 0x0007ff00;
  572. nv_wr32(dev, NV10_PGRAPH_SURFACE, tmp);
  573. tmp = nv_rd32(dev, NV10_PGRAPH_SURFACE) | 0x00020100;
  574. nv_wr32(dev, NV10_PGRAPH_SURFACE, tmp);
  575. /* begin RAM config */
  576. vramsz = pci_resource_len(dev->pdev, 0) - 1;
  577. nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
  578. nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
  579. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0000);
  580. nv_wr32(dev, NV10_PGRAPH_RDI_DATA , nv_rd32(dev, NV04_PFB_CFG0));
  581. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0004);
  582. nv_wr32(dev, NV10_PGRAPH_RDI_DATA , nv_rd32(dev, NV04_PFB_CFG1));
  583. nv_wr32(dev, 0x400820, 0);
  584. nv_wr32(dev, 0x400824, 0);
  585. nv_wr32(dev, 0x400864, vramsz - 1);
  586. nv_wr32(dev, 0x400868, vramsz - 1);
  587. /* interesting.. the below overwrites some of the tile setup above.. */
  588. nv_wr32(dev, 0x400B20, 0x00000000);
  589. nv_wr32(dev, 0x400B04, 0xFFFFFFFF);
  590. nv_wr32(dev, NV03_PGRAPH_ABS_UCLIP_XMIN, 0);
  591. nv_wr32(dev, NV03_PGRAPH_ABS_UCLIP_YMIN, 0);
  592. nv_wr32(dev, NV03_PGRAPH_ABS_UCLIP_XMAX, 0x7fff);
  593. nv_wr32(dev, NV03_PGRAPH_ABS_UCLIP_YMAX, 0x7fff);
  594. return 0;
  595. }
  596. void
  597. nv20_graph_takedown(struct drm_device *dev)
  598. {
  599. struct drm_nouveau_private *dev_priv = dev->dev_private;
  600. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  601. nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0x00000000);
  602. nouveau_irq_unregister(dev, 12);
  603. nouveau_gpuobj_ref(NULL, &pgraph->ctx_table);
  604. }
  605. int
  606. nv30_graph_init(struct drm_device *dev)
  607. {
  608. struct drm_nouveau_private *dev_priv = dev->dev_private;
  609. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  610. int ret, i;
  611. switch (dev_priv->chipset) {
  612. case 0x30:
  613. case 0x31:
  614. pgraph->grctx_size = NV30_31_GRCTX_SIZE;
  615. break;
  616. case 0x34:
  617. pgraph->grctx_size = NV34_GRCTX_SIZE;
  618. break;
  619. case 0x35:
  620. case 0x36:
  621. pgraph->grctx_size = NV35_36_GRCTX_SIZE;
  622. break;
  623. default:
  624. NV_ERROR(dev, "unknown chipset, disabling acceleration\n");
  625. pgraph->accel_blocked = true;
  626. return 0;
  627. }
  628. nv_wr32(dev, NV03_PMC_ENABLE,
  629. nv_rd32(dev, NV03_PMC_ENABLE) & ~NV_PMC_ENABLE_PGRAPH);
  630. nv_wr32(dev, NV03_PMC_ENABLE,
  631. nv_rd32(dev, NV03_PMC_ENABLE) | NV_PMC_ENABLE_PGRAPH);
  632. if (!pgraph->ctx_table) {
  633. /* Create Context Pointer Table */
  634. ret = nouveau_gpuobj_new(dev, NULL, 32 * 4, 16,
  635. NVOBJ_FLAG_ZERO_ALLOC,
  636. &pgraph->ctx_table);
  637. if (ret)
  638. return ret;
  639. }
  640. ret = nv30_graph_register(dev);
  641. if (ret) {
  642. nouveau_gpuobj_ref(NULL, &pgraph->ctx_table);
  643. return ret;
  644. }
  645. nv_wr32(dev, NV20_PGRAPH_CHANNEL_CTX_TABLE,
  646. pgraph->ctx_table->pinst >> 4);
  647. nouveau_irq_register(dev, 12, nv20_graph_isr);
  648. nv_wr32(dev, NV03_PGRAPH_INTR , 0xFFFFFFFF);
  649. nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0xFFFFFFFF);
  650. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0xFFFFFFFF);
  651. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x00000000);
  652. nv_wr32(dev, NV04_PGRAPH_DEBUG_1, 0x401287c0);
  653. nv_wr32(dev, 0x400890, 0x01b463ff);
  654. nv_wr32(dev, NV04_PGRAPH_DEBUG_3, 0xf2de0475);
  655. nv_wr32(dev, NV10_PGRAPH_DEBUG_4, 0x00008000);
  656. nv_wr32(dev, NV04_PGRAPH_LIMIT_VIOL_PIX, 0xf04bdff6);
  657. nv_wr32(dev, 0x400B80, 0x1003d888);
  658. nv_wr32(dev, 0x400B84, 0x0c000000);
  659. nv_wr32(dev, 0x400098, 0x00000000);
  660. nv_wr32(dev, 0x40009C, 0x0005ad00);
  661. nv_wr32(dev, 0x400B88, 0x62ff00ff); /* suspiciously like PGRAPH_DEBUG_2 */
  662. nv_wr32(dev, 0x4000a0, 0x00000000);
  663. nv_wr32(dev, 0x4000a4, 0x00000008);
  664. nv_wr32(dev, 0x4008a8, 0xb784a400);
  665. nv_wr32(dev, 0x400ba0, 0x002f8685);
  666. nv_wr32(dev, 0x400ba4, 0x00231f3f);
  667. nv_wr32(dev, 0x4008a4, 0x40000020);
  668. if (dev_priv->chipset == 0x34) {
  669. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0004);
  670. nv_wr32(dev, NV10_PGRAPH_RDI_DATA , 0x00200201);
  671. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0008);
  672. nv_wr32(dev, NV10_PGRAPH_RDI_DATA , 0x00000008);
  673. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00EA0000);
  674. nv_wr32(dev, NV10_PGRAPH_RDI_DATA , 0x00000032);
  675. nv_wr32(dev, NV10_PGRAPH_RDI_INDEX, 0x00E00004);
  676. nv_wr32(dev, NV10_PGRAPH_RDI_DATA , 0x00000002);
  677. }
  678. nv_wr32(dev, 0x4000c0, 0x00000016);
  679. /* Turn all the tiling regions off. */
  680. for (i = 0; i < NV10_PFB_TILE__SIZE; i++)
  681. nv20_graph_set_tile_region(dev, i);
  682. nv_wr32(dev, NV10_PGRAPH_CTX_CONTROL, 0x10000100);
  683. nv_wr32(dev, NV10_PGRAPH_STATE , 0xFFFFFFFF);
  684. nv_wr32(dev, 0x0040075c , 0x00000001);
  685. /* begin RAM config */
  686. /* vramsz = pci_resource_len(dev->pdev, 0) - 1; */
  687. nv_wr32(dev, 0x4009A4, nv_rd32(dev, NV04_PFB_CFG0));
  688. nv_wr32(dev, 0x4009A8, nv_rd32(dev, NV04_PFB_CFG1));
  689. if (dev_priv->chipset != 0x34) {
  690. nv_wr32(dev, 0x400750, 0x00EA0000);
  691. nv_wr32(dev, 0x400754, nv_rd32(dev, NV04_PFB_CFG0));
  692. nv_wr32(dev, 0x400750, 0x00EA0004);
  693. nv_wr32(dev, 0x400754, nv_rd32(dev, NV04_PFB_CFG1));
  694. }
  695. return 0;
  696. }
  697. static int
  698. nv20_graph_register(struct drm_device *dev)
  699. {
  700. struct drm_nouveau_private *dev_priv = dev->dev_private;
  701. if (dev_priv->engine.graph.registered)
  702. return 0;
  703. NVOBJ_CLASS(dev, 0x506e, SW); /* nvsw */
  704. NVOBJ_CLASS(dev, 0x0030, GR); /* null */
  705. NVOBJ_CLASS(dev, 0x0039, GR); /* m2mf */
  706. NVOBJ_CLASS(dev, 0x004a, GR); /* gdirect */
  707. NVOBJ_CLASS(dev, 0x009f, GR); /* imageblit (nv12) */
  708. NVOBJ_CLASS(dev, 0x008a, GR); /* ifc */
  709. NVOBJ_CLASS(dev, 0x0089, GR); /* sifm */
  710. NVOBJ_CLASS(dev, 0x0062, GR); /* surf2d */
  711. NVOBJ_CLASS(dev, 0x0043, GR); /* rop */
  712. NVOBJ_CLASS(dev, 0x0012, GR); /* beta1 */
  713. NVOBJ_CLASS(dev, 0x0072, GR); /* beta4 */
  714. NVOBJ_CLASS(dev, 0x0019, GR); /* cliprect */
  715. NVOBJ_CLASS(dev, 0x0044, GR); /* pattern */
  716. NVOBJ_CLASS(dev, 0x009e, GR); /* swzsurf */
  717. NVOBJ_CLASS(dev, 0x0096, GR); /* celcius */
  718. /* kelvin */
  719. if (dev_priv->chipset < 0x25)
  720. NVOBJ_CLASS(dev, 0x0097, GR);
  721. else
  722. NVOBJ_CLASS(dev, 0x0597, GR);
  723. /* nvsw */
  724. NVOBJ_CLASS(dev, 0x506e, SW);
  725. NVOBJ_MTHD (dev, 0x506e, 0x0500, nv04_graph_mthd_page_flip);
  726. dev_priv->engine.graph.registered = true;
  727. return 0;
  728. }
  729. static int
  730. nv30_graph_register(struct drm_device *dev)
  731. {
  732. struct drm_nouveau_private *dev_priv = dev->dev_private;
  733. if (dev_priv->engine.graph.registered)
  734. return 0;
  735. NVOBJ_CLASS(dev, 0x506e, SW); /* nvsw */
  736. NVOBJ_CLASS(dev, 0x0030, GR); /* null */
  737. NVOBJ_CLASS(dev, 0x0039, GR); /* m2mf */
  738. NVOBJ_CLASS(dev, 0x004a, GR); /* gdirect */
  739. NVOBJ_CLASS(dev, 0x009f, GR); /* imageblit (nv12) */
  740. NVOBJ_CLASS(dev, 0x008a, GR); /* ifc */
  741. NVOBJ_CLASS(dev, 0x038a, GR); /* ifc (nv30) */
  742. NVOBJ_CLASS(dev, 0x0089, GR); /* sifm */
  743. NVOBJ_CLASS(dev, 0x0389, GR); /* sifm (nv30) */
  744. NVOBJ_CLASS(dev, 0x0062, GR); /* surf2d */
  745. NVOBJ_CLASS(dev, 0x0362, GR); /* surf2d (nv30) */
  746. NVOBJ_CLASS(dev, 0x0043, GR); /* rop */
  747. NVOBJ_CLASS(dev, 0x0012, GR); /* beta1 */
  748. NVOBJ_CLASS(dev, 0x0072, GR); /* beta4 */
  749. NVOBJ_CLASS(dev, 0x0019, GR); /* cliprect */
  750. NVOBJ_CLASS(dev, 0x0044, GR); /* pattern */
  751. NVOBJ_CLASS(dev, 0x039e, GR); /* swzsurf */
  752. /* rankine */
  753. if (0x00000003 & (1 << (dev_priv->chipset & 0x0f)))
  754. NVOBJ_CLASS(dev, 0x0397, GR);
  755. else
  756. if (0x00000010 & (1 << (dev_priv->chipset & 0x0f)))
  757. NVOBJ_CLASS(dev, 0x0697, GR);
  758. else
  759. if (0x000001e0 & (1 << (dev_priv->chipset & 0x0f)))
  760. NVOBJ_CLASS(dev, 0x0497, GR);
  761. /* nvsw */
  762. NVOBJ_CLASS(dev, 0x506e, SW);
  763. NVOBJ_MTHD (dev, 0x506e, 0x0500, nv04_graph_mthd_page_flip);
  764. dev_priv->engine.graph.registered = true;
  765. return 0;
  766. }
  767. static void
  768. nv20_graph_isr(struct drm_device *dev)
  769. {
  770. u32 stat;
  771. while ((stat = nv_rd32(dev, NV03_PGRAPH_INTR))) {
  772. u32 nsource = nv_rd32(dev, NV03_PGRAPH_NSOURCE);
  773. u32 nstatus = nv_rd32(dev, NV03_PGRAPH_NSTATUS);
  774. u32 addr = nv_rd32(dev, NV04_PGRAPH_TRAPPED_ADDR);
  775. u32 chid = (addr & 0x01f00000) >> 20;
  776. u32 subc = (addr & 0x00070000) >> 16;
  777. u32 mthd = (addr & 0x00001ffc);
  778. u32 data = nv_rd32(dev, NV04_PGRAPH_TRAPPED_DATA);
  779. u32 class = nv_rd32(dev, 0x400160 + subc * 4) & 0xfff;
  780. u32 show = stat;
  781. if (stat & NV_PGRAPH_INTR_ERROR) {
  782. if (nsource & NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD) {
  783. if (!nouveau_gpuobj_mthd_call2(dev, chid, class, mthd, data))
  784. show &= ~NV_PGRAPH_INTR_ERROR;
  785. }
  786. }
  787. nv_wr32(dev, NV03_PGRAPH_INTR, stat);
  788. nv_wr32(dev, NV04_PGRAPH_FIFO, 0x00000001);
  789. if (show && nouveau_ratelimit()) {
  790. NV_INFO(dev, "PGRAPH -");
  791. nouveau_bitfield_print(nv10_graph_intr, show);
  792. printk(" nsource:");
  793. nouveau_bitfield_print(nv04_graph_nsource, nsource);
  794. printk(" nstatus:");
  795. nouveau_bitfield_print(nv10_graph_nstatus, nstatus);
  796. printk("\n");
  797. NV_INFO(dev, "PGRAPH - ch %d/%d class 0x%04x "
  798. "mthd 0x%04x data 0x%08x\n",
  799. chid, subc, class, mthd, data);
  800. }
  801. }
  802. }