drm/nouveau/mmu/gp100,gp10b: implement vmm on top of new base
authorBen Skeggs <bskeggs@redhat.com>
Tue, 31 Oct 2017 17:56:19 +0000 (03:56 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 2 Nov 2017 03:32:26 +0000 (13:32 +1000)
Adds support for:
- Selection of old/new-style page table layout (GP100MmuLayout=0/1).
- System-memory PDs.

New layout disabled by default for the moment, as we don't have a
backend that can handle it yet.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvif/class.h
drivers/gpu/drm/nouveau/include/nvif/ifc00d.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/gp100.c
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/gp10b.c
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp10b.c [new file with mode: 0644]

index 76dff06..d5236da 100644 (file)
@@ -19,6 +19,7 @@
 #define NVIF_CLASS_VMM_NV50                          /* if500d.h */  0x8000500d
 #define NVIF_CLASS_VMM_GF100                         /* if900d.h */  0x8000900d
 #define NVIF_CLASS_VMM_GM200                         /* ifb00d.h */  0x8000b00d
+#define NVIF_CLASS_VMM_GP100                         /* ifc00d.h */  0x8000c00d
 
 /* the below match nvidia-assigned (either in hw, or sw) class numbers */
 #define NV_NULL_CLASS                                                0x00000030
diff --git a/drivers/gpu/drm/nouveau/include/nvif/ifc00d.h b/drivers/gpu/drm/nouveau/include/nvif/ifc00d.h
new file mode 100644 (file)
index 0000000..39be62c
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __NVIF_IFC00D_H__
+#define __NVIF_IFC00D_H__
+#include "if000c.h"
+
+struct gp100_vmm_vn {
+       /* nvif_vmm_vX ... */
+};
+#endif
index 55963dc..e7ef528 100644 (file)
@@ -22,3 +22,5 @@ nvkm-y += nvkm/subdev/mmu/vmmgk104.o
 nvkm-y += nvkm/subdev/mmu/vmmgk20a.o
 nvkm-y += nvkm/subdev/mmu/vmmgm200.o
 nvkm-y += nvkm/subdev/mmu/vmmgm20b.o
+nvkm-y += nvkm/subdev/mmu/vmmgp100.o
+nvkm-y += nvkm/subdev/mmu/vmmgp10b.o
index 6cfd325..b1ba864 100644 (file)
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#include "priv.h"
+#include "vmm.h"
+
+#include <core/option.h>
+
+#include <nvif/class.h>
 
 static const struct nvkm_mmu_func
 gp100_mmu = {
-       .limit = (1ULL << 40),
-       .dma_bits = 40,
-       .pgt_bits  = 27 - 12,
-       .spg_shift = 12,
-       .lpg_shift = 17,
-       .create = gf100_vm_create,
-       .map_pgt = gf100_vm_map_pgt,
-       .map = gf100_vm_map,
-       .map_sg = gf100_vm_map_sg,
-       .unmap = gf100_vm_unmap,
-       .flush = gf100_vm_flush,
+       .limit = (1ULL << 49),
+       .dma_bits = 47,
+       .lpg_shift = 16,
+       .vmm = {{ -1, -1, NVIF_CLASS_VMM_GP100}, gp100_vmm_new },
 };
 
 int
 gp100_mmu_new(struct nvkm_device *device, int index, struct nvkm_mmu **pmmu)
 {
+       if (!nvkm_boolopt(device->cfgopt, "GP100MmuLayout", false))
+               return gm200_mmu_new(device, index, pmmu);
        return nvkm_mmu_new_(&gp100_mmu, device, index, pmmu);
 }
index e0a41ce..5d760a1 100644 (file)
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  */
-#include "priv.h"
+#include "vmm.h"
+
+#include <core/option.h>
+
+#include <nvif/class.h>
 
 static const struct nvkm_mmu_func
 gp10b_mmu = {
-       .limit = (1ULL << 40),
-       .dma_bits = 40,
-       .pgt_bits  = 27 - 12,
-       .spg_shift = 12,
-       .lpg_shift = 17,
-       .create = gf100_vm_create,
-       .map_pgt = gf100_vm_map_pgt,
-       .map = gf100_vm_map,
-       .map_sg = gf100_vm_map_sg,
-       .unmap = gf100_vm_unmap,
-       .flush = gf100_vm_flush,
+       .limit = (1ULL << 49),
+       .dma_bits = 47,
+       .lpg_shift = 16,
+       .vmm = {{ -1, -1, NVIF_CLASS_VMM_GP100}, gp10b_vmm_new },
 };
 
 int
 gp10b_mmu_new(struct nvkm_device *device, int index, struct nvkm_mmu **pmmu)
 {
+       if (!nvkm_boolopt(device->cfgopt, "GP100MmuLayout", false))
+               return gm20b_mmu_new(device, index, pmmu);
        return nvkm_mmu_new_(&gp10b_mmu, device, index, pmmu);
 }
index 5cca1b4..504408d 100644 (file)
@@ -78,6 +78,9 @@ extern const struct nvkm_vmm_desc gm200_vmm_desc_16_16[];
 extern const struct nvkm_vmm_desc gm200_vmm_desc_17_12[];
 extern const struct nvkm_vmm_desc gm200_vmm_desc_17_17[];
 
+extern const struct nvkm_vmm_desc gp100_vmm_desc_12[];
+extern const struct nvkm_vmm_desc gp100_vmm_desc_16[];
+
 struct nvkm_vmm_page {
        u8 shift;
        const struct nvkm_vmm_desc *desc;
@@ -137,6 +140,8 @@ int gm200_vmm_new_(const struct nvkm_vmm_func *, const struct nvkm_vmm_func *,
 int gm200_vmm_join_(struct nvkm_vmm *, struct nvkm_memory *, u64 base);
 int gm200_vmm_join(struct nvkm_vmm *, struct nvkm_memory *);
 
+int gp100_vmm_join(struct nvkm_vmm *, struct nvkm_memory *);
+
 int nv04_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32,
                 struct lock_class_key *, const char *, struct nvkm_vmm **);
 int nv41_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32,
@@ -165,4 +170,10 @@ int gm20b_vmm_new_fixed(struct nvkm_mmu *, u64, u64, void *, u32,
 int gm20b_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32,
                  struct lock_class_key *, const char *,
                  struct nvkm_vmm **);
+int gp100_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32,
+                 struct lock_class_key *, const char *,
+                 struct nvkm_vmm **);
+int gp10b_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32,
+                 struct lock_class_key *, const char *,
+                 struct nvkm_vmm **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp100.c
new file mode 100644 (file)
index 0000000..68f6781
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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 "vmm.h"
+
+static const struct nvkm_vmm_desc_func
+gp100_vmm_desc_spt = {
+};
+
+static const struct nvkm_vmm_desc_func
+gp100_vmm_desc_lpt = {
+};
+
+static const struct nvkm_vmm_desc_func
+gp100_vmm_desc_pd0 = {
+};
+
+static const struct nvkm_vmm_desc_func
+gp100_vmm_desc_pd1 = {
+};
+
+const struct nvkm_vmm_desc
+gp100_vmm_desc_16[] = {
+       { LPT, 5,  8, 0x0100, &gp100_vmm_desc_lpt },
+       { PGD, 8, 16, 0x1000, &gp100_vmm_desc_pd0 },
+       { PGD, 9,  8, 0x1000, &gp100_vmm_desc_pd1 },
+       { PGD, 9,  8, 0x1000, &gp100_vmm_desc_pd1 },
+       { PGD, 2,  8, 0x1000, &gp100_vmm_desc_pd1 },
+       {}
+};
+
+const struct nvkm_vmm_desc
+gp100_vmm_desc_12[] = {
+       { SPT, 9,  8, 0x1000, &gp100_vmm_desc_spt },
+       { PGD, 8, 16, 0x1000, &gp100_vmm_desc_pd0 },
+       { PGD, 9,  8, 0x1000, &gp100_vmm_desc_pd1 },
+       { PGD, 9,  8, 0x1000, &gp100_vmm_desc_pd1 },
+       { PGD, 2,  8, 0x1000, &gp100_vmm_desc_pd1 },
+       {}
+};
+
+int
+gp100_vmm_join(struct nvkm_vmm *vmm, struct nvkm_memory *inst)
+{
+       const u64 base = BIT_ULL(10) /* VER2 */ | BIT_ULL(11); /* 64KiB */
+       return gf100_vmm_join_(vmm, inst, base);
+}
+
+static const struct nvkm_vmm_func
+gp100_vmm = {
+       .join = gp100_vmm_join,
+       .part = gf100_vmm_part,
+       .page = {
+               { 47, &gp100_vmm_desc_16[4], NVKM_VMM_PAGE_Sxxx },
+               { 38, &gp100_vmm_desc_16[3], NVKM_VMM_PAGE_Sxxx },
+               { 29, &gp100_vmm_desc_16[2], NVKM_VMM_PAGE_Sxxx },
+               { 21, &gp100_vmm_desc_16[1], NVKM_VMM_PAGE_SVxC },
+               { 16, &gp100_vmm_desc_16[0], NVKM_VMM_PAGE_SVxC },
+               { 12, &gp100_vmm_desc_12[0], NVKM_VMM_PAGE_SVHx },
+               {}
+       }
+};
+
+int
+gp100_vmm_new(struct nvkm_mmu *mmu, u64 addr, u64 size, void *argv, u32 argc,
+             struct lock_class_key *key, const char *name,
+             struct nvkm_vmm **pvmm)
+{
+       return nv04_vmm_new_(&gp100_vmm, mmu, 0, addr, size,
+                            argv, argc, key, name, pvmm);
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp10b.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgp10b.c
new file mode 100644 (file)
index 0000000..8b7f9b8
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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 "vmm.h"
+
+static const struct nvkm_vmm_func
+gp10b_vmm = {
+       .join = gp100_vmm_join,
+       .part = gf100_vmm_part,
+       .page = {
+               { 47, &gp100_vmm_desc_16[4], NVKM_VMM_PAGE_Sxxx },
+               { 38, &gp100_vmm_desc_16[3], NVKM_VMM_PAGE_Sxxx },
+               { 29, &gp100_vmm_desc_16[2], NVKM_VMM_PAGE_Sxxx },
+               { 21, &gp100_vmm_desc_16[1], NVKM_VMM_PAGE_SxHC },
+               { 16, &gp100_vmm_desc_16[0], NVKM_VMM_PAGE_SxHC },
+               { 12, &gp100_vmm_desc_12[0], NVKM_VMM_PAGE_SxHx },
+               {}
+       }
+};
+
+int
+gp10b_vmm_new(struct nvkm_mmu *mmu, u64 addr, u64 size, void *argv, u32 argc,
+             struct lock_class_key *key, const char *name,
+             struct nvkm_vmm **pvmm)
+{
+       return nv04_vmm_new_(&gp10b_vmm, mmu, 0, addr, size,
+                            argv, argc, key, name, pvmm);
+}