drm/nouveau/fb: move comptag init out of ram submodule
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
This commit is contained in:
parent
7ef44bee64
commit
af793b8cd9
@ -100,6 +100,7 @@ static int
|
||||
nvkm_fb_oneinit(struct nvkm_subdev *subdev)
|
||||
{
|
||||
struct nvkm_fb *fb = nvkm_fb(subdev);
|
||||
u32 tags = 0;
|
||||
|
||||
if (fb->func->ram_new) {
|
||||
int ret = fb->func->ram_new(fb, &fb->ram);
|
||||
@ -115,7 +116,16 @@ nvkm_fb_oneinit(struct nvkm_subdev *subdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
/* Initialise compression tag allocator.
|
||||
*
|
||||
* LTC oneinit() will override this on Fermi and newer.
|
||||
*/
|
||||
if (fb->func->tags) {
|
||||
tags = fb->func->tags(fb);
|
||||
nvkm_debug(subdev, "%d comptags\n", tags);
|
||||
}
|
||||
|
||||
return nvkm_mm_init(&fb->tags, 0, 0, tags, 1);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -27,6 +27,7 @@
|
||||
static const struct nv50_fb_func
|
||||
g84_fb = {
|
||||
.ram_new = nv50_ram_new,
|
||||
.tags = nv20_fb_tags,
|
||||
.trap = 0x001d07ff,
|
||||
};
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
static const struct nv50_fb_func
|
||||
gt215_fb = {
|
||||
.ram_new = gt215_ram_new,
|
||||
.tags = nv20_fb_tags,
|
||||
.trap = 0x000d0fff,
|
||||
};
|
||||
|
||||
|
@ -77,8 +77,16 @@ nv20_fb_tile_prog(struct nvkm_fb *fb, int i, struct nvkm_fb_tile *tile)
|
||||
nvkm_wr32(device, 0x100300 + (i * 0x04), tile->zcomp);
|
||||
}
|
||||
|
||||
u32
|
||||
nv20_fb_tags(struct nvkm_fb *fb)
|
||||
{
|
||||
const u32 tags = nvkm_rd32(fb->subdev.device, 0x100320);
|
||||
return tags ? tags + 1 : 0;
|
||||
}
|
||||
|
||||
static const struct nvkm_fb_func
|
||||
nv20_fb = {
|
||||
.tags = nv20_fb_tags,
|
||||
.tile.regions = 8,
|
||||
.tile.init = nv20_fb_tile_init,
|
||||
.tile.comp = nv20_fb_tile_comp,
|
||||
|
@ -44,6 +44,7 @@ nv25_fb_tile_comp(struct nvkm_fb *fb, int i, u32 size, u32 flags,
|
||||
|
||||
static const struct nvkm_fb_func
|
||||
nv25_fb = {
|
||||
.tags = nv20_fb_tags,
|
||||
.tile.regions = 8,
|
||||
.tile.init = nv20_fb_tile_init,
|
||||
.tile.comp = nv25_fb_tile_comp,
|
||||
|
@ -116,6 +116,7 @@ nv30_fb_init(struct nvkm_fb *fb)
|
||||
|
||||
static const struct nvkm_fb_func
|
||||
nv30_fb = {
|
||||
.tags = nv20_fb_tags,
|
||||
.init = nv30_fb_init,
|
||||
.tile.regions = 8,
|
||||
.tile.init = nv30_fb_tile_init,
|
||||
|
@ -45,6 +45,7 @@ nv35_fb_tile_comp(struct nvkm_fb *fb, int i, u32 size, u32 flags,
|
||||
|
||||
static const struct nvkm_fb_func
|
||||
nv35_fb = {
|
||||
.tags = nv20_fb_tags,
|
||||
.init = nv30_fb_init,
|
||||
.tile.regions = 8,
|
||||
.tile.init = nv30_fb_tile_init,
|
||||
|
@ -45,6 +45,7 @@ nv36_fb_tile_comp(struct nvkm_fb *fb, int i, u32 size, u32 flags,
|
||||
|
||||
static const struct nvkm_fb_func
|
||||
nv36_fb = {
|
||||
.tags = nv20_fb_tags,
|
||||
.init = nv30_fb_init,
|
||||
.tile.regions = 8,
|
||||
.tile.init = nv30_fb_tile_init,
|
||||
|
@ -51,6 +51,7 @@ nv40_fb_init(struct nvkm_fb *fb)
|
||||
|
||||
static const struct nvkm_fb_func
|
||||
nv40_fb = {
|
||||
.tags = nv20_fb_tags,
|
||||
.init = nv40_fb_init,
|
||||
.tile.regions = 8,
|
||||
.tile.init = nv30_fb_tile_init,
|
||||
|
@ -45,6 +45,7 @@ nv41_fb_init(struct nvkm_fb *fb)
|
||||
|
||||
static const struct nvkm_fb_func
|
||||
nv41_fb = {
|
||||
.tags = nv20_fb_tags,
|
||||
.init = nv41_fb_init,
|
||||
.tile.regions = 12,
|
||||
.tile.init = nv30_fb_tile_init,
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
static const struct nvkm_fb_func
|
||||
nv47_fb = {
|
||||
.tags = nv20_fb_tags,
|
||||
.init = nv41_fb_init,
|
||||
.tile.regions = 15,
|
||||
.tile.init = nv30_fb_tile_init,
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
static const struct nvkm_fb_func
|
||||
nv49_fb = {
|
||||
.tags = nv20_fb_tags,
|
||||
.init = nv41_fb_init,
|
||||
.tile.regions = 15,
|
||||
.tile.init = nv30_fb_tile_init,
|
||||
|
@ -244,6 +244,15 @@ nv50_fb_init(struct nvkm_fb *base)
|
||||
nvkm_wr32(device, 0x100c90, fb->func->trap);
|
||||
}
|
||||
|
||||
static u32
|
||||
nv50_fb_tags(struct nvkm_fb *base)
|
||||
{
|
||||
struct nv50_fb *fb = nv50_fb(base);
|
||||
if (fb->func->tags)
|
||||
return fb->func->tags(&fb->base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *
|
||||
nv50_fb_dtor(struct nvkm_fb *base)
|
||||
{
|
||||
@ -262,6 +271,7 @@ nv50_fb_dtor(struct nvkm_fb *base)
|
||||
static const struct nvkm_fb_func
|
||||
nv50_fb_ = {
|
||||
.dtor = nv50_fb_dtor,
|
||||
.tags = nv50_fb_tags,
|
||||
.oneinit = nv50_fb_oneinit,
|
||||
.init = nv50_fb_init,
|
||||
.intr = nv50_fb_intr,
|
||||
@ -287,6 +297,7 @@ nv50_fb_new_(const struct nv50_fb_func *func, struct nvkm_device *device,
|
||||
static const struct nv50_fb_func
|
||||
nv50_fb = {
|
||||
.ram_new = nv50_ram_new,
|
||||
.tags = nv20_fb_tags,
|
||||
.trap = 0x000707ff,
|
||||
};
|
||||
|
||||
|
@ -12,6 +12,7 @@ struct nv50_fb {
|
||||
|
||||
struct nv50_fb_func {
|
||||
int (*ram_new)(struct nvkm_fb *, struct nvkm_ram **);
|
||||
u32 (*tags)(struct nvkm_fb *);
|
||||
u32 trap;
|
||||
};
|
||||
|
||||
|
@ -6,6 +6,7 @@ struct nvkm_bios;
|
||||
|
||||
struct nvkm_fb_func {
|
||||
void *(*dtor)(struct nvkm_fb *);
|
||||
u32 (*tags)(struct nvkm_fb *);
|
||||
int (*oneinit)(struct nvkm_fb *);
|
||||
void (*init)(struct nvkm_fb *);
|
||||
int (*init_page)(struct nvkm_fb *);
|
||||
@ -42,6 +43,7 @@ void nv10_fb_tile_init(struct nvkm_fb *, int i, u32 addr, u32 size,
|
||||
void nv10_fb_tile_fini(struct nvkm_fb *, int i, struct nvkm_fb_tile *);
|
||||
void nv10_fb_tile_prog(struct nvkm_fb *, int, struct nvkm_fb_tile *);
|
||||
|
||||
u32 nv20_fb_tags(struct nvkm_fb *);
|
||||
void nv20_fb_tile_init(struct nvkm_fb *, int i, u32 addr, u32 size,
|
||||
u32 pitch, u32 flags, struct nvkm_fb_tile *);
|
||||
void nv20_fb_tile_fini(struct nvkm_fb *, int i, struct nvkm_fb_tile *);
|
||||
|
@ -46,8 +46,7 @@ nvkm_ram_del(struct nvkm_ram **pram)
|
||||
|
||||
int
|
||||
nvkm_ram_ctor(const struct nvkm_ram_func *func, struct nvkm_fb *fb,
|
||||
enum nvkm_ram_type type, u64 size, u32 tags,
|
||||
struct nvkm_ram *ram)
|
||||
enum nvkm_ram_type type, u64 size, struct nvkm_ram *ram)
|
||||
{
|
||||
static const char *name[] = {
|
||||
[NVKM_RAM_TYPE_UNKNOWN] = "of unknown memory type",
|
||||
@ -78,23 +77,14 @@ nvkm_ram_ctor(const struct nvkm_ram_func *func, struct nvkm_fb *fb,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!nvkm_mm_initialised(&fb->tags)) {
|
||||
ret = nvkm_mm_init(&fb->tags, 0, 0, tags ? ++tags : 0, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
nvkm_debug(subdev, "%d compression tags\n", tags);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nvkm_ram_new_(const struct nvkm_ram_func *func, struct nvkm_fb *fb,
|
||||
enum nvkm_ram_type type, u64 size, u32 tags,
|
||||
struct nvkm_ram **pram)
|
||||
enum nvkm_ram_type type, u64 size, struct nvkm_ram **pram)
|
||||
{
|
||||
if (!(*pram = kzalloc(sizeof(**pram), GFP_KERNEL)))
|
||||
return -ENOMEM;
|
||||
return nvkm_ram_ctor(func, fb, type, size, tags, *pram);
|
||||
return nvkm_ram_ctor(func, fb, type, size, *pram);
|
||||
}
|
||||
|
@ -3,11 +3,9 @@
|
||||
#include "priv.h"
|
||||
|
||||
int nvkm_ram_ctor(const struct nvkm_ram_func *, struct nvkm_fb *,
|
||||
enum nvkm_ram_type, u64 size, u32 tags,
|
||||
struct nvkm_ram *);
|
||||
enum nvkm_ram_type, u64 size, struct nvkm_ram *);
|
||||
int nvkm_ram_new_(const struct nvkm_ram_func *, struct nvkm_fb *,
|
||||
enum nvkm_ram_type, u64 size, u32 tags,
|
||||
struct nvkm_ram **);
|
||||
enum nvkm_ram_type, u64 size, struct nvkm_ram **);
|
||||
void nvkm_ram_del(struct nvkm_ram **);
|
||||
int nvkm_ram_init(struct nvkm_ram *);
|
||||
|
||||
|
@ -604,7 +604,7 @@ gf100_ram_ctor(const struct nvkm_ram_func *func, struct nvkm_fb *fb,
|
||||
nvkm_debug(subdev, "Upper: %4lld MiB @ %010llx\n", usize >> 20, ubase);
|
||||
nvkm_debug(subdev, "Total: %4lld MiB\n", total >> 20);
|
||||
|
||||
ret = nvkm_ram_ctor(func, fb, type, total, 0, ram);
|
||||
ret = nvkm_ram_ctor(func, fb, type, total, ram);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -73,7 +73,7 @@ mcp77_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
*pram = &ram->base;
|
||||
|
||||
ret = nvkm_ram_ctor(&mcp77_ram_func, fb, NVKM_RAM_TYPE_STOLEN,
|
||||
size, 0, &ram->base);
|
||||
size, &ram->base);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -61,5 +61,5 @@ nv04_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
else
|
||||
type = NVKM_RAM_TYPE_SDRAM;
|
||||
|
||||
return nvkm_ram_new_(&nv04_ram_func, fb, type, size, 0, pram);
|
||||
return nvkm_ram_new_(&nv04_ram_func, fb, type, size, pram);
|
||||
}
|
||||
|
@ -36,5 +36,5 @@ nv10_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
else
|
||||
type = NVKM_RAM_TYPE_SDRAM;
|
||||
|
||||
return nvkm_ram_new_(&nv04_ram_func, fb, type, size, 0, pram);
|
||||
return nvkm_ram_new_(&nv04_ram_func, fb, type, size, pram);
|
||||
}
|
||||
|
@ -44,5 +44,5 @@ nv1a_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
}
|
||||
|
||||
return nvkm_ram_new_(&nv04_ram_func, fb, NVKM_RAM_TYPE_STOLEN,
|
||||
mib * 1024 * 1024, 0, pram);
|
||||
mib * 1024 * 1024, pram);
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ nv20_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
struct nvkm_device *device = fb->subdev.device;
|
||||
u32 pbus1218 = nvkm_rd32(device, 0x001218);
|
||||
u32 size = (nvkm_rd32(device, 0x10020c) & 0xff000000);
|
||||
u32 tags = nvkm_rd32(device, 0x100320);
|
||||
enum nvkm_ram_type type = NVKM_RAM_TYPE_UNKNOWN;
|
||||
int ret;
|
||||
|
||||
@ -40,7 +39,7 @@ nv20_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
case 0x00000300: type = NVKM_RAM_TYPE_GDDR2; break;
|
||||
}
|
||||
|
||||
ret = nvkm_ram_new_(&nv04_ram_func, fb, type, size, tags, pram);
|
||||
ret = nvkm_ram_new_(&nv04_ram_func, fb, type, size, pram);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -187,13 +187,13 @@ nv40_ram_func = {
|
||||
|
||||
int
|
||||
nv40_ram_new_(struct nvkm_fb *fb, enum nvkm_ram_type type, u64 size,
|
||||
u32 tags, struct nvkm_ram **pram)
|
||||
struct nvkm_ram **pram)
|
||||
{
|
||||
struct nv40_ram *ram;
|
||||
if (!(ram = kzalloc(sizeof(*ram), GFP_KERNEL)))
|
||||
return -ENOMEM;
|
||||
*pram = &ram->base;
|
||||
return nvkm_ram_ctor(&nv40_ram_func, fb, type, size, tags, &ram->base);
|
||||
return nvkm_ram_ctor(&nv40_ram_func, fb, type, size, &ram->base);
|
||||
}
|
||||
|
||||
int
|
||||
@ -202,7 +202,6 @@ nv40_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
struct nvkm_device *device = fb->subdev.device;
|
||||
u32 pbus1218 = nvkm_rd32(device, 0x001218);
|
||||
u32 size = nvkm_rd32(device, 0x10020c) & 0xff000000;
|
||||
u32 tags = nvkm_rd32(device, 0x100320);
|
||||
enum nvkm_ram_type type = NVKM_RAM_TYPE_UNKNOWN;
|
||||
int ret;
|
||||
|
||||
@ -213,7 +212,7 @@ nv40_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
case 0x00000300: type = NVKM_RAM_TYPE_DDR2 ; break;
|
||||
}
|
||||
|
||||
ret = nv40_ram_new_(fb, type, size, tags, pram);
|
||||
ret = nv40_ram_new_(fb, type, size, pram);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -9,6 +9,6 @@ struct nv40_ram {
|
||||
u32 coef;
|
||||
};
|
||||
|
||||
int nv40_ram_new_(struct nvkm_fb *fb, enum nvkm_ram_type, u64, u32,
|
||||
int nv40_ram_new_(struct nvkm_fb *fb, enum nvkm_ram_type, u64,
|
||||
struct nvkm_ram **);
|
||||
#endif
|
||||
|
@ -28,7 +28,6 @@ nv41_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
{
|
||||
struct nvkm_device *device = fb->subdev.device;
|
||||
u32 size = nvkm_rd32(device, 0x10020c) & 0xff000000;
|
||||
u32 tags = nvkm_rd32(device, 0x100320);
|
||||
u32 fb474 = nvkm_rd32(device, 0x100474);
|
||||
enum nvkm_ram_type type = NVKM_RAM_TYPE_UNKNOWN;
|
||||
int ret;
|
||||
@ -40,7 +39,7 @@ nv41_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
if (fb474 & 0x00000001)
|
||||
type = NVKM_RAM_TYPE_DDR1;
|
||||
|
||||
ret = nv40_ram_new_(fb, type, size, tags, pram);
|
||||
ret = nv40_ram_new_(fb, type, size, pram);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -38,5 +38,5 @@ nv44_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
if (fb474 & 0x00000001)
|
||||
type = NVKM_RAM_TYPE_DDR1;
|
||||
|
||||
return nv40_ram_new_(fb, type, size, 0, pram);
|
||||
return nv40_ram_new_(fb, type, size, pram);
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ nv49_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
{
|
||||
struct nvkm_device *device = fb->subdev.device;
|
||||
u32 size = nvkm_rd32(device, 0x10020c) & 0xff000000;
|
||||
u32 tags = nvkm_rd32(device, 0x100320);
|
||||
u32 fb914 = nvkm_rd32(device, 0x100914);
|
||||
enum nvkm_ram_type type = NVKM_RAM_TYPE_UNKNOWN;
|
||||
int ret;
|
||||
@ -40,7 +39,7 @@ nv49_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
case 0x00000003: break;
|
||||
}
|
||||
|
||||
ret = nv40_ram_new_(fb, type, size, tags, pram);
|
||||
ret = nv40_ram_new_(fb, type, size, pram);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -29,5 +29,5 @@ nv4e_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
|
||||
struct nvkm_device *device = fb->subdev.device;
|
||||
u32 size = nvkm_rd32(device, 0x10020c) & 0xff000000;
|
||||
return nvkm_ram_new_(&nv04_ram_func, fb, NVKM_RAM_TYPE_UNKNOWN,
|
||||
size, 0, pram);
|
||||
size, pram);
|
||||
}
|
||||
|
@ -639,7 +639,6 @@ nv50_ram_ctor(const struct nvkm_ram_func *func,
|
||||
const u32 rsvd_head = ( 256 * 1024); /* vga memory */
|
||||
const u32 rsvd_tail = (1024 * 1024); /* vbios etc */
|
||||
u64 size = nvkm_rd32(device, 0x10020c);
|
||||
u32 tags = nvkm_rd32(device, 0x100320);
|
||||
enum nvkm_ram_type type = NVKM_RAM_TYPE_UNKNOWN;
|
||||
int ret;
|
||||
|
||||
@ -660,7 +659,7 @@ nv50_ram_ctor(const struct nvkm_ram_func *func,
|
||||
|
||||
size = (size & 0x000000ff) << 32 | (size & 0xffffff00);
|
||||
|
||||
ret = nvkm_ram_ctor(func, fb, type, size, tags, ram);
|
||||
ret = nvkm_ram_ctor(func, fb, type, size, ram);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user