nv50_fifo.c 14 KB

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