drm/nouveau/bar: expose interface to bar2 teardown

Will prevent spurious MMU fault interrupts if something decides to touch
BAR1 after we've unloaded the driver.

Exposed external to BAR so that INSTMEM can use it to better control the
suspend/resume fast-path access.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
This commit is contained in:
Ben Skeggs 2017-11-01 03:56:19 +10:00
parent 48fe02478a
commit e988952eef
6 changed files with 29 additions and 1 deletions

View File

@ -15,6 +15,7 @@ struct nvkm_bar {
};
void nvkm_bar_bar2_init(struct nvkm_device *);
void nvkm_bar_bar2_fini(struct nvkm_device *);
void nvkm_bar_flush(struct nvkm_bar *);
struct nvkm_vm *nvkm_bar_kmap(struct nvkm_bar *);
int nvkm_bar_umap(struct nvkm_bar *, u64 size, int type, struct nvkm_vma *);

View File

@ -45,6 +45,16 @@ nvkm_bar_umap(struct nvkm_bar *bar, u64 size, int type, struct nvkm_vma *vma)
return bar->func->umap(bar, size, type, vma);
}
void
nvkm_bar_bar2_fini(struct nvkm_device *device)
{
struct nvkm_bar *bar = device->bar;
if (bar && bar->bar2) {
bar->func->bar2.fini(bar);
bar->bar2 = false;
}
}
void
nvkm_bar_bar2_init(struct nvkm_device *device)
{
@ -61,7 +71,7 @@ nvkm_bar_fini(struct nvkm_subdev *subdev, bool suspend)
{
struct nvkm_bar *bar = nvkm_bar(subdev);
bar->func->bar1.fini(bar);
bar->bar2 = false;
nvkm_bar_bar2_fini(subdev->device);
return 0;
}

View File

@ -48,6 +48,7 @@ g84_bar_func = {
.bar1.fini = nv50_bar_bar1_fini,
.bar1.wait = nv50_bar_bar1_wait,
.bar2.init = nv50_bar_bar2_init,
.bar2.fini = nv50_bar_bar2_fini,
.bar2.wait = nv50_bar_bar1_wait,
.kmap = nv50_bar_kmap,
.umap = nv50_bar_umap,

View File

@ -64,6 +64,12 @@ gf100_bar_bar1_init(struct nvkm_bar *base)
nvkm_wr32(device, 0x001704, 0x80000000 | addr);
}
void
gf100_bar_bar2_fini(struct nvkm_bar *bar)
{
nvkm_mask(bar->subdev.device, 0x001714, 0x80000000, 0x00000000);
}
void
gf100_bar_bar2_init(struct nvkm_bar *base)
{
@ -190,6 +196,7 @@ gf100_bar_func = {
.bar1.fini = gf100_bar_bar1_fini,
.bar1.wait = gf100_bar_bar1_wait,
.bar2.init = gf100_bar_bar2_init,
.bar2.fini = gf100_bar_bar2_fini,
.bar2.wait = gf100_bar_bar1_wait,
.kmap = gf100_bar_kmap,
.umap = gf100_bar_umap,

View File

@ -76,6 +76,12 @@ nv50_bar_bar1_init(struct nvkm_bar *base)
nvkm_wr32(device, 0x001708, 0x80000000 | bar->bar1->node->offset >> 4);
}
void
nv50_bar_bar2_fini(struct nvkm_bar *bar)
{
nvkm_wr32(bar->subdev.device, 0x00170c, 0x00000000);
}
void
nv50_bar_bar2_init(struct nvkm_bar *base)
{
@ -224,6 +230,7 @@ nv50_bar_func = {
.bar1.fini = nv50_bar_bar1_fini,
.bar1.wait = nv50_bar_bar1_wait,
.bar2.init = nv50_bar_bar2_init,
.bar2.fini = nv50_bar_bar2_fini,
.bar2.wait = nv50_bar_bar1_wait,
.kmap = nv50_bar_kmap,
.umap = nv50_bar_umap,

View File

@ -23,8 +23,10 @@ struct nvkm_bar_func {
};
void nv50_bar_bar1_fini(struct nvkm_bar *);
void nv50_bar_bar2_fini(struct nvkm_bar *);
void g84_bar_flush(struct nvkm_bar *);
void gf100_bar_bar1_fini(struct nvkm_bar *);
void gf100_bar_bar2_fini(struct nvkm_bar *);
#endif