]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/nouveau/devinit/gf100: make devinit on resume safer
authorAlexandre Courbot <acourbot@nvidia.com>
Fri, 1 Apr 2016 06:40:59 +0000 (15:40 +0900)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 20 May 2016 04:43:04 +0000 (14:43 +1000)
In case of successful suspend, devinit will have to be run and this is
the behavior currently hardcoded. However, as FD bug 94725 suggests,
there might be cases where runtime suspend leaves the GPU powered, and
in such cases devinit should not be run on resume.

On GF100+ we have a reliable way to know whether we need to run devinit.
Use it instead of blindly trusting the flag set by nvkm_devinit_fini().

The code around the NvForcePost also needs to be slightly reworked in
order to keep working.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Suggested-by: Dave Airlie <airlied@redhat.com>
Suggested-by: Karol Herbst <nouveau@karolherbst.de>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/subdev/devinit.h
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gf100.c

index 193626c69517512ff24bce801a94f5b757263c0c..709d786f180867fae521dfe2134234ddcbda0cce 100644 (file)
@@ -7,6 +7,7 @@ struct nvkm_devinit {
        const struct nvkm_devinit_func *func;
        struct nvkm_subdev subdev;
        bool post;
+       bool force_post;
 };
 
 u32 nvkm_devinit_mmio(struct nvkm_devinit *, u32 addr);
index 5f25402f6b096f0e7ff67c39b4f8bef6ff8f57f8..9edd53773a19b9e920eec0448a70baac3040dc57 100644 (file)
@@ -83,6 +83,12 @@ nvkm_devinit_preinit(struct nvkm_subdev *subdev)
        if (init->func->preinit)
                init->func->preinit(init);
 
+       /* Override the post flag during the first call if NvForcePost is set */
+       if (init->force_post) {
+               init->post = init->force_post;
+               init->force_post = false;
+       }
+
        /* unlock the extended vga crtc regs */
        nvkm_lockvgac(subdev->device, false);
        return 0;
@@ -126,5 +132,5 @@ nvkm_devinit_ctor(const struct nvkm_devinit_func *func,
 {
        nvkm_subdev_ctor(&nvkm_devinit, device, index, 0, &init->subdev);
        init->func = func;
-       init->post = nvkm_boolopt(device->cfgopt, "NvForcePost", false);
+       init->force_post = nvkm_boolopt(device->cfgopt, "NvForcePost", false);
 }
index 2923598b5fe99e239c6cde5e55d5c6af5cf77c7b..8b1b34c3ad2624cfbda40054a7c5410b8a0364f6 100644 (file)
@@ -97,9 +97,11 @@ gf100_devinit_preinit(struct nvkm_devinit *base)
        struct nvkm_subdev *subdev = &init->base.subdev;
        struct nvkm_device *device = subdev->device;
 
-       /* This bit is set by devinit, and flips back to 0 on suspend */
-       if (!base->post)
-               base->post = ((nvkm_rd32(device, 0x2240c) & BIT(1)) == 0);
+       /*
+        * This bit is set by devinit, and flips back to 0 on suspend. We
+        * can use it as a reliable way to know whether we should run devinit.
+        */
+       base->post = ((nvkm_rd32(device, 0x2240c) & BIT(1)) == 0);
 }
 
 static const struct nvkm_devinit_func