summaryrefslogtreecommitdiff
path: root/drm/nouveau/nvkm/core
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2015-08-20 14:54:22 +1000
committerBen Skeggs <bskeggs@redhat.com>2015-08-28 12:37:44 +1000
commited4bb4e997bd83443c9bf6766c2de60d3a2f8897 (patch)
tree631a8691e3b81f1227d63328e30d7b27887f0245 /drm/nouveau/nvkm/core
parent724b52d8519cd6ed1f8123d08f4ff09fe7a85e4c (diff)
downloadnouveau-ed4bb4e997bd83443c9bf6766c2de60d3a2f8897.tar.gz
core: remove the remainder of the previous style
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drm/nouveau/nvkm/core')
-rw-r--r--drm/nouveau/nvkm/core/engine.c79
-rw-r--r--drm/nouveau/nvkm/core/gpuobj.c93
-rw-r--r--drm/nouveau/nvkm/core/object.c167
-rw-r--r--drm/nouveau/nvkm/core/oproxy.c2
-rw-r--r--drm/nouveau/nvkm/core/ramht.c45
-rw-r--r--drm/nouveau/nvkm/core/subdev.c223
6 files changed, 68 insertions, 541 deletions
diff --git a/drm/nouveau/nvkm/core/engine.c b/drm/nouveau/nvkm/core/engine.c
index 3fef9cc34..8a7bae7bd 100644
--- a/drm/nouveau/nvkm/core/engine.c
+++ b/drm/nouveau/nvkm/core/engine.c
@@ -67,29 +67,26 @@ nvkm_engine_tile(struct nvkm_engine *engine, int region)
}
static void
-nvkm_engine_intr(struct nvkm_subdev *obj)
+nvkm_engine_intr(struct nvkm_subdev *subdev)
{
- struct nvkm_engine *engine = container_of(obj, typeof(*engine), subdev);
+ struct nvkm_engine *engine = nvkm_engine(subdev);
if (engine->func->intr)
engine->func->intr(engine);
}
static int
-nvkm_engine_fini(struct nvkm_subdev *obj, bool suspend)
+nvkm_engine_fini(struct nvkm_subdev *subdev, bool suspend)
{
- struct nvkm_engine *engine = container_of(obj, typeof(*engine), subdev);
- if (engine->subdev.object.oclass)
- return engine->subdev.object.oclass->ofuncs->fini(&engine->subdev.object, suspend);
+ struct nvkm_engine *engine = nvkm_engine(subdev);
if (engine->func->fini)
return engine->func->fini(engine, suspend);
return 0;
}
static int
-nvkm_engine_init(struct nvkm_subdev *obj)
+nvkm_engine_init(struct nvkm_subdev *subdev)
{
- struct nvkm_engine *engine = container_of(obj, typeof(*engine), subdev);
- struct nvkm_subdev *subdev = &engine->subdev;
+ struct nvkm_engine *engine = nvkm_engine(subdev);
struct nvkm_fb *fb = subdev->device->fb;
int ret = 0, i;
s64 time;
@@ -99,9 +96,6 @@ nvkm_engine_init(struct nvkm_subdev *obj)
return ret;
}
- if (engine->subdev.object.oclass)
- return engine->subdev.object.oclass->ofuncs->init(&engine->subdev.object);
-
if (engine->func->oneinit && !engine->subdev.oneinit) {
nvkm_trace(subdev, "one-time init running...\n");
time = ktime_to_us(ktime_get());
@@ -125,13 +119,9 @@ nvkm_engine_init(struct nvkm_subdev *obj)
}
static void *
-nvkm_engine_dtor(struct nvkm_subdev *obj)
+nvkm_engine_dtor(struct nvkm_subdev *subdev)
{
- struct nvkm_engine *engine = container_of(obj, typeof(*engine), subdev);
- if (engine->subdev.object.oclass) {
- engine->subdev.object.oclass->ofuncs->dtor(&engine->subdev.object);
- return NULL;
- }
+ struct nvkm_engine *engine = nvkm_engine(subdev);
if (engine->func->dtor)
return engine->func->dtor(engine);
return engine;
@@ -173,56 +163,3 @@ nvkm_engine_new_(const struct nvkm_engine_func *func,
return nvkm_engine_ctor(func, device, index, pmc_enable,
enable, *pengine);
}
-
-struct nvkm_engine *
-nvkm_engine(void *obj, int idx)
-{
- obj = nvkm_subdev(obj, idx);
- if (obj && nv_iclass(obj, NV_ENGINE_CLASS))
- return nv_engine(obj);
- return NULL;
-}
-
-int
-nvkm_engine_create_(struct nvkm_object *parent, struct nvkm_object *engobj,
- struct nvkm_oclass *oclass, bool enable,
- const char *iname, const char *fname,
- int length, void **pobject)
-{
- struct nvkm_engine *engine;
- int ret;
-
- ret = nvkm_subdev_create_(parent, engobj, oclass, NV_ENGINE_CLASS,
- iname, fname, length, pobject);
- engine = *pobject;
- if (ret)
- return ret;
-
- if (parent) {
- struct nvkm_device *device = nv_device(parent);
- int engidx = nv_engidx(engine);
-
- if (device->disable_mask & (1ULL << engidx)) {
- if (!nvkm_boolopt(device->cfgopt, iname, false)) {
- nvkm_debug(&engine->subdev,
- "engine disabled by hw/fw\n");
- return -ENODEV;
- }
-
- nvkm_warn(&engine->subdev,
- "ignoring hw/fw engine disable\n");
- }
-
- if (!nvkm_boolopt(device->cfgopt, iname, enable)) {
- if (!enable)
- nvkm_warn(&engine->subdev,
- "disabled, %s=1 to enable\n", iname);
- return -ENODEV;
- }
- }
-
- INIT_LIST_HEAD(&engine->contexts);
- spin_lock_init(&engine->lock);
- engine->subdev.func = &nvkm_engine_func;
- return 0;
-}
diff --git a/drm/nouveau/nvkm/core/gpuobj.c b/drm/nouveau/nvkm/core/gpuobj.c
index b8fc539e0..c3a790eb8 100644
--- a/drm/nouveau/nvkm/core/gpuobj.c
+++ b/drm/nouveau/nvkm/core/gpuobj.c
@@ -218,99 +218,6 @@ nvkm_gpuobj_new(struct nvkm_device *device, u32 size, int align, bool zero,
return ret;
}
-void
-nvkm_gpuobj_destroy(struct nvkm_gpuobj *gpuobj)
-{
- if (gpuobj->node)
- nvkm_mm_free(&gpuobj->parent->heap, &gpuobj->node);
-
- gpuobj->heap.block_size = 1;
- nvkm_mm_fini(&gpuobj->heap);
-
- nvkm_memory_del(&gpuobj->memory);
- nvkm_object_destroy(&gpuobj->object);
-}
-
-#include <engine/fifo/chan.h>
-
-int
-nvkm_gpuobj_create_(struct nvkm_object *parent, struct nvkm_object *engine,
- struct nvkm_oclass *oclass, u32 pclass,
- struct nvkm_object *objgpu, u32 size, u32 align, u32 flags,
- int length, void **pobject)
-{
- struct nvkm_device *device = nv_device(parent);
- struct nvkm_gpuobj *pargpu = NULL;
- struct nvkm_gpuobj *gpuobj;
- struct nvkm_object *object = objgpu;
- const bool zero = (flags & NVOBJ_FLAG_ZERO_ALLOC);
- int ret;
-
- *pobject = NULL;
-
- while (object && object->func != &nvkm_fifo_chan_func)
- object = object->parent;
-
- if (object) {
- struct nvkm_fifo_chan *chan = nvkm_fifo_chan(object);
- pargpu = chan->inst;
- } else
- if (objgpu) {
- while ((objgpu = nv_pclass(objgpu, NV_GPUOBJ_CLASS))) {
- if (nv_gpuobj(objgpu)->heap.block_size)
- break;
- objgpu = objgpu->parent;
- }
-
- if (WARN_ON(objgpu == NULL))
- return -EINVAL;
- pargpu = nv_gpuobj(objgpu);
- }
-
- ret = nvkm_object_create_(parent, engine, oclass, pclass |
- NV_GPUOBJ_CLASS, length, pobject);
- gpuobj = *pobject;
- if (ret)
- return ret;
-
- ret = nvkm_gpuobj_ctor(device, size, align, zero, pargpu, gpuobj);
- if (!(flags & NVOBJ_FLAG_HEAP))
- gpuobj->heap.block_size = 0;
- return ret;
-}
-
-void
-_nvkm_gpuobj_dtor(struct nvkm_object *object)
-{
- nvkm_gpuobj_destroy(nv_gpuobj(object));
-}
-
-int
-_nvkm_gpuobj_init(struct nvkm_object *object)
-{
- return nvkm_gpuobj_init(nv_gpuobj(object));
-}
-
-int
-_nvkm_gpuobj_fini(struct nvkm_object *object, bool suspend)
-{
- return nvkm_gpuobj_fini(nv_gpuobj(object), suspend);
-}
-
-u32
-_nvkm_gpuobj_rd32(struct nvkm_object *object, u64 addr)
-{
- struct nvkm_gpuobj *gpuobj = nv_gpuobj(object);
- return nvkm_ro32(gpuobj, addr);
-}
-
-void
-_nvkm_gpuobj_wr32(struct nvkm_object *object, u64 addr, u32 data)
-{
- struct nvkm_gpuobj *gpuobj = nv_gpuobj(object);
- nvkm_wo32(gpuobj, addr, data);
-}
-
int
nvkm_gpuobj_map(struct nvkm_gpuobj *gpuobj, struct nvkm_vm *vm,
u32 access, struct nvkm_vma *vma)
diff --git a/drm/nouveau/nvkm/core/object.c b/drm/nouveau/nvkm/core/object.c
index 0680eae07..8976526b1 100644
--- a/drm/nouveau/nvkm/core/object.c
+++ b/drm/nouveau/nvkm/core/object.c
@@ -27,11 +27,6 @@
int
nvkm_object_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
{
- if (object->oclass) {
- if (object->oclass->ofuncs->mthd)
- return object->oclass->ofuncs->mthd(object, mthd, data, size);
- return -ENODEV;
- }
if (likely(object->func->mthd))
return object->func->mthd(object, mthd, data, size);
return -ENODEV;
@@ -41,11 +36,6 @@ int
nvkm_object_ntfy(struct nvkm_object *object, u32 mthd,
struct nvkm_event **pevent)
{
- if (object->oclass) {
- if (object->oclass->ofuncs->ntfy)
- return object->oclass->ofuncs->ntfy(object, mthd, pevent);
- return -ENODEV;
- }
if (likely(object->func->ntfy))
return object->func->ntfy(object, mthd, pevent);
return -ENODEV;
@@ -54,11 +44,6 @@ nvkm_object_ntfy(struct nvkm_object *object, u32 mthd,
int
nvkm_object_map(struct nvkm_object *object, u64 *addr, u32 *size)
{
- if (object->oclass) {
- if (object->oclass->ofuncs->map)
- return object->oclass->ofuncs->map(object, addr, size);
- return -ENODEV;
- }
if (likely(object->func->map))
return object->func->map(object, addr, size);
return -ENODEV;
@@ -67,14 +52,6 @@ nvkm_object_map(struct nvkm_object *object, u64 *addr, u32 *size)
int
nvkm_object_rd08(struct nvkm_object *object, u64 addr, u8 *data)
{
- if (object->oclass) {
- if (object->oclass->ofuncs->rd08) {
- *data = object->oclass->ofuncs->rd08(object, addr);
- return 0;
- }
- *data = 0x00;
- return -ENODEV;
- }
if (likely(object->func->rd08))
return object->func->rd08(object, addr, data);
return -ENODEV;
@@ -83,14 +60,6 @@ nvkm_object_rd08(struct nvkm_object *object, u64 addr, u8 *data)
int
nvkm_object_rd16(struct nvkm_object *object, u64 addr, u16 *data)
{
- if (object->oclass) {
- if (object->oclass->ofuncs->rd16) {
- *data = object->oclass->ofuncs->rd16(object, addr);
- return 0;
- }
- *data = 0x0000;
- return -ENODEV;
- }
if (likely(object->func->rd16))
return object->func->rd16(object, addr, data);
return -ENODEV;
@@ -99,14 +68,6 @@ nvkm_object_rd16(struct nvkm_object *object, u64 addr, u16 *data)
int
nvkm_object_rd32(struct nvkm_object *object, u64 addr, u32 *data)
{
- if (object->oclass) {
- if (object->oclass->ofuncs->rd32) {
- *data = object->oclass->ofuncs->rd32(object, addr);
- return 0;
- }
- *data = 0x00000000;
- return -ENODEV;
- }
if (likely(object->func->rd32))
return object->func->rd32(object, addr, data);
return -ENODEV;
@@ -115,13 +76,6 @@ nvkm_object_rd32(struct nvkm_object *object, u64 addr, u32 *data)
int
nvkm_object_wr08(struct nvkm_object *object, u64 addr, u8 data)
{
- if (object->oclass) {
- if (object->oclass->ofuncs->wr08) {
- object->oclass->ofuncs->wr08(object, addr, data);
- return 0;
- }
- return -ENODEV;
- }
if (likely(object->func->wr08))
return object->func->wr08(object, addr, data);
return -ENODEV;
@@ -130,13 +84,6 @@ nvkm_object_wr08(struct nvkm_object *object, u64 addr, u8 data)
int
nvkm_object_wr16(struct nvkm_object *object, u64 addr, u16 data)
{
- if (object->oclass) {
- if (object->oclass->ofuncs->wr16) {
- object->oclass->ofuncs->wr16(object, addr, data);
- return 0;
- }
- return -ENODEV;
- }
if (likely(object->func->wr16))
return object->func->wr16(object, addr, data);
return -ENODEV;
@@ -145,13 +92,6 @@ nvkm_object_wr16(struct nvkm_object *object, u64 addr, u16 data)
int
nvkm_object_wr32(struct nvkm_object *object, u64 addr, u32 data)
{
- if (object->oclass) {
- if (object->oclass->ofuncs->wr32) {
- object->oclass->ofuncs->wr32(object, addr, data);
- return 0;
- }
- return -ENODEV;
- }
if (likely(object->func->wr32))
return object->func->wr32(object, addr, data);
return -ENODEV;
@@ -161,8 +101,6 @@ int
nvkm_object_bind(struct nvkm_object *object, struct nvkm_gpuobj *gpuobj,
int align, struct nvkm_gpuobj **pgpuobj)
{
- if (object->oclass)
- return -ENODEV;
if (object->func->bind)
return object->func->bind(object, gpuobj, align, pgpuobj);
return -ENODEV;
@@ -171,8 +109,6 @@ nvkm_object_bind(struct nvkm_object *object, struct nvkm_gpuobj *gpuobj,
int
nvkm_object_fini(struct nvkm_object *object, bool suspend)
{
- if (object->oclass)
- return object->oclass->ofuncs->fini(object, suspend);
if (object->func->fini)
return object->func->fini(object, suspend);
return 0;
@@ -181,8 +117,6 @@ nvkm_object_fini(struct nvkm_object *object, bool suspend)
int
nvkm_object_init(struct nvkm_object *object)
{
- if (object->oclass)
- return object->oclass->ofuncs->init(object);
if (object->func->init)
return object->func->init(object);
return 0;
@@ -193,11 +127,6 @@ nvkm_object_del(struct nvkm_object **pobject)
{
struct nvkm_object *object = *pobject;
- if (object && object->oclass) {
- object->oclass->ofuncs->dtor(object);
- return;
- }
-
if (object && !WARN_ON(!object->func)) {
if (object->func->dtor)
*pobject = object->func->dtor(object);
@@ -214,14 +143,11 @@ nvkm_object_ctor(const struct nvkm_object_func *func,
object->func = func;
object->client = oclass->client;
object->engine = nvkm_engine_ref(oclass->engine);
- object->oclass_name = oclass->base.oclass;
+ object->oclass = oclass->base.oclass;
object->handle = oclass->handle;
object->parent = oclass->parent;
atomic_set(&object->refcount, 1);
atomic_set(&object->usecount, 0);
-#ifdef NVKM_OBJECT_MAGIC
- object->_magic = NVKM_OBJECT_MAGIC;
-#endif
}
int
@@ -251,97 +177,6 @@ nvkm_object_new(const struct nvkm_oclass *oclass, void *data, u32 size,
return nvkm_object_new_(func, oclass, data, size, pobject);
}
-int
-nvkm_object_create_(struct nvkm_object *parent, struct nvkm_object *engobj,
- struct nvkm_oclass *oclass, u32 pclass,
- int size, void **pobject)
-{
- struct nvkm_engine *engine = engobj ? nv_engine(engobj) : NULL;
- struct nvkm_object *object;
-
- object = *pobject = kzalloc(size, GFP_KERNEL);
- if (!object)
- return -ENOMEM;
-
- nvkm_object_ref(parent, &object->parent);
- object->engine = nvkm_engine_ref(engine);
- object->oclass = oclass;
- object->pclass = pclass;
- atomic_set(&object->refcount, 1);
- atomic_set(&object->usecount, 0);
-
-#ifdef NVKM_OBJECT_MAGIC
- object->_magic = NVKM_OBJECT_MAGIC;
-#endif
- return 0;
-}
-
-int
-_nvkm_object_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
- struct nvkm_oclass *oclass, void *data, u32 size,
- struct nvkm_object **pobject)
-{
- if (size != 0)
- return -ENOSYS;
- return nvkm_object_create(parent, engine, oclass, 0, pobject);
-}
-
-void
-nvkm_object_destroy(struct nvkm_object *object)
-{
- nvkm_engine_unref(&object->engine);
- nvkm_object_ref(NULL, &object->parent);
- kfree(object);
-}
-
-int
-_nvkm_object_init(struct nvkm_object *object)
-{
- return 0;
-}
-
-int
-_nvkm_object_fini(struct nvkm_object *object, bool suspend)
-{
- return 0;
-}
-
-struct nvkm_ofuncs
-nvkm_object_ofuncs = {
- .ctor = _nvkm_object_ctor,
- .dtor = nvkm_object_destroy,
- .init = _nvkm_object_init,
- .fini = _nvkm_object_fini,
-};
-
-int
-nvkm_object_old(struct nvkm_object *parent, struct nvkm_object *engine,
- struct nvkm_oclass *oclass, void *data, u32 size,
- struct nvkm_object **pobject)
-{
- struct nvkm_ofuncs *ofuncs = oclass->ofuncs;
- struct nvkm_object *object = NULL;
- int ret;
-
- ret = ofuncs->ctor(parent, engine, oclass, data, size, &object);
- *pobject = object;
- if (ret < 0) {
- if (object) {
- ofuncs->dtor(object);
- *pobject = NULL;
- }
-
- return ret;
- }
-
- if (ret == 0) {
- if (!nv_iclass(object, NV_SUBDEV_CLASS))
- atomic_set(&object->refcount, 1);
- }
-
- return 0;
-}
-
void
nvkm_object_ref(struct nvkm_object *obj, struct nvkm_object **ref)
{
diff --git a/drm/nouveau/nvkm/core/oproxy.c b/drm/nouveau/nvkm/core/oproxy.c
index b2b743587..f32aa0dc4 100644
--- a/drm/nouveau/nvkm/core/oproxy.c
+++ b/drm/nouveau/nvkm/core/oproxy.c
@@ -92,8 +92,6 @@ nvkm_oproxy_sclass(struct nvkm_object *object, int index,
{
struct nvkm_oproxy *oproxy = nvkm_oproxy(object);
oclass->parent = oproxy->object;
- if (oproxy->object->oclass)
- return -ENOSYS;
if (!oproxy->object->func->sclass)
return -ENODEV;
return oproxy->object->func->sclass(oproxy->object, index, oclass);
diff --git a/drm/nouveau/nvkm/core/ramht.c b/drm/nouveau/nvkm/core/ramht.c
index 307d53269..3216e157a 100644
--- a/drm/nouveau/nvkm/core/ramht.c
+++ b/drm/nouveau/nvkm/core/ramht.c
@@ -67,40 +67,27 @@ nvkm_ramht_update(struct nvkm_ramht *ramht, int co, struct nvkm_object *object,
data->chid = chid;
data->handle = handle;
- if (!object) {
- inst = 0;
- goto done;
- }
-
- if (nv_iclass(object, NV_GPUOBJ_CLASS)) {
- struct nvkm_gpuobj *gpuobj = nv_gpuobj(object);
- if (ramht->device->card_type >= NV_50)
- inst = gpuobj->node->offset;
- else
- inst = gpuobj->addr;
- goto done;
- }
+ if (object) {
+ ret = nvkm_object_bind(object, ramht->parent, 16, &data->inst);
+ if (ret) {
+ if (ret != -ENODEV) {
+ data->chid = -1;
+ return ret;
+ }
+ data->inst = NULL;
+ }
- ret = nvkm_object_bind(object, ramht->parent, 16, &data->inst);
- if (ret) {
- if (ret != -ENODEV) {
- data->chid = -1;
- return ret;
+ if (data->inst) {
+ if (ramht->device->card_type >= NV_50)
+ inst = data->inst->node->offset;
+ else
+ inst = data->inst->addr;
}
- data->inst = NULL;
- }
- if (data->inst) {
- if (ramht->device->card_type >= NV_50)
- inst = data->inst->node->offset;
- else
- inst = data->inst->addr;
+ if (addr < 0) context |= inst << -addr;
+ else context |= inst >> addr;
}
-done:
- if (addr < 0) context |= inst << -addr;
- else context |= inst >> addr;
-
nvkm_kmap(ramht->gpuobj);
nvkm_wo32(ramht->gpuobj, (co << 3) + 0, handle);
nvkm_wo32(ramht->gpuobj, (co << 3) + 4, context);
diff --git a/drm/nouveau/nvkm/core/subdev.c b/drm/nouveau/nvkm/core/subdev.c
index b0647c233..65e0cb35e 100644
--- a/drm/nouveau/nvkm/core/subdev.c
+++ b/drm/nouveau/nvkm/core/subdev.c
@@ -25,61 +25,55 @@
#include <core/device.h>
#include <core/option.h>
-static struct lock_class_key nvkm_subdev_lock_class[NVDEV_SUBDEV_NR];
+static struct lock_class_key nvkm_subdev_lock_class[NVKM_SUBDEV_NR];
const char *
-nvkm_subdev_name[64] = {
- [NVDEV_SUBDEV_BAR ] = "bar",
- [NVDEV_SUBDEV_VBIOS ] = "bios",
- [NVDEV_SUBDEV_BUS ] = "bus",
- [NVDEV_SUBDEV_CLK ] = "clk",
- [NVDEV_SUBDEV_DEVINIT] = "devinit",
- [NVDEV_SUBDEV_FB ] = "fb",
- [NVDEV_SUBDEV_FUSE ] = "fuse",
- [NVDEV_SUBDEV_GPIO ] = "gpio",
- [NVDEV_SUBDEV_I2C ] = "i2c",
- [NVDEV_SUBDEV_IBUS ] = "priv",
- [NVDEV_SUBDEV_INSTMEM] = "imem",
- [NVDEV_SUBDEV_LTC ] = "ltc",
- [NVDEV_SUBDEV_MC ] = "mc",
- [NVDEV_SUBDEV_MMU ] = "mmu",
- [NVDEV_SUBDEV_MXM ] = "mxm",
- [NVDEV_SUBDEV_PMU ] = "pmu",
- [NVDEV_SUBDEV_THERM ] = "therm",
- [NVDEV_SUBDEV_TIMER ] = "tmr",
- [NVDEV_SUBDEV_VOLT ] = "volt",
- [NVDEV_ENGINE_BSP ] = "bsp",
- [NVDEV_ENGINE_CE0 ] = "ce0",
- [NVDEV_ENGINE_CE1 ] = "ce1",
- [NVDEV_ENGINE_CE2 ] = "ce2",
- [NVDEV_ENGINE_CIPHER ] = "cipher",
- [NVDEV_ENGINE_DISP ] = "disp",
- [NVDEV_ENGINE_DMAOBJ ] = "dma",
- [NVDEV_ENGINE_FIFO ] = "fifo",
- [NVDEV_ENGINE_GR ] = "gr",
- [NVDEV_ENGINE_IFB ] = "ifb",
- [NVDEV_ENGINE_ME ] = "me",
- [NVDEV_ENGINE_MPEG ] = "mpeg",
- [NVDEV_ENGINE_MSENC ] = "msenc",
- [NVDEV_ENGINE_MSPDEC ] = "mspdec",
- [NVDEV_ENGINE_MSPPP ] = "msppp",
- [NVDEV_ENGINE_MSVLD ] = "msvld",
- [NVDEV_ENGINE_PM ] = "pm",
- [NVDEV_ENGINE_SEC ] = "sec",
- [NVDEV_ENGINE_SW ] = "sw",
- [NVDEV_ENGINE_VIC ] = "vic",
- [NVDEV_ENGINE_VP ] = "vp",
+nvkm_subdev_name[NVKM_SUBDEV_NR] = {
+ [NVKM_SUBDEV_BAR ] = "bar",
+ [NVKM_SUBDEV_VBIOS ] = "bios",
+ [NVKM_SUBDEV_BUS ] = "bus",
+ [NVKM_SUBDEV_CLK ] = "clk",
+ [NVKM_SUBDEV_DEVINIT] = "devinit",
+ [NVKM_SUBDEV_FB ] = "fb",
+ [NVKM_SUBDEV_FUSE ] = "fuse",
+ [NVKM_SUBDEV_GPIO ] = "gpio",
+ [NVKM_SUBDEV_I2C ] = "i2c",
+ [NVKM_SUBDEV_IBUS ] = "priv",
+ [NVKM_SUBDEV_INSTMEM] = "imem",
+ [NVKM_SUBDEV_LTC ] = "ltc",
+ [NVKM_SUBDEV_MC ] = "mc",
+ [NVKM_SUBDEV_MMU ] = "mmu",
+ [NVKM_SUBDEV_MXM ] = "mxm",
+ [NVKM_SUBDEV_PMU ] = "pmu",
+ [NVKM_SUBDEV_THERM ] = "therm",
+ [NVKM_SUBDEV_TIMER ] = "tmr",
+ [NVKM_SUBDEV_VOLT ] = "volt",
+ [NVKM_ENGINE_BSP ] = "bsp",
+ [NVKM_ENGINE_CE0 ] = "ce0",
+ [NVKM_ENGINE_CE1 ] = "ce1",
+ [NVKM_ENGINE_CE2 ] = "ce2",
+ [NVKM_ENGINE_CIPHER ] = "cipher",
+ [NVKM_ENGINE_DISP ] = "disp",
+ [NVKM_ENGINE_DMAOBJ ] = "dma",
+ [NVKM_ENGINE_FIFO ] = "fifo",
+ [NVKM_ENGINE_GR ] = "gr",
+ [NVKM_ENGINE_IFB ] = "ifb",
+ [NVKM_ENGINE_ME ] = "me",
+ [NVKM_ENGINE_MPEG ] = "mpeg",
+ [NVKM_ENGINE_MSENC ] = "msenc",
+ [NVKM_ENGINE_MSPDEC ] = "mspdec",
+ [NVKM_ENGINE_MSPPP ] = "msppp",
+ [NVKM_ENGINE_MSVLD ] = "msvld",
+ [NVKM_ENGINE_PM ] = "pm",
+ [NVKM_ENGINE_SEC ] = "sec",
+ [NVKM_ENGINE_SW ] = "sw",
+ [NVKM_ENGINE_VIC ] = "vic",
+ [NVKM_ENGINE_VP ] = "vp",
};
void
nvkm_subdev_intr(struct nvkm_subdev *subdev)
{
- if (subdev->object.oclass) {
- if (subdev->intr)
- subdev->intr(subdev);
- return;
- }
-
if (subdev->func->intr)
subdev->func->intr(subdev);
}
@@ -91,18 +85,10 @@ nvkm_subdev_fini(struct nvkm_subdev *subdev, bool suspend)
const char *action = suspend ? "suspend" : "fini";
u32 pmc_enable = subdev->pmc_enable;
s64 time;
- int ret;
nvkm_trace(subdev, "%s running...\n", action);
time = ktime_to_us(ktime_get());
- if (!subdev->func) {
- ret = subdev->object.oclass->ofuncs->fini(&subdev->object, suspend);
- if (ret)
- return ret;
- goto done;
- }
-
if (subdev->func->fini) {
int ret = subdev->func->fini(subdev, suspend);
if (ret) {
@@ -118,7 +104,6 @@ nvkm_subdev_fini(struct nvkm_subdev *subdev, bool suspend)
nvkm_rd32(device, 0x000200);
}
-done:
time = ktime_to_us(ktime_get()) - time;
nvkm_trace(subdev, "%s completed in %lldus\n", action, time);
return 0;
@@ -132,7 +117,7 @@ nvkm_subdev_preinit(struct nvkm_subdev *subdev)
nvkm_trace(subdev, "preinit running...\n");
time = ktime_to_us(ktime_get());
- if (!subdev->object.oclass && subdev->func->preinit) {
+ if (subdev->func->preinit) {
int ret = subdev->func->preinit(subdev);
if (ret) {
nvkm_error(subdev, "preinit failed, %d\n", ret);
@@ -154,13 +139,6 @@ nvkm_subdev_init(struct nvkm_subdev *subdev)
nvkm_trace(subdev, "init running...\n");
time = ktime_to_us(ktime_get());
- if (!subdev->func) {
- ret = subdev->object.oclass->ofuncs->init(&subdev->object);
- if (ret)
- return ret;
- goto done;
- }
-
if (subdev->func->oneinit && !subdev->oneinit) {
s64 time;
nvkm_trace(subdev, "one-time init running...\n");
@@ -184,7 +162,6 @@ nvkm_subdev_init(struct nvkm_subdev *subdev)
}
}
-done:
time = ktime_to_us(ktime_get()) - time;
nvkm_trace(subdev, "init completed in %lldus\n", time);
return 0;
@@ -196,11 +173,6 @@ nvkm_subdev_del(struct nvkm_subdev **psubdev)
struct nvkm_subdev *subdev = *psubdev;
s64 time;
- if (subdev && subdev->object.oclass) {
- subdev->object.oclass->ofuncs->dtor(&subdev->object);
- return;
- }
-
if (subdev && !WARN_ON(!subdev->func)) {
nvkm_trace(subdev, "destroy running...\n");
time = ktime_to_us(ktime_get());
@@ -213,18 +185,12 @@ nvkm_subdev_del(struct nvkm_subdev **psubdev)
}
}
-static const struct nvkm_object_func
-nvkm_subdev_func = {
-};
-
void
nvkm_subdev_ctor(const struct nvkm_subdev_func *func,
struct nvkm_device *device, int index, u32 pmc_enable,
struct nvkm_subdev *subdev)
{
const char *name = nvkm_subdev_name[index];
- struct nvkm_oclass hack = {};
- nvkm_object_ctor(&nvkm_subdev_func, &hack, &subdev->object);
subdev->func = func;
subdev->device = device;
subdev->index = index;
@@ -233,106 +199,3 @@ nvkm_subdev_ctor(const struct nvkm_subdev_func *func,
__mutex_init(&subdev->mutex, name, &nvkm_subdev_lock_class[index]);
subdev->debug = nvkm_dbgopt(device->dbgopt, name);
}
-
-struct nvkm_subdev *
-nvkm_subdev(void *obj, int idx)
-{
- struct nvkm_object *object = nv_object(obj);
- while (object && !nv_iclass(object, NV_SUBDEV_CLASS))
- object = object->parent;
- if (object == NULL || !object->parent || nv_subidx(nv_subdev(object)) != idx) {
- struct nvkm_device *device = nv_device(obj);
- return nvkm_device_subdev(device, idx);
- }
- return object ? nv_subdev(object) : NULL;
-}
-
-void
-nvkm_subdev_reset(struct nvkm_object *obj)
-{
- struct nvkm_subdev *subdev = container_of(obj, typeof(*subdev), object);
- nvkm_trace(subdev, "resetting...\n");
- nvkm_object_fini(&subdev->object, false);
- nvkm_trace(subdev, "reset\n");
-}
-
-int
-nvkm_subdev_init_old(struct nvkm_subdev *subdev)
-{
- int ret = _nvkm_object_init(&subdev->object);
- if (ret)
- return ret;
-
- nvkm_subdev_reset(&subdev->object);
- return 0;
-}
-
-int
-_nvkm_subdev_init(struct nvkm_object *object)
-{
- struct nvkm_subdev *subdev = (void *)object;
- return nvkm_subdev_init_old(subdev);
-}
-
-int
-nvkm_subdev_fini_old(struct nvkm_subdev *subdev, bool suspend)
-{
- struct nvkm_device *device = subdev->device;
-
- if (subdev->unit) {
- nvkm_mask(device, 0x000200, subdev->unit, 0x00000000);
- nvkm_mask(device, 0x000200, subdev->unit, subdev->unit);
- }
-
- return _nvkm_object_fini(&subdev->object, suspend);
-}
-
-int
-_nvkm_subdev_fini(struct nvkm_object *object, bool suspend)
-{
- struct nvkm_subdev *subdev = (void *)object;
- return nvkm_subdev_fini_old(subdev, suspend);
-}
-
-void
-nvkm_subdev_destroy(struct nvkm_subdev *subdev)
-{
- nvkm_object_destroy(&subdev->object);
-}
-
-void
-_nvkm_subdev_dtor(struct nvkm_object *object)
-{
- nvkm_subdev_destroy(nv_subdev(object));
-}
-
-int
-nvkm_subdev_create_(struct nvkm_object *parent, struct nvkm_object *engine,
- struct nvkm_oclass *oclass, u32 pclass,
- const char *subname, const char *sysname,
- int size, void **pobject)
-{
- const int subidx = oclass->handle & 0xff;
- const char *name = nvkm_subdev_name[subidx];
- struct nvkm_subdev *subdev;
- int ret;
-
- ret = nvkm_object_create_(parent, engine, oclass, pclass |
- NV_SUBDEV_CLASS, size, pobject);
- subdev = *pobject;
- if (ret)
- return ret;
-
- __mutex_init(&subdev->mutex, name, &nvkm_subdev_lock_class[subidx]);
- subdev->index = subidx;
-
- if (parent) {
- struct nvkm_device *device = nv_device(parent);
- subdev->debug = nvkm_dbgopt(device->dbgopt, name);
- subdev->device = device;
- } else {
- subdev->device = nv_device(subdev);
- }
-
- return 0;
-}