Commit 50551b15 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/ce: switch to instanced constructor

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent b7da823a
......@@ -60,7 +60,6 @@ struct nvkm_device {
struct notifier_block nb;
} acpi;
struct nvkm_engine *ce[9];
struct nvkm_engine *cipher;
struct nvkm_disp *disp;
struct nvkm_dma *dma;
......@@ -121,7 +120,6 @@ struct nvkm_device_chip {
#undef NVKM_LAYOUT_INST
#undef NVKM_LAYOUT_ONCE
int (*ce[9] )(struct nvkm_device *, int idx, struct nvkm_engine **);
int (*cipher )(struct nvkm_device *, int idx, struct nvkm_engine **);
int (*disp )(struct nvkm_device *, int idx, struct nvkm_disp **);
int (*dma )(struct nvkm_device *, int idx, struct nvkm_dma **);
......
......@@ -53,8 +53,13 @@ int nvkm_engine_ctor_(const struct nvkm_engine_func *, bool old, struct nvkm_dev
#define nvkm_engine_ctor_n(f,d,t,i,e,s) nvkm_engine_ctor_((f), false, (d), (t), (i), (e), (s))
#define nvkm_engine_ctor__(_1,_2,_3,_4,_5,_6,IMPL,...) IMPL
#define nvkm_engine_ctor(A...) nvkm_engine_ctor__(A, nvkm_engine_ctor_n, nvkm_engine_ctor_o)(A)
int nvkm_engine_new_(const struct nvkm_engine_func *, struct nvkm_device *,
int index, bool enable, struct nvkm_engine **);
int nvkm_engine_new__(const struct nvkm_engine_func *, bool old, struct nvkm_device *,
enum nvkm_subdev_type, int, bool enable, struct nvkm_engine **);
#define nvkm_engine_new__o(f,d,i, e,s) nvkm_engine_new__((f), true, (d), (i), -1 , (e), (s))
#define nvkm_engine_new__n(f,d,t,i,e,s) nvkm_engine_new__((f), false, (d), (t), (i), (e), (s))
#define nvkm_engine_new___(_1,_2,_3,_4,_5,_6,IMPL,...) IMPL
#define nvkm_engine_new_(A...) nvkm_engine_new___(A, nvkm_engine_new__n, nvkm_engine_new__o)(A)
struct nvkm_engine *nvkm_engine_ref(struct nvkm_engine *);
void nvkm_engine_unref(struct nvkm_engine **);
void nvkm_engine_tile(struct nvkm_engine *, int region);
......
......@@ -26,4 +26,5 @@ NVKM_LAYOUT_ONCE(NVKM_SUBDEV_CLK , struct nvkm_clk , clk)
NVKM_LAYOUT_ONCE(NVKM_SUBDEV_GSP , struct nvkm_gsp , gsp)
NVKM_LAYOUT_ONCE(NVKM_ENGINE_BSP , struct nvkm_engine , bsp)
NVKM_LAYOUT_INST(NVKM_ENGINE_CE , struct nvkm_engine , ce, 9)
NVKM_LAYOUT_ONCE(NVKM_ENGINE_VP , struct nvkm_engine , vp)
......@@ -3,13 +3,13 @@
#define __NVKM_CE_H__
#include <engine/falcon.h>
int gt215_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
int gf100_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
int gk104_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
int gm107_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
int gm200_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
int gp100_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
int gp102_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
int gv100_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
int tu102_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
int gt215_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
int gf100_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
int gk104_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
int gm107_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
int gm200_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
int gp100_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
int gp102_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
int gv100_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
int tu102_ce_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_engine **);
#endif
......@@ -63,8 +63,12 @@ void nvkm_falcon_del(struct nvkm_falcon **);
int nvkm_falcon_get(struct nvkm_falcon *, const struct nvkm_subdev *);
void nvkm_falcon_put(struct nvkm_falcon *, const struct nvkm_subdev *);
int nvkm_falcon_new_(const struct nvkm_falcon_func *, struct nvkm_device *,
int index, bool enable, u32 addr, struct nvkm_engine **);
int nvkm_falcon_new__(const struct nvkm_falcon_func *, bool old, struct nvkm_device *,
enum nvkm_subdev_type, int inst, bool enable, u32 addr, struct nvkm_engine **);
#define nvkm_falcon_new__o(f,d,i, e,a,s) nvkm_falcon_new__((f), true, (d), (i), -1 , (e), (a), (s))
#define nvkm_falcon_new__n(f,d,t,i,e,a,s) nvkm_falcon_new__((f), false, (d), (t), (i), (e), (a), (s))
#define nvkm_falcon_new___(_1,_2,_3,_4,_5,_6,_7,IMPL,...) IMPL
#define nvkm_falcon_new_(A...) nvkm_falcon_new___(A, nvkm_falcon_new__n, nvkm_falcon_new__o)(A)
struct nvkm_falcon_func {
struct {
......
......@@ -194,11 +194,11 @@ nvkm_engine_ctor_(const struct nvkm_engine_func *func, bool old, struct nvkm_dev
}
int
nvkm_engine_new_(const struct nvkm_engine_func *func,
struct nvkm_device *device, int index, bool enable,
nvkm_engine_new__(const struct nvkm_engine_func *func, bool old, struct nvkm_device *device,
enum nvkm_subdev_type type, int inst, bool enable,
struct nvkm_engine **pengine)
{
if (!(*pengine = kzalloc(sizeof(**pengine), GFP_KERNEL)))
return -ENOMEM;
return nvkm_engine_ctor(func, device, index, enable, *pengine);
return nvkm_engine_ctor_(func, old, device, type, inst, enable, *pengine);
}
......@@ -33,15 +33,6 @@ nvkm_subdev_type[NVKM_SUBDEV_NR] = {
#include <core/layout.h>
#undef NVKM_LAYOUT_ONCE
#undef NVKM_LAYOUT_INST
[NVKM_ENGINE_CE0 ] = "ce0",
[NVKM_ENGINE_CE1 ] = "ce1",
[NVKM_ENGINE_CE2 ] = "ce2",
[NVKM_ENGINE_CE3 ] = "ce3",
[NVKM_ENGINE_CE4 ] = "ce4",
[NVKM_ENGINE_CE5 ] = "ce5",
[NVKM_ENGINE_CE6 ] = "ce6",
[NVKM_ENGINE_CE7 ] = "ce7",
[NVKM_ENGINE_CE8 ] = "ce8",
[NVKM_ENGINE_CIPHER ] = "cipher",
[NVKM_ENGINE_DISP ] = "disp",
[NVKM_ENGINE_DMAOBJ ] = "dma",
......@@ -211,10 +202,6 @@ nvkm_subdev_ctor_(const struct nvkm_subdev_func *func, bool old,
if (old) {
switch (subdev->type) {
case NVKM_ENGINE_CE0 ... NVKM_ENGINE_CE_LAST:
subdev->type = NVKM_ENGINE_CE;
subdev->inst = subdev->index - NVKM_ENGINE_CE0;
break;
case NVKM_ENGINE_NVENC0 ... NVKM_ENGINE_NVENC_LAST:
subdev->type = NVKM_ENGINE_NVENC;
subdev->inst = subdev->index - NVKM_ENGINE_NVENC0;
......
......@@ -63,16 +63,9 @@ gf100_ce1 = {
};
int
gf100_ce_new(struct nvkm_device *device, int index,
gf100_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_engine **pengine)
{
if (index == NVKM_ENGINE_CE0) {
return nvkm_falcon_new_(&gf100_ce0, device, index, true,
0x104000, pengine);
} else
if (index == NVKM_ENGINE_CE1) {
return nvkm_falcon_new_(&gf100_ce1, device, index, true,
0x105000, pengine);
}
return -ENODEV;
return nvkm_falcon_new_(inst ? &gf100_ce1 : &gf100_ce0, device, type, inst, true,
0x104000 + (inst * 0x1000), pengine);
}
......@@ -94,8 +94,8 @@ gk104_ce = {
};
int
gk104_ce_new(struct nvkm_device *device, int index,
gk104_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_engine **pengine)
{
return nvkm_engine_new_(&gk104_ce, device, index, true, pengine);
return nvkm_engine_new_(&gk104_ce, device, type, inst, true, pengine);
}
......@@ -36,8 +36,8 @@ gm107_ce = {
};
int
gm107_ce_new(struct nvkm_device *device, int index,
gm107_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_engine **pengine)
{
return nvkm_engine_new_(&gm107_ce, device, index, true, pengine);
return nvkm_engine_new_(&gm107_ce, device, type, inst, true, pengine);
}
......@@ -35,8 +35,8 @@ gm200_ce = {
};
int
gm200_ce_new(struct nvkm_device *device, int index,
gm200_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_engine **pengine)
{
return nvkm_engine_new_(&gm200_ce, device, index, true, pengine);
return nvkm_engine_new_(&gm200_ce, device, type, inst, true, pengine);
}
......@@ -95,8 +95,8 @@ gp100_ce = {
};
int
gp100_ce_new(struct nvkm_device *device, int index,
gp100_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_engine **pengine)
{
return nvkm_engine_new_(&gp100_ce, device, index, true, pengine);
return nvkm_engine_new_(&gp100_ce, device, type, inst, true, pengine);
}
......@@ -37,8 +37,8 @@ gp102_ce = {
};
int
gp102_ce_new(struct nvkm_device *device, int index,
gp102_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_engine **pengine)
{
return nvkm_engine_new_(&gp102_ce, device, index, true, pengine);
return nvkm_engine_new_(&gp102_ce, device, type, inst, true, pengine);
}
......@@ -75,9 +75,9 @@ gt215_ce = {
};
int
gt215_ce_new(struct nvkm_device *device, int index,
gt215_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_engine **pengine)
{
return nvkm_falcon_new_(&gt215_ce, device, index,
return nvkm_falcon_new_(&gt215_ce, device, type, inst,
(device->chipset != 0xaf), 0x104000, pengine);
}
......@@ -33,8 +33,8 @@ gv100_ce = {
};
int
gv100_ce_new(struct nvkm_device *device, int index,
gv100_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_engine **pengine)
{
return nvkm_engine_new_(&gv100_ce, device, index, true, pengine);
return nvkm_engine_new_(&gv100_ce, device, type, inst, true, pengine);
}
......@@ -33,8 +33,8 @@ tu102_ce = {
};
int
tu102_ce_new(struct nvkm_device *device, int index,
tu102_ce_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
struct nvkm_engine **pengine)
{
return nvkm_engine_new_(&tu102_ce, device, index, true, pengine);
return nvkm_engine_new_(&tu102_ce, device, type, inst, true, pengine);
}
......@@ -335,9 +335,9 @@ nvkm_falcon = {
};
int
nvkm_falcon_new_(const struct nvkm_falcon_func *func,
struct nvkm_device *device, int index, bool enable,
u32 addr, struct nvkm_engine **pengine)
nvkm_falcon_new__(const struct nvkm_falcon_func *func, bool old, struct nvkm_device *device,
enum nvkm_subdev_type type, int inst, bool enable, u32 addr,
struct nvkm_engine **pengine)
{
struct nvkm_falcon *falcon;
......@@ -351,6 +351,5 @@ nvkm_falcon_new_(const struct nvkm_falcon_func *func,
falcon->data.size = func->data.size;
*pengine = &falcon->engine;
return nvkm_engine_ctor(&nvkm_falcon, device, index,
enable, &falcon->engine);
return nvkm_engine_ctor_(&nvkm_falcon, old, device, type, inst, enable, &falcon->engine);
}
......@@ -83,9 +83,9 @@ gf100_devinit_disable(struct nvkm_devinit *init)
if (r022500 & 0x00000008)
disable |= (1ULL << NVKM_ENGINE_MSENC);
if (r022500 & 0x00000100)
disable |= (1ULL << NVKM_ENGINE_CE0);
nvkm_subdev_disable(device, NVKM_ENGINE_CE, 0);
if (r022500 & 0x00000200)
disable |= (1ULL << NVKM_ENGINE_CE1);
nvkm_subdev_disable(device, NVKM_ENGINE_CE, 1);
return disable;
}
......
......@@ -35,9 +35,9 @@ gm107_devinit_disable(struct nvkm_devinit *init)
u64 disable = 0ULL;
if (r021c00 & 0x00000001)
disable |= (1ULL << NVKM_ENGINE_CE0);
nvkm_subdev_disable(device, NVKM_ENGINE_CE, 0);
if (r021c00 & 0x00000004)
disable |= (1ULL << NVKM_ENGINE_CE2);
nvkm_subdev_disable(device, NVKM_ENGINE_CE, 2);
if (r021c04 & 0x00000001)
disable |= (1ULL << NVKM_ENGINE_DISP);
......
......@@ -80,7 +80,7 @@ gt215_devinit_disable(struct nvkm_devinit *init)
if (!(r00154c & 0x00000020))
disable |= (1ULL << NVKM_ENGINE_MSVLD);
if (!(r00154c & 0x00000200))
disable |= (1ULL << NVKM_ENGINE_CE0);
nvkm_subdev_disable(device, NVKM_ENGINE_CE, 0);
return disable;
}
......
......@@ -46,7 +46,7 @@ mcp89_devinit_disable(struct nvkm_devinit *init)
if (!(r00154c & 0x00000040))
disable |= (1ULL << NVKM_ENGINE_VIC);
if (!(r00154c & 0x00000200))
disable |= (1ULL << NVKM_ENGINE_CE0);
nvkm_subdev_disable(device, NVKM_ENGINE_CE, 0);
return disable;
}
......
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