Commit 3b9ba66a authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/disp/nv50-: delay subunit construction until oneinit

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: default avatarBen Skeggs <bskeggs@redhat.com>
parent 85a3b9c8
...@@ -376,6 +376,12 @@ nvkm_disp_oneinit(struct nvkm_engine *engine) ...@@ -376,6 +376,12 @@ nvkm_disp_oneinit(struct nvkm_engine *engine)
if (ret) if (ret)
return ret; return ret;
if (disp->func->oneinit) {
ret = disp->func->oneinit(disp);
if (ret)
return ret;
}
i = 0; i = 0;
list_for_each_entry(head, &disp->head, head) list_for_each_entry(head, &disp->head, head)
i = max(i, head->id + 1); i = max(i, head->id + 1);
......
...@@ -59,9 +59,44 @@ nv50_disp_dtor_(struct nvkm_disp *base) ...@@ -59,9 +59,44 @@ nv50_disp_dtor_(struct nvkm_disp *base)
return disp; 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 static const struct nvkm_disp_func
nv50_disp_ = { nv50_disp_ = {
.dtor = nv50_disp_dtor_, .dtor = nv50_disp_dtor_,
.oneinit = nv50_disp_oneinit_,
.intr = nv50_disp_intr_, .intr = nv50_disp_intr_,
.root = nv50_disp_root_, .root = nv50_disp_root_,
}; };
...@@ -71,7 +106,7 @@ nv50_disp_new_(const struct nv50_disp_func *func, struct nvkm_device *device, ...@@ -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) int index, int heads, struct nvkm_disp **pdisp)
{ {
struct nv50_disp *disp; struct nv50_disp *disp;
int ret, i; int ret;
if (!(disp = kzalloc(sizeof(*disp), GFP_KERNEL))) if (!(disp = kzalloc(sizeof(*disp), GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
...@@ -85,33 +120,12 @@ nv50_disp_new_(const struct nv50_disp_func *func, struct nvkm_device *device, ...@@ -85,33 +120,12 @@ nv50_disp_new_(const struct nv50_disp_func *func, struct nvkm_device *device,
disp->wq = create_singlethread_workqueue("nvkm-disp"); disp->wq = create_singlethread_workqueue("nvkm-disp");
if (!disp->wq) if (!disp->wq)
return -ENOMEM; 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++) { INIT_WORK(&disp->supervisor, func->super);
ret = func->dac.new(&disp->base, i); disp->head.nr = heads;
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 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 static u32
......
...@@ -15,6 +15,10 @@ struct nv50_disp { ...@@ -15,6 +15,10 @@ struct nv50_disp {
struct nvkm_event uevent; struct nvkm_event uevent;
struct {
int nr;
} head;
struct { struct {
u32 lvdsconf; u32 lvdsconf;
} sor; } sor;
......
...@@ -12,6 +12,7 @@ void nvkm_disp_vblank(struct nvkm_disp *, int head); ...@@ -12,6 +12,7 @@ void nvkm_disp_vblank(struct nvkm_disp *, int head);
struct nvkm_disp_func { struct nvkm_disp_func {
void *(*dtor)(struct nvkm_disp *); void *(*dtor)(struct nvkm_disp *);
int (*oneinit)(struct nvkm_disp *);
void (*intr)(struct nvkm_disp *); void (*intr)(struct nvkm_disp *);
const struct nvkm_disp_oclass *(*root)(struct nvkm_disp *); const struct nvkm_disp_oclass *(*root)(struct nvkm_disp *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment