summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2017-07-31 14:13:28 +1000
committerJérôme Glisse <jglisse@redhat.com>2017-08-09 18:13:31 -0400
commitb6f921a3637b6fa60965b4e294fde09154a4a62e (patch)
treee76e40ac224ec4f3188544c4cc170c4d9b97bc11
parent5c811e53b37bcdaa95c3a37549fdfbdb4e6c63cc (diff)
mmu/nv50,g84: 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/Kbuild2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/g84.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.c16
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.h1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmg84.c38
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.c87
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.h20
7 files changed, 158 insertions, 8 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild
index 685a2e2b54fc..74ad6f1894a7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild
@@ -11,3 +11,5 @@ nvkm-y += nvkm/subdev/mmu/vmm.o
nvkm-y += nvkm/subdev/mmu/vmmnv04.o
nvkm-y += nvkm/subdev/mmu/vmmnv41.o
nvkm-y += nvkm/subdev/mmu/vmmnv44.o
+nvkm-y += nvkm/subdev/mmu/vmmnv50.o
+nvkm-y += nvkm/subdev/mmu/vmmg84.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/g84.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/g84.c
index b8f7d887eab0..7fe8c1db931a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/g84.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/g84.c
@@ -20,9 +20,11 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "nv50.h"
+#include "vmmnv50.h"
static const struct nv50_mmu_func
g84_mmu = {
+ .uvmm = &g84_vmm_user,
};
int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.c
index bbd56b2c9514..dffcc3a2a54f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.c
@@ -22,6 +22,7 @@
* Authors: Ben Skeggs
*/
#include "nv50.h"
+#include "vmmnv50.h"
#include <core/gpuobj.h>
#include <subdev/fb.h>
@@ -199,14 +200,12 @@ nv50_vm_flush(struct nvkm_vm *vm)
}
static int
-nv50_vm_create(struct nvkm_mmu *mmu, u64 offset, u64 length, u64 mm_offset,
- struct lock_class_key *key, struct nvkm_vm **pvm)
+nv50_mmu_uvmm(struct nvkm_mmu *base, int i, const struct nvkm_vmm_user **puvmm)
{
- u32 block = (1 << (mmu->func->pgt_bits + 12));
- if (block > length)
- block = length;
-
- return nvkm_vm_create(mmu, offset, length, mm_offset, block, key, pvm);
+ struct nv50_mmu *mmu = nv50_mmu(base);
+ if (i == 0)
+ *puvmm = mmu->func->uvmm;
+ return 1;
}
static void *
@@ -223,12 +222,12 @@ nv50_mmu_ = {
.pgt_bits = 29 - 12,
.spg_shift = 12,
.lpg_shift = 16,
- .create = nv50_vm_create,
.map_pgt = nv50_vm_map_pgt,
.map = nv50_vm_map,
.map_sg = nv50_vm_map_sg,
.unmap = nv50_vm_unmap,
.flush = nv50_vm_flush,
+ .uvmm = nv50_mmu_uvmm,
};
int
@@ -248,6 +247,7 @@ nv50_mmu_new_(const struct nv50_mmu_func *func, struct nvkm_device *device,
static const struct nv50_mmu_func
nv50_mmu = {
+ .uvmm = &nv50_vmm_user,
};
int
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.h
index 6a59e4262d4e..7c0400daa13c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/nv50.h
@@ -9,6 +9,7 @@ struct nv50_mmu {
};
struct nv50_mmu_func {
+ const struct nvkm_vmm_user *uvmm;
};
int nv50_mmu_new_(const struct nv50_mmu_func *, struct nvkm_device *, int,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmg84.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmg84.c
new file mode 100644
index 000000000000..7e63aa8698bc
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmg84.c
@@ -0,0 +1,38 @@
+/*
+ * 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 "vmmnv50.h"
+
+static const struct nv50_vmm_func
+g84_vmm = {
+};
+
+static int
+g84_vmm_new(struct nvkm_mmu *mmu, u64 addr, u64 size, void *argv, u32 argc,
+ struct lock_class_key *key, struct nvkm_vmm **pvmm)
+{
+ return nv50_vmm_new_(&g84_vmm, mmu, addr, size, argv, argc, key, pvmm);
+}
+
+const struct nvkm_vmm_user
+g84_vmm_user = {
+ .ctor = g84_vmm_new,
+};
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.c
new file mode 100644
index 000000000000..5a290832f45e
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.c
@@ -0,0 +1,87 @@
+/*
+ * 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 "vmmnv50.h"
+
+static const struct nvkm_vmm_page *
+nv50_vmm_page(struct nvkm_vmm *base)
+{
+ static const struct nvkm_vmm_page
+ page[] = {
+ { 16, NVKM_VMM_PAGE_COMP },
+ { 12 },
+ {}
+ };
+ return page;
+}
+
+static void *
+nv50_vmm_dtor(struct nvkm_vmm *base)
+{
+ struct nv50_vmm *vmm = nv50_vmm(base);
+ return vmm;
+}
+
+static const struct nvkm_vmm_func
+nv50_vmm_ = {
+ .dtor = nv50_vmm_dtor,
+ .page = nv50_vmm_page,
+ .page_block = 1 << 29,
+};
+
+int
+nv50_vmm_new_(const struct nv50_vmm_func *func, struct nvkm_mmu *mmu,
+ u64 addr, u64 size, void *argv, u32 argc,
+ struct lock_class_key *key, struct nvkm_vmm **pvmm)
+{
+ struct nv50_vmm *vmm;
+ int ret;
+
+ if (argc != 0)
+ return -ENOSYS;
+
+ if (!(vmm = kzalloc(sizeof(*vmm), GFP_KERNEL)))
+ return -ENOMEM;
+ vmm->func = func;
+ *pvmm = &vmm->base;
+
+ ret = nvkm_vmm_ctor(&nv50_vmm_, mmu, 40, addr, size, key, &vmm->base);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static const struct nv50_vmm_func
+nv50_vmm = {
+};
+
+static int
+nv50_vmm_new(struct nvkm_mmu *mmu, u64 addr, u64 size, void *argv, u32 argc,
+ struct lock_class_key *key, struct nvkm_vmm **pvmm)
+{
+ return nv50_vmm_new_(&nv50_vmm, mmu, addr, size, argv, argc, key, pvmm);
+}
+
+const struct nvkm_vmm_user
+nv50_vmm_user = {
+ .ctor = nv50_vmm_new,
+};
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.h
new file mode 100644
index 000000000000..33112c89d270
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.h
@@ -0,0 +1,20 @@
+#ifndef __NV50_VMM_H__
+#define __NV50_VMM_H__
+#define nv50_vmm(p) container_of((p), struct nv50_vmm, base)
+#include "vmm.h"
+
+struct nv50_vmm {
+ const struct nv50_vmm_func *func;
+ struct nvkm_vmm base;
+};
+
+struct nv50_vmm_func {
+};
+
+int nv50_vmm_new_(const struct nv50_vmm_func *, struct nvkm_mmu *,
+ u64, u64, void *, u32, struct lock_class_key *,
+ struct nvkm_vmm **);
+
+extern const struct nvkm_vmm_user nv50_vmm_user;
+extern const struct nvkm_vmm_user g84_vmm_user;
+#endif