nv50_fifo.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  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. struct nv50_fifo_priv {
  30. struct nouveau_gpuobj_ref *thingo[2];
  31. int cur_thingo;
  32. };
  33. #define IS_G80 ((dev_priv->chipset & 0xf0) == 0x50)
  34. static void
  35. nv50_fifo_init_thingo(struct drm_device *dev)
  36. {
  37. struct drm_nouveau_private *dev_priv = dev->dev_private;
  38. struct nv50_fifo_priv *priv = dev_priv->engine.fifo.priv;
  39. struct nouveau_gpuobj_ref *cur;
  40. int i, nr;
  41. NV_DEBUG(dev, "\n");
  42. cur = priv->thingo[priv->cur_thingo];
  43. priv->cur_thingo = !priv->cur_thingo;
  44. /* We never schedule channel 0 or 127 */
  45. dev_priv->engine.instmem.prepare_access(dev, true);
  46. for (i = 1, nr = 0; i < 127; i++) {
  47. if (dev_priv->fifos[i] && dev_priv->fifos[i]->ramfc)
  48. nv_wo32(dev, cur->gpuobj, nr++, i);
  49. }
  50. dev_priv->engine.instmem.finish_access(dev);
  51. nv_wr32(dev, 0x32f4, cur->instance >> 12);
  52. nv_wr32(dev, 0x32ec, nr);
  53. nv_wr32(dev, 0x2500, 0x101);
  54. }
  55. static int
  56. nv50_fifo_channel_enable(struct drm_device *dev, int channel, bool nt)
  57. {
  58. struct drm_nouveau_private *dev_priv = dev->dev_private;
  59. struct nouveau_channel *chan = dev_priv->fifos[channel];
  60. uint32_t inst;
  61. NV_DEBUG(dev, "ch%d\n", channel);
  62. if (!chan->ramfc)
  63. return -EINVAL;
  64. if (IS_G80)
  65. inst = chan->ramfc->instance >> 12;
  66. else
  67. inst = chan->ramfc->instance >> 8;
  68. nv_wr32(dev, NV50_PFIFO_CTX_TABLE(channel),
  69. inst | NV50_PFIFO_CTX_TABLE_CHANNEL_ENABLED);
  70. if (!nt)
  71. nv50_fifo_init_thingo(dev);
  72. return 0;
  73. }
  74. static void
  75. nv50_fifo_channel_disable(struct drm_device *dev, int channel, bool nt)
  76. {
  77. struct drm_nouveau_private *dev_priv = dev->dev_private;
  78. uint32_t inst;
  79. NV_DEBUG(dev, "ch%d, nt=%d\n", channel, nt);
  80. if (IS_G80)
  81. inst = NV50_PFIFO_CTX_TABLE_INSTANCE_MASK_G80;
  82. else
  83. inst = NV50_PFIFO_CTX_TABLE_INSTANCE_MASK_G84;
  84. nv_wr32(dev, NV50_PFIFO_CTX_TABLE(channel), inst);
  85. if (!nt)
  86. nv50_fifo_init_thingo(dev);
  87. }
  88. static void
  89. nv50_fifo_init_reset(struct drm_device *dev)
  90. {
  91. uint32_t pmc_e = NV_PMC_ENABLE_PFIFO;
  92. NV_DEBUG(dev, "\n");
  93. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) & ~pmc_e);
  94. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) | pmc_e);
  95. }
  96. static void
  97. nv50_fifo_init_intr(struct drm_device *dev)
  98. {
  99. NV_DEBUG(dev, "\n");
  100. nv_wr32(dev, NV03_PFIFO_INTR_0, 0xFFFFFFFF);
  101. nv_wr32(dev, NV03_PFIFO_INTR_EN_0, 0xFFFFFFFF);
  102. }
  103. static void
  104. nv50_fifo_init_context_table(struct drm_device *dev)
  105. {
  106. struct drm_nouveau_private *dev_priv = dev->dev_private;
  107. int i;
  108. NV_DEBUG(dev, "\n");
  109. for (i = 0; i < NV50_PFIFO_CTX_TABLE__SIZE; i++) {
  110. if (dev_priv->fifos[i])
  111. nv50_fifo_channel_enable(dev, i, true);
  112. else
  113. nv50_fifo_channel_disable(dev, i, true);
  114. }
  115. nv50_fifo_init_thingo(dev);
  116. }
  117. static void
  118. nv50_fifo_init_regs__nv(struct drm_device *dev)
  119. {
  120. NV_DEBUG(dev, "\n");
  121. nv_wr32(dev, 0x250c, 0x6f3cfc34);
  122. }
  123. static void
  124. nv50_fifo_init_regs(struct drm_device *dev)
  125. {
  126. NV_DEBUG(dev, "\n");
  127. nv_wr32(dev, 0x2500, 0);
  128. nv_wr32(dev, 0x3250, 0);
  129. nv_wr32(dev, 0x3220, 0);
  130. nv_wr32(dev, 0x3204, 0);
  131. nv_wr32(dev, 0x3210, 0);
  132. nv_wr32(dev, 0x3270, 0);
  133. /* Enable dummy channels setup by nv50_instmem.c */
  134. nv50_fifo_channel_enable(dev, 0, true);
  135. nv50_fifo_channel_enable(dev, 127, true);
  136. }
  137. int
  138. nv50_fifo_init(struct drm_device *dev)
  139. {
  140. struct drm_nouveau_private *dev_priv = dev->dev_private;
  141. struct nv50_fifo_priv *priv;
  142. int ret;
  143. NV_DEBUG(dev, "\n");
  144. priv = dev_priv->engine.fifo.priv;
  145. if (priv) {
  146. priv->cur_thingo = !priv->cur_thingo;
  147. goto just_reset;
  148. }
  149. priv = kzalloc(sizeof(*priv), GFP_KERNEL);
  150. if (!priv)
  151. return -ENOMEM;
  152. dev_priv->engine.fifo.priv = priv;
  153. ret = nouveau_gpuobj_new_ref(dev, NULL, NULL, 0, 128*4, 0x1000,
  154. NVOBJ_FLAG_ZERO_ALLOC, &priv->thingo[0]);
  155. if (ret) {
  156. NV_ERROR(dev, "error creating thingo0: %d\n", ret);
  157. return ret;
  158. }
  159. ret = nouveau_gpuobj_new_ref(dev, NULL, NULL, 0, 128*4, 0x1000,
  160. NVOBJ_FLAG_ZERO_ALLOC, &priv->thingo[1]);
  161. if (ret) {
  162. NV_ERROR(dev, "error creating thingo1: %d\n", ret);
  163. return ret;
  164. }
  165. just_reset:
  166. nv50_fifo_init_reset(dev);
  167. nv50_fifo_init_intr(dev);
  168. nv50_fifo_init_context_table(dev);
  169. nv50_fifo_init_regs__nv(dev);
  170. nv50_fifo_init_regs(dev);
  171. dev_priv->engine.fifo.enable(dev);
  172. dev_priv->engine.fifo.reassign(dev, true);
  173. return 0;
  174. }
  175. void
  176. nv50_fifo_takedown(struct drm_device *dev)
  177. {
  178. struct drm_nouveau_private *dev_priv = dev->dev_private;
  179. struct nv50_fifo_priv *priv = dev_priv->engine.fifo.priv;
  180. NV_DEBUG(dev, "\n");
  181. if (!priv)
  182. return;
  183. nouveau_gpuobj_ref_del(dev, &priv->thingo[0]);
  184. nouveau_gpuobj_ref_del(dev, &priv->thingo[1]);
  185. dev_priv->engine.fifo.priv = NULL;
  186. kfree(priv);
  187. }
  188. int
  189. nv50_fifo_channel_id(struct drm_device *dev)
  190. {
  191. return nv_rd32(dev, NV03_PFIFO_CACHE1_PUSH1) &
  192. NV50_PFIFO_CACHE1_PUSH1_CHID_MASK;
  193. }
  194. int
  195. nv50_fifo_create_context(struct nouveau_channel *chan)
  196. {
  197. struct drm_device *dev = chan->dev;
  198. struct drm_nouveau_private *dev_priv = dev->dev_private;
  199. struct nouveau_gpuobj *ramfc = NULL;
  200. int ret;
  201. NV_DEBUG(dev, "ch%d\n", chan->id);
  202. if (IS_G80) {
  203. uint32_t ramin_poffset = chan->ramin->gpuobj->im_pramin->start;
  204. uint32_t ramin_voffset = chan->ramin->gpuobj->im_backing_start;
  205. ret = nouveau_gpuobj_new_fake(dev, ramin_poffset, ramin_voffset,
  206. 0x100, NVOBJ_FLAG_ZERO_ALLOC |
  207. NVOBJ_FLAG_ZERO_FREE, &ramfc,
  208. &chan->ramfc);
  209. if (ret)
  210. return ret;
  211. ret = nouveau_gpuobj_new_fake(dev, ramin_poffset + 0x0400,
  212. ramin_voffset + 0x0400, 4096,
  213. 0, NULL, &chan->cache);
  214. if (ret)
  215. return ret;
  216. } else {
  217. ret = nouveau_gpuobj_new_ref(dev, chan, NULL, 0, 0x100, 256,
  218. NVOBJ_FLAG_ZERO_ALLOC |
  219. NVOBJ_FLAG_ZERO_FREE,
  220. &chan->ramfc);
  221. if (ret)
  222. return ret;
  223. ramfc = chan->ramfc->gpuobj;
  224. ret = nouveau_gpuobj_new_ref(dev, chan, NULL, 0, 4096, 256,
  225. 0, &chan->cache);
  226. if (ret)
  227. return ret;
  228. }
  229. dev_priv->engine.instmem.prepare_access(dev, true);
  230. nv_wo32(dev, ramfc, 0x08/4, chan->pushbuf_base);
  231. nv_wo32(dev, ramfc, 0x10/4, chan->pushbuf_base);
  232. nv_wo32(dev, ramfc, 0x48/4, chan->pushbuf->instance >> 4);
  233. nv_wo32(dev, ramfc, 0x80/4, (0xc << 24) | (chan->ramht->instance >> 4));
  234. nv_wo32(dev, ramfc, 0x3c/4, 0x00086078);
  235. nv_wo32(dev, ramfc, 0x44/4, 0x2101ffff);
  236. nv_wo32(dev, ramfc, 0x60/4, 0x7fffffff);
  237. nv_wo32(dev, ramfc, 0x40/4, 0x00000000);
  238. nv_wo32(dev, ramfc, 0x7c/4, 0x30000001);
  239. nv_wo32(dev, ramfc, 0x78/4, 0x00000000);
  240. nv_wo32(dev, ramfc, 0x4c/4, 0xffffffff);
  241. if (!IS_G80) {
  242. nv_wo32(dev, chan->ramin->gpuobj, 0, chan->id);
  243. nv_wo32(dev, chan->ramin->gpuobj, 1,
  244. chan->ramfc->instance >> 8);
  245. nv_wo32(dev, ramfc, 0x88/4, chan->cache->instance >> 10);
  246. nv_wo32(dev, ramfc, 0x98/4, chan->ramin->instance >> 12);
  247. }
  248. dev_priv->engine.instmem.finish_access(dev);
  249. ret = nv50_fifo_channel_enable(dev, chan->id, false);
  250. if (ret) {
  251. NV_ERROR(dev, "error enabling ch%d: %d\n", chan->id, ret);
  252. nouveau_gpuobj_ref_del(dev, &chan->ramfc);
  253. return ret;
  254. }
  255. return 0;
  256. }
  257. void
  258. nv50_fifo_destroy_context(struct nouveau_channel *chan)
  259. {
  260. struct drm_device *dev = chan->dev;
  261. NV_DEBUG(dev, "ch%d\n", chan->id);
  262. nouveau_gpuobj_ref_del(dev, &chan->ramfc);
  263. nouveau_gpuobj_ref_del(dev, &chan->cache);
  264. nv50_fifo_channel_disable(dev, chan->id, false);
  265. /* Dummy channel, also used on ch 127 */
  266. if (chan->id == 0)
  267. nv50_fifo_channel_disable(dev, 127, false);
  268. }
  269. int
  270. nv50_fifo_load_context(struct nouveau_channel *chan)
  271. {
  272. struct drm_device *dev = chan->dev;
  273. struct drm_nouveau_private *dev_priv = dev->dev_private;
  274. struct nouveau_gpuobj *ramfc = chan->ramfc->gpuobj;
  275. struct nouveau_gpuobj *cache = chan->cache->gpuobj;
  276. int ptr, cnt;
  277. NV_DEBUG(dev, "ch%d\n", chan->id);
  278. dev_priv->engine.instmem.prepare_access(dev, false);
  279. nv_wr32(dev, 0x3330, nv_ro32(dev, ramfc, 0x00/4));
  280. nv_wr32(dev, 0x3334, nv_ro32(dev, ramfc, 0x04/4));
  281. nv_wr32(dev, 0x3240, nv_ro32(dev, ramfc, 0x08/4));
  282. nv_wr32(dev, 0x3320, nv_ro32(dev, ramfc, 0x0c/4));
  283. nv_wr32(dev, 0x3244, nv_ro32(dev, ramfc, 0x10/4));
  284. nv_wr32(dev, 0x3328, nv_ro32(dev, ramfc, 0x14/4));
  285. nv_wr32(dev, 0x3368, nv_ro32(dev, ramfc, 0x18/4));
  286. nv_wr32(dev, 0x336c, nv_ro32(dev, ramfc, 0x1c/4));
  287. nv_wr32(dev, 0x3370, nv_ro32(dev, ramfc, 0x20/4));
  288. nv_wr32(dev, 0x3374, nv_ro32(dev, ramfc, 0x24/4));
  289. nv_wr32(dev, 0x3378, nv_ro32(dev, ramfc, 0x28/4));
  290. nv_wr32(dev, 0x337c, nv_ro32(dev, ramfc, 0x2c/4));
  291. nv_wr32(dev, 0x3228, nv_ro32(dev, ramfc, 0x30/4));
  292. nv_wr32(dev, 0x3364, nv_ro32(dev, ramfc, 0x34/4));
  293. nv_wr32(dev, 0x32a0, nv_ro32(dev, ramfc, 0x38/4));
  294. nv_wr32(dev, 0x3224, nv_ro32(dev, ramfc, 0x3c/4));
  295. nv_wr32(dev, 0x324c, nv_ro32(dev, ramfc, 0x40/4));
  296. nv_wr32(dev, 0x2044, nv_ro32(dev, ramfc, 0x44/4));
  297. nv_wr32(dev, 0x322c, nv_ro32(dev, ramfc, 0x48/4));
  298. nv_wr32(dev, 0x3234, nv_ro32(dev, ramfc, 0x4c/4));
  299. nv_wr32(dev, 0x3340, nv_ro32(dev, ramfc, 0x50/4));
  300. nv_wr32(dev, 0x3344, nv_ro32(dev, ramfc, 0x54/4));
  301. nv_wr32(dev, 0x3280, nv_ro32(dev, ramfc, 0x58/4));
  302. nv_wr32(dev, 0x3254, nv_ro32(dev, ramfc, 0x5c/4));
  303. nv_wr32(dev, 0x3260, nv_ro32(dev, ramfc, 0x60/4));
  304. nv_wr32(dev, 0x3264, nv_ro32(dev, ramfc, 0x64/4));
  305. nv_wr32(dev, 0x3268, nv_ro32(dev, ramfc, 0x68/4));
  306. nv_wr32(dev, 0x326c, nv_ro32(dev, ramfc, 0x6c/4));
  307. nv_wr32(dev, 0x32e4, nv_ro32(dev, ramfc, 0x70/4));
  308. nv_wr32(dev, 0x3248, nv_ro32(dev, ramfc, 0x74/4));
  309. nv_wr32(dev, 0x2088, nv_ro32(dev, ramfc, 0x78/4));
  310. nv_wr32(dev, 0x2058, nv_ro32(dev, ramfc, 0x7c/4));
  311. nv_wr32(dev, 0x2210, nv_ro32(dev, ramfc, 0x80/4));
  312. cnt = nv_ro32(dev, ramfc, 0x84/4);
  313. for (ptr = 0; ptr < cnt; ptr++) {
  314. nv_wr32(dev, NV40_PFIFO_CACHE1_METHOD(ptr),
  315. nv_ro32(dev, cache, (ptr * 2) + 0));
  316. nv_wr32(dev, NV40_PFIFO_CACHE1_DATA(ptr),
  317. nv_ro32(dev, cache, (ptr * 2) + 1));
  318. }
  319. nv_wr32(dev, NV03_PFIFO_CACHE1_PUT, cnt << 2);
  320. nv_wr32(dev, NV03_PFIFO_CACHE1_GET, 0);
  321. /* guessing that all the 0x34xx regs aren't on NV50 */
  322. if (!IS_G80) {
  323. nv_wr32(dev, 0x340c, nv_ro32(dev, ramfc, 0x88/4));
  324. nv_wr32(dev, 0x3400, nv_ro32(dev, ramfc, 0x8c/4));
  325. nv_wr32(dev, 0x3404, nv_ro32(dev, ramfc, 0x90/4));
  326. nv_wr32(dev, 0x3408, nv_ro32(dev, ramfc, 0x94/4));
  327. nv_wr32(dev, 0x3410, nv_ro32(dev, ramfc, 0x98/4));
  328. }
  329. dev_priv->engine.instmem.finish_access(dev);
  330. nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH1, chan->id | (1<<16));
  331. return 0;
  332. }
  333. int
  334. nv50_fifo_unload_context(struct drm_device *dev)
  335. {
  336. struct drm_nouveau_private *dev_priv = dev->dev_private;
  337. struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
  338. struct nouveau_gpuobj *ramfc, *cache;
  339. struct nouveau_channel *chan = NULL;
  340. int chid, get, put, ptr;
  341. NV_DEBUG(dev, "\n");
  342. chid = pfifo->channel_id(dev);
  343. if (chid < 1 || chid >= dev_priv->engine.fifo.channels - 1)
  344. return 0;
  345. chan = dev_priv->fifos[chid];
  346. if (!chan) {
  347. NV_ERROR(dev, "Inactive channel on PFIFO: %d\n", chid);
  348. return -EINVAL;
  349. }
  350. NV_DEBUG(dev, "ch%d\n", chan->id);
  351. ramfc = chan->ramfc->gpuobj;
  352. cache = chan->cache->gpuobj;
  353. dev_priv->engine.instmem.prepare_access(dev, true);
  354. nv_wo32(dev, ramfc, 0x00/4, nv_rd32(dev, 0x3330));
  355. nv_wo32(dev, ramfc, 0x04/4, nv_rd32(dev, 0x3334));
  356. nv_wo32(dev, ramfc, 0x08/4, nv_rd32(dev, 0x3240));
  357. nv_wo32(dev, ramfc, 0x0c/4, nv_rd32(dev, 0x3320));
  358. nv_wo32(dev, ramfc, 0x10/4, nv_rd32(dev, 0x3244));
  359. nv_wo32(dev, ramfc, 0x14/4, nv_rd32(dev, 0x3328));
  360. nv_wo32(dev, ramfc, 0x18/4, nv_rd32(dev, 0x3368));
  361. nv_wo32(dev, ramfc, 0x1c/4, nv_rd32(dev, 0x336c));
  362. nv_wo32(dev, ramfc, 0x20/4, nv_rd32(dev, 0x3370));
  363. nv_wo32(dev, ramfc, 0x24/4, nv_rd32(dev, 0x3374));
  364. nv_wo32(dev, ramfc, 0x28/4, nv_rd32(dev, 0x3378));
  365. nv_wo32(dev, ramfc, 0x2c/4, nv_rd32(dev, 0x337c));
  366. nv_wo32(dev, ramfc, 0x30/4, nv_rd32(dev, 0x3228));
  367. nv_wo32(dev, ramfc, 0x34/4, nv_rd32(dev, 0x3364));
  368. nv_wo32(dev, ramfc, 0x38/4, nv_rd32(dev, 0x32a0));
  369. nv_wo32(dev, ramfc, 0x3c/4, nv_rd32(dev, 0x3224));
  370. nv_wo32(dev, ramfc, 0x40/4, nv_rd32(dev, 0x324c));
  371. nv_wo32(dev, ramfc, 0x44/4, nv_rd32(dev, 0x2044));
  372. nv_wo32(dev, ramfc, 0x48/4, nv_rd32(dev, 0x322c));
  373. nv_wo32(dev, ramfc, 0x4c/4, nv_rd32(dev, 0x3234));
  374. nv_wo32(dev, ramfc, 0x50/4, nv_rd32(dev, 0x3340));
  375. nv_wo32(dev, ramfc, 0x54/4, nv_rd32(dev, 0x3344));
  376. nv_wo32(dev, ramfc, 0x58/4, nv_rd32(dev, 0x3280));
  377. nv_wo32(dev, ramfc, 0x5c/4, nv_rd32(dev, 0x3254));
  378. nv_wo32(dev, ramfc, 0x60/4, nv_rd32(dev, 0x3260));
  379. nv_wo32(dev, ramfc, 0x64/4, nv_rd32(dev, 0x3264));
  380. nv_wo32(dev, ramfc, 0x68/4, nv_rd32(dev, 0x3268));
  381. nv_wo32(dev, ramfc, 0x6c/4, nv_rd32(dev, 0x326c));
  382. nv_wo32(dev, ramfc, 0x70/4, nv_rd32(dev, 0x32e4));
  383. nv_wo32(dev, ramfc, 0x74/4, nv_rd32(dev, 0x3248));
  384. nv_wo32(dev, ramfc, 0x78/4, nv_rd32(dev, 0x2088));
  385. nv_wo32(dev, ramfc, 0x7c/4, nv_rd32(dev, 0x2058));
  386. nv_wo32(dev, ramfc, 0x80/4, nv_rd32(dev, 0x2210));
  387. put = (nv_rd32(dev, NV03_PFIFO_CACHE1_PUT) & 0x7ff) >> 2;
  388. get = (nv_rd32(dev, NV03_PFIFO_CACHE1_GET) & 0x7ff) >> 2;
  389. ptr = 0;
  390. while (put != get) {
  391. nv_wo32(dev, cache, ptr++,
  392. nv_rd32(dev, NV40_PFIFO_CACHE1_METHOD(get)));
  393. nv_wo32(dev, cache, ptr++,
  394. nv_rd32(dev, NV40_PFIFO_CACHE1_DATA(get)));
  395. get = (get + 1) & 0x1ff;
  396. }
  397. /* guessing that all the 0x34xx regs aren't on NV50 */
  398. if (!IS_G80) {
  399. nv_wo32(dev, ramfc, 0x84/4, ptr >> 1);
  400. nv_wo32(dev, ramfc, 0x88/4, nv_rd32(dev, 0x340c));
  401. nv_wo32(dev, ramfc, 0x8c/4, nv_rd32(dev, 0x3400));
  402. nv_wo32(dev, ramfc, 0x90/4, nv_rd32(dev, 0x3404));
  403. nv_wo32(dev, ramfc, 0x94/4, nv_rd32(dev, 0x3408));
  404. nv_wo32(dev, ramfc, 0x98/4, nv_rd32(dev, 0x3410));
  405. }
  406. dev_priv->engine.instmem.finish_access(dev);
  407. /*XXX: probably reload ch127 (NULL) state back too */
  408. nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH1, 127);
  409. return 0;
  410. }