Commit a78dbce9 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/bar: modify interface to bar2 vmm mapping

Match API with the BAR1 version.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 570889dc
...@@ -17,8 +17,8 @@ struct nvkm_bar { ...@@ -17,8 +17,8 @@ struct nvkm_bar {
struct nvkm_vmm *nvkm_bar_bar1_vmm(struct nvkm_device *); struct nvkm_vmm *nvkm_bar_bar1_vmm(struct nvkm_device *);
void nvkm_bar_bar2_init(struct nvkm_device *); void nvkm_bar_bar2_init(struct nvkm_device *);
void nvkm_bar_bar2_fini(struct nvkm_device *); void nvkm_bar_bar2_fini(struct nvkm_device *);
struct nvkm_vmm *nvkm_bar_bar2_vmm(struct nvkm_device *);
void nvkm_bar_flush(struct nvkm_bar *); void nvkm_bar_flush(struct nvkm_bar *);
struct nvkm_vm *nvkm_bar_kmap(struct nvkm_bar *);
int nv50_bar_new(struct nvkm_device *, int, struct nvkm_bar **); int nv50_bar_new(struct nvkm_device *, int, struct nvkm_bar **);
int g84_bar_new(struct nvkm_device *, int, struct nvkm_bar **); int g84_bar_new(struct nvkm_device *, int, struct nvkm_bar **);
......
...@@ -30,19 +30,22 @@ nvkm_bar_flush(struct nvkm_bar *bar) ...@@ -30,19 +30,22 @@ nvkm_bar_flush(struct nvkm_bar *bar)
bar->func->flush(bar); bar->func->flush(bar);
} }
struct nvkm_vm * struct nvkm_vmm *
nvkm_bar_kmap(struct nvkm_bar *bar) nvkm_bar_bar1_vmm(struct nvkm_device *device)
{ {
/* disallow kmap() until after vm has been bootstrapped */ return device->bar->func->bar1.vmm(device->bar);
if (bar && bar->func->kmap && bar->subdev.oneinit)
return bar->func->kmap(bar);
return NULL;
} }
struct nvkm_vmm * struct nvkm_vmm *
nvkm_bar_bar1_vmm(struct nvkm_device *device) nvkm_bar_bar2_vmm(struct nvkm_device *device)
{ {
return device->bar->func->bar1.vmm(device->bar); /* Denies access to BAR2 when it's not initialised, used by INSTMEM
* to know when object access needs to go through the BAR0 window.
*/
struct nvkm_bar *bar = device->bar;
if (bar && bar->func->bar2.vmm && bar->subdev.oneinit)
return bar->func->bar2.vmm(bar);
return NULL;
} }
void void
......
...@@ -51,7 +51,7 @@ g84_bar_func = { ...@@ -51,7 +51,7 @@ g84_bar_func = {
.bar2.init = nv50_bar_bar2_init, .bar2.init = nv50_bar_bar2_init,
.bar2.fini = nv50_bar_bar2_fini, .bar2.fini = nv50_bar_bar2_fini,
.bar2.wait = nv50_bar_bar1_wait, .bar2.wait = nv50_bar_bar1_wait,
.kmap = nv50_bar_kmap, .bar2.vmm = nv50_bar_bar2_vmm,
.flush = g84_bar_flush, .flush = g84_bar_flush,
}; };
......
...@@ -28,12 +28,6 @@ ...@@ -28,12 +28,6 @@
#include <subdev/fb.h> #include <subdev/fb.h>
#include <subdev/mmu.h> #include <subdev/mmu.h>
static struct nvkm_vm *
gf100_bar_kmap(struct nvkm_bar *base)
{
return gf100_bar(base)->bar[0].vm;
}
struct nvkm_vmm * struct nvkm_vmm *
gf100_bar_bar1_vmm(struct nvkm_bar *base) gf100_bar_bar1_vmm(struct nvkm_bar *base)
{ {
...@@ -63,6 +57,12 @@ gf100_bar_bar1_init(struct nvkm_bar *base) ...@@ -63,6 +57,12 @@ gf100_bar_bar1_init(struct nvkm_bar *base)
nvkm_wr32(device, 0x001704, 0x80000000 | addr); nvkm_wr32(device, 0x001704, 0x80000000 | addr);
} }
struct nvkm_vmm *
gf100_bar_bar2_vmm(struct nvkm_bar *base)
{
return gf100_bar(base)->bar[0].vm;
}
void void
gf100_bar_bar2_fini(struct nvkm_bar *bar) gf100_bar_bar2_fini(struct nvkm_bar *bar)
{ {
...@@ -142,7 +142,7 @@ gf100_bar_oneinit(struct nvkm_bar *base) ...@@ -142,7 +142,7 @@ gf100_bar_oneinit(struct nvkm_bar *base)
int ret; int ret;
/* BAR2 */ /* BAR2 */
if (bar->base.func->kmap) { if (bar->base.func->bar2.init) {
ret = gf100_bar_oneinit_bar(bar, &bar->bar[0], &bar2_lock, 3); ret = gf100_bar_oneinit_bar(bar, &bar->bar[0], &bar2_lock, 3);
if (ret) if (ret)
return ret; return ret;
...@@ -198,7 +198,7 @@ gf100_bar_func = { ...@@ -198,7 +198,7 @@ gf100_bar_func = {
.bar2.init = gf100_bar_bar2_init, .bar2.init = gf100_bar_bar2_init,
.bar2.fini = gf100_bar_bar2_fini, .bar2.fini = gf100_bar_bar2_fini,
.bar2.wait = gf100_bar_bar1_wait, .bar2.wait = gf100_bar_bar1_wait,
.kmap = gf100_bar_kmap, .bar2.vmm = gf100_bar_bar2_vmm,
.flush = g84_bar_flush, .flush = g84_bar_flush,
}; };
......
...@@ -23,4 +23,5 @@ void gf100_bar_bar1_init(struct nvkm_bar *); ...@@ -23,4 +23,5 @@ void gf100_bar_bar1_init(struct nvkm_bar *);
void gf100_bar_bar1_wait(struct nvkm_bar *); void gf100_bar_bar1_wait(struct nvkm_bar *);
struct nvkm_vmm *gf100_bar_bar1_vmm(struct nvkm_bar *); struct nvkm_vmm *gf100_bar_bar1_vmm(struct nvkm_bar *);
void gf100_bar_bar2_init(struct nvkm_bar *); void gf100_bar_bar2_init(struct nvkm_bar *);
struct nvkm_vmm *gf100_bar_bar2_vmm(struct nvkm_bar *);
#endif #endif
...@@ -28,12 +28,6 @@ ...@@ -28,12 +28,6 @@
#include <subdev/mmu.h> #include <subdev/mmu.h>
#include <subdev/timer.h> #include <subdev/timer.h>
struct nvkm_vm *
nv50_bar_kmap(struct nvkm_bar *base)
{
return nv50_bar(base)->bar2_vm;
}
static void static void
nv50_bar_flush(struct nvkm_bar *base) nv50_bar_flush(struct nvkm_bar *base)
{ {
...@@ -75,6 +69,12 @@ nv50_bar_bar1_init(struct nvkm_bar *base) ...@@ -75,6 +69,12 @@ nv50_bar_bar1_init(struct nvkm_bar *base)
nvkm_wr32(device, 0x001708, 0x80000000 | bar->bar1->node->offset >> 4); nvkm_wr32(device, 0x001708, 0x80000000 | bar->bar1->node->offset >> 4);
} }
struct nvkm_vmm *
nv50_bar_bar2_vmm(struct nvkm_bar *base)
{
return nv50_bar(base)->bar2_vm;
}
void void
nv50_bar_bar2_fini(struct nvkm_bar *bar) nv50_bar_bar2_fini(struct nvkm_bar *bar)
{ {
...@@ -232,7 +232,7 @@ nv50_bar_func = { ...@@ -232,7 +232,7 @@ nv50_bar_func = {
.bar2.init = nv50_bar_bar2_init, .bar2.init = nv50_bar_bar2_init,
.bar2.fini = nv50_bar_bar2_fini, .bar2.fini = nv50_bar_bar2_fini,
.bar2.wait = nv50_bar_bar1_wait, .bar2.wait = nv50_bar_bar1_wait,
.kmap = nv50_bar_kmap, .bar2.vmm = nv50_bar_bar2_vmm,
.flush = nv50_bar_flush, .flush = nv50_bar_flush,
}; };
......
...@@ -24,6 +24,5 @@ void nv50_bar_bar1_init(struct nvkm_bar *); ...@@ -24,6 +24,5 @@ void nv50_bar_bar1_init(struct nvkm_bar *);
void nv50_bar_bar1_wait(struct nvkm_bar *); void nv50_bar_bar1_wait(struct nvkm_bar *);
struct nvkm_vmm *nv50_bar_bar1_vmm(struct nvkm_bar *); struct nvkm_vmm *nv50_bar_bar1_vmm(struct nvkm_bar *);
void nv50_bar_bar2_init(struct nvkm_bar *); void nv50_bar_bar2_init(struct nvkm_bar *);
struct nvkm_vm *nv50_bar_kmap(struct nvkm_bar *); struct nvkm_vmm *nv50_bar_bar2_vmm(struct nvkm_bar *);
void nv50_bar_unmap(struct nvkm_bar *, struct nvkm_vma *);
#endif #endif
...@@ -18,7 +18,6 @@ struct nvkm_bar_func { ...@@ -18,7 +18,6 @@ struct nvkm_bar_func {
struct nvkm_vmm *(*vmm)(struct nvkm_bar *); struct nvkm_vmm *(*vmm)(struct nvkm_bar *);
} bar1, bar2; } bar1, bar2;
struct nvkm_vm *(*kmap)(struct nvkm_bar *);
void (*flush)(struct nvkm_bar *); void (*flush)(struct nvkm_bar *);
}; };
......
...@@ -107,11 +107,10 @@ nv50_instobj_acquire(struct nvkm_memory *memory) ...@@ -107,11 +107,10 @@ nv50_instobj_acquire(struct nvkm_memory *memory)
{ {
struct nv50_instobj *iobj = nv50_instobj(memory); struct nv50_instobj *iobj = nv50_instobj(memory);
struct nv50_instmem *imem = iobj->imem; struct nv50_instmem *imem = iobj->imem;
struct nvkm_bar *bar = imem->base.subdev.device->bar;
struct nvkm_vm *vm; struct nvkm_vm *vm;
unsigned long flags; unsigned long flags;
if (!iobj->map && (vm = nvkm_bar_kmap(bar))) if (!iobj->map && (vm = nvkm_bar_bar2_vmm(imem->base.subdev.device)))
nvkm_memory_boot(memory, vm); nvkm_memory_boot(memory, vm);
if (!IS_ERR_OR_NULL(iobj->map)) if (!IS_ERR_OR_NULL(iobj->map))
return iobj->map; return iobj->map;
......
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