nv50_instmem.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. /*
  2. * Copyright (C) 2007 Ben Skeggs.
  3. *
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining
  7. * a copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sublicense, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial
  16. * portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  21. * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  22. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  23. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  24. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. */
  27. #include "drmP.h"
  28. #include "drm.h"
  29. #include "nouveau_drv.h"
  30. struct nv50_instmem_priv {
  31. uint32_t save1700[5]; /* 0x1700->0x1710 */
  32. struct nouveau_gpuobj *pramin_pt;
  33. struct nouveau_gpuobj *pramin_bar;
  34. struct nouveau_gpuobj *fb_bar;
  35. };
  36. #define NV50_INSTMEM_PAGE_SHIFT 12
  37. #define NV50_INSTMEM_PAGE_SIZE (1 << NV50_INSTMEM_PAGE_SHIFT)
  38. #define NV50_INSTMEM_PT_SIZE(a) (((a) >> 12) << 3)
  39. /*NOTE: - Assumes 0x1700 already covers the correct MiB of PRAMIN
  40. */
  41. #define BAR0_WI32(g, o, v) do { \
  42. u32 offset = (g)->vinst + (o); \
  43. nv_wr32(dev, NV_RAMIN + (offset & 0xfffff), (v)); \
  44. } while (0)
  45. int
  46. nv50_instmem_init(struct drm_device *dev)
  47. {
  48. struct drm_nouveau_private *dev_priv = dev->dev_private;
  49. struct nouveau_channel *chan;
  50. uint32_t c_offset, c_size, c_ramfc, c_vmpd, c_base, pt_size;
  51. uint32_t save_nv001700;
  52. uint64_t v;
  53. struct nv50_instmem_priv *priv;
  54. int ret, i;
  55. priv = kzalloc(sizeof(*priv), GFP_KERNEL);
  56. if (!priv)
  57. return -ENOMEM;
  58. dev_priv->engine.instmem.priv = priv;
  59. /* Save state, will restore at takedown. */
  60. for (i = 0x1700; i <= 0x1710; i += 4)
  61. priv->save1700[(i-0x1700)/4] = nv_rd32(dev, i);
  62. /* Reserve the last MiB of VRAM, we should probably try to avoid
  63. * setting up the below tables over the top of the VBIOS image at
  64. * some point.
  65. */
  66. dev_priv->ramin_rsvd_vram = 1 << 20;
  67. c_offset = dev_priv->vram_size - dev_priv->ramin_rsvd_vram;
  68. c_size = 128 << 10;
  69. c_vmpd = ((dev_priv->chipset & 0xf0) == 0x50) ? 0x1400 : 0x200;
  70. c_ramfc = ((dev_priv->chipset & 0xf0) == 0x50) ? 0x0 : 0x20;
  71. c_base = c_vmpd + 0x4000;
  72. pt_size = NV50_INSTMEM_PT_SIZE(dev_priv->ramin_size);
  73. NV_DEBUG(dev, " Rsvd VRAM base: 0x%08x\n", c_offset);
  74. NV_DEBUG(dev, " VBIOS image: 0x%08x\n",
  75. (nv_rd32(dev, 0x619f04) & ~0xff) << 8);
  76. NV_DEBUG(dev, " Aperture size: %d MiB\n", dev_priv->ramin_size >> 20);
  77. NV_DEBUG(dev, " PT size: %d KiB\n", pt_size >> 10);
  78. /* Determine VM layout, we need to do this first to make sure
  79. * we allocate enough memory for all the page tables.
  80. */
  81. dev_priv->vm_gart_base = roundup(NV50_VM_BLOCK, NV50_VM_BLOCK);
  82. dev_priv->vm_gart_size = NV50_VM_BLOCK;
  83. dev_priv->vm_vram_base = dev_priv->vm_gart_base + dev_priv->vm_gart_size;
  84. dev_priv->vm_vram_size = dev_priv->vram_size;
  85. if (dev_priv->vm_vram_size > NV50_VM_MAX_VRAM)
  86. dev_priv->vm_vram_size = NV50_VM_MAX_VRAM;
  87. dev_priv->vm_vram_size = roundup(dev_priv->vm_vram_size, NV50_VM_BLOCK);
  88. dev_priv->vm_vram_pt_nr = dev_priv->vm_vram_size / NV50_VM_BLOCK;
  89. dev_priv->vm_end = dev_priv->vm_vram_base + dev_priv->vm_vram_size;
  90. NV_DEBUG(dev, "NV50VM: GART 0x%016llx-0x%016llx\n",
  91. dev_priv->vm_gart_base,
  92. dev_priv->vm_gart_base + dev_priv->vm_gart_size - 1);
  93. NV_DEBUG(dev, "NV50VM: VRAM 0x%016llx-0x%016llx\n",
  94. dev_priv->vm_vram_base,
  95. dev_priv->vm_vram_base + dev_priv->vm_vram_size - 1);
  96. c_size += dev_priv->vm_vram_pt_nr * (NV50_VM_BLOCK / 65536 * 8);
  97. /* Map BAR0 PRAMIN aperture over the memory we want to use */
  98. save_nv001700 = nv_rd32(dev, NV50_PUNK_BAR0_PRAMIN);
  99. nv_wr32(dev, NV50_PUNK_BAR0_PRAMIN, (c_offset >> 16));
  100. /* Create a fake channel, and use it as our "dummy" channels 0/127.
  101. * The main reason for creating a channel is so we can use the gpuobj
  102. * code. However, it's probably worth noting that NVIDIA also setup
  103. * their channels 0/127 with the same values they configure here.
  104. * So, there may be some other reason for doing this.
  105. *
  106. * Have to create the entire channel manually, as the real channel
  107. * creation code assumes we have PRAMIN access, and we don't until
  108. * we're done here.
  109. */
  110. chan = kzalloc(sizeof(*chan), GFP_KERNEL);
  111. if (!chan)
  112. return -ENOMEM;
  113. chan->id = 0;
  114. chan->dev = dev;
  115. chan->file_priv = (struct drm_file *)-2;
  116. dev_priv->fifos[0] = dev_priv->fifos[127] = chan;
  117. INIT_LIST_HEAD(&chan->ramht_refs);
  118. /* Channel's PRAMIN object + heap */
  119. ret = nouveau_gpuobj_new_fake(dev, 0, c_offset, c_size, 0, &chan->ramin);
  120. if (ret)
  121. return ret;
  122. if (drm_mm_init(&chan->ramin_heap, c_base, c_size - c_base))
  123. return -ENOMEM;
  124. /* RAMFC + zero channel's PRAMIN up to start of VM pagedir */
  125. ret = nouveau_gpuobj_new_fake(dev, c_ramfc, c_offset + c_ramfc,
  126. 0x4000, 0, &chan->ramfc);
  127. if (ret)
  128. return ret;
  129. for (i = 0; i < c_vmpd; i += 4)
  130. BAR0_WI32(chan->ramin, i, 0);
  131. /* VM page directory */
  132. ret = nouveau_gpuobj_new_fake(dev, c_vmpd, c_offset + c_vmpd,
  133. 0x4000, 0, &chan->vm_pd);
  134. if (ret)
  135. return ret;
  136. for (i = 0; i < 0x4000; i += 8) {
  137. BAR0_WI32(chan->vm_pd, i + 0x00, 0x00000000);
  138. BAR0_WI32(chan->vm_pd, i + 0x04, 0x00000000);
  139. }
  140. /* PRAMIN page table, cheat and map into VM at 0x0000000000.
  141. * We map the entire fake channel into the start of the PRAMIN BAR
  142. */
  143. ret = nouveau_gpuobj_new(dev, chan, pt_size, 0x1000, 0,
  144. &priv->pramin_pt);
  145. if (ret)
  146. return ret;
  147. v = c_offset | 1;
  148. if (dev_priv->vram_sys_base) {
  149. v += dev_priv->vram_sys_base;
  150. v |= 0x30;
  151. }
  152. i = 0;
  153. while (v < dev_priv->vram_sys_base + c_offset + c_size) {
  154. BAR0_WI32(priv->pramin_pt, i + 0, lower_32_bits(v));
  155. BAR0_WI32(priv->pramin_pt, i + 4, upper_32_bits(v));
  156. v += 0x1000;
  157. i += 8;
  158. }
  159. while (i < pt_size) {
  160. BAR0_WI32(priv->pramin_pt, i + 0, 0x00000000);
  161. BAR0_WI32(priv->pramin_pt, i + 4, 0x00000000);
  162. i += 8;
  163. }
  164. BAR0_WI32(chan->vm_pd, 0x00, priv->pramin_pt->vinst | 0x63);
  165. BAR0_WI32(chan->vm_pd, 0x04, 0x00000000);
  166. /* VRAM page table(s), mapped into VM at +1GiB */
  167. for (i = 0; i < dev_priv->vm_vram_pt_nr; i++) {
  168. ret = nouveau_gpuobj_new(dev, chan, NV50_VM_BLOCK / 0x10000 * 8,
  169. 0, 0, &chan->vm_vram_pt[i]);
  170. if (ret) {
  171. NV_ERROR(dev, "Error creating VRAM page tables: %d\n",
  172. ret);
  173. dev_priv->vm_vram_pt_nr = i;
  174. return ret;
  175. }
  176. /*XXX: double-check this is ok */
  177. dev_priv->vm_vram_pt[i] = chan->vm_vram_pt[i];
  178. for (v = 0; v < dev_priv->vm_vram_pt[i]->im_pramin->size;
  179. v += 4)
  180. BAR0_WI32(dev_priv->vm_vram_pt[i], v, 0);
  181. BAR0_WI32(chan->vm_pd, 0x10 + (i*8),
  182. chan->vm_vram_pt[i]->vinst | 0x61);
  183. BAR0_WI32(chan->vm_pd, 0x14 + (i*8), 0);
  184. }
  185. /* DMA object for PRAMIN BAR */
  186. ret = nouveau_gpuobj_new(dev, chan, 6*4, 16, 0, &priv->pramin_bar);
  187. if (ret)
  188. return ret;
  189. BAR0_WI32(priv->pramin_bar, 0x00, 0x7fc00000);
  190. BAR0_WI32(priv->pramin_bar, 0x04, dev_priv->ramin_size - 1);
  191. BAR0_WI32(priv->pramin_bar, 0x08, 0x00000000);
  192. BAR0_WI32(priv->pramin_bar, 0x0c, 0x00000000);
  193. BAR0_WI32(priv->pramin_bar, 0x10, 0x00000000);
  194. BAR0_WI32(priv->pramin_bar, 0x14, 0x00000000);
  195. /* DMA object for FB BAR */
  196. ret = nouveau_gpuobj_new(dev, chan, 6*4, 16, 0, &priv->fb_bar);
  197. if (ret)
  198. return ret;
  199. BAR0_WI32(priv->fb_bar, 0x00, 0x7fc00000);
  200. BAR0_WI32(priv->fb_bar, 0x04, 0x40000000 +
  201. pci_resource_len(dev->pdev, 1) - 1);
  202. BAR0_WI32(priv->fb_bar, 0x08, 0x40000000);
  203. BAR0_WI32(priv->fb_bar, 0x0c, 0x00000000);
  204. BAR0_WI32(priv->fb_bar, 0x10, 0x00000000);
  205. BAR0_WI32(priv->fb_bar, 0x14, 0x00000000);
  206. /* Poke the relevant regs, and pray it works :) */
  207. nv_wr32(dev, NV50_PUNK_BAR_CFG_BASE, (chan->ramin->vinst >> 12));
  208. nv_wr32(dev, NV50_PUNK_UNK1710, 0);
  209. nv_wr32(dev, NV50_PUNK_BAR_CFG_BASE, (chan->ramin->vinst >> 12) |
  210. NV50_PUNK_BAR_CFG_BASE_VALID);
  211. nv_wr32(dev, NV50_PUNK_BAR1_CTXDMA, (priv->fb_bar->cinst >> 4) |
  212. NV50_PUNK_BAR1_CTXDMA_VALID);
  213. nv_wr32(dev, NV50_PUNK_BAR3_CTXDMA, (priv->pramin_bar->cinst >> 4) |
  214. NV50_PUNK_BAR3_CTXDMA_VALID);
  215. for (i = 0; i < 8; i++)
  216. nv_wr32(dev, 0x1900 + (i*4), 0);
  217. /* Assume that praying isn't enough, check that we can re-read the
  218. * entire fake channel back from the PRAMIN BAR */
  219. for (i = 0; i < c_size; i += 4) {
  220. if (nv_rd32(dev, NV_RAMIN + i) != nv_ri32(dev, i)) {
  221. NV_ERROR(dev, "Error reading back PRAMIN at 0x%08x\n",
  222. i);
  223. return -EINVAL;
  224. }
  225. }
  226. nv_wr32(dev, NV50_PUNK_BAR0_PRAMIN, save_nv001700);
  227. /* Global PRAMIN heap */
  228. if (drm_mm_init(&dev_priv->ramin_heap, c_size, dev_priv->ramin_size - c_size)) {
  229. NV_ERROR(dev, "Failed to init RAMIN heap\n");
  230. }
  231. /*XXX: incorrect, but needed to make hash func "work" */
  232. dev_priv->ramht_offset = 0x10000;
  233. dev_priv->ramht_bits = 9;
  234. dev_priv->ramht_size = (1 << dev_priv->ramht_bits) * 8;
  235. return 0;
  236. }
  237. void
  238. nv50_instmem_takedown(struct drm_device *dev)
  239. {
  240. struct drm_nouveau_private *dev_priv = dev->dev_private;
  241. struct nv50_instmem_priv *priv = dev_priv->engine.instmem.priv;
  242. struct nouveau_channel *chan = dev_priv->fifos[0];
  243. int i;
  244. NV_DEBUG(dev, "\n");
  245. if (!priv)
  246. return;
  247. /* Restore state from before init */
  248. for (i = 0x1700; i <= 0x1710; i += 4)
  249. nv_wr32(dev, i, priv->save1700[(i - 0x1700) / 4]);
  250. nouveau_gpuobj_ref(NULL, &priv->fb_bar);
  251. nouveau_gpuobj_ref(NULL, &priv->pramin_bar);
  252. nouveau_gpuobj_ref(NULL, &priv->pramin_pt);
  253. /* Destroy dummy channel */
  254. if (chan) {
  255. for (i = 0; i < dev_priv->vm_vram_pt_nr; i++)
  256. nouveau_gpuobj_ref(NULL, &chan->vm_vram_pt[i]);
  257. dev_priv->vm_vram_pt_nr = 0;
  258. nouveau_gpuobj_ref(NULL, &chan->vm_pd);
  259. nouveau_gpuobj_ref(NULL, &chan->ramfc);
  260. nouveau_gpuobj_ref(NULL, &chan->ramin);
  261. drm_mm_takedown(&chan->ramin_heap);
  262. dev_priv->fifos[0] = dev_priv->fifos[127] = NULL;
  263. kfree(chan);
  264. }
  265. dev_priv->engine.instmem.priv = NULL;
  266. kfree(priv);
  267. }
  268. int
  269. nv50_instmem_suspend(struct drm_device *dev)
  270. {
  271. struct drm_nouveau_private *dev_priv = dev->dev_private;
  272. struct nouveau_channel *chan = dev_priv->fifos[0];
  273. struct nouveau_gpuobj *ramin = chan->ramin;
  274. int i;
  275. ramin->im_backing_suspend = vmalloc(ramin->im_pramin->size);
  276. if (!ramin->im_backing_suspend)
  277. return -ENOMEM;
  278. for (i = 0; i < ramin->im_pramin->size; i += 4)
  279. ramin->im_backing_suspend[i/4] = nv_ri32(dev, i);
  280. return 0;
  281. }
  282. void
  283. nv50_instmem_resume(struct drm_device *dev)
  284. {
  285. struct drm_nouveau_private *dev_priv = dev->dev_private;
  286. struct nv50_instmem_priv *priv = dev_priv->engine.instmem.priv;
  287. struct nouveau_channel *chan = dev_priv->fifos[0];
  288. struct nouveau_gpuobj *ramin = chan->ramin;
  289. int i;
  290. nv_wr32(dev, NV50_PUNK_BAR0_PRAMIN, (ramin->im_backing_start >> 16));
  291. for (i = 0; i < ramin->im_pramin->size; i += 4)
  292. BAR0_WI32(ramin, i, ramin->im_backing_suspend[i/4]);
  293. vfree(ramin->im_backing_suspend);
  294. ramin->im_backing_suspend = NULL;
  295. /* Poke the relevant regs, and pray it works :) */
  296. nv_wr32(dev, NV50_PUNK_BAR_CFG_BASE, (chan->ramin->vinst >> 12));
  297. nv_wr32(dev, NV50_PUNK_UNK1710, 0);
  298. nv_wr32(dev, NV50_PUNK_BAR_CFG_BASE, (chan->ramin->vinst >> 12) |
  299. NV50_PUNK_BAR_CFG_BASE_VALID);
  300. nv_wr32(dev, NV50_PUNK_BAR1_CTXDMA, (priv->fb_bar->cinst >> 4) |
  301. NV50_PUNK_BAR1_CTXDMA_VALID);
  302. nv_wr32(dev, NV50_PUNK_BAR3_CTXDMA, (priv->pramin_bar->cinst >> 4) |
  303. NV50_PUNK_BAR3_CTXDMA_VALID);
  304. for (i = 0; i < 8; i++)
  305. nv_wr32(dev, 0x1900 + (i*4), 0);
  306. }
  307. int
  308. nv50_instmem_populate(struct drm_device *dev, struct nouveau_gpuobj *gpuobj,
  309. uint32_t *sz)
  310. {
  311. int ret;
  312. if (gpuobj->im_backing)
  313. return -EINVAL;
  314. *sz = ALIGN(*sz, NV50_INSTMEM_PAGE_SIZE);
  315. if (*sz == 0)
  316. return -EINVAL;
  317. ret = nouveau_bo_new(dev, NULL, *sz, 0, TTM_PL_FLAG_VRAM, 0, 0x0000,
  318. true, false, &gpuobj->im_backing);
  319. if (ret) {
  320. NV_ERROR(dev, "error getting PRAMIN backing pages: %d\n", ret);
  321. return ret;
  322. }
  323. ret = nouveau_bo_pin(gpuobj->im_backing, TTM_PL_FLAG_VRAM);
  324. if (ret) {
  325. NV_ERROR(dev, "error pinning PRAMIN backing VRAM: %d\n", ret);
  326. nouveau_bo_ref(NULL, &gpuobj->im_backing);
  327. return ret;
  328. }
  329. gpuobj->im_backing_start = gpuobj->im_backing->bo.mem.mm_node->start;
  330. gpuobj->im_backing_start <<= PAGE_SHIFT;
  331. return 0;
  332. }
  333. void
  334. nv50_instmem_clear(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
  335. {
  336. struct drm_nouveau_private *dev_priv = dev->dev_private;
  337. if (gpuobj && gpuobj->im_backing) {
  338. if (gpuobj->im_bound)
  339. dev_priv->engine.instmem.unbind(dev, gpuobj);
  340. nouveau_bo_unpin(gpuobj->im_backing);
  341. nouveau_bo_ref(NULL, &gpuobj->im_backing);
  342. gpuobj->im_backing = NULL;
  343. }
  344. }
  345. int
  346. nv50_instmem_bind(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
  347. {
  348. struct drm_nouveau_private *dev_priv = dev->dev_private;
  349. struct nv50_instmem_priv *priv = dev_priv->engine.instmem.priv;
  350. struct nouveau_gpuobj *pramin_pt = priv->pramin_pt;
  351. uint32_t pte, pte_end;
  352. uint64_t vram;
  353. if (!gpuobj->im_backing || !gpuobj->im_pramin || gpuobj->im_bound)
  354. return -EINVAL;
  355. NV_DEBUG(dev, "st=0x%lx sz=0x%lx\n",
  356. gpuobj->im_pramin->start, gpuobj->im_pramin->size);
  357. pte = (gpuobj->im_pramin->start >> 12) << 1;
  358. pte_end = ((gpuobj->im_pramin->size >> 12) << 1) + pte;
  359. vram = gpuobj->im_backing_start;
  360. NV_DEBUG(dev, "pramin=0x%lx, pte=%d, pte_end=%d\n",
  361. gpuobj->im_pramin->start, pte, pte_end);
  362. NV_DEBUG(dev, "first vram page: 0x%08x\n", gpuobj->im_backing_start);
  363. vram |= 1;
  364. if (dev_priv->vram_sys_base) {
  365. vram += dev_priv->vram_sys_base;
  366. vram |= 0x30;
  367. }
  368. while (pte < pte_end) {
  369. nv_wo32(pramin_pt, (pte * 4) + 0, lower_32_bits(vram));
  370. nv_wo32(pramin_pt, (pte * 4) + 4, upper_32_bits(vram));
  371. vram += NV50_INSTMEM_PAGE_SIZE;
  372. pte += 2;
  373. }
  374. dev_priv->engine.instmem.flush(dev);
  375. nv50_vm_flush(dev, 4);
  376. nv50_vm_flush(dev, 6);
  377. gpuobj->im_bound = 1;
  378. return 0;
  379. }
  380. int
  381. nv50_instmem_unbind(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
  382. {
  383. struct drm_nouveau_private *dev_priv = dev->dev_private;
  384. struct nv50_instmem_priv *priv = dev_priv->engine.instmem.priv;
  385. uint32_t pte, pte_end;
  386. if (gpuobj->im_bound == 0)
  387. return -EINVAL;
  388. pte = (gpuobj->im_pramin->start >> 12) << 1;
  389. pte_end = ((gpuobj->im_pramin->size >> 12) << 1) + pte;
  390. while (pte < pte_end) {
  391. nv_wo32(priv->pramin_pt, (pte * 4) + 0, 0x00000000);
  392. nv_wo32(priv->pramin_pt, (pte * 4) + 4, 0x00000000);
  393. pte += 2;
  394. }
  395. dev_priv->engine.instmem.flush(dev);
  396. gpuobj->im_bound = 0;
  397. return 0;
  398. }
  399. void
  400. nv50_instmem_flush(struct drm_device *dev)
  401. {
  402. nv_wr32(dev, 0x00330c, 0x00000001);
  403. if (!nv_wait(0x00330c, 0x00000002, 0x00000000))
  404. NV_ERROR(dev, "PRAMIN flush timeout\n");
  405. }
  406. void
  407. nv84_instmem_flush(struct drm_device *dev)
  408. {
  409. nv_wr32(dev, 0x070000, 0x00000001);
  410. if (!nv_wait(0x070000, 0x00000002, 0x00000000))
  411. NV_ERROR(dev, "PRAMIN flush timeout\n");
  412. }
  413. void
  414. nv50_vm_flush(struct drm_device *dev, int engine)
  415. {
  416. nv_wr32(dev, 0x100c80, (engine << 16) | 1);
  417. if (!nv_wait(0x100c80, 0x00000001, 0x00000000))
  418. NV_ERROR(dev, "vm flush timeout: engine %d\n", engine);
  419. }