Commit c44c06ae authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/imem: cosmetic changes

This is purely preparation for upcoming commits, there should be no
code changes here.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent ac51596f
......@@ -21,7 +21,7 @@ nv_memobj(void *obj)
}
struct nvkm_instmem {
struct nvkm_subdev base;
struct nvkm_subdev subdev;
struct list_head list;
u32 reserved;
......
......@@ -559,7 +559,7 @@ nv04_fifo_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{
struct nv04_instmem_priv *imem = nv04_instmem(parent);
struct nv04_instmem *imem = nv04_instmem(parent);
struct nv04_fifo_priv *priv;
int ret;
......
......@@ -143,7 +143,7 @@ nv10_fifo_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{
struct nv04_instmem_priv *imem = nv04_instmem(parent);
struct nv04_instmem *imem = nv04_instmem(parent);
struct nv04_fifo_priv *priv;
int ret;
......
......@@ -150,7 +150,7 @@ nv17_fifo_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{
struct nv04_instmem_priv *imem = nv04_instmem(parent);
struct nv04_instmem *imem = nv04_instmem(parent);
struct nv04_fifo_priv *priv;
int ret;
......
......@@ -268,7 +268,7 @@ nv40_fifo_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{
struct nv04_instmem_priv *imem = nv04_instmem(parent);
struct nv04_instmem *imem = nv04_instmem(parent);
struct nv04_fifo_priv *priv;
int ret;
......
......@@ -56,9 +56,9 @@ nvkm_instobj_create_(struct nvkm_object *parent, struct nvkm_object *engine,
if (ret)
return ret;
mutex_lock(&imem->base.mutex);
mutex_lock(&imem->subdev.mutex);
list_add(&iobj->head, &imem->list);
mutex_unlock(&imem->base.mutex);
mutex_unlock(&imem->subdev.mutex);
return 0;
}
......@@ -70,7 +70,7 @@ static int
nvkm_instmem_alloc(struct nvkm_instmem *imem, struct nvkm_object *parent,
u32 size, u32 align, struct nvkm_object **pobject)
{
struct nvkm_instmem_impl *impl = (void *)imem->base.object.oclass;
struct nvkm_instmem_impl *impl = (void *)imem->subdev.object.oclass;
struct nvkm_instobj_args args = { .size = size, .align = align };
return nvkm_object_ctor(parent, &parent->engine->subdev.object,
impl->instobj, &args, sizeof(args), pobject);
......@@ -84,7 +84,7 @@ _nvkm_instmem_fini(struct nvkm_object *object, bool suspend)
int i, ret = 0;
if (suspend) {
mutex_lock(&imem->base.mutex);
mutex_lock(&imem->subdev.mutex);
list_for_each_entry(iobj, &imem->list, head) {
iobj->suspend = vmalloc(iobj->size);
if (!iobj->suspend) {
......@@ -95,12 +95,12 @@ _nvkm_instmem_fini(struct nvkm_object *object, bool suspend)
for (i = 0; i < iobj->size; i += 4)
iobj->suspend[i / 4] = nv_ro32(iobj, i);
}
mutex_unlock(&imem->base.mutex);
mutex_unlock(&imem->subdev.mutex);
if (ret)
return ret;
}
return nvkm_subdev_fini(&imem->base, suspend);
return nvkm_subdev_fini(&imem->subdev, suspend);
}
int
......@@ -110,11 +110,11 @@ _nvkm_instmem_init(struct nvkm_object *object)
struct nvkm_instobj *iobj;
int ret, i;
ret = nvkm_subdev_init(&imem->base);
ret = nvkm_subdev_init(&imem->subdev);
if (ret)
return ret;
mutex_lock(&imem->base.mutex);
mutex_lock(&imem->subdev.mutex);
list_for_each_entry(iobj, &imem->list, head) {
if (iobj->suspend) {
for (i = 0; i < iobj->size; i += 4)
......@@ -123,7 +123,7 @@ _nvkm_instmem_init(struct nvkm_object *object)
iobj->suspend = NULL;
}
}
mutex_unlock(&imem->base.mutex);
mutex_unlock(&imem->subdev.mutex);
return 0;
}
......
......@@ -32,30 +32,27 @@
static u32
nv04_instobj_rd32(struct nvkm_object *object, u64 addr)
{
struct nv04_instmem_priv *priv = (void *)nvkm_instmem(object);
struct nv04_instobj_priv *node = (void *)object;
return nv_ro32(priv, node->mem->offset + addr);
struct nv04_instmem *imem = (void *)nvkm_instmem(object);
struct nv04_instobj *node = (void *)object;
return nv_ro32(imem, node->mem->offset + addr);
}
static void
nv04_instobj_wr32(struct nvkm_object *object, u64 addr, u32 data)
{
struct nv04_instmem_priv *priv = (void *)nvkm_instmem(object);
struct nv04_instobj_priv *node = (void *)object;
nv_wo32(priv, node->mem->offset + addr, data);
struct nv04_instmem *imem = (void *)nvkm_instmem(object);
struct nv04_instobj *node = (void *)object;
nv_wo32(imem, node->mem->offset + addr, data);
}
static void
nv04_instobj_dtor(struct nvkm_object *object)
{
struct nv04_instmem_priv *priv = (void *)nvkm_instmem(object);
struct nv04_instobj_priv *node = (void *)object;
struct nvkm_subdev *subdev = (void *)priv;
mutex_lock(&subdev->mutex);
nvkm_mm_free(&priv->heap, &node->mem);
mutex_unlock(&subdev->mutex);
struct nv04_instmem *imem = (void *)nvkm_instmem(object);
struct nv04_instobj *node = (void *)object;
mutex_lock(&imem->base.subdev.mutex);
nvkm_mm_free(&imem->heap, &node->mem);
mutex_unlock(&imem->base.subdev.mutex);
nvkm_instobj_destroy(&node->base);
}
......@@ -64,10 +61,9 @@ nv04_instobj_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{
struct nv04_instmem_priv *priv = (void *)nvkm_instmem(parent);
struct nv04_instobj_priv *node;
struct nv04_instmem *imem = (void *)nvkm_instmem(parent);
struct nv04_instobj *node;
struct nvkm_instobj_args *args = data;
struct nvkm_subdev *subdev = (void *)priv;
int ret;
if (!args->align)
......@@ -78,10 +74,10 @@ nv04_instobj_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
if (ret)
return ret;
mutex_lock(&subdev->mutex);
ret = nvkm_mm_head(&priv->heap, 0, 1, args->size, args->size,
mutex_lock(&imem->base.subdev.mutex);
ret = nvkm_mm_head(&imem->heap, 0, 1, args->size, args->size,
args->align, &node->mem);
mutex_unlock(&subdev->mutex);
mutex_unlock(&imem->base.subdev.mutex);
if (ret)
return ret;
......@@ -121,15 +117,15 @@ nv04_instmem_wr32(struct nvkm_object *object, u64 addr, u32 data)
void
nv04_instmem_dtor(struct nvkm_object *object)
{
struct nv04_instmem_priv *priv = (void *)object;
nvkm_gpuobj_ref(NULL, &priv->ramfc);
nvkm_gpuobj_ref(NULL, &priv->ramro);
nvkm_ramht_ref(NULL, &priv->ramht);
nvkm_gpuobj_ref(NULL, &priv->vbios);
nvkm_mm_fini(&priv->heap);
if (priv->iomem)
iounmap(priv->iomem);
nvkm_instmem_destroy(&priv->base);
struct nv04_instmem *imem = (void *)object;
nvkm_gpuobj_ref(NULL, &imem->ramfc);
nvkm_gpuobj_ref(NULL, &imem->ramro);
nvkm_ramht_ref(NULL, &imem->ramht);
nvkm_gpuobj_ref(NULL, &imem->vbios);
nvkm_mm_fini(&imem->heap);
if (imem->iomem)
iounmap(imem->iomem);
nvkm_instmem_destroy(&imem->base);
}
static int
......@@ -137,41 +133,41 @@ nv04_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{
struct nv04_instmem_priv *priv;
struct nv04_instmem *imem;
int ret;
ret = nvkm_instmem_create(parent, engine, oclass, &priv);
*pobject = nv_object(priv);
ret = nvkm_instmem_create(parent, engine, oclass, &imem);
*pobject = nv_object(imem);
if (ret)
return ret;
/* PRAMIN aperture maps over the end of VRAM, reserve it */
priv->base.reserved = 512 * 1024;
imem->base.reserved = 512 * 1024;
ret = nvkm_mm_init(&priv->heap, 0, priv->base.reserved, 1);
ret = nvkm_mm_init(&imem->heap, 0, imem->base.reserved, 1);
if (ret)
return ret;
/* 0x00000-0x10000: reserve for probable vbios image */
ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x10000, 0, 0,
&priv->vbios);
ret = nvkm_gpuobj_new(nv_object(imem), NULL, 0x10000, 0, 0,
&imem->vbios);
if (ret)
return ret;
/* 0x10000-0x18000: reserve for RAMHT */
ret = nvkm_ramht_new(nv_object(priv), NULL, 0x08000, 0, &priv->ramht);
ret = nvkm_ramht_new(nv_object(imem), NULL, 0x08000, 0, &imem->ramht);
if (ret)
return ret;
/* 0x18000-0x18800: reserve for RAMFC (enough for 32 nv30 channels) */
ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x00800, 0,
NVOBJ_FLAG_ZERO_ALLOC, &priv->ramfc);
ret = nvkm_gpuobj_new(nv_object(imem), NULL, 0x00800, 0,
NVOBJ_FLAG_ZERO_ALLOC, &imem->ramfc);
if (ret)
return ret;
/* 0x18800-0x18a00: reserve for RAMRO */
ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x00200, 0, 0,
&priv->ramro);
ret = nvkm_gpuobj_new(nv_object(imem), NULL, 0x00200, 0, 0,
&imem->ramro);
if (ret)
return ret;
......
......@@ -6,7 +6,7 @@
extern struct nvkm_instobj_impl nv04_instobj_oclass;
struct nv04_instmem_priv {
struct nv04_instmem {
struct nvkm_instmem base;
void __iomem *iomem;
......@@ -18,13 +18,13 @@ struct nv04_instmem_priv {
struct nvkm_gpuobj *ramfc;
};
static inline struct nv04_instmem_priv *
static inline struct nv04_instmem *
nv04_instmem(void *obj)
{
return (void *)nvkm_instmem(obj);
}
struct nv04_instobj_priv {
struct nv04_instobj {
struct nvkm_instobj base;
struct nvkm_mm_node *mem;
};
......
......@@ -33,15 +33,15 @@
static u32
nv40_instmem_rd32(struct nvkm_object *object, u64 addr)
{
struct nv04_instmem_priv *priv = (void *)object;
return ioread32_native(priv->iomem + addr);
struct nv04_instmem *imem = (void *)object;
return ioread32_native(imem->iomem + addr);
}
static void
nv40_instmem_wr32(struct nvkm_object *object, u64 addr, u32 data)
{
struct nv04_instmem_priv *priv = (void *)object;
iowrite32_native(data, priv->iomem + addr);
struct nv04_instmem *imem = (void *)object;
iowrite32_native(data, imem->iomem + addr);
}
static int
......@@ -50,11 +50,11 @@ nv40_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_object **pobject)
{
struct nvkm_device *device = nv_device(parent);
struct nv04_instmem_priv *priv;
struct nv04_instmem *imem;
int ret, bar, vs;
ret = nvkm_instmem_create(parent, engine, oclass, &priv);
*pobject = nv_object(priv);
ret = nvkm_instmem_create(parent, engine, oclass, &imem);
*pobject = nv_object(imem);
if (ret)
return ret;
......@@ -64,10 +64,10 @@ nv40_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
else
bar = 3;
priv->iomem = ioremap(nv_device_resource_start(device, bar),
imem->iomem = ioremap(nv_device_resource_start(device, bar),
nv_device_resource_len(device, bar));
if (!priv->iomem) {
nv_error(priv, "unable to map PRAMIN BAR\n");
if (!imem->iomem) {
nv_error(imem, "unable to map PRAMIN BAR\n");
return -EFAULT;
}
......@@ -75,46 +75,46 @@ nv40_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
* to fit graphics contexts for every channel, the magics come
* from engine/gr/nv40.c
*/
vs = hweight8((nv_rd32(priv, 0x001540) & 0x0000ff00) >> 8);
if (device->chipset == 0x40) priv->base.reserved = 0x6aa0 * vs;
else if (device->chipset < 0x43) priv->base.reserved = 0x4f00 * vs;
else if (nv44_gr_class(priv)) priv->base.reserved = 0x4980 * vs;
else priv->base.reserved = 0x4a40 * vs;
priv->base.reserved += 16 * 1024;
priv->base.reserved *= 32; /* per-channel */
priv->base.reserved += 512 * 1024; /* pci(e)gart table */
priv->base.reserved += 512 * 1024; /* object storage */
priv->base.reserved = round_up(priv->base.reserved, 4096);
ret = nvkm_mm_init(&priv->heap, 0, priv->base.reserved, 1);
vs = hweight8((nv_rd32(imem, 0x001540) & 0x0000ff00) >> 8);
if (device->chipset == 0x40) imem->base.reserved = 0x6aa0 * vs;
else if (device->chipset < 0x43) imem->base.reserved = 0x4f00 * vs;
else if (nv44_gr_class(imem)) imem->base.reserved = 0x4980 * vs;
else imem->base.reserved = 0x4a40 * vs;
imem->base.reserved += 16 * 1024;
imem->base.reserved *= 32; /* per-channel */
imem->base.reserved += 512 * 1024; /* pci(e)gart table */
imem->base.reserved += 512 * 1024; /* object storage */
imem->base.reserved = round_up(imem->base.reserved, 4096);
ret = nvkm_mm_init(&imem->heap, 0, imem->base.reserved, 1);
if (ret)
return ret;
/* 0x00000-0x10000: reserve for probable vbios image */
ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x10000, 0, 0,
&priv->vbios);
ret = nvkm_gpuobj_new(nv_object(imem), NULL, 0x10000, 0, 0,
&imem->vbios);
if (ret)
return ret;
/* 0x10000-0x18000: reserve for RAMHT */
ret = nvkm_ramht_new(nv_object(priv), NULL, 0x08000, 0, &priv->ramht);
ret = nvkm_ramht_new(nv_object(imem), NULL, 0x08000, 0, &imem->ramht);
if (ret)
return ret;
/* 0x18000-0x18200: reserve for RAMRO
* 0x18200-0x20000: padding
*/
ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x08000, 0, 0,
&priv->ramro);
ret = nvkm_gpuobj_new(nv_object(imem), NULL, 0x08000, 0, 0,
&imem->ramro);
if (ret)
return ret;
/* 0x20000-0x21000: reserve for RAMFC
* 0x21000-0x40000: padding and some unknown crap
*/
ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x20000, 0,
NVOBJ_FLAG_ZERO_ALLOC, &priv->ramfc);
ret = nvkm_gpuobj_new(nv_object(imem), NULL, 0x20000, 0,
NVOBJ_FLAG_ZERO_ALLOC, &imem->ramfc);
if (ret)
return ret;
......
......@@ -25,13 +25,13 @@
#include <subdev/fb.h>
struct nv50_instmem_priv {
struct nv50_instmem {
struct nvkm_instmem base;
spinlock_t lock;
u64 addr;
};
struct nv50_instobj_priv {
struct nv50_instobj {
struct nvkm_instobj base;
struct nvkm_mem *mem;
};
......@@ -43,45 +43,45 @@ struct nv50_instobj_priv {
static u32
nv50_instobj_rd32(struct nvkm_object *object, u64 offset)
{
struct nv50_instmem_priv *priv = (void *)nvkm_instmem(object);
struct nv50_instobj_priv *node = (void *)object;
struct nv50_instmem *imem = (void *)nvkm_instmem(object);
struct nv50_instobj *node = (void *)object;
unsigned long flags;
u64 base = (node->mem->offset + offset) & 0xffffff00000ULL;
u64 addr = (node->mem->offset + offset) & 0x000000fffffULL;
u32 data;
spin_lock_irqsave(&priv->lock, flags);
if (unlikely(priv->addr != base)) {
nv_wr32(priv, 0x001700, base >> 16);
priv->addr = base;
spin_lock_irqsave(&imem->lock, flags);
if (unlikely(imem->addr != base)) {
nv_wr32(imem, 0x001700, base >> 16);
imem->addr = base;
}
data = nv_rd32(priv, 0x700000 + addr);
spin_unlock_irqrestore(&priv->lock, flags);
data = nv_rd32(imem, 0x700000 + addr);
spin_unlock_irqrestore(&imem->lock, flags);
return data;
}
static void
nv50_instobj_wr32(struct nvkm_object *object, u64 offset, u32 data)
{
struct nv50_instmem_priv *priv = (void *)nvkm_instmem(object);
struct nv50_instobj_priv *node = (void *)object;
struct nv50_instmem *imem = (void *)nvkm_instmem(object);
struct nv50_instobj *node = (void *)object;
unsigned long flags;
u64 base = (node->mem->offset + offset) & 0xffffff00000ULL;
u64 addr = (node->mem->offset + offset) & 0x000000fffffULL;
spin_lock_irqsave(&priv->lock, flags);
if (unlikely(priv->addr != base)) {
nv_wr32(priv, 0x001700, base >> 16);
priv->addr = base;
spin_lock_irqsave(&imem->lock, flags);
if (unlikely(imem->addr != base)) {
nv_wr32(imem, 0x001700, base >> 16);
imem->addr = base;
}
nv_wr32(priv, 0x700000 + addr, data);
spin_unlock_irqrestore(&priv->lock, flags);
nv_wr32(imem, 0x700000 + addr, data);
spin_unlock_irqrestore(&imem->lock, flags);
}
static void
nv50_instobj_dtor(struct nvkm_object *object)
{
struct nv50_instobj_priv *node = (void *)object;
struct nv50_instobj *node = (void *)object;
struct nvkm_fb *fb = nvkm_fb(object);
fb->ram->put(fb, &node->mem);
nvkm_instobj_destroy(&node->base);
......@@ -94,7 +94,7 @@ nv50_instobj_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
{
struct nvkm_fb *fb = nvkm_fb(parent);
struct nvkm_instobj_args *args = data;
struct nv50_instobj_priv *node;
struct nv50_instobj *node;
int ret;
args->size = max((args->size + 4095) & ~4095, (u32)4096);
......@@ -134,9 +134,9 @@ nv50_instobj_oclass = {
static int
nv50_instmem_fini(struct nvkm_object *object, bool suspend)
{
struct nv50_instmem_priv *priv = (void *)object;
priv->addr = ~0ULL;
return nvkm_instmem_fini(&priv->base, suspend);
struct nv50_instmem *imem = (void *)object;
imem->addr = ~0ULL;
return nvkm_instmem_fini(&imem->base, suspend);
}
static int
......@@ -144,15 +144,15 @@ nv50_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{
struct nv50_instmem_priv *priv;
struct nv50_instmem *imem;
int ret;
ret = nvkm_instmem_create(parent, engine, oclass, &priv);
*pobject = nv_object(priv);
ret = nvkm_instmem_create(parent, engine, oclass, &imem);
*pobject = nv_object(imem);
if (ret)
return ret;
spin_lock_init(&priv->lock);
spin_lock_init(&imem->lock);
return 0;
}
......
......@@ -36,14 +36,14 @@ struct nvkm_instmem_impl {
#define nvkm_instmem_create(p,e,o,d) \
nvkm_instmem_create_((p), (e), (o), sizeof(**d), (void **)d)
#define nvkm_instmem_destroy(p) \
nvkm_subdev_destroy(&(p)->base)
nvkm_subdev_destroy(&(p)->subdev)
#define nvkm_instmem_init(p) ({ \
struct nvkm_instmem *imem = (p); \
_nvkm_instmem_init(nv_object(imem)); \
struct nvkm_instmem *_imem = (p); \
_nvkm_instmem_init(nv_object(_imem)); \
})
#define nvkm_instmem_fini(p,s) ({ \
struct nvkm_instmem *imem = (p); \
_nvkm_instmem_fini(nv_object(imem), (s)); \
struct nvkm_instmem *_imem = (p); \
_nvkm_instmem_fini(nv_object(_imem), (s)); \
})
int nvkm_instmem_create_(struct nvkm_object *, struct nvkm_object *,
......
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