drm/nouveau/disp/nv50-: delay subunit construction until oneinit
authorBen Skeggs <bskeggs@redhat.com>
Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 18 May 2018 05:01:20 +0000 (15:01 +1000)
We should be reading registers to determine which subunits are really
present on a given board, and this needs to be done after DEVINIT.

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

index 93a75e5b27911a33d1df9bb085bbf173f1b2c154..5b9d9c632aeb1ba54ad3bfcc9cfb1940a3a53615 100644 (file)
@@ -376,6 +376,12 @@ nvkm_disp_oneinit(struct nvkm_engine *engine)
        if (ret)
                return ret;
 
+       if (disp->func->oneinit) {
+               ret = disp->func->oneinit(disp);
+               if (ret)
+                       return ret;
+       }
+
        i = 0;
        list_for_each_entry(head, &disp->head, head)
                i = max(i, head->id + 1);
index 0c570dbd3021b45472a31a96afee19e88a4adea0..43373b3662632a715b0029938a81cd80f7254fc0 100644 (file)
@@ -59,9 +59,44 @@ nv50_disp_dtor_(struct nvkm_disp *base)
        return disp;
 }
 
+static int
+nv50_disp_oneinit_(struct nvkm_disp *base)
+{
+       struct nv50_disp *disp = nv50_disp(base);
+       const struct nv50_disp_func *func = disp->func;
+       int ret, i;
+
+       for (i = 0; func->head.new && i < disp->head.nr; i++) {
+               ret = func->head.new(&disp->base, i);
+               if (ret)
+                       return ret;
+       }
+
+       for (i = 0; func->dac.new && i < func->dac.nr; i++) {
+               ret = func->dac.new(&disp->base, i);
+               if (ret)
+                       return ret;
+       }
+
+       for (i = 0; func->pior.new && i < func->pior.nr; i++) {
+               ret = func->pior.new(&disp->base, i);
+               if (ret)
+                       return ret;
+       }
+
+       for (i = 0; func->sor.new && i < func->sor.nr; i++) {
+               ret = func->sor.new(&disp->base, i);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
+}
+
 static const struct nvkm_disp_func
 nv50_disp_ = {
        .dtor = nv50_disp_dtor_,
+       .oneinit = nv50_disp_oneinit_,
        .intr = nv50_disp_intr_,
        .root = nv50_disp_root_,
 };
@@ -71,7 +106,7 @@ nv50_disp_new_(const struct nv50_disp_func *func, struct nvkm_device *device,
               int index, int heads, struct nvkm_disp **pdisp)
 {
        struct nv50_disp *disp;
-       int ret, i;
+       int ret;
 
        if (!(disp = kzalloc(sizeof(*disp), GFP_KERNEL)))
                return -ENOMEM;
@@ -85,33 +120,12 @@ nv50_disp_new_(const struct nv50_disp_func *func, struct nvkm_device *device,
        disp->wq = create_singlethread_workqueue("nvkm-disp");
        if (!disp->wq)
                return -ENOMEM;
-       INIT_WORK(&disp->supervisor, func->super);
-
-       for (i = 0; func->head.new && i < heads; i++) {
-               ret = func->head.new(&disp->base, i);
-               if (ret)
-                       return ret;
-       }
 
-       for (i = 0; func->dac.new && i < func->dac.nr; i++) {
-               ret = func->dac.new(&disp->base, i);
-               if (ret)
-                       return ret;
-       }
-
-       for (i = 0; func->pior.new && i < func->pior.nr; i++) {
-               ret = func->pior.new(&disp->base, i);
-               if (ret)
-                       return ret;
-       }
-
-       for (i = 0; func->sor.new && i < func->sor.nr; i++) {
-               ret = func->sor.new(&disp->base, i);
-               if (ret)
-                       return ret;
-       }
+       INIT_WORK(&disp->supervisor, func->super);
+       disp->head.nr = heads;
 
-       return nvkm_event_init(func->uevent, 1, 1 + (heads * 4), &disp->uevent);
+       return nvkm_event_init(func->uevent, 1, ARRAY_SIZE(disp->chan),
+                              &disp->uevent);
 }
 
 static u32
index eb0b8acb1c5bb5a69c0335eb74e178577f34bcee..0ae32cda45e7121337dfc7b787fd1e8f67059ea4 100644 (file)
@@ -15,6 +15,10 @@ struct nv50_disp {
 
        struct nvkm_event uevent;
 
+       struct {
+               int nr;
+       } head;
+
        struct {
                u32 lvdsconf;
        } sor;
index 6c9bfff6d043b1794a439ea37274837b77991547..c614351f50127c750625cb50a8ba72c02bd4ee48 100644 (file)
@@ -12,6 +12,7 @@ void nvkm_disp_vblank(struct nvkm_disp *, int head);
 
 struct nvkm_disp_func {
        void *(*dtor)(struct nvkm_disp *);
+       int (*oneinit)(struct nvkm_disp *);
        void (*intr)(struct nvkm_disp *);
 
        const struct nvkm_disp_oclass *(*root)(struct nvkm_disp *);