Commit 1c6aab75 authored by Ben Skeggs's avatar Ben Skeggs Committed by Dave Airlie

drm/nouveau/disp: merge nv50_disp_new_() and nvkm_disp_new()

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 3517e6b6
......@@ -30,6 +30,7 @@
#include <core/client.h>
#include <core/notify.h>
#include <core/ramht.h>
#include <subdev/bios.h>
#include <subdev/bios/dcb.h>
......@@ -394,8 +395,12 @@ nvkm_disp_dtor(struct nvkm_engine *engine)
struct nvkm_head *head;
void *data = disp;
if (disp->func->dtor)
data = disp->func->dtor(disp);
nvkm_ramht_del(&disp->ramht);
nvkm_gpuobj_del(&disp->inst);
nvkm_event_fini(&disp->uevent);
if (disp->super.wq)
destroy_workqueue(disp->super.wq);
nvkm_event_fini(&disp->vblank);
nvkm_event_fini(&disp->hpd);
......@@ -436,23 +441,33 @@ nvkm_disp = {
};
int
nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
enum nvkm_subdev_type type, int inst, struct nvkm_disp *disp)
nvkm_disp_new_(const struct nvkm_disp_func *func, struct nvkm_device *device,
enum nvkm_subdev_type type, int inst, struct nvkm_disp **pdisp)
{
struct nvkm_disp *disp;
int ret;
if (!(disp = *pdisp = kzalloc(sizeof(**pdisp), GFP_KERNEL)))
return -ENOMEM;
disp->func = func;
INIT_LIST_HEAD(&disp->heads);
INIT_LIST_HEAD(&disp->iors);
INIT_LIST_HEAD(&disp->outps);
INIT_LIST_HEAD(&disp->conns);
spin_lock_init(&disp->client.lock);
return nvkm_engine_ctor(&nvkm_disp, device, type, inst, true, &disp->engine);
}
int
nvkm_disp_new_(const struct nvkm_disp_func *func, struct nvkm_device *device,
enum nvkm_subdev_type type, int inst, struct nvkm_disp **pdisp)
{
if (!(*pdisp = kzalloc(sizeof(**pdisp), GFP_KERNEL)))
ret = nvkm_engine_ctor(&nvkm_disp, device, type, inst, true, &disp->engine);
if (ret)
return ret;
if (func->super) {
disp->super.wq = create_singlethread_workqueue("nvkm-disp");
if (!disp->super.wq)
return -ENOMEM;
return nvkm_disp_ctor(func, device, type, inst, *pdisp);
INIT_WORK(&disp->super.work, func->super);
}
return nvkm_event_init(func->uevent, 1, ARRAY_SIZE(disp->chan), &disp->uevent);
}
......@@ -298,7 +298,6 @@ g84_disp_core_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
static const struct nvkm_disp_func
g84_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = nv50_disp_init,
.fini = nv50_disp_fini,
......@@ -324,5 +323,5 @@ int
g84_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&g84_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&g84_disp, device, type, inst, pdisp);
}
......@@ -345,7 +345,6 @@ g94_disp_core_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
static const struct nvkm_disp_func
g94_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = nv50_disp_init,
.fini = nv50_disp_fini,
......@@ -371,5 +370,5 @@ int
g94_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&g94_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&g94_disp, device, type, inst, pdisp);
}
......@@ -152,7 +152,6 @@ ga102_sor_new(struct nvkm_disp *disp, int id)
static const struct nvkm_disp_func
ga102_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = tu102_disp_init,
.fini = gv100_disp_fini,
......@@ -178,5 +177,5 @@ int
ga102_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&ga102_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&ga102_disp, device, type, inst, pdisp);
}
......@@ -1202,7 +1202,6 @@ gf119_disp_init(struct nvkm_disp *disp)
static const struct nvkm_disp_func
gf119_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = gf119_disp_init,
.fini = gf119_disp_fini,
......@@ -1228,5 +1227,5 @@ int
gf119_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&gf119_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&gf119_disp, device, type, inst, pdisp);
}
......@@ -296,7 +296,6 @@ gk104_disp_core_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
static const struct nvkm_disp_func
gk104_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = gf119_disp_init,
.fini = gf119_disp_fini,
......@@ -322,5 +321,5 @@ int
gk104_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&gk104_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&gk104_disp, device, type, inst, pdisp);
}
......@@ -30,7 +30,6 @@
static const struct nvkm_disp_func
gk110_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = gf119_disp_init,
.fini = gf119_disp_fini,
......@@ -56,5 +55,5 @@ int
gk110_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&gk110_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&gk110_disp, device, type, inst, pdisp);
}
......@@ -86,7 +86,6 @@ gm107_sor_new(struct nvkm_disp *disp, int id)
static const struct nvkm_disp_func
gm107_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = gf119_disp_init,
.fini = gf119_disp_fini,
......@@ -112,5 +111,5 @@ int
gm107_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&gm107_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&gm107_disp, device, type, inst, pdisp);
}
......@@ -183,7 +183,6 @@ gm200_sor_new(struct nvkm_disp *disp, int id)
static const struct nvkm_disp_func
gm200_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = gf119_disp_init,
.fini = gf119_disp_fini,
......@@ -209,5 +208,5 @@ int
gm200_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&gm200_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&gm200_disp, device, type, inst, pdisp);
}
......@@ -101,7 +101,6 @@ gp100_sor_new(struct nvkm_disp *disp, int id)
static const struct nvkm_disp_func
gp100_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = gf119_disp_init,
.fini = gf119_disp_fini,
......@@ -126,5 +125,5 @@ int
gp100_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&gp100_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&gp100_disp, device, type, inst, pdisp);
}
......@@ -172,7 +172,6 @@ gp102_disp_intr_error(struct nvkm_disp *disp, int chid)
static const struct nvkm_disp_func
gp102_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = gf119_disp_init,
.fini = gf119_disp_fini,
......@@ -197,5 +196,5 @@ int
gp102_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&gp102_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&gp102_disp, device, type, inst, pdisp);
}
......@@ -80,7 +80,6 @@ gt200_disp_ovly_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
static const struct nvkm_disp_func
gt200_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = nv50_disp_init,
.fini = nv50_disp_fini,
......@@ -106,5 +105,5 @@ int
gt200_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&gt200_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&gt200_disp, device, type, inst, pdisp);
}
......@@ -173,7 +173,6 @@ gt215_sor_new(struct nvkm_disp *disp, int id)
static const struct nvkm_disp_func
gt215_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = nv50_disp_init,
.fini = nv50_disp_fini,
......@@ -199,5 +198,5 @@ int
gt215_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&gt215_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&gt215_disp, device, type, inst, pdisp);
}
......@@ -1285,7 +1285,6 @@ gv100_disp_init(struct nvkm_disp *disp)
static const struct nvkm_disp_func
gv100_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = gv100_disp_init,
.fini = gv100_disp_fini,
......@@ -1311,5 +1310,5 @@ int
gv100_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&gv100_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&gv100_disp, device, type, inst, pdisp);
}
......@@ -54,7 +54,6 @@ mcp77_sor_new(struct nvkm_disp *disp, int id)
static const struct nvkm_disp_func
mcp77_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = nv50_disp_init,
.fini = nv50_disp_fini,
......@@ -80,5 +79,5 @@ int
mcp77_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&mcp77_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&mcp77_disp, device, type, inst, pdisp);
}
......@@ -59,7 +59,6 @@ mcp89_sor_new(struct nvkm_disp *disp, int id)
static const struct nvkm_disp_func
mcp89_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = nv50_disp_init,
.fini = nv50_disp_fini,
......@@ -85,5 +84,5 @@ int
mcp89_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&mcp89_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&mcp89_disp, device, type, inst, pdisp);
}
......@@ -1788,22 +1788,8 @@ nv50_disp_oneinit(struct nvkm_disp *disp)
0x1000, 0, disp->inst, &disp->ramht);
}
void *
nv50_disp_dtor(struct nvkm_disp *disp)
{
nvkm_ramht_del(&disp->ramht);
nvkm_gpuobj_del(&disp->inst);
nvkm_event_fini(&disp->uevent);
if (disp->super.wq)
destroy_workqueue(disp->super.wq);
return disp;
}
static const struct nvkm_disp_func
nv50_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = nv50_disp_init,
.fini = nv50_disp_fini,
......@@ -1825,35 +1811,9 @@ nv50_disp = {
}
};
int
nv50_disp_new_(const struct nvkm_disp_func *func, struct nvkm_device *device,
enum nvkm_subdev_type type, int inst, struct nvkm_disp **pdisp)
{
struct nvkm_disp *disp;
int ret;
if (!(disp = kzalloc(sizeof(*disp), GFP_KERNEL)))
return -ENOMEM;
disp->func = func;
*pdisp = disp;
ret = nvkm_disp_ctor(func, device, type, inst, disp);
if (ret)
return ret;
disp->super.wq = create_singlethread_workqueue("nvkm-disp");
if (!disp->super.wq)
return -ENOMEM;
INIT_WORK(&disp->super.work, func->super);
return nvkm_event_init(func->uevent, 1, ARRAY_SIZE(disp->chan),
&disp->uevent);
}
int
nv50_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&nv50_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&nv50_disp, device, type, inst, pdisp);
}
......@@ -15,7 +15,6 @@ int nvkm_disp_new_(const struct nvkm_disp_func *, struct nvkm_device *, enum nvk
void nvkm_disp_vblank(struct nvkm_disp *, int head);
struct nvkm_disp_func {
void *(*dtor)(struct nvkm_disp *);
int (*oneinit)(struct nvkm_disp *);
int (*init)(struct nvkm_disp *);
void (*fini)(struct nvkm_disp *);
......@@ -46,9 +45,6 @@ int nvkm_disp_ntfy(struct nvkm_object *, u32, struct nvkm_event **);
int nv04_disp_mthd(struct nvkm_object *, u32, void *, u32);
int nv50_disp_root_mthd_(struct nvkm_object *, u32, void *, u32);
int nv50_disp_new_(const struct nvkm_disp_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
struct nvkm_disp **);
void *nv50_disp_dtor(struct nvkm_disp *);
int nv50_disp_oneinit(struct nvkm_disp *);
int nv50_disp_init(struct nvkm_disp *);
void nv50_disp_fini(struct nvkm_disp *);
......
......@@ -238,7 +238,6 @@ tu102_disp_init(struct nvkm_disp *disp)
static const struct nvkm_disp_func
tu102_disp = {
.dtor = nv50_disp_dtor,
.oneinit = nv50_disp_oneinit,
.init = tu102_disp_init,
.fini = gv100_disp_fini,
......@@ -264,5 +263,5 @@ int
tu102_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_disp **pdisp)
{
return nv50_disp_new_(&tu102_disp, device, type, inst, pdisp);
return nvkm_disp_new_(&tu102_disp, device, type, inst, pdisp);
}
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