]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
drm/nouveau/mmu: implement page table sub-allocation
[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 bool bootstrapped;
43 };
44
45 int nvkm_vm_new(struct nvkm_device *, u64 offset, u64 length, u64 mm_offset,
46 struct lock_class_key *, struct nvkm_vm **);
47 int nvkm_vm_ref(struct nvkm_vm *, struct nvkm_vm **, struct nvkm_gpuobj *pgd);
48 int nvkm_vm_boot(struct nvkm_vm *, u64 size);
49 int nvkm_vm_get(struct nvkm_vm *, u64 size, u32 page_shift, u32 access,
50 struct nvkm_vma *);
51 void nvkm_vm_put(struct nvkm_vma *);
52 void nvkm_vm_map(struct nvkm_vma *, struct nvkm_mem *);
53 void nvkm_vm_map_at(struct nvkm_vma *, u64 offset, struct nvkm_mem *);
54 void nvkm_vm_unmap(struct nvkm_vma *);
55 void nvkm_vm_unmap_at(struct nvkm_vma *, u64 offset, u64 length);
56
57 struct nvkm_mmu {
58 const struct nvkm_mmu_func *func;
59 struct nvkm_subdev subdev;
60
61 u64 limit;
62 u8 dma_bits;
63 u8 lpg_shift;
64
65 struct nvkm_vmm *vmm;
66
67 struct {
68 struct mutex mutex;
69 struct list_head list;
70 } ptc, ptp;
71 };
72
73 int nv04_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
74 int nv41_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
75 int nv44_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
76 int nv50_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
77 int g84_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
78 int gf100_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
79 int gk104_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
80 int gk20a_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
81 int gm200_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
82 int gm20b_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
83 int gp100_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
84 int gp10b_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
85 #endif