Commit 8d6461d8 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/sw: switch to instanced constructor

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent d1866250
...@@ -60,7 +60,6 @@ struct nvkm_device { ...@@ -60,7 +60,6 @@ struct nvkm_device {
struct notifier_block nb; struct notifier_block nb;
} acpi; } acpi;
struct nvkm_sw *sw;
struct nvkm_engine *vic; struct nvkm_engine *vic;
#define NVKM_LAYOUT_ONCE(type,data,ptr) data *ptr; #define NVKM_LAYOUT_ONCE(type,data,ptr) data *ptr;
...@@ -103,7 +102,6 @@ struct nvkm_device_chip { ...@@ -103,7 +102,6 @@ struct nvkm_device_chip {
#undef NVKM_LAYOUT_INST #undef NVKM_LAYOUT_INST
#undef NVKM_LAYOUT_ONCE #undef NVKM_LAYOUT_ONCE
int (*sw )(struct nvkm_device *, int idx, struct nvkm_sw **);
int (*vic )(struct nvkm_device *, int idx, struct nvkm_engine **); int (*vic )(struct nvkm_device *, int idx, struct nvkm_engine **);
}; };
......
...@@ -47,12 +47,8 @@ struct nvkm_engine_func { ...@@ -47,12 +47,8 @@ struct nvkm_engine_func {
struct nvkm_sclass sclass[]; struct nvkm_sclass sclass[];
}; };
int nvkm_engine_ctor_(const struct nvkm_engine_func *, bool old, struct nvkm_device *, int nvkm_engine_ctor(const struct nvkm_engine_func *, struct nvkm_device *,
enum nvkm_subdev_type, int inst, bool enable, struct nvkm_engine *); enum nvkm_subdev_type, int inst, bool enable, struct nvkm_engine *);
#define nvkm_engine_ctor_o(f,d,i, e,s) nvkm_engine_ctor_((f), true, (d), (i), -1 , (e), (s))
#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 nvkm_engine_new_(const struct nvkm_engine_func *, struct nvkm_device *,
enum nvkm_subdev_type, int, bool enable, struct nvkm_engine **); enum nvkm_subdev_type, int, bool enable, struct nvkm_engine **);
......
...@@ -44,4 +44,5 @@ NVKM_LAYOUT_INST(NVKM_ENGINE_NVENC , struct nvkm_nvenc , nvenc, 3) ...@@ -44,4 +44,5 @@ NVKM_LAYOUT_INST(NVKM_ENGINE_NVENC , struct nvkm_nvenc , nvenc, 3)
NVKM_LAYOUT_ONCE(NVKM_ENGINE_PM , struct nvkm_pm , pm) NVKM_LAYOUT_ONCE(NVKM_ENGINE_PM , struct nvkm_pm , pm)
NVKM_LAYOUT_ONCE(NVKM_ENGINE_SEC , struct nvkm_engine , sec) NVKM_LAYOUT_ONCE(NVKM_ENGINE_SEC , struct nvkm_engine , sec)
NVKM_LAYOUT_ONCE(NVKM_ENGINE_SEC2 , struct nvkm_sec2 , sec2) NVKM_LAYOUT_ONCE(NVKM_ENGINE_SEC2 , struct nvkm_sec2 , sec2)
NVKM_LAYOUT_ONCE(NVKM_ENGINE_SW , struct nvkm_sw , sw)
NVKM_LAYOUT_ONCE(NVKM_ENGINE_VP , struct nvkm_engine , vp) NVKM_LAYOUT_ONCE(NVKM_ENGINE_VP , struct nvkm_engine , vp)
...@@ -106,12 +106,8 @@ struct nvkm_subdev_func { ...@@ -106,12 +106,8 @@ struct nvkm_subdev_func {
extern const char *nvkm_subdev_type[NVKM_SUBDEV_NR]; extern const char *nvkm_subdev_type[NVKM_SUBDEV_NR];
int nvkm_subdev_new_(const struct nvkm_subdev_func *, struct nvkm_device *, enum nvkm_subdev_type, int nvkm_subdev_new_(const struct nvkm_subdev_func *, struct nvkm_device *, enum nvkm_subdev_type,
int inst, struct nvkm_subdev **); int inst, struct nvkm_subdev **);
void nvkm_subdev_ctor_(const struct nvkm_subdev_func *, bool old, struct nvkm_device *, void nvkm_subdev_ctor(const struct nvkm_subdev_func *, struct nvkm_device *,
enum nvkm_subdev_type, int inst, struct nvkm_subdev *); enum nvkm_subdev_type, int inst, struct nvkm_subdev *);
#define nvkm_subdev_ctor_o(f,d,i, s) nvkm_subdev_ctor_((f), true, (d), (i), -1 , (s))
#define nvkm_subdev_ctor_n(f,d,t,i,s) nvkm_subdev_ctor_((f), false, (d), (t), (i), (s))
#define nvkm_subdev_ctor__(_1,_2,_3,_4,_5,IMPL,...) IMPL
#define nvkm_subdev_ctor(A...) nvkm_subdev_ctor__(A, nvkm_subdev_ctor_n, nvkm_subdev_ctor_o)(A)
void nvkm_subdev_disable(struct nvkm_device *, enum nvkm_subdev_type, int inst); void nvkm_subdev_disable(struct nvkm_device *, enum nvkm_subdev_type, int inst);
void nvkm_subdev_del(struct nvkm_subdev **); void nvkm_subdev_del(struct nvkm_subdev **);
int nvkm_subdev_preinit(struct nvkm_subdev *); int nvkm_subdev_preinit(struct nvkm_subdev *);
......
...@@ -12,8 +12,8 @@ struct nvkm_sw { ...@@ -12,8 +12,8 @@ struct nvkm_sw {
bool nvkm_sw_mthd(struct nvkm_sw *sw, int chid, int subc, u32 mthd, u32 data); bool nvkm_sw_mthd(struct nvkm_sw *sw, int chid, int subc, u32 mthd, u32 data);
int nv04_sw_new(struct nvkm_device *, int, struct nvkm_sw **); int nv04_sw_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_sw **);
int nv10_sw_new(struct nvkm_device *, int, struct nvkm_sw **); int nv10_sw_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_sw **);
int nv50_sw_new(struct nvkm_device *, int, struct nvkm_sw **); int nv50_sw_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_sw **);
int gf100_sw_new(struct nvkm_device *, int, struct nvkm_sw **); int gf100_sw_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_sw **);
#endif #endif
...@@ -176,10 +176,10 @@ nvkm_engine = { ...@@ -176,10 +176,10 @@ nvkm_engine = {
}; };
int int
nvkm_engine_ctor_(const struct nvkm_engine_func *func, bool old, struct nvkm_device *device, nvkm_engine_ctor(const struct nvkm_engine_func *func, struct nvkm_device *device,
enum nvkm_subdev_type type, int inst, bool enable, struct nvkm_engine *engine) enum nvkm_subdev_type type, int inst, bool enable, struct nvkm_engine *engine)
{ {
nvkm_subdev_ctor_(&nvkm_engine, old, device, type, inst, &engine->subdev); nvkm_subdev_ctor(&nvkm_engine, device, type, inst, &engine->subdev);
engine->func = func; engine->func = func;
refcount_set(&engine->use.refcount, 0); refcount_set(&engine->use.refcount, 0);
mutex_init(&engine->use.mutex); mutex_init(&engine->use.mutex);
......
...@@ -33,7 +33,6 @@ nvkm_subdev_type[NVKM_SUBDEV_NR] = { ...@@ -33,7 +33,6 @@ nvkm_subdev_type[NVKM_SUBDEV_NR] = {
#include <core/layout.h> #include <core/layout.h>
#undef NVKM_LAYOUT_ONCE #undef NVKM_LAYOUT_ONCE
#undef NVKM_LAYOUT_INST #undef NVKM_LAYOUT_INST
[NVKM_ENGINE_SW ] = "sw",
[NVKM_ENGINE_VIC ] = "vic", [NVKM_ENGINE_VIC ] = "vic",
}; };
...@@ -169,9 +168,8 @@ nvkm_subdev_disable(struct nvkm_device *device, enum nvkm_subdev_type type, int ...@@ -169,9 +168,8 @@ nvkm_subdev_disable(struct nvkm_device *device, enum nvkm_subdev_type type, int
} }
void void
nvkm_subdev_ctor_(const struct nvkm_subdev_func *func, bool old, nvkm_subdev_ctor(const struct nvkm_subdev_func *func, struct nvkm_device *device,
struct nvkm_device *device, enum nvkm_subdev_type type, int inst, enum nvkm_subdev_type type, int inst, struct nvkm_subdev *subdev)
struct nvkm_subdev *subdev)
{ {
subdev->func = func; subdev->func = func;
subdev->device = device; subdev->device = device;
......
...@@ -97,7 +97,7 @@ nvkm_sw = { ...@@ -97,7 +97,7 @@ nvkm_sw = {
int int
nvkm_sw_new_(const struct nvkm_sw_func *func, struct nvkm_device *device, nvkm_sw_new_(const struct nvkm_sw_func *func, struct nvkm_device *device,
int index, struct nvkm_sw **psw) enum nvkm_subdev_type type, int inst, struct nvkm_sw **psw)
{ {
struct nvkm_sw *sw; struct nvkm_sw *sw;
...@@ -106,5 +106,5 @@ nvkm_sw_new_(const struct nvkm_sw_func *func, struct nvkm_device *device, ...@@ -106,5 +106,5 @@ nvkm_sw_new_(const struct nvkm_sw_func *func, struct nvkm_device *device,
INIT_LIST_HEAD(&sw->chan); INIT_LIST_HEAD(&sw->chan);
sw->func = func; sw->func = func;
return nvkm_engine_ctor(&nvkm_sw, device, index, true, &sw->engine); return nvkm_engine_ctor(&nvkm_sw, device, type, inst, true, &sw->engine);
} }
...@@ -149,7 +149,7 @@ gf100_sw = { ...@@ -149,7 +149,7 @@ gf100_sw = {
}; };
int int
gf100_sw_new(struct nvkm_device *device, int index, struct nvkm_sw **psw) gf100_sw_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_sw **psw)
{ {
return nvkm_sw_new_(&gf100_sw, device, index, psw); return nvkm_sw_new_(&gf100_sw, device, type, inst, psw);
} }
...@@ -133,7 +133,7 @@ nv04_sw = { ...@@ -133,7 +133,7 @@ nv04_sw = {
}; };
int int
nv04_sw_new(struct nvkm_device *device, int index, struct nvkm_sw **psw) nv04_sw_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_sw **psw)
{ {
return nvkm_sw_new_(&nv04_sw, device, index, psw); return nvkm_sw_new_(&nv04_sw, device, type, inst, psw);
} }
...@@ -62,7 +62,7 @@ nv10_sw = { ...@@ -62,7 +62,7 @@ nv10_sw = {
}; };
int int
nv10_sw_new(struct nvkm_device *device, int index, struct nvkm_sw **psw) nv10_sw_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_sw **psw)
{ {
return nvkm_sw_new_(&nv10_sw, device, index, psw); return nvkm_sw_new_(&nv10_sw, device, type, inst, psw);
} }
...@@ -142,7 +142,7 @@ nv50_sw = { ...@@ -142,7 +142,7 @@ nv50_sw = {
}; };
int int
nv50_sw_new(struct nvkm_device *device, int index, struct nvkm_sw **psw) nv50_sw_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_sw **psw)
{ {
return nvkm_sw_new_(&nv50_sw, device, index, psw); return nvkm_sw_new_(&nv50_sw, device, type, inst, psw);
} }
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#include <engine/sw.h> #include <engine/sw.h>
struct nvkm_sw_chan; struct nvkm_sw_chan;
int nvkm_sw_new_(const struct nvkm_sw_func *, struct nvkm_device *, int nvkm_sw_new_(const struct nvkm_sw_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
int index, struct nvkm_sw **); struct nvkm_sw **);
struct nvkm_sw_chan_sclass { struct nvkm_sw_chan_sclass {
int (*ctor)(struct nvkm_sw_chan *, const struct nvkm_oclass *, int (*ctor)(struct nvkm_sw_chan *, const struct nvkm_oclass *,
......
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