]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
drm/nouveau/mmu/gm20b: fork from gf100
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / nouveau / include / nvkm / subdev / mmu.h
1 #ifndef __NVKM_MMU_H__
2 #define __NVKM_MMU_H__
3 #include <core/subdev.h>
4 #include <core/mm.h>
5 struct nvkm_gpuobj;
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 nvkm_vm *vm;
20 struct nvkm_mm_node *node;
21 union {
22 u64 offset;
23 u64 addr;
24 };
25 u32 access;
26 };
27
28 struct nvkm_vm {
29 struct nvkm_mmu *mmu;
30
31 struct mutex mutex;
32 struct nvkm_mm mm;
33 struct kref refcount;
34
35 struct list_head pgd_list;
36 atomic_t engref[NVKM_SUBDEV_NR];
37
38 struct nvkm_vm_pgt *pgt;
39 u32 fpde;
40 u32 lpde;
41 };
42
43 int nvkm_vm_new(struct nvkm_device *, u64 offset, u64 length, u64 mm_offset,
44 struct lock_class_key *, struct nvkm_vm **);
45 int nvkm_vm_ref(struct nvkm_vm *, struct nvkm_vm **, struct nvkm_gpuobj *pgd);
46 int nvkm_vm_boot(struct nvkm_vm *, u64 size);
47 int nvkm_vm_get(struct nvkm_vm *, u64 size, u32 page_shift, u32 access,
48 struct nvkm_vma *);
49 void nvkm_vm_put(struct nvkm_vma *);
50 void nvkm_vm_map(struct nvkm_vma *, struct nvkm_mem *);
51 void nvkm_vm_map_at(struct nvkm_vma *, u64 offset, struct nvkm_mem *);
52 void nvkm_vm_unmap(struct nvkm_vma *);
53 void nvkm_vm_unmap_at(struct nvkm_vma *, u64 offset, u64 length);
54
55 struct nvkm_mmu {
56 const struct nvkm_mmu_func *func;
57 struct nvkm_subdev subdev;
58
59 u64 limit;
60 u8 dma_bits;
61 u8 lpg_shift;
62
63 struct nvkm_vmm *vmm;
64 };
65
66 int nv04_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
67 int nv41_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
68 int nv44_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
69 int nv50_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
70 int g84_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
71 int gf100_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
72 int gk104_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
73 int gk20a_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
74 int gm200_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
75 int gm20b_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
76 #endif