Commit 99c59172 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/fb/gf100-: allocate mmu debug buffers

Later chipsets require setting this up both in FB and GR, so let's just
move the allocation to FB.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 917d95a8
...@@ -55,6 +55,9 @@ struct nvkm_fb { ...@@ -55,6 +55,9 @@ struct nvkm_fb {
struct nvkm_fb_tile region[16]; struct nvkm_fb_tile region[16];
int regions; int regions;
} tile; } tile;
struct nvkm_memory *mmu_rd;
struct nvkm_memory *mmu_wr;
}; };
bool nvkm_fb_memtype_valid(struct nvkm_fb *, u32 memtype); bool nvkm_fb_memtype_valid(struct nvkm_fb *, u32 memtype);
......
...@@ -1616,30 +1616,10 @@ gf100_gr_oneinit(struct nvkm_gr *base) ...@@ -1616,30 +1616,10 @@ gf100_gr_oneinit(struct nvkm_gr *base)
{ {
struct gf100_gr *gr = gf100_gr(base); struct gf100_gr *gr = gf100_gr(base);
struct nvkm_device *device = gr->base.engine.subdev.device; struct nvkm_device *device = gr->base.engine.subdev.device;
int ret, i, j; int i, j;
nvkm_pmu_pgob(device->pmu, false); nvkm_pmu_pgob(device->pmu, false);
ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, 0x1000, 256, false,
&gr->unk4188b4);
if (ret)
return ret;
ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, 0x1000, 256, false,
&gr->unk4188b8);
if (ret)
return ret;
nvkm_kmap(gr->unk4188b4);
for (i = 0; i < 0x1000; i += 4)
nvkm_wo32(gr->unk4188b4, i, 0x00000010);
nvkm_done(gr->unk4188b4);
nvkm_kmap(gr->unk4188b8);
for (i = 0; i < 0x1000; i += 4)
nvkm_wo32(gr->unk4188b8, i, 0x00000010);
nvkm_done(gr->unk4188b8);
gr->rop_nr = gr->func->rops(gr); gr->rop_nr = gr->func->rops(gr);
gr->gpc_nr = nvkm_rd32(device, 0x409604) & 0x0000001f; gr->gpc_nr = nvkm_rd32(device, 0x409604) & 0x0000001f;
for (i = 0; i < gr->gpc_nr; i++) { for (i = 0; i < gr->gpc_nr; i++) {
...@@ -1736,8 +1716,6 @@ gf100_gr_dtor(struct nvkm_gr *base) ...@@ -1736,8 +1716,6 @@ gf100_gr_dtor(struct nvkm_gr *base)
gf100_gr_dtor_init(gr->fuc_sw_ctx); gf100_gr_dtor_init(gr->fuc_sw_ctx);
gf100_gr_dtor_init(gr->fuc_sw_nonctx); gf100_gr_dtor_init(gr->fuc_sw_nonctx);
nvkm_memory_del(&gr->unk4188b8);
nvkm_memory_del(&gr->unk4188b4);
return gr; return gr;
} }
...@@ -1822,6 +1800,7 @@ int ...@@ -1822,6 +1800,7 @@ int
gf100_gr_init(struct gf100_gr *gr) gf100_gr_init(struct gf100_gr *gr)
{ {
struct nvkm_device *device = gr->base.engine.subdev.device; struct nvkm_device *device = gr->base.engine.subdev.device;
struct nvkm_fb *fb = device->fb;
const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total); const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total);
u32 data[TPC_MAX / 8] = {}; u32 data[TPC_MAX / 8] = {};
u8 tpcnr[GPC_MAX]; u8 tpcnr[GPC_MAX];
...@@ -1834,8 +1813,8 @@ gf100_gr_init(struct gf100_gr *gr) ...@@ -1834,8 +1813,8 @@ gf100_gr_init(struct gf100_gr *gr)
nvkm_wr32(device, GPC_BCAST(0x088c), 0x00000000); nvkm_wr32(device, GPC_BCAST(0x088c), 0x00000000);
nvkm_wr32(device, GPC_BCAST(0x0890), 0x00000000); nvkm_wr32(device, GPC_BCAST(0x0890), 0x00000000);
nvkm_wr32(device, GPC_BCAST(0x0894), 0x00000000); nvkm_wr32(device, GPC_BCAST(0x0894), 0x00000000);
nvkm_wr32(device, GPC_BCAST(0x08b4), nvkm_memory_addr(gr->unk4188b4) >> 8); nvkm_wr32(device, GPC_BCAST(0x08b4), nvkm_memory_addr(fb->mmu_wr) >> 8);
nvkm_wr32(device, GPC_BCAST(0x08b8), nvkm_memory_addr(gr->unk4188b8) >> 8); nvkm_wr32(device, GPC_BCAST(0x08b8), nvkm_memory_addr(fb->mmu_rd) >> 8);
gf100_gr_mmio(gr, gr->func->mmio); gf100_gr_mmio(gr, gr->func->mmio);
......
...@@ -101,9 +101,6 @@ struct gf100_gr { ...@@ -101,9 +101,6 @@ struct gf100_gr {
u8 ppc_mask[GPC_MAX]; u8 ppc_mask[GPC_MAX];
u8 ppc_tpc_nr[GPC_MAX][4]; u8 ppc_tpc_nr[GPC_MAX][4];
struct nvkm_memory *unk4188b4;
struct nvkm_memory *unk4188b8;
struct gf100_gr_data mmio_data[4]; struct gf100_gr_data mmio_data[4];
struct gf100_gr_mmio mmio_list[4096/8]; struct gf100_gr_mmio mmio_list[4096/8];
u32 size; u32 size;
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include "gf100.h" #include "gf100.h"
#include "ctxgf100.h" #include "ctxgf100.h"
#include <subdev/fb.h>
#include <nvif/class.h> #include <nvif/class.h>
/******************************************************************************* /*******************************************************************************
...@@ -181,6 +183,7 @@ int ...@@ -181,6 +183,7 @@ int
gk104_gr_init(struct gf100_gr *gr) gk104_gr_init(struct gf100_gr *gr)
{ {
struct nvkm_device *device = gr->base.engine.subdev.device; struct nvkm_device *device = gr->base.engine.subdev.device;
struct nvkm_fb *fb = device->fb;
const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total); const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total);
u32 data[TPC_MAX / 8] = {}; u32 data[TPC_MAX / 8] = {};
u8 tpcnr[GPC_MAX]; u8 tpcnr[GPC_MAX];
...@@ -193,8 +196,8 @@ gk104_gr_init(struct gf100_gr *gr) ...@@ -193,8 +196,8 @@ gk104_gr_init(struct gf100_gr *gr)
nvkm_wr32(device, GPC_BCAST(0x088c), 0x00000000); nvkm_wr32(device, GPC_BCAST(0x088c), 0x00000000);
nvkm_wr32(device, GPC_BCAST(0x0890), 0x00000000); nvkm_wr32(device, GPC_BCAST(0x0890), 0x00000000);
nvkm_wr32(device, GPC_BCAST(0x0894), 0x00000000); nvkm_wr32(device, GPC_BCAST(0x0894), 0x00000000);
nvkm_wr32(device, GPC_BCAST(0x08b4), nvkm_memory_addr(gr->unk4188b4) >> 8); nvkm_wr32(device, GPC_BCAST(0x08b4), nvkm_memory_addr(fb->mmu_wr) >> 8);
nvkm_wr32(device, GPC_BCAST(0x08b8), nvkm_memory_addr(gr->unk4188b8) >> 8); nvkm_wr32(device, GPC_BCAST(0x08b8), nvkm_memory_addr(fb->mmu_rd) >> 8);
gf100_gr_mmio(gr, gr->func->mmio); gf100_gr_mmio(gr, gr->func->mmio);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "gf100.h" #include "gf100.h"
#include "ctxgf100.h" #include "ctxgf100.h"
#include <subdev/fb.h>
#include <subdev/timer.h> #include <subdev/timer.h>
#include <nvif/class.h> #include <nvif/class.h>
...@@ -219,6 +220,7 @@ int ...@@ -219,6 +220,7 @@ int
gk20a_gr_init(struct gf100_gr *gr) gk20a_gr_init(struct gf100_gr *gr)
{ {
struct nvkm_device *device = gr->base.engine.subdev.device; struct nvkm_device *device = gr->base.engine.subdev.device;
struct nvkm_fb *fb = device->fb;
const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total); const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total);
u32 data[TPC_MAX / 8] = {}; u32 data[TPC_MAX / 8] = {};
u8 tpcnr[GPC_MAX]; u8 tpcnr[GPC_MAX];
...@@ -239,8 +241,8 @@ gk20a_gr_init(struct gf100_gr *gr) ...@@ -239,8 +241,8 @@ gk20a_gr_init(struct gf100_gr *gr)
return ret; return ret;
/* MMU debug buffer */ /* MMU debug buffer */
nvkm_wr32(device, 0x100cc8, nvkm_memory_addr(gr->unk4188b4) >> 8); nvkm_wr32(device, 0x100cc8, nvkm_memory_addr(fb->mmu_wr) >> 8);
nvkm_wr32(device, 0x100ccc, nvkm_memory_addr(gr->unk4188b8) >> 8); nvkm_wr32(device, 0x100ccc, nvkm_memory_addr(fb->mmu_rd) >> 8);
if (gr->func->init_gpc_mmu) if (gr->func->init_gpc_mmu)
gr->func->init_gpc_mmu(gr); gr->func->init_gpc_mmu(gr);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <subdev/bios.h> #include <subdev/bios.h>
#include <subdev/bios/P0260.h> #include <subdev/bios/P0260.h>
#include <subdev/fb.h>
#include <nvif/class.h> #include <nvif/class.h>
...@@ -311,6 +312,7 @@ int ...@@ -311,6 +312,7 @@ int
gm107_gr_init(struct gf100_gr *gr) gm107_gr_init(struct gf100_gr *gr)
{ {
struct nvkm_device *device = gr->base.engine.subdev.device; struct nvkm_device *device = gr->base.engine.subdev.device;
struct nvkm_fb *fb = device->fb;
const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total); const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total);
u32 data[TPC_MAX / 8] = {}; u32 data[TPC_MAX / 8] = {};
u8 tpcnr[GPC_MAX]; u8 tpcnr[GPC_MAX];
...@@ -320,8 +322,8 @@ gm107_gr_init(struct gf100_gr *gr) ...@@ -320,8 +322,8 @@ gm107_gr_init(struct gf100_gr *gr)
nvkm_wr32(device, GPC_BCAST(0x0880), 0x00000000); nvkm_wr32(device, GPC_BCAST(0x0880), 0x00000000);
nvkm_wr32(device, GPC_BCAST(0x0890), 0x00000000); nvkm_wr32(device, GPC_BCAST(0x0890), 0x00000000);
nvkm_wr32(device, GPC_BCAST(0x0894), 0x00000000); nvkm_wr32(device, GPC_BCAST(0x0894), 0x00000000);
nvkm_wr32(device, GPC_BCAST(0x08b4), nvkm_memory_addr(gr->unk4188b4) >> 8); nvkm_wr32(device, GPC_BCAST(0x08b4), nvkm_memory_addr(fb->mmu_wr) >> 8);
nvkm_wr32(device, GPC_BCAST(0x08b8), nvkm_memory_addr(gr->unk4188b8) >> 8); nvkm_wr32(device, GPC_BCAST(0x08b8), nvkm_memory_addr(fb->mmu_rd) >> 8);
gf100_gr_mmio(gr, gr->func->mmio); gf100_gr_mmio(gr, gr->func->mmio);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "gf100.h" #include "gf100.h"
#include "ctxgf100.h" #include "ctxgf100.h"
#include <subdev/fb.h>
#include <subdev/secboot.h> #include <subdev/secboot.h>
#include <nvif/class.h> #include <nvif/class.h>
...@@ -56,6 +57,7 @@ int ...@@ -56,6 +57,7 @@ int
gm200_gr_init(struct gf100_gr *gr) gm200_gr_init(struct gf100_gr *gr)
{ {
struct nvkm_device *device = gr->base.engine.subdev.device; struct nvkm_device *device = gr->base.engine.subdev.device;
struct nvkm_fb *fb = device->fb;
const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total); const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total);
u32 data[TPC_MAX / 8] = {}; u32 data[TPC_MAX / 8] = {};
u8 tpcnr[GPC_MAX]; u8 tpcnr[GPC_MAX];
...@@ -63,8 +65,8 @@ gm200_gr_init(struct gf100_gr *gr) ...@@ -63,8 +65,8 @@ gm200_gr_init(struct gf100_gr *gr)
int i; int i;
/*XXX: belongs in fb */ /*XXX: belongs in fb */
nvkm_wr32(device, 0x100cc8, nvkm_memory_addr(gr->unk4188b4) >> 8); nvkm_wr32(device, 0x100cc8, nvkm_memory_addr(fb->mmu_wr) >> 8);
nvkm_wr32(device, 0x100ccc, nvkm_memory_addr(gr->unk4188b8) >> 8); nvkm_wr32(device, 0x100ccc, nvkm_memory_addr(fb->mmu_rd) >> 8);
nvkm_mask(device, 0x100cc4, 0x00040000, 0x00040000); nvkm_mask(device, 0x100cc4, 0x00040000, 0x00040000);
gr->func->init_gpc_mmu(gr); gr->func->init_gpc_mmu(gr);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "priv.h" #include "priv.h"
#include "ram.h" #include "ram.h"
#include <core/memory.h>
#include <subdev/bios.h> #include <subdev/bios.h>
#include <subdev/bios/M0203.h> #include <subdev/bios/M0203.h>
#include <engine/gr.h> #include <engine/gr.h>
...@@ -142,6 +143,9 @@ nvkm_fb_dtor(struct nvkm_subdev *subdev) ...@@ -142,6 +143,9 @@ nvkm_fb_dtor(struct nvkm_subdev *subdev)
struct nvkm_fb *fb = nvkm_fb(subdev); struct nvkm_fb *fb = nvkm_fb(subdev);
int i; int i;
nvkm_memory_del(&fb->mmu_wr);
nvkm_memory_del(&fb->mmu_rd);
for (i = 0; i < fb->tile.regions; i++) for (i = 0; i < fb->tile.regions; i++)
fb->func->tile.fini(fb, i, &fb->tile.region[i]); fb->func->tile.fini(fb, i, &fb->tile.region[i]);
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#include "gf100.h" #include "gf100.h"
#include "ram.h" #include "ram.h"
#include <core/memory.h>
#include <core/option.h>
extern const u8 gf100_pte_storage_type_map[256]; extern const u8 gf100_pte_storage_type_map[256];
bool bool
...@@ -46,6 +49,28 @@ gf100_fb_intr(struct nvkm_fb *base) ...@@ -46,6 +49,28 @@ gf100_fb_intr(struct nvkm_fb *base)
nvkm_debug(subdev, "PBFB intr\n"); nvkm_debug(subdev, "PBFB intr\n");
} }
int
gf100_fb_oneinit(struct nvkm_fb *fb)
{
struct nvkm_device *device = fb->subdev.device;
int ret, size = 0x1000;
size = nvkm_longopt(device->cfgopt, "MmuDebugBufferSize", size);
size = min(size, 0x1000);
ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, size, 0x1000,
false, &fb->mmu_rd);
if (ret)
return ret;
ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, size, 0x1000,
false, &fb->mmu_wr);
if (ret)
return ret;
return 0;
}
void void
gf100_fb_init(struct nvkm_fb *base) gf100_fb_init(struct nvkm_fb *base)
{ {
...@@ -98,6 +123,7 @@ gf100_fb_new_(const struct nvkm_fb_func *func, struct nvkm_device *device, ...@@ -98,6 +123,7 @@ gf100_fb_new_(const struct nvkm_fb_func *func, struct nvkm_device *device,
static const struct nvkm_fb_func static const struct nvkm_fb_func
gf100_fb = { gf100_fb = {
.dtor = gf100_fb_dtor, .dtor = gf100_fb_dtor,
.oneinit = gf100_fb_oneinit,
.init = gf100_fb_init, .init = gf100_fb_init,
.intr = gf100_fb_intr, .intr = gf100_fb_intr,
.ram_new = gf100_ram_new, .ram_new = gf100_ram_new,
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
static const struct nvkm_fb_func static const struct nvkm_fb_func
gk104_fb = { gk104_fb = {
.dtor = gf100_fb_dtor, .dtor = gf100_fb_dtor,
.oneinit = gf100_fb_oneinit,
.init = gf100_fb_init, .init = gf100_fb_init,
.intr = gf100_fb_intr, .intr = gf100_fb_intr,
.ram_new = gk104_ram_new, .ram_new = gk104_ram_new,
......
...@@ -30,6 +30,7 @@ gk20a_fb_init(struct nvkm_fb *fb) ...@@ -30,6 +30,7 @@ gk20a_fb_init(struct nvkm_fb *fb)
static const struct nvkm_fb_func static const struct nvkm_fb_func
gk20a_fb = { gk20a_fb = {
.oneinit = gf100_fb_oneinit,
.init = gk20a_fb_init, .init = gk20a_fb_init,
.memtype_valid = gf100_fb_memtype_valid, .memtype_valid = gf100_fb_memtype_valid,
}; };
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
static const struct nvkm_fb_func static const struct nvkm_fb_func
gm107_fb = { gm107_fb = {
.dtor = gf100_fb_dtor, .dtor = gf100_fb_dtor,
.oneinit = gf100_fb_oneinit,
.init = gf100_fb_init, .init = gf100_fb_init,
.intr = gf100_fb_intr, .intr = gf100_fb_intr,
.ram_new = gm107_ram_new, .ram_new = gm107_ram_new,
......
...@@ -59,5 +59,6 @@ void nv44_fb_tile_prog(struct nvkm_fb *, int, struct nvkm_fb_tile *); ...@@ -59,5 +59,6 @@ void nv44_fb_tile_prog(struct nvkm_fb *, int, struct nvkm_fb_tile *);
void nv46_fb_tile_init(struct nvkm_fb *, int i, u32 addr, u32 size, void nv46_fb_tile_init(struct nvkm_fb *, int i, u32 addr, u32 size,
u32 pitch, u32 flags, struct nvkm_fb_tile *); u32 pitch, u32 flags, struct nvkm_fb_tile *);
int gf100_fb_oneinit(struct nvkm_fb *);
bool gf100_fb_memtype_valid(struct nvkm_fb *, u32); bool gf100_fb_memtype_valid(struct nvkm_fb *, u32);
#endif #endif
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