Blob Blame History Raw
From: Ben Skeggs <bskeggs@redhat.com>
Date: Wed, 1 Nov 2017 03:56:19 +1000
Subject: drm/nouveau/imem: use fast-path for resume restore
Git-commit: ffd937bbd219331e4b67344c104dea09b9ed4a6a
Patch-mainline: v4.15-rc1
References: FATE#326289 FATE#326079 FATE#326049 FATE#322398 FATE#326166

Before: "imem: init completed in 299277us"
 After: "imem: init completed in  11574us"

Suspend from Fedora 26 gnome desktop on GP102.

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

--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/base.c
@@ -81,7 +81,6 @@ static int
 nvkm_bar_init(struct nvkm_subdev *subdev)
 {
 	struct nvkm_bar *bar = nvkm_bar(subdev);
-	nvkm_bar_bar2_init(subdev->device);
 	bar->func->bar1.init(bar);
 	bar->func->bar1.wait(bar);
 	if (bar->func->init)
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c
@@ -33,10 +33,17 @@ nvkm_instobj_load(struct nvkm_instobj *i
 {
 	struct nvkm_memory *memory = &iobj->memory;
 	const u64 size = nvkm_memory_size(memory);
+	void __iomem *map;
 	int i;
 
-	for (i = 0; i < size; i += 4)
-		nvkm_wo32(memory, i, iobj->suspend[i / 4]);
+	if (!(map = nvkm_kmap(memory))) {
+		for (i = 0; i < size; i += 4)
+			nvkm_wo32(memory, i, iobj->suspend[i / 4]);
+	} else {
+		memcpy_toio(map, iobj->suspend, size);
+	}
+	nvkm_done(memory);
+
 	kvfree(iobj->suspend);
 	iobj->suspend = NULL;
 }
@@ -188,6 +195,8 @@ nvkm_instmem_init(struct nvkm_subdev *su
 			nvkm_instobj_load(iobj);
 	}
 
+	nvkm_bar_bar2_init(subdev->device);
+
 	list_for_each_entry(iobj, &imem->list, head) {
 		if (iobj->suspend)
 			nvkm_instobj_load(iobj);
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
@@ -206,7 +206,7 @@ nv50_instobj_release(struct nvkm_memory
 		}
 
 		/* Switch back to NULL accessors when last map is gone. */
-		iobj->base.memory.ptrs = &nv50_instobj_slow;
+		iobj->base.memory.ptrs = NULL;
 		mutex_unlock(&subdev->mutex);
 	}
 }
@@ -345,7 +345,6 @@ nv50_instobj_new(struct nvkm_instmem *ba
 	*pmemory = &iobj->base.memory;
 
 	nvkm_instobj_ctor(&nv50_instobj_func, &imem->base, &iobj->base);
-	iobj->base.memory.ptrs = &nv50_instobj_slow;
 	iobj->imem = imem;
 	refcount_set(&iobj->maps, 0);
 	INIT_LIST_HEAD(&iobj->lru);