drm/nouveau/devinit: run devinit scripts right after preinit
authorBen Skeggs <bskeggs@redhat.com>
Thu, 20 Aug 2015 04:54:20 +0000 (14:54 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 28 Aug 2015 02:40:44 +0000 (12:40 +1000)
This ensures we have a valid mask of disabled engines before we start
trying to execute fini()/init() on the subdevs, potentially touching
devices that don't exist.

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

index 9e053460a9c777177ffbe25f2b881ddc24b68842..6c1407fd317b08fb66ebfe37d3211feede93962a 100644 (file)
@@ -13,6 +13,7 @@ u32 nvkm_devinit_mmio(struct nvkm_devinit *, u32 addr);
 int nvkm_devinit_pll_set(struct nvkm_devinit *, u32 type, u32 khz);
 void nvkm_devinit_meminit(struct nvkm_devinit *);
 u64 nvkm_devinit_disable(struct nvkm_devinit *);
+int nvkm_devinit_post(struct nvkm_devinit *, u64 *disable);
 
 int nv04_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
 int nv05_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
index 2d8ef80f32e740a63616d362745380583b2fb8e8..99a07694a298554539a91066a2b92346b21cfa59 100644 (file)
@@ -2167,7 +2167,9 @@ nvkm_device_preinit(struct nvkm_device *device)
                }
        }
 
-       /*XXX: devinit */
+       ret = nvkm_devinit_post(device->devinit, &device->disable_mask);
+       if (ret)
+               goto fail;
 
        time = ktime_to_us(ktime_get()) - time;
        nvdev_trace(device, "preinit completed in %lldus\n", time);
index 47823f5a2cdff13b1778284e719d4c96d32f0729..5f25402f6b096f0e7ff67c39b4f8bef6ff8f57f8 100644 (file)
@@ -50,11 +50,21 @@ nvkm_devinit_meminit(struct nvkm_devinit *init)
 u64
 nvkm_devinit_disable(struct nvkm_devinit *init)
 {
-       if (init->func->disable)
+       if (init && init->func->disable)
                return init->func->disable(init);
        return 0;
 }
 
+int
+nvkm_devinit_post(struct nvkm_devinit *init, u64 *disable)
+{
+       int ret = 0;
+       if (init && init->func->post)
+               ret = init->func->post(init, init->post);
+       *disable = nvkm_devinit_disable(init);
+       return ret;
+}
+
 static int
 nvkm_devinit_fini(struct nvkm_subdev *subdev, bool suspend)
 {
@@ -82,17 +92,8 @@ static int
 nvkm_devinit_init(struct nvkm_subdev *subdev)
 {
        struct nvkm_devinit *init = nvkm_devinit(subdev);
-       int ret;
-
-       ret = init->func->post(init, init->post);
-       if (ret)
-               return ret;
-
        if (init->func->init)
                init->func->init(init);
-
-       if (init->func->disable)
-               subdev->device->disable_mask |= init->func->disable(init);
        return 0;
 }