Blob Blame History Raw
From: Ben Skeggs <bskeggs@redhat.com>
Date: Wed, 1 Nov 2017 03:56:19 +1000
Subject: drm/nouveau/imem/nv50: prevent fast-path for mapped objects when BAR
 isn't ready
Git-commit: 69b136f200006ee37b039195eaeb08942c419ecc
Patch-mainline: v4.15-rc1
References: FATE#326289 FATE#326079 FATE#326049 FATE#322398 FATE#326166

Another piece of solving the "GP100 BAR2 VMM bootstrap" puzzle.

Without doing this, we'd attempt to write PDEs for the lower page table
levels through BAR2 before BAR2 access has been fully initialised.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
@@ -196,9 +196,11 @@ nv50_instobj_acquire(struct nvkm_memory
 	}
 
 	/* Attempt to get a direct CPU mapping of the object. */
-	if (!iobj->map && (vmm = nvkm_bar_bar2_vmm(imem->subdev.device)))
-		nv50_instobj_kmap(iobj, vmm);
-	map = iobj->map;
+	if ((vmm = nvkm_bar_bar2_vmm(imem->subdev.device))) {
+		if (!iobj->map)
+			nv50_instobj_kmap(iobj, vmm);
+		map = iobj->map;
+	}
 
 	if (!refcount_inc_not_zero(&iobj->maps)) {
 		if (map)