Commit 0fa5680c authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/vic: switch to instanced constructor

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent 8d6461d8
...@@ -32,7 +32,6 @@ struct nvkm_device { ...@@ -32,7 +32,6 @@ struct nvkm_device {
struct nvkm_event event; struct nvkm_event event;
u64 disable_mask;
u32 debug; u32 debug;
const struct nvkm_device_chip *chip; const struct nvkm_device_chip *chip;
...@@ -60,8 +59,6 @@ struct nvkm_device { ...@@ -60,8 +59,6 @@ struct nvkm_device {
struct notifier_block nb; struct notifier_block nb;
} acpi; } acpi;
struct nvkm_engine *vic;
#define NVKM_LAYOUT_ONCE(type,data,ptr) data *ptr; #define NVKM_LAYOUT_ONCE(type,data,ptr) data *ptr;
#define NVKM_LAYOUT_INST(type,data,ptr,cnt) data *ptr[cnt]; #define NVKM_LAYOUT_INST(type,data,ptr,cnt) data *ptr[cnt];
#include <core/layout.h> #include <core/layout.h>
...@@ -101,8 +98,6 @@ struct nvkm_device_chip { ...@@ -101,8 +98,6 @@ struct nvkm_device_chip {
#include <core/layout.h> #include <core/layout.h>
#undef NVKM_LAYOUT_INST #undef NVKM_LAYOUT_INST
#undef NVKM_LAYOUT_ONCE #undef NVKM_LAYOUT_ONCE
int (*vic )(struct nvkm_device *, int idx, struct nvkm_engine **);
}; };
struct nvkm_device *nvkm_device_find(u64 name); struct nvkm_device *nvkm_device_find(u64 name);
......
...@@ -45,4 +45,5 @@ NVKM_LAYOUT_ONCE(NVKM_ENGINE_PM , struct nvkm_pm , pm) ...@@ -45,4 +45,5 @@ 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_SW , struct nvkm_sw , sw)
NVKM_LAYOUT_ONCE(NVKM_ENGINE_VIC , struct nvkm_engine , vic)
NVKM_LAYOUT_ONCE(NVKM_ENGINE_VP , struct nvkm_engine , vp) NVKM_LAYOUT_ONCE(NVKM_ENGINE_VP , struct nvkm_engine , vp)
...@@ -14,8 +14,7 @@ struct nvkm_devinit { ...@@ -14,8 +14,7 @@ struct nvkm_devinit {
u32 nvkm_devinit_mmio(struct nvkm_devinit *, u32 addr); u32 nvkm_devinit_mmio(struct nvkm_devinit *, u32 addr);
int nvkm_devinit_pll_set(struct nvkm_devinit *, u32 type, u32 khz); int nvkm_devinit_pll_set(struct nvkm_devinit *, u32 type, u32 khz);
void nvkm_devinit_meminit(struct nvkm_devinit *); void nvkm_devinit_meminit(struct nvkm_devinit *);
u64 nvkm_devinit_disable(struct nvkm_devinit *); int nvkm_devinit_post(struct nvkm_devinit *);
int nvkm_devinit_post(struct nvkm_devinit *, u64 *disable);
int nv04_devinit_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_devinit **); int nv04_devinit_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_devinit **);
int nv05_devinit_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_devinit **); int nv05_devinit_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_devinit **);
......
...@@ -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_VIC ] = "vic",
}; };
void void
......
...@@ -2644,9 +2644,6 @@ nvkm_device_subdev(struct nvkm_device *device, int type, int inst) ...@@ -2644,9 +2644,6 @@ nvkm_device_subdev(struct nvkm_device *device, int type, int inst)
{ {
struct nvkm_subdev *subdev; struct nvkm_subdev *subdev;
if (device->disable_mask & (1ULL << (type + inst)))
return NULL;
list_for_each_entry(subdev, &device->subdev, head) { list_for_each_entry(subdev, &device->subdev, head) {
if (subdev->index == type + inst) if (subdev->index == type + inst)
return subdev; return subdev;
...@@ -2725,7 +2722,7 @@ nvkm_device_preinit(struct nvkm_device *device) ...@@ -2725,7 +2722,7 @@ nvkm_device_preinit(struct nvkm_device *device)
goto fail; goto fail;
} }
ret = nvkm_devinit_post(device->devinit, &device->disable_mask); ret = nvkm_devinit_post(device->devinit);
if (ret) if (ret)
goto fail; goto fail;
...@@ -2790,7 +2787,6 @@ nvkm_device_del(struct nvkm_device **pdevice) ...@@ -2790,7 +2787,6 @@ nvkm_device_del(struct nvkm_device **pdevice)
struct nvkm_subdev *subdev, *subtmp; struct nvkm_subdev *subdev, *subtmp;
if (device) { if (device) {
mutex_lock(&nv_devices_mutex); mutex_lock(&nv_devices_mutex);
device->disable_mask = 0;
list_for_each_entry_safe_reverse(subdev, subtmp, &device->subdev, head) list_for_each_entry_safe_reverse(subdev, subtmp, &device->subdev, head)
nvkm_subdev_del(&subdev); nvkm_subdev_del(&subdev);
...@@ -3104,21 +3100,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func, ...@@ -3104,21 +3100,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
mutex_init(&device->mutex); mutex_init(&device->mutex);
for (i = 0; i < NVKM_SUBDEV_NR; i++) { for (i = 0; i < NVKM_SUBDEV_NR; i++) {
#define _(s,m) case s: \
if (device->chip->m && (subdev_mask & (1ULL << (s)))) { \
ret = device->chip->m(device, (s), &device->m); \
if (ret) { \
subdev = nvkm_device_subdev(device, (s), 0); \
nvkm_subdev_del(&subdev); \
device->m = NULL; \
if (ret != -ENODEV) { \
nvdev_error(device, "%s ctor failed, %d\n", \
nvkm_subdev_type[(s)], ret); \
goto done; \
} \
} \
} \
break
switch (i) { switch (i) {
#define NVKM_LAYOUT_ONCE(type,data,ptr) case type: \ #define NVKM_LAYOUT_ONCE(type,data,ptr) case type: \
if (device->chip->ptr.inst && (subdev_mask & (BIT_ULL(type)))) { \ if (device->chip->ptr.inst && (subdev_mask & (BIT_ULL(type)))) { \
...@@ -3162,7 +3143,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func, ...@@ -3162,7 +3143,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
#include <core/layout.h> #include <core/layout.h>
#undef NVKM_LAYOUT_INST #undef NVKM_LAYOUT_INST
#undef NVKM_LAYOUT_ONCE #undef NVKM_LAYOUT_ONCE
_(NVKM_ENGINE_VIC , vic);
case NVKM_ENGINE_CE1: case NVKM_ENGINE_CE1:
case NVKM_ENGINE_CE2: case NVKM_ENGINE_CE2:
case NVKM_ENGINE_CE3: case NVKM_ENGINE_CE3:
...@@ -3180,7 +3160,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func, ...@@ -3180,7 +3160,6 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
WARN_ON(1); WARN_ON(1);
continue; continue;
} }
#undef _
} }
ret = 0; ret = 0;
......
...@@ -56,12 +56,12 @@ nvkm_devinit_disable(struct nvkm_devinit *init) ...@@ -56,12 +56,12 @@ nvkm_devinit_disable(struct nvkm_devinit *init)
} }
int int
nvkm_devinit_post(struct nvkm_devinit *init, u64 *disable) nvkm_devinit_post(struct nvkm_devinit *init)
{ {
int ret = 0; int ret = 0;
if (init && init->func->post) if (init && init->func->post)
ret = init->func->post(init, init->post); ret = init->func->post(init, init->post);
*disable = nvkm_devinit_disable(init); nvkm_devinit_disable(init);
return ret; return ret;
} }
......
...@@ -44,7 +44,7 @@ mcp89_devinit_disable(struct nvkm_devinit *init) ...@@ -44,7 +44,7 @@ mcp89_devinit_disable(struct nvkm_devinit *init)
if (!(r00154c & 0x00000020)) if (!(r00154c & 0x00000020))
nvkm_subdev_disable(device, NVKM_ENGINE_MSVLD, 0); nvkm_subdev_disable(device, NVKM_ENGINE_MSVLD, 0);
if (!(r00154c & 0x00000040)) if (!(r00154c & 0x00000040))
disable |= (1ULL << NVKM_ENGINE_VIC); nvkm_subdev_disable(device, NVKM_ENGINE_VIC, 0);
if (!(r00154c & 0x00000200)) if (!(r00154c & 0x00000200))
nvkm_subdev_disable(device, NVKM_ENGINE_CE, 0); nvkm_subdev_disable(device, NVKM_ENGINE_CE, 0);
......
...@@ -17,6 +17,7 @@ struct nvkm_devinit_func { ...@@ -17,6 +17,7 @@ struct nvkm_devinit_func {
void nvkm_devinit_ctor(const struct nvkm_devinit_func *, struct nvkm_device *, void nvkm_devinit_ctor(const struct nvkm_devinit_func *, struct nvkm_device *,
enum nvkm_subdev_type, int inst, struct nvkm_devinit *); enum nvkm_subdev_type, int inst, struct nvkm_devinit *);
u64 nvkm_devinit_disable(struct nvkm_devinit *);
int nv04_devinit_post(struct nvkm_devinit *, bool); int nv04_devinit_post(struct nvkm_devinit *, bool);
int tu102_devinit_post(struct nvkm_devinit *, bool); int tu102_devinit_post(struct nvkm_devinit *, bool);
......
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