1 /* SPDX-License-Identifier: MIT */
4 #include <core/subdev.h>
5 #include <subdev/gsp.h>
12 bool mapref:1; /* PTs (de)referenced on (un)map (vs pre-allocated). */
13 bool sparse:1; /* Unmapped PDEs/PTEs will not trigger MMU faults. */
14 #define NVKM_VMA_PAGE_NONE 7
15 u8 page:3; /* Requested page type (index, or NONE for automatic). */
16 u8 refd:3; /* Current page type (index, or NONE for unreferenced). */
17 bool used:1; /* Region allocated. */
18 bool part:1; /* Region was split from an allocated region by map(). */
19 bool busy:1; /* Region busy (for temporarily preventing user access). */
20 bool mapped:1; /* Region contains valid pages. */
21 bool no_comp:1; /* Force no memory compression. */
22 struct nvkm_memory *memory; /* Memory currently mapped into VMA. */
23 struct nvkm_tags *tags; /* Compression tag reference. */
27 const struct nvkm_vmm_func *func;
53 struct nvkm_vmm_pt *pd;
54 struct list_head join;
56 struct list_head list;
61 atomic_t engref[NVKM_SUBDEV_NR];
71 struct nvkm_gsp_client client;
72 struct nvkm_gsp_device device;
73 struct nvkm_gsp_object object;
75 struct nvkm_vma *rsvd;
79 int nvkm_vmm_new(struct nvkm_device *, u64 addr, u64 size, void *argv, u32 argc,
80 struct lock_class_key *, const char *name, struct nvkm_vmm **);
81 struct nvkm_vmm *nvkm_vmm_ref(struct nvkm_vmm *);
82 void nvkm_vmm_unref(struct nvkm_vmm **);
83 int nvkm_vmm_boot(struct nvkm_vmm *);
84 int nvkm_vmm_join(struct nvkm_vmm *, struct nvkm_memory *inst);
85 void nvkm_vmm_part(struct nvkm_vmm *, struct nvkm_memory *inst);
86 int nvkm_vmm_get(struct nvkm_vmm *, u8 page, u64 size, struct nvkm_vma **);
87 void nvkm_vmm_put(struct nvkm_vmm *, struct nvkm_vma **);
90 struct nvkm_memory *memory;
93 struct nvkm_mm_node *mem;
94 struct scatterlist *sgl;
99 const struct nvkm_vmm_page *page;
102 struct nvkm_tags *tags;
108 int nvkm_vmm_map(struct nvkm_vmm *, struct nvkm_vma *, void *argv, u32 argc,
109 struct nvkm_vmm_map *);
110 void nvkm_vmm_unmap(struct nvkm_vmm *, struct nvkm_vma *);
112 struct nvkm_memory *nvkm_umem_search(struct nvkm_client *, u64);
113 struct nvkm_vmm *nvkm_uvmm_search(struct nvkm_client *, u64 handle);
116 const struct nvkm_mmu_func *func;
117 struct nvkm_subdev subdev;
123 #define NVKM_MEM_VRAM 0x01
124 #define NVKM_MEM_HOST 0x02
125 #define NVKM_MEM_COMP 0x04
126 #define NVKM_MEM_DISP 0x08
133 #define NVKM_MEM_KIND 0x10
134 #define NVKM_MEM_MAPPABLE 0x20
135 #define NVKM_MEM_COHERENT 0x40
136 #define NVKM_MEM_UNCACHED 0x80
141 struct nvkm_vmm *vmm;
145 struct list_head list;
148 struct mutex mutex; /* serialises mmu invalidations */
150 struct nvkm_device_oclass user;
153 int nv04_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
154 int nv41_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
155 int nv44_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
156 int nv50_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
157 int g84_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
158 int mcp77_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
159 int gf100_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
160 int gk104_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
161 int gk20a_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
162 int gm200_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
163 int gm20b_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
164 int gp100_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
165 int gp10b_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
166 int gv100_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);
167 int tu102_mmu_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_mmu **);