summaryrefslogtreecommitdiff
path: root/drm
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2015-08-20 14:54:13 +1000
committerBen Skeggs <bskeggs@redhat.com>2015-08-28 12:37:34 +1000
commit2ae96906e23cca5655721ac0458b657f652ac119 (patch)
tree45ce11a9ad64d47a75a0a8cbbabf31e703186cec /drm
parent4e82a4beaf2214794bbb748a30d9d33b24465d37 (diff)
downloadnouveau-2ae96906e23cca5655721ac0458b657f652ac119.tar.gz
imem: remove object accessor functions
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drm')
-rw-r--r--drm/nouveau/include/nvkm/subdev/instmem.h7
-rw-r--r--drm/nouveau/nvkm/engine/gr/nv04.c2
-rw-r--r--drm/nouveau/nvkm/engine/mpeg/nv31.c6
-rw-r--r--drm/nouveau/nvkm/engine/mpeg/nv40.c6
-rw-r--r--drm/nouveau/nvkm/subdev/instmem/nv04.c24
-rw-r--r--drm/nouveau/nvkm/subdev/instmem/nv40.c18
6 files changed, 40 insertions, 23 deletions
diff --git a/drm/nouveau/include/nvkm/subdev/instmem.h b/drm/nouveau/include/nvkm/subdev/instmem.h
index d8941b7be..b6906f436 100644
--- a/drm/nouveau/include/nvkm/subdev/instmem.h
+++ b/drm/nouveau/include/nvkm/subdev/instmem.h
@@ -26,6 +26,13 @@ struct nvkm_instmem {
u32 reserved;
int (*alloc)(struct nvkm_instmem *, struct nvkm_object *,
u32 size, u32 align, struct nvkm_object **);
+
+ const struct nvkm_instmem_func *func;
+};
+
+struct nvkm_instmem_func {
+ u32 (*rd32)(struct nvkm_instmem *, u32 addr);
+ void (*wr32)(struct nvkm_instmem *, u32 addr, u32 data);
};
static inline struct nvkm_instmem *
diff --git a/drm/nouveau/nvkm/engine/gr/nv04.c b/drm/nouveau/nvkm/engine/gr/nv04.c
index a44571297..7295a9159 100644
--- a/drm/nouveau/nvkm/engine/gr/nv04.c
+++ b/drm/nouveau/nvkm/engine/gr/nv04.c
@@ -573,7 +573,7 @@ nv04_gr_mthd_bind_class(struct nvkm_object *object, u32 *args, u32 size)
{
struct nvkm_instmem *imem = nvkm_instmem(object);
u32 inst = *(u32 *)args << 4;
- return nv_ro32(imem, inst);
+ return imem->func->rd32(imem, inst);
}
static int
diff --git a/drm/nouveau/nvkm/engine/mpeg/nv31.c b/drm/nouveau/nvkm/engine/mpeg/nv31.c
index 4ece5c065..d4d1abba0 100644
--- a/drm/nouveau/nvkm/engine/mpeg/nv31.c
+++ b/drm/nouveau/nvkm/engine/mpeg/nv31.c
@@ -63,9 +63,9 @@ nv31_mpeg_mthd_dma(struct nvkm_object *object, u32 mthd, void *arg, u32 len)
struct nvkm_device *device = mpeg->base.engine.subdev.device;
struct nvkm_instmem *imem = device->imem;
u32 inst = *(u32 *)arg << 4;
- u32 dma0 = nv_ro32(imem, inst + 0);
- u32 dma1 = nv_ro32(imem, inst + 4);
- u32 dma2 = nv_ro32(imem, inst + 8);
+ u32 dma0 = imem->func->rd32(imem, inst + 0);
+ u32 dma1 = imem->func->rd32(imem, inst + 4);
+ u32 dma2 = imem->func->rd32(imem, inst + 8);
u32 base = (dma2 & 0xfffff000) | (dma0 >> 20);
u32 size = dma1 + 1;
diff --git a/drm/nouveau/nvkm/engine/mpeg/nv40.c b/drm/nouveau/nvkm/engine/mpeg/nv40.c
index 47ae1d890..7c009c3aa 100644
--- a/drm/nouveau/nvkm/engine/mpeg/nv40.c
+++ b/drm/nouveau/nvkm/engine/mpeg/nv40.c
@@ -36,9 +36,9 @@ nv40_mpeg_mthd_dma(struct nvkm_object *object, u32 mthd, void *arg, u32 len)
struct nvkm_device *device = mpeg->base.engine.subdev.device;
struct nvkm_instmem *imem = device->imem;
u32 inst = *(u32 *)arg << 4;
- u32 dma0 = nv_ro32(imem, inst + 0);
- u32 dma1 = nv_ro32(imem, inst + 4);
- u32 dma2 = nv_ro32(imem, inst + 8);
+ u32 dma0 = imem->func->rd32(imem, inst + 0);
+ u32 dma1 = imem->func->rd32(imem, inst + 4);
+ u32 dma2 = imem->func->rd32(imem, inst + 8);
u32 base = (dma2 & 0xfffff000) | (dma0 >> 20);
u32 size = dma1 + 1;
diff --git a/drm/nouveau/nvkm/subdev/instmem/nv04.c b/drm/nouveau/nvkm/subdev/instmem/nv04.c
index 6410cc1fd..8ba95f366 100644
--- a/drm/nouveau/nvkm/subdev/instmem/nv04.c
+++ b/drm/nouveau/nvkm/subdev/instmem/nv04.c
@@ -32,17 +32,17 @@
static u32
nv04_instobj_rd32(struct nvkm_object *object, u64 addr)
{
- struct nv04_instmem *imem = (void *)nvkm_instmem(object);
+ struct nvkm_instmem *imem = nvkm_instmem(object);
struct nv04_instobj *node = (void *)object;
- return nv_ro32(imem, node->mem->offset + addr);
+ return imem->func->rd32(imem, node->mem->offset + addr);
}
static void
nv04_instobj_wr32(struct nvkm_object *object, u64 addr, u32 data)
{
- struct nv04_instmem *imem = (void *)nvkm_instmem(object);
+ struct nvkm_instmem *imem = nvkm_instmem(object);
struct nv04_instobj *node = (void *)object;
- nv_wo32(imem, node->mem->offset + addr, data);
+ imem->func->wr32(imem, node->mem->offset + addr, data);
}
static void
@@ -103,16 +103,14 @@ nv04_instobj_oclass = {
*****************************************************************************/
static u32
-nv04_instmem_rd32(struct nvkm_object *object, u64 addr)
+nv04_instmem_rd32(struct nvkm_instmem *imem, u32 addr)
{
- struct nvkm_instmem *imem = (void *)object;
return nvkm_rd32(imem->subdev.device, 0x700000 + addr);
}
static void
-nv04_instmem_wr32(struct nvkm_object *object, u64 addr, u32 data)
+nv04_instmem_wr32(struct nvkm_instmem *imem, u32 addr, u32 data)
{
- struct nvkm_instmem *imem = (void *)object;
nvkm_wr32(imem->subdev.device, 0x700000 + addr, data);
}
@@ -130,6 +128,12 @@ nv04_instmem_dtor(struct nvkm_object *object)
nvkm_instmem_destroy(&imem->base);
}
+static const struct nvkm_instmem_func
+nv04_instmem_func = {
+ .rd32 = nv04_instmem_rd32,
+ .wr32 = nv04_instmem_wr32,
+};
+
static int
nv04_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
@@ -143,6 +147,8 @@ nv04_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
if (ret)
return ret;
+ imem->base.func = &nv04_instmem_func;
+
/* PRAMIN aperture maps over the end of VRAM, reserve it */
imem->base.reserved = 512 * 1024;
@@ -184,8 +190,6 @@ nv04_instmem_oclass = &(struct nvkm_instmem_impl) {
.dtor = nv04_instmem_dtor,
.init = _nvkm_instmem_init,
.fini = _nvkm_instmem_fini,
- .rd32 = nv04_instmem_rd32,
- .wr32 = nv04_instmem_wr32,
},
.instobj = &nv04_instobj_oclass.base,
}.base;
diff --git a/drm/nouveau/nvkm/subdev/instmem/nv40.c b/drm/nouveau/nvkm/subdev/instmem/nv40.c
index c194a28b7..c645e0261 100644
--- a/drm/nouveau/nvkm/subdev/instmem/nv40.c
+++ b/drm/nouveau/nvkm/subdev/instmem/nv40.c
@@ -31,19 +31,25 @@
*****************************************************************************/
static u32
-nv40_instmem_rd32(struct nvkm_object *object, u64 addr)
+nv40_instmem_rd32(struct nvkm_instmem *obj, u32 addr)
{
- struct nv04_instmem *imem = (void *)object;
+ struct nv04_instmem *imem = container_of(obj, typeof(*imem), base);
return ioread32_native(imem->iomem + addr);
}
static void
-nv40_instmem_wr32(struct nvkm_object *object, u64 addr, u32 data)
+nv40_instmem_wr32(struct nvkm_instmem *obj, u32 addr, u32 data)
{
- struct nv04_instmem *imem = (void *)object;
+ struct nv04_instmem *imem = container_of(obj, typeof(*imem), base);
iowrite32_native(data, imem->iomem + addr);
}
+static const struct nvkm_instmem_func
+nv40_instmem_func = {
+ .rd32 = nv40_instmem_rd32,
+ .wr32 = nv40_instmem_wr32,
+};
+
static int
nv40_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
@@ -58,6 +64,8 @@ nv40_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
if (ret)
return ret;
+ imem->base.func = &nv40_instmem_func;
+
/* map bar */
if (nv_device_resource_len(device, 2))
bar = 2;
@@ -129,8 +137,6 @@ nv40_instmem_oclass = &(struct nvkm_instmem_impl) {
.dtor = nv04_instmem_dtor,
.init = _nvkm_instmem_init,
.fini = _nvkm_instmem_fini,
- .rd32 = nv40_instmem_rd32,
- .wr32 = nv40_instmem_wr32,
},
.instobj = &nv04_instobj_oclass.base,
}.base;