Commit 570889dc authored by Ben Skeggs's avatar Ben Skeggs

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

Upcoming changes will remove the nvkm_vmm pointer from nvkm_vma, instead
requiring it to be explicitly specified on each operation.

It's not currently possible to get this information for BAR1 mappings,
so let's fix that ahead of time.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent e988952e
#ifndef __NVKM_OS_H__ #ifndef __NVKM_OS_H__
#define __NVKM_OS_H__ #define __NVKM_OS_H__
#include <nvif/os.h> #include <nvif/os.h>
#define nvkm_vmm nvkm_vm
#endif #endif
...@@ -14,11 +14,11 @@ struct nvkm_bar { ...@@ -14,11 +14,11 @@ struct nvkm_bar {
bool iomap_uncached; bool iomap_uncached;
}; };
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 *);
void nvkm_bar_flush(struct nvkm_bar *); void nvkm_bar_flush(struct nvkm_bar *);
struct nvkm_vm *nvkm_bar_kmap(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 *);
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 **);
......
...@@ -1362,13 +1362,13 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg) ...@@ -1362,13 +1362,13 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)
reg->bus.base = device->func->resource_addr(device, 1); reg->bus.base = device->func->resource_addr(device, 1);
reg->bus.is_iomem = true; reg->bus.is_iomem = true;
if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) { if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
struct nvkm_bar *bar = nvxx_bar(&drm->client.device); struct nvkm_vmm *bar = nvkm_bar_bar1_vmm(device);
int page_shift = 12; int page_shift = 12;
if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_FERMI) if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_FERMI)
page_shift = mem->page_shift; page_shift = mem->page_shift;
ret = nvkm_bar_umap(bar, mem->size << 12, page_shift, ret = nvkm_vm_get(bar, mem->size << 12, page_shift,
&mem->bar_vma); NV_MEM_ACCESS_RW, &mem->bar_vma);
if (ret) if (ret)
return ret; return ret;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <core/enum.h> #include <core/enum.h>
#include <core/gpuobj.h> #include <core/gpuobj.h>
#include <subdev/bar.h> #include <subdev/bar.h>
#include <subdev/fb.h>
#include <engine/sw.h> #include <engine/sw.h>
#include <nvif/class.h> #include <nvif/class.h>
...@@ -559,6 +560,7 @@ gf100_fifo_oneinit(struct nvkm_fifo *base) ...@@ -559,6 +560,7 @@ gf100_fifo_oneinit(struct nvkm_fifo *base)
struct gf100_fifo *fifo = gf100_fifo(base); struct gf100_fifo *fifo = gf100_fifo(base);
struct nvkm_subdev *subdev = &fifo->base.engine.subdev; struct nvkm_subdev *subdev = &fifo->base.engine.subdev;
struct nvkm_device *device = subdev->device; struct nvkm_device *device = subdev->device;
struct nvkm_vmm *bar = nvkm_bar_bar1_vmm(device);
int ret; int ret;
/* Determine number of PBDMAs by checking valid enable bits. */ /* Determine number of PBDMAs by checking valid enable bits. */
...@@ -584,7 +586,8 @@ gf100_fifo_oneinit(struct nvkm_fifo *base) ...@@ -584,7 +586,8 @@ gf100_fifo_oneinit(struct nvkm_fifo *base)
if (ret) if (ret)
return ret; return ret;
ret = nvkm_bar_umap(device->bar, 128 * 0x1000, 12, &fifo->user.bar); ret = nvkm_vm_get(bar, nvkm_memory_size(fifo->user.mem), 12,
NV_MEM_ACCESS_RW, &fifo->user.bar);
if (ret) if (ret)
return ret; return ret;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <core/client.h> #include <core/client.h>
#include <core/gpuobj.h> #include <core/gpuobj.h>
#include <subdev/bar.h> #include <subdev/bar.h>
#include <subdev/fb.h>
#include <subdev/timer.h> #include <subdev/timer.h>
#include <subdev/top.h> #include <subdev/top.h>
#include <engine/sw.h> #include <engine/sw.h>
...@@ -771,6 +772,7 @@ gk104_fifo_oneinit(struct nvkm_fifo *base) ...@@ -771,6 +772,7 @@ gk104_fifo_oneinit(struct nvkm_fifo *base)
struct gk104_fifo *fifo = gk104_fifo(base); struct gk104_fifo *fifo = gk104_fifo(base);
struct nvkm_subdev *subdev = &fifo->base.engine.subdev; struct nvkm_subdev *subdev = &fifo->base.engine.subdev;
struct nvkm_device *device = subdev->device; struct nvkm_device *device = subdev->device;
struct nvkm_vmm *bar = nvkm_bar_bar1_vmm(device);
int engn, runl, pbid, ret, i, j; int engn, runl, pbid, ret, i, j;
enum nvkm_devidx engidx; enum nvkm_devidx engidx;
u32 *map; u32 *map;
...@@ -834,8 +836,8 @@ gk104_fifo_oneinit(struct nvkm_fifo *base) ...@@ -834,8 +836,8 @@ gk104_fifo_oneinit(struct nvkm_fifo *base)
if (ret) if (ret)
return ret; return ret;
ret = nvkm_bar_umap(device->bar, fifo->base.nr * 0x200, 12, ret = nvkm_vm_get(bar, nvkm_memory_size(fifo->user.mem), 12,
&fifo->user.bar); NV_MEM_ACCESS_RW, &fifo->user.bar);
if (ret) if (ret)
return ret; return ret;
......
...@@ -39,10 +39,10 @@ nvkm_bar_kmap(struct nvkm_bar *bar) ...@@ -39,10 +39,10 @@ nvkm_bar_kmap(struct nvkm_bar *bar)
return NULL; return NULL;
} }
int struct nvkm_vmm *
nvkm_bar_umap(struct nvkm_bar *bar, u64 size, int type, struct nvkm_vma *vma) nvkm_bar_bar1_vmm(struct nvkm_device *device)
{ {
return bar->func->umap(bar, size, type, vma); return device->bar->func->bar1.vmm(device->bar);
} }
void void
......
...@@ -47,11 +47,11 @@ g84_bar_func = { ...@@ -47,11 +47,11 @@ g84_bar_func = {
.bar1.init = nv50_bar_bar1_init, .bar1.init = nv50_bar_bar1_init,
.bar1.fini = nv50_bar_bar1_fini, .bar1.fini = nv50_bar_bar1_fini,
.bar1.wait = nv50_bar_bar1_wait, .bar1.wait = nv50_bar_bar1_wait,
.bar1.vmm = nv50_bar_bar1_vmm,
.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, .kmap = nv50_bar_kmap,
.umap = nv50_bar_umap,
.flush = g84_bar_flush, .flush = g84_bar_flush,
}; };
......
...@@ -34,11 +34,10 @@ gf100_bar_kmap(struct nvkm_bar *base) ...@@ -34,11 +34,10 @@ gf100_bar_kmap(struct nvkm_bar *base)
return gf100_bar(base)->bar[0].vm; return gf100_bar(base)->bar[0].vm;
} }
int struct nvkm_vmm *
gf100_bar_umap(struct nvkm_bar *base, u64 size, int type, struct nvkm_vma *vma) gf100_bar_bar1_vmm(struct nvkm_bar *base)
{ {
struct gf100_bar *bar = gf100_bar(base); return gf100_bar(base)->bar[1].vm;
return nvkm_vm_get(bar->bar[1].vm, size, type, NV_MEM_ACCESS_RW, vma);
} }
void void
...@@ -195,11 +194,11 @@ gf100_bar_func = { ...@@ -195,11 +194,11 @@ gf100_bar_func = {
.bar1.init = gf100_bar_bar1_init, .bar1.init = gf100_bar_bar1_init,
.bar1.fini = gf100_bar_bar1_fini, .bar1.fini = gf100_bar_bar1_fini,
.bar1.wait = gf100_bar_bar1_wait, .bar1.wait = gf100_bar_bar1_wait,
.bar1.vmm = gf100_bar_bar1_vmm,
.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, .kmap = gf100_bar_kmap,
.umap = gf100_bar_umap,
.flush = g84_bar_flush, .flush = g84_bar_flush,
}; };
......
...@@ -21,6 +21,6 @@ void *gf100_bar_dtor(struct nvkm_bar *); ...@@ -21,6 +21,6 @@ void *gf100_bar_dtor(struct nvkm_bar *);
int gf100_bar_oneinit(struct nvkm_bar *); int gf100_bar_oneinit(struct nvkm_bar *);
void gf100_bar_bar1_init(struct nvkm_bar *); 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 *);
void gf100_bar_bar2_init(struct nvkm_bar *); void gf100_bar_bar2_init(struct nvkm_bar *);
int gf100_bar_umap(struct nvkm_bar *, u64, int, struct nvkm_vma *);
#endif #endif
...@@ -28,7 +28,7 @@ gk20a_bar_func = { ...@@ -28,7 +28,7 @@ gk20a_bar_func = {
.bar1.init = gf100_bar_bar1_init, .bar1.init = gf100_bar_bar1_init,
.bar1.fini = gf100_bar_bar1_fini, .bar1.fini = gf100_bar_bar1_fini,
.bar1.wait = gf100_bar_bar1_wait, .bar1.wait = gf100_bar_bar1_wait,
.umap = gf100_bar_umap, .bar1.vmm = gf100_bar_bar1_vmm,
.flush = g84_bar_flush, .flush = g84_bar_flush,
}; };
......
...@@ -34,13 +34,6 @@ nv50_bar_kmap(struct nvkm_bar *base) ...@@ -34,13 +34,6 @@ nv50_bar_kmap(struct nvkm_bar *base)
return nv50_bar(base)->bar2_vm; return nv50_bar(base)->bar2_vm;
} }
int
nv50_bar_umap(struct nvkm_bar *base, u64 size, int type, struct nvkm_vma *vma)
{
struct nv50_bar *bar = nv50_bar(base);
return nvkm_vm_get(bar->bar1_vm, size, type, NV_MEM_ACCESS_RW, vma);
}
static void static void
nv50_bar_flush(struct nvkm_bar *base) nv50_bar_flush(struct nvkm_bar *base)
{ {
...@@ -56,6 +49,12 @@ nv50_bar_flush(struct nvkm_bar *base) ...@@ -56,6 +49,12 @@ nv50_bar_flush(struct nvkm_bar *base)
spin_unlock_irqrestore(&bar->base.lock, flags); spin_unlock_irqrestore(&bar->base.lock, flags);
} }
struct nvkm_vmm *
nv50_bar_bar1_vmm(struct nvkm_bar *base)
{
return nv50_bar(base)->bar1_vm;
}
void void
nv50_bar_bar1_wait(struct nvkm_bar *base) nv50_bar_bar1_wait(struct nvkm_bar *base)
{ {
...@@ -229,11 +228,11 @@ nv50_bar_func = { ...@@ -229,11 +228,11 @@ nv50_bar_func = {
.bar1.init = nv50_bar_bar1_init, .bar1.init = nv50_bar_bar1_init,
.bar1.fini = nv50_bar_bar1_fini, .bar1.fini = nv50_bar_bar1_fini,
.bar1.wait = nv50_bar_bar1_wait, .bar1.wait = nv50_bar_bar1_wait,
.bar1.vmm = nv50_bar_bar1_vmm,
.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, .kmap = nv50_bar_kmap,
.umap = nv50_bar_umap,
.flush = nv50_bar_flush, .flush = nv50_bar_flush,
}; };
......
...@@ -22,8 +22,8 @@ int nv50_bar_oneinit(struct nvkm_bar *); ...@@ -22,8 +22,8 @@ int nv50_bar_oneinit(struct nvkm_bar *);
void nv50_bar_init(struct nvkm_bar *); void nv50_bar_init(struct nvkm_bar *);
void nv50_bar_bar1_init(struct nvkm_bar *); 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 *);
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_vm *nv50_bar_kmap(struct nvkm_bar *);
int nv50_bar_umap(struct nvkm_bar *, u64, int, struct nvkm_vma *);
void nv50_bar_unmap(struct nvkm_bar *, struct nvkm_vma *); void nv50_bar_unmap(struct nvkm_bar *, struct nvkm_vma *);
#endif #endif
...@@ -15,10 +15,10 @@ struct nvkm_bar_func { ...@@ -15,10 +15,10 @@ struct nvkm_bar_func {
void (*init)(struct nvkm_bar *); void (*init)(struct nvkm_bar *);
void (*fini)(struct nvkm_bar *); void (*fini)(struct nvkm_bar *);
void (*wait)(struct nvkm_bar *); void (*wait)(struct nvkm_bar *);
struct nvkm_vmm *(*vmm)(struct nvkm_bar *);
} bar1, bar2; } bar1, bar2;
struct nvkm_vm *(*kmap)(struct nvkm_bar *); struct nvkm_vm *(*kmap)(struct nvkm_bar *);
int (*umap)(struct nvkm_bar *, u64 size, int type, struct nvkm_vma *);
void (*flush)(struct nvkm_bar *); void (*flush)(struct nvkm_bar *);
}; };
......
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