nv50_instmem.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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]->size; v += 4)
  179. BAR0_WI32(dev_priv->vm_vram_pt[i], v, 0);
  180. BAR0_WI32(chan->vm_pd, 0x10 + (i*8),
  181. chan->vm_vram_pt[i]->vinst | 0x61);
  182. BAR0_WI32(chan->vm_pd, 0x14 + (i*8), 0);
  183. }
  184. /* DMA object for PRAMIN BAR */
  185. ret = nouveau_gpuobj_new(dev, chan, 6*4, 16, 0, &priv->pramin_bar);
  186. if (ret)
  187. return ret;
  188. BAR0_WI32(priv->pramin_bar, 0x00, 0x7fc00000);
  189. BAR0_WI32(priv->pramin_bar, 0x04, dev_priv->ramin_size - 1);
  190. BAR0_WI32(priv->pramin_bar, 0x08, 0x00000000);
  191. BAR0_WI32(priv->pramin_bar, 0x0c, 0x00000000);
  192. BAR0_WI32(priv->pramin_bar, 0x10, 0x00000000);
  193. BAR0_WI32(priv->pramin_bar, 0x14, 0x00000000);
  194. /* DMA object for FB BAR */
  195. ret = nouveau_gpuobj_new(dev, chan, 6*4, 16, 0, &priv->fb_bar);
  196. if (ret)
  197. return ret;
  198. BAR0_WI32(priv->fb_bar, 0x00, 0x7fc00000);
  199. BAR0_WI32(priv->fb_bar, 0x04, 0x40000000 +
  200. pci_resource_len(dev->pdev, 1) - 1);
  201. BAR0_WI32(priv->fb_bar, 0x08, 0x40000000);
  202. BAR0_WI32(priv->fb_bar, 0x0c, 0x00000000);
  203. BAR0_WI32(priv->fb_bar, 0x10, 0x00000000);
  204. BAR0_WI32(priv->fb_bar, 0x14, 0x00000000);
  205. /* Poke the relevant regs, and pray it works :) */
  206. nv_wr32(dev, NV50_PUNK_BAR_CFG_BASE, (chan->ramin->vinst >> 12));
  207. nv_wr32(dev, NV50_PUNK_UNK1710, 0);
  208. nv_wr32(dev, NV50_PUNK_BAR_CFG_BASE, (chan->ramin->vinst >> 12) |
  209. NV50_PUNK_BAR_CFG_BASE_VALID);
  210. nv_wr32(dev, NV50_PUNK_BAR1_CTXDMA, (priv->fb_bar->cinst >> 4) |
  211. NV50_PUNK_BAR1_CTXDMA_VALID);
  212. nv_wr32(dev, NV50_PUNK_BAR3_CTXDMA, (priv->pramin_bar->cinst >> 4) |
  213. NV50_PUNK_BAR3_CTXDMA_VALID);
  214. for (i = 0; i < 8; i++)
  215. nv_wr32(dev, 0x1900 + (i*4), 0);
  216. /* Assume that praying isn't enough, check that we can re-read the
  217. * entire fake channel back from the PRAMIN BAR */
  218. for (i = 0; i < c_size; i += 4) {
  219. if (nv_rd32(dev, NV_RAMIN + i) != nv_ri32(dev, i)) {
  220. NV_ERROR(dev, "Error reading back PRAMIN at 0x%08x\n",
  221. i);
  222. return -EINVAL;
  223. }
  224. }
  225. nv_wr32(dev, NV50_PUNK_BAR0_PRAMIN, save_nv001700);
  226. /* Global PRAMIN heap */
  227. if (drm_mm_init(&dev_priv->ramin_heap, c_size, dev_priv->ramin_size - c_size)) {
  228. NV_ERROR(dev, "Failed to init RAMIN heap\n");
  229. }
  230. /*XXX: incorrect, but needed to make hash func "work" */
  231. dev_priv->ramht_offset = 0x10000;
  232. dev_priv->ramht_bits = 9;
  233. dev_priv->ramht_size = (1 << dev_priv->ramht_bits) * 8;
  234. return 0;
  235. }
  236. void
  237. nv50_instmem_takedown(struct drm_device *dev)
  238. {
  239. struct drm_nouveau_private *dev_priv = dev->dev_private;
  240. struct nv50_instmem_priv *priv = dev_priv->engine.instmem.priv;
  241. struct nouveau_channel *chan = dev_priv->fifos[0];
  242. int i;
  243. NV_DEBUG(dev, "\n");
  244. if (!priv)
  245. return;
  246. /* Restore state from before init */
  247. for (i = 0x1700; i <= 0x1710; i += 4)
  248. nv_wr32(dev, i, priv->save1700[(i - 0x1700) / 4]);
  249. nouveau_gpuobj_ref(NULL, &priv->fb_bar);
  250. nouveau_gpuobj_ref(NULL, &priv->pramin_bar);
  251. nouveau_gpuobj_ref(NULL, &priv->pramin_pt);
  252. /* Destroy dummy channel */
  253. if (chan) {
  254. for (i = 0; i < dev_priv->vm_vram_pt_nr; i++)
  255. nouveau_gpuobj_ref(NULL, &chan->vm_vram_pt[i]);
  256. dev_priv->vm_vram_pt_nr = 0;
  257. nouveau_gpuobj_ref(NULL, &chan->vm_pd);
  258. nouveau_gpuobj_ref(NULL, &chan->ramfc);
  259. nouveau_gpuobj_ref(NULL, &chan->ramin);
  260. drm_mm_takedown(&chan->ramin_heap);
  261. dev_priv->fifos[0] = dev_priv->fifos[127] = NULL;
  262. kfree(chan);
  263. }
  264. dev_priv->engine.instmem.priv = NULL;
  265. kfree(priv);
  266. }
  267. int
  268. nv50_instmem_suspend(struct drm_device *dev)
  269. {
  270. struct drm_nouveau_private *dev_priv = dev->dev_private;
  271. struct nouveau_channel *chan = dev_priv->fifos[0];
  272. struct nouveau_gpuobj *ramin = chan->ramin;
  273. int i;
  274. ramin->im_backing_suspend = vmalloc(ramin->size);
  275. if (!ramin->im_backing_suspend)
  276. return -ENOMEM;
  277. for (i = 0; i < ramin->size; i += 4)
  278. ramin->im_backing_suspend[i/4] = nv_ri32(dev, i);
  279. return 0;
  280. }
  281. void
  282. nv50_instmem_resume(struct drm_device *dev)
  283. {
  284. struct drm_nouveau_private *dev_priv = dev->dev_private;
  285. struct nv50_instmem_priv *priv = dev_priv->engine.instmem.priv;
  286. struct nouveau_channel *chan = dev_priv->fifos[0];
  287. struct nouveau_gpuobj *ramin = chan->ramin;
  288. int i;
  289. nv_wr32(dev, NV50_PUNK_BAR0_PRAMIN, (ramin->vinst >> 16));
  290. for (i = 0; i < ramin->size; i += 4)
  291. BAR0_WI32(ramin, i, ramin->im_backing_suspend[i/4]);
  292. vfree(ramin->im_backing_suspend);
  293. ramin->im_backing_suspend = NULL;
  294. /* Poke the relevant regs, and pray it works :) */
  295. nv_wr32(dev, NV50_PUNK_BAR_CFG_BASE, (chan->ramin->vinst >> 12));
  296. nv_wr32(dev, NV50_PUNK_UNK1710, 0);
  297. nv_wr32(dev, NV50_PUNK_BAR_CFG_BASE, (chan->ramin->vinst >> 12) |
  298. NV50_PUNK_BAR_CFG_BASE_VALID);
  299. nv_wr32(dev, NV50_PUNK_BAR1_CTXDMA, (priv->fb_bar->cinst >> 4) |
  300. NV50_PUNK_BAR1_CTXDMA_VALID);
  301. nv_wr32(dev, NV50_PUNK_BAR3_CTXDMA, (priv->pramin_bar->cinst >> 4) |
  302. NV50_PUNK_BAR3_CTXDMA_VALID);
  303. for (i = 0; i < 8; i++)
  304. nv_wr32(dev, 0x1900 + (i*4), 0);
  305. }
  306. int
  307. nv50_instmem_populate(struct drm_device *dev, struct nouveau_gpuobj *gpuobj,
  308. uint32_t *sz)
  309. {
  310. int ret;
  311. if (gpuobj->im_backing)
  312. return -EINVAL;
  313. *sz = ALIGN(*sz, NV50_INSTMEM_PAGE_SIZE);
  314. if (*sz == 0)
  315. return -EINVAL;
  316. ret = nouveau_bo_new(dev, NULL, *sz, 0, TTM_PL_FLAG_VRAM, 0, 0x0000,
  317. true, false, &gpuobj->im_backing);
  318. if (ret) {
  319. NV_ERROR(dev, "error getting PRAMIN backing pages: %d\n", ret);
  320. return ret;
  321. }
  322. ret = nouveau_bo_pin(gpuobj->im_backing, TTM_PL_FLAG_VRAM);
  323. if (ret) {
  324. NV_ERROR(dev, "error pinning PRAMIN backing VRAM: %d\n", ret);
  325. nouveau_bo_ref(NULL, &gpuobj->im_backing);
  326. return ret;
  327. }
  328. gpuobj->vinst = gpuobj->im_backing->bo.mem.mm_node->start << PAGE_SHIFT;
  329. return 0;
  330. }
  331. void
  332. nv50_instmem_clear(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
  333. {
  334. struct drm_nouveau_private *dev_priv = dev->dev_private;
  335. if (gpuobj && gpuobj->im_backing) {
  336. if (gpuobj->im_bound)
  337. dev_priv->engine.instmem.unbind(dev, gpuobj);
  338. nouveau_bo_unpin(gpuobj->im_backing);
  339. nouveau_bo_ref(NULL, &gpuobj->im_backing);
  340. gpuobj->im_backing = NULL;
  341. }
  342. }
  343. int
  344. nv50_instmem_bind(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
  345. {
  346. struct drm_nouveau_private *dev_priv = dev->dev_private;
  347. struct nv50_instmem_priv *priv = dev_priv->engine.instmem.priv;
  348. struct nouveau_gpuobj *pramin_pt = priv->pramin_pt;
  349. uint32_t pte, pte_end;
  350. uint64_t vram;
  351. if (!gpuobj->im_backing || !gpuobj->im_pramin || gpuobj->im_bound)
  352. return -EINVAL;
  353. NV_DEBUG(dev, "st=0x%lx sz=0x%lx\n",
  354. gpuobj->im_pramin->start, gpuobj->im_pramin->size);
  355. pte = (gpuobj->im_pramin->start >> 12) << 1;
  356. pte_end = ((gpuobj->im_pramin->size >> 12) << 1) + pte;
  357. vram = gpuobj->vinst;
  358. NV_DEBUG(dev, "pramin=0x%lx, pte=%d, pte_end=%d\n",
  359. gpuobj->im_pramin->start, pte, pte_end);
  360. NV_DEBUG(dev, "first vram page: 0x%010llx\n", gpuobj->vinst);
  361. vram |= 1;
  362. if (dev_priv->vram_sys_base) {
  363. vram += dev_priv->vram_sys_base;
  364. vram |= 0x30;
  365. }
  366. while (pte < pte_end) {
  367. nv_wo32(pramin_pt, (pte * 4) + 0, lower_32_bits(vram));
  368. nv_wo32(pramin_pt, (pte * 4) + 4, upper_32_bits(vram));
  369. vram += NV50_INSTMEM_PAGE_SIZE;
  370. pte += 2;
  371. }
  372. dev_priv->engine.instmem.flush(dev);
  373. nv50_vm_flush(dev, 4);
  374. nv50_vm_flush(dev, 6);
  375. gpuobj->im_bound = 1;
  376. return 0;
  377. }
  378. int
  379. nv50_instmem_unbind(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
  380. {
  381. struct drm_nouveau_private *dev_priv = dev->dev_private;
  382. struct nv50_instmem_priv *priv = dev_priv->engine.instmem.priv;
  383. uint32_t pte, pte_end;
  384. if (gpuobj->im_bound == 0)
  385. return -EINVAL;
  386. pte = (gpuobj->im_pramin->start >> 12) << 1;
  387. pte_end = ((gpuobj->im_pramin->size >> 12) << 1) + pte;
  388. while (pte < pte_end) {
  389. nv_wo32(priv->pramin_pt, (pte * 4) + 0, 0x00000000);
  390. nv_wo32(priv->pramin_pt, (pte * 4) + 4, 0x00000000);
  391. pte += 2;
  392. }
  393. dev_priv->engine.instmem.flush(dev);
  394. gpuobj->im_bound = 0;
  395. return 0;
  396. }
  397. void
  398. nv50_instmem_flush(struct drm_device *dev)
  399. {
  400. nv_wr32(dev, 0x00330c, 0x00000001);
  401. if (!nv_wait(0x00330c, 0x00000002, 0x00000000))
  402. NV_ERROR(dev, "PRAMIN flush timeout\n");
  403. }
  404. void
  405. nv84_instmem_flush(struct drm_device *dev)
  406. {
  407. nv_wr32(dev, 0x070000, 0x00000001);
  408. if (!nv_wait(0x070000, 0x00000002, 0x00000000))
  409. NV_ERROR(dev, "PRAMIN flush timeout\n");
  410. }
  411. void
  412. nv50_vm_flush(struct drm_device *dev, int engine)
  413. {
  414. nv_wr32(dev, 0x100c80, (engine << 16) | 1);
  415. if (!nv_wait(0x100c80, 0x00000001, 0x00000000))
  416. NV_ERROR(dev, "vm flush timeout: engine %d\n", engine);
  417. }