]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/nouveau/mmu/gf100: 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:25 +0000 (13:32 +1000)
Adds support for:
- Selection of a 64KiB big page size (NvFbBigPage=16).
- System-memory PDs.

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

index 9c02927b4ca95a5831a224c30e116058fa1dc8f8..df8d6a32d2dc1d0a7b29fee8746498e9f3d4700f 100644 (file)
@@ -17,6 +17,7 @@
 #define NVIF_CLASS_VMM                               /* if000c.h */  0x8000000c
 #define NVIF_CLASS_VMM_NV04                          /* if000d.h */  0x8000000d
 #define NVIF_CLASS_VMM_NV50                          /* if500d.h */  0x8000500d
+#define NVIF_CLASS_VMM_GF100                         /* if900d.h */  0x8000900d
 
 /* 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/if900d.h b/drivers/gpu/drm/nouveau/include/nvif/if900d.h
new file mode 100644 (file)
index 0000000..112716f
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __NVIF_IF900D_H__
+#define __NVIF_IF900D_H__
+#include "if000c.h"
+
+struct gf100_vmm_vn {
+       /* nvif_vmm_vX ... */
+};
+#endif
index 2ec7e50568ab2bb847fcaa27c7222796c990cb25..908e57a2fc96c5d9b4eb8577d4fded3dc27f7316 100644 (file)
@@ -17,3 +17,4 @@ 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/vmmgf100.o
index 3cc1013538c57f3ce4a1e77c8e58f59dd60698e6..6a942e2bcc390fabbcc78460053e243a179abc74 100644 (file)
  *
  * Authors: Ben Skeggs
  */
-#include "priv.h"
+#include "vmm.h"
 
+#include <core/gpuobj.h>
 #include <subdev/fb.h>
 #include <subdev/timer.h>
 
-#include <core/gpuobj.h>
+#include <nvif/class.h>
 
 /* Map from compressed to corresponding uncompressed storage type.
  * The value 0xff represents an invalid storage type.
@@ -209,6 +210,7 @@ gf100_mmu = {
        .map_sg = gf100_vm_map_sg,
        .unmap = gf100_vm_unmap,
        .flush = gf100_vm_flush,
+       .vmm = {{ -1, -1, NVIF_CLASS_VMM_GF100}, gf100_vmm_new },
 };
 
 int
index 894f701c2fe87226dc4904cff3caf4932c08d0eb..1e207ce3faa8ef11484b0c55ead746922f231630 100644 (file)
@@ -52,6 +52,9 @@ struct nvkm_vmm_pt {
 struct nvkm_vmm_desc_func {
 };
 
+extern const struct nvkm_vmm_desc_func gf100_vmm_pgd;
+extern const struct nvkm_vmm_desc_func gf100_vmm_pgt;
+
 struct nvkm_vmm_desc {
        enum {
                PGD,
@@ -111,6 +114,13 @@ int nv04_vmm_new_(const struct nvkm_vmm_func *, struct nvkm_mmu *, u32,
                  u64, u64, void *, u32, struct lock_class_key *,
                  const char *, struct nvkm_vmm **);
 
+int gf100_vmm_new_(const struct nvkm_vmm_func *, const struct nvkm_vmm_func *,
+                  struct nvkm_mmu *, u64, u64, void *, u32,
+                  struct lock_class_key *, const char *, struct nvkm_vmm **);
+int gf100_vmm_join_(struct nvkm_vmm *, struct nvkm_memory *, u64 base);
+int gf100_vmm_join(struct nvkm_vmm *, struct nvkm_memory *);
+void gf100_vmm_part(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,
@@ -121,4 +131,6 @@ int nv50_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32,
                 struct lock_class_key *, const char *, struct nvkm_vmm **);
 int g84_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32,
                struct lock_class_key *, const char *, struct nvkm_vmm **);
+int gf100_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/vmmgf100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgf100.c
new file mode 100644 (file)
index 0000000..f8234af
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * 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"
+
+#include <subdev/fb.h>
+
+const struct nvkm_vmm_desc_func
+gf100_vmm_pgt = {
+};
+
+const struct nvkm_vmm_desc_func
+gf100_vmm_pgd = {
+};
+
+static const struct nvkm_vmm_desc
+gf100_vmm_desc_17_12[] = {
+       { SPT, 15, 8, 0x1000, &gf100_vmm_pgt },
+       { PGD, 13, 8, 0x1000, &gf100_vmm_pgd },
+       {}
+};
+
+static const struct nvkm_vmm_desc
+gf100_vmm_desc_17_17[] = {
+       { LPT, 10, 8, 0x1000, &gf100_vmm_pgt },
+       { PGD, 13, 8, 0x1000, &gf100_vmm_pgd },
+       {}
+};
+
+static const struct nvkm_vmm_desc
+gf100_vmm_desc_16_12[] = {
+       { SPT, 14, 8, 0x1000, &gf100_vmm_pgt },
+       { PGD, 14, 8, 0x1000, &gf100_vmm_pgd },
+       {}
+};
+
+static const struct nvkm_vmm_desc
+gf100_vmm_desc_16_16[] = {
+       { LPT, 10, 8, 0x1000, &gf100_vmm_pgt },
+       { PGD, 14, 8, 0x1000, &gf100_vmm_pgd },
+       {}
+};
+
+void
+gf100_vmm_part(struct nvkm_vmm *vmm, struct nvkm_memory *inst)
+{
+       nvkm_fo64(inst, 0x0200, 0x00000000, 2);
+}
+
+int
+gf100_vmm_join_(struct nvkm_vmm *vmm, struct nvkm_memory *inst, u64 base)
+{
+       struct nvkm_mmu_pt *pd = vmm->pd->pt[0];
+
+       switch (nvkm_memory_target(pd->memory)) {
+       case NVKM_MEM_TARGET_VRAM: base |= 0ULL << 0; break;
+       case NVKM_MEM_TARGET_HOST: base |= 2ULL << 0;
+               base |= BIT_ULL(2) /* VOL. */;
+               break;
+       case NVKM_MEM_TARGET_NCOH: base |= 3ULL << 0; break;
+       default:
+               WARN_ON(1);
+               return -EINVAL;
+       }
+       base |= pd->addr;
+
+       nvkm_kmap(inst);
+       nvkm_wo64(inst, 0x0200, base);
+       nvkm_wo64(inst, 0x0208, vmm->limit - 1);
+       nvkm_done(inst);
+       return 0;
+}
+
+int
+gf100_vmm_join(struct nvkm_vmm *vmm, struct nvkm_memory *inst)
+{
+       return gf100_vmm_join_(vmm, inst, 0);
+}
+
+static const struct nvkm_vmm_func
+gf100_vmm_17 = {
+       .join = gf100_vmm_join,
+       .part = gf100_vmm_part,
+       .page = {
+               { 17, &gf100_vmm_desc_17_17[0], NVKM_VMM_PAGE_xVxC },
+               { 12, &gf100_vmm_desc_17_12[0], NVKM_VMM_PAGE_xVHx },
+               {}
+       }
+};
+
+static const struct nvkm_vmm_func
+gf100_vmm_16 = {
+       .join = gf100_vmm_join,
+       .part = gf100_vmm_part,
+       .page = {
+               { 16, &gf100_vmm_desc_16_16[0], NVKM_VMM_PAGE_xVxC },
+               { 12, &gf100_vmm_desc_16_12[0], NVKM_VMM_PAGE_xVHx },
+               {}
+       }
+};
+
+int
+gf100_vmm_new_(const struct nvkm_vmm_func *func_16,
+              const struct nvkm_vmm_func *func_17,
+              struct nvkm_mmu *mmu, u64 addr, u64 size, void *argv, u32 argc,
+              struct lock_class_key *key, const char *name,
+              struct nvkm_vmm **pvmm)
+{
+       switch (mmu->subdev.device->fb->page) {
+       case 16: return nv04_vmm_new_(func_16, mmu, 0, addr, size,
+                                     argv, argc, key, name, pvmm);
+       case 17: return nv04_vmm_new_(func_17, mmu, 0, addr, size,
+                                     argv, argc, key, name, pvmm);
+       default:
+               WARN_ON(1);
+               return -EINVAL;
+       }
+}
+
+int
+gf100_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 gf100_vmm_new_(&gf100_vmm_16, &gf100_vmm_17, mmu, addr,
+                             size, argv, argc, key, name, pvmm);
+}