xref: /linux/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
1 #ifndef __NVKM_MMU_H__
2 #define __NVKM_MMU_H__
3 #include <core/subdev.h>
4 #include <core/mm.h>
5 struct nvkm_device;
6 struct nvkm_mem;
7 
8 struct nvkm_vm_pgt {
9 	struct nvkm_memory *mem[2];
10 	u32 refcount[2];
11 };
12 
13 struct nvkm_vm_pgd {
14 	struct list_head head;
15 	struct nvkm_gpuobj *obj;
16 };
17 
18 struct nvkm_vma {
19 	struct list_head head;
20 	int refcount;
21 	struct nvkm_vm *vm;
22 	struct nvkm_mm_node *node;
23 	u64 offset;
24 	u32 access;
25 };
26 
27 struct nvkm_vm {
28 	struct nvkm_mmu *mmu;
29 
30 	struct mutex mutex;
31 	struct nvkm_mm mm;
32 	struct kref refcount;
33 
34 	struct list_head pgd_list;
35 	atomic_t engref[NVKM_SUBDEV_NR];
36 
37 	struct nvkm_vm_pgt *pgt;
38 	u32 fpde;
39 	u32 lpde;
40 };
41 
42 int  nvkm_vm_new(struct nvkm_device *, u64 offset, u64 length, u64 mm_offset,
43 		 struct lock_class_key *, struct nvkm_vm **);
44 int  nvkm_vm_ref(struct nvkm_vm *, struct nvkm_vm **, struct nvkm_gpuobj *pgd);
45 int  nvkm_vm_boot(struct nvkm_vm *, u64 size);
46 int  nvkm_vm_get(struct nvkm_vm *, u64 size, u32 page_shift, u32 access,
47 		 struct nvkm_vma *);
48 void nvkm_vm_put(struct nvkm_vma *);
49 void nvkm_vm_map(struct nvkm_vma *, struct nvkm_mem *);
50 void nvkm_vm_map_at(struct nvkm_vma *, u64 offset, struct nvkm_mem *);
51 void nvkm_vm_unmap(struct nvkm_vma *);
52 void nvkm_vm_unmap_at(struct nvkm_vma *, u64 offset, u64 length);
53 
54 struct nvkm_mmu {
55 	const struct nvkm_mmu_func *func;
56 	struct nvkm_subdev subdev;
57 
58 	u64 limit;
59 	u8  dma_bits;
60 	u8  lpg_shift;
61 };
62 
63 int nv04_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
64 int nv41_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
65 int nv44_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
66 int nv50_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
67 int gf100_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
68 #endif
69