summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2017-07-31 14:01:57 +1000
committerJérôme Glisse <jglisse@redhat.com>2017-08-09 18:13:31 -0400
commitae6a2be6c08905a493fcabe1d9242c8cf4caf2c8 (patch)
treeae566f7ed0bd5b07d7671acc2bdb33a3cecbbf7d
parent5878d7c68b7409f14fffb6460d1df60161725430 (diff)
mmu/nv41: implement vmm on top of new base
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv41.c22
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv04.h1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv41.c51
4 files changed, 67 insertions, 8 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild
index 603682dac9a2..cb48aa0dd423 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild
@@ -9,3 +9,4 @@ nvkm-y += nvkm/subdev/mmu/gp100.o
nvkm-y += nvkm/subdev/mmu/vmm.o
nvkm-y += nvkm/subdev/mmu/vmmnv04.o
+nvkm-y += nvkm/subdev/mmu/vmmnv41.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv41.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv41.c
index c6a26f907009..efb434c77edb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv41.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv41.c
@@ -22,6 +22,7 @@
* Authors: Ben Skeggs
*/
#include "nv04.h"
+#include "vmmnv04.h"
#include <core/gpuobj.h>
#include <core/option.h>
@@ -92,15 +93,10 @@ nv41_mmu_oneinit(struct nvkm_mmu *base)
struct nvkm_device *device = mmu->base.subdev.device;
int ret;
- ret = nvkm_vm_create(&mmu->base, 0, NV41_GART_SIZE, 0, 4096, NULL,
- &mmu->vm);
- if (ret)
- return ret;
-
ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST,
(NV41_GART_SIZE / NV41_GART_PAGE) * 4, 16, true,
- &mmu->vm->pgt[0].mem[0]);
- mmu->vm->pgt[0].refcount[0] = 1;
+ &mmu->base.vmm->pgt[0].mem[0]);
+ mmu->base.vmm->pgt[0].refcount[0] = 1;
return ret;
}
@@ -109,12 +105,20 @@ nv41_mmu_init(struct nvkm_mmu *base)
{
struct nv04_mmu *mmu = nv04_mmu(base);
struct nvkm_device *device = mmu->base.subdev.device;
- struct nvkm_memory *dma = mmu->vm->pgt[0].mem[0];
+ struct nvkm_memory *dma = mmu->base.vmm->pgt[0].mem[0];
nvkm_wr32(device, 0x100800, 0x00000002 | nvkm_memory_addr(dma));
nvkm_mask(device, 0x10008c, 0x00000100, 0x00000100);
nvkm_wr32(device, 0x100820, 0x00000000);
}
+static int
+nv41_mmu_uvmm(struct nvkm_mmu *base, int i, const struct nvkm_vmm_user **puvmm)
+{
+ if (i == 0)
+ *puvmm = &nv41_vmm_user;
+ return 1;
+}
+
static const struct nvkm_mmu_func
nv41_mmu = {
.dtor = nv04_mmu_dtor,
@@ -128,6 +132,8 @@ nv41_mmu = {
.map_sg = nv41_vm_map_sg,
.unmap = nv41_vm_unmap,
.flush = nv41_vm_flush,
+ .uvmm = nv41_mmu_uvmm,
+ .vmm_global = true,
};
int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv04.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv04.h
index 52eed3669dd1..e12013829f6e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv04.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv04.h
@@ -13,4 +13,5 @@ void *nv04_vmm_dtor(struct nvkm_vmm *);
const struct nvkm_vmm_page *nv04_vmm_page(struct nvkm_vmm *);
extern const struct nvkm_vmm_user nv04_vmm_user;
+extern const struct nvkm_vmm_user nv41_vmm_user;
#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv41.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv41.c
new file mode 100644
index 000000000000..00edb2d7f2f1
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv41.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2017 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include "vmmnv04.h"
+
+static const struct nvkm_vmm_func
+nv41_vmm = {
+ .dtor = nv04_vmm_dtor,
+ .page = nv04_vmm_page,
+};
+
+static int
+nv41_vmm_new(struct nvkm_mmu *mmu, u64 addr, u64 size, void *argv, u32 argc,
+ struct lock_class_key *key, struct nvkm_vmm **pvmm)
+{
+ struct nv04_vmm *vmm;
+ int ret;
+
+ if (argc != 0)
+ return -ENOSYS;
+
+ ret = nv04_vmm_new_(&nv41_vmm, mmu, 29, addr, size, key, &vmm);
+ *pvmm = vmm ? &vmm->base : NULL;
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+const struct nvkm_vmm_user
+nv41_vmm_user = {
+ .ctor = nv41_vmm_new,
+};