aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nv50_instmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/nouveau/nv50_instmem.c')
-rw-r--r--drivers/gpu/drm/nouveau/nv50_instmem.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/drivers/gpu/drm/nouveau/nv50_instmem.c b/drivers/gpu/drm/nouveau/nv50_instmem.c
index a361d1612bd7..d9feee3b9f58 100644
--- a/drivers/gpu/drm/nouveau/nv50_instmem.c
+++ b/drivers/gpu/drm/nouveau/nv50_instmem.c
@@ -35,8 +35,6 @@ struct nv50_instmem_priv {
35 struct nouveau_gpuobj_ref *pramin_pt; 35 struct nouveau_gpuobj_ref *pramin_pt;
36 struct nouveau_gpuobj_ref *pramin_bar; 36 struct nouveau_gpuobj_ref *pramin_bar;
37 struct nouveau_gpuobj_ref *fb_bar; 37 struct nouveau_gpuobj_ref *fb_bar;
38
39 bool last_access_wr;
40}; 38};
41 39
42#define NV50_INSTMEM_PAGE_SHIFT 12 40#define NV50_INSTMEM_PAGE_SHIFT 12
@@ -262,16 +260,13 @@ nv50_instmem_init(struct drm_device *dev)
262 260
263 /* Assume that praying isn't enough, check that we can re-read the 261 /* Assume that praying isn't enough, check that we can re-read the
264 * entire fake channel back from the PRAMIN BAR */ 262 * entire fake channel back from the PRAMIN BAR */
265 dev_priv->engine.instmem.prepare_access(dev, false);
266 for (i = 0; i < c_size; i += 4) { 263 for (i = 0; i < c_size; i += 4) {
267 if (nv_rd32(dev, NV_RAMIN + i) != nv_ri32(dev, i)) { 264 if (nv_rd32(dev, NV_RAMIN + i) != nv_ri32(dev, i)) {
268 NV_ERROR(dev, "Error reading back PRAMIN at 0x%08x\n", 265 NV_ERROR(dev, "Error reading back PRAMIN at 0x%08x\n",
269 i); 266 i);
270 dev_priv->engine.instmem.finish_access(dev);
271 return -EINVAL; 267 return -EINVAL;
272 } 268 }
273 } 269 }
274 dev_priv->engine.instmem.finish_access(dev);
275 270
276 nv_wr32(dev, NV50_PUNK_BAR0_PRAMIN, save_nv001700); 271 nv_wr32(dev, NV50_PUNK_BAR0_PRAMIN, save_nv001700);
277 272
@@ -451,13 +446,12 @@ nv50_instmem_bind(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
451 vram |= 0x30; 446 vram |= 0x30;
452 } 447 }
453 448
454 dev_priv->engine.instmem.prepare_access(dev, true);
455 while (pte < pte_end) { 449 while (pte < pte_end) {
456 nv_wo32(dev, pramin_pt, pte++, lower_32_bits(vram)); 450 nv_wo32(dev, pramin_pt, pte++, lower_32_bits(vram));
457 nv_wo32(dev, pramin_pt, pte++, upper_32_bits(vram)); 451 nv_wo32(dev, pramin_pt, pte++, upper_32_bits(vram));
458 vram += NV50_INSTMEM_PAGE_SIZE; 452 vram += NV50_INSTMEM_PAGE_SIZE;
459 } 453 }
460 dev_priv->engine.instmem.finish_access(dev); 454 dev_priv->engine.instmem.flush(dev);
461 455
462 nv_wr32(dev, 0x100c80, 0x00040001); 456 nv_wr32(dev, 0x100c80, 0x00040001);
463 if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) { 457 if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
@@ -490,36 +484,21 @@ nv50_instmem_unbind(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
490 pte = (gpuobj->im_pramin->start >> 12) << 1; 484 pte = (gpuobj->im_pramin->start >> 12) << 1;
491 pte_end = ((gpuobj->im_pramin->size >> 12) << 1) + pte; 485 pte_end = ((gpuobj->im_pramin->size >> 12) << 1) + pte;
492 486
493 dev_priv->engine.instmem.prepare_access(dev, true);
494 while (pte < pte_end) { 487 while (pte < pte_end) {
495 nv_wo32(dev, priv->pramin_pt->gpuobj, pte++, 0x00000000); 488 nv_wo32(dev, priv->pramin_pt->gpuobj, pte++, 0x00000000);
496 nv_wo32(dev, priv->pramin_pt->gpuobj, pte++, 0x00000000); 489 nv_wo32(dev, priv->pramin_pt->gpuobj, pte++, 0x00000000);
497 } 490 }
498 dev_priv->engine.instmem.finish_access(dev); 491 dev_priv->engine.instmem.flush(dev);
499 492
500 gpuobj->im_bound = 0; 493 gpuobj->im_bound = 0;
501 return 0; 494 return 0;
502} 495}
503 496
504void 497void
505nv50_instmem_prepare_access(struct drm_device *dev, bool write) 498nv50_instmem_flush(struct drm_device *dev)
506{
507 struct drm_nouveau_private *dev_priv = dev->dev_private;
508 struct nv50_instmem_priv *priv = dev_priv->engine.instmem.priv;
509
510 priv->last_access_wr = write;
511}
512
513void
514nv50_instmem_finish_access(struct drm_device *dev)
515{ 499{
516 struct drm_nouveau_private *dev_priv = dev->dev_private; 500 nv_wr32(dev, 0x070000, 0x00000001);
517 struct nv50_instmem_priv *priv = dev_priv->engine.instmem.priv; 501 if (!nv_wait(0x070000, 0x00000001, 0x00000000))
518 502 NV_ERROR(dev, "PRAMIN flush timeout\n");
519 if (priv->last_access_wr) {
520 nv_wr32(dev, 0x070000, 0x00000001);
521 if (!nv_wait(0x070000, 0x00000001, 0x00000000))
522 NV_ERROR(dev, "PRAMIN flush timeout\n");
523 }
524} 503}
525 504