drm/nouveau/fifo: perform reset from preinit
authorBen Skeggs <bskeggs@redhat.com>
Tue, 31 Oct 2017 17:56:19 +0000 (03:56 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 2 Nov 2017 03:32:17 +0000 (13:32 +1000)
RM appears to do this really early in its initialisation, before DEVINIT.

We currently do this before BAR2 initialisation for some reason.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/core/engine.h
drivers/gpu/drm/nouveau/nvkm/core/engine.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c

index d4cd2fb..7730499 100644 (file)
@@ -15,6 +15,7 @@ struct nvkm_engine {
 
 struct nvkm_engine_func {
        void *(*dtor)(struct nvkm_engine *);
+       void (*preinit)(struct nvkm_engine *);
        int (*oneinit)(struct nvkm_engine *);
        int (*init)(struct nvkm_engine *);
        int (*fini)(struct nvkm_engine *, bool suspend);
index b6c9169..657231c 100644 (file)
@@ -126,6 +126,15 @@ nvkm_engine_init(struct nvkm_subdev *subdev)
        return ret;
 }
 
+static int
+nvkm_engine_preinit(struct nvkm_subdev *subdev)
+{
+       struct nvkm_engine *engine = nvkm_engine(subdev);
+       if (engine->func->preinit)
+               engine->func->preinit(engine);
+       return 0;
+}
+
 static void *
 nvkm_engine_dtor(struct nvkm_subdev *subdev)
 {
@@ -138,6 +147,7 @@ nvkm_engine_dtor(struct nvkm_subdev *subdev)
 static const struct nvkm_subdev_func
 nvkm_engine_func = {
        .dtor = nvkm_engine_dtor,
+       .preinit = nvkm_engine_preinit,
        .init = nvkm_engine_init,
        .fini = nvkm_engine_fini,
        .intr = nvkm_engine_intr,
index 660ca7a..64f6b76 100644 (file)
@@ -27,6 +27,7 @@
 #include <core/client.h>
 #include <core/gpuobj.h>
 #include <core/notify.h>
+#include <subdev/mc.h>
 
 #include <nvif/event.h>
 #include <nvif/unpack.h>
@@ -278,6 +279,12 @@ nvkm_fifo_oneinit(struct nvkm_engine *engine)
        return 0;
 }
 
+static void
+nvkm_fifo_preinit(struct nvkm_engine *engine)
+{
+       nvkm_mc_reset(engine->subdev.device, NVKM_ENGINE_FIFO);
+}
+
 static int
 nvkm_fifo_init(struct nvkm_engine *engine)
 {
@@ -302,6 +309,7 @@ nvkm_fifo_dtor(struct nvkm_engine *engine)
 static const struct nvkm_engine_func
 nvkm_fifo = {
        .dtor = nvkm_fifo_dtor,
+       .preinit = nvkm_fifo_preinit,
        .oneinit = nvkm_fifo_oneinit,
        .init = nvkm_fifo_init,
        .fini = nvkm_fifo_fini,