xref: /linux/drivers/gpu/drm/nouveau/include/nvif/vmm.h (revision a1c613ae4c322ddd58d5a8539dbfba2a0380a8c0)
1 #ifndef __NVIF_VMM_H__
2 #define __NVIF_VMM_H__
3 #include <nvif/object.h>
4 struct nvif_mem;
5 struct nvif_mmu;
6 
7 enum nvif_vmm_type {
8 	UNMANAGED,
9 	MANAGED,
10 	RAW,
11 };
12 
13 enum nvif_vmm_get {
14 	ADDR,
15 	PTES,
16 	LAZY
17 };
18 
19 struct nvif_vma {
20 	u64 addr;
21 	u64 size;
22 };
23 
24 struct nvif_vmm {
25 	struct nvif_object object;
26 	u64 start;
27 	u64 limit;
28 
29 	struct {
30 		u8 shift;
31 		bool sparse:1;
32 		bool vram:1;
33 		bool host:1;
34 		bool comp:1;
35 	} *page;
36 	int page_nr;
37 };
38 
39 int nvif_vmm_ctor(struct nvif_mmu *, const char *name, s32 oclass,
40 		  enum nvif_vmm_type, u64 addr, u64 size, void *argv, u32 argc,
41 		  struct nvif_vmm *);
42 void nvif_vmm_dtor(struct nvif_vmm *);
43 int nvif_vmm_get(struct nvif_vmm *, enum nvif_vmm_get, bool sparse,
44 		 u8 page, u8 align, u64 size, struct nvif_vma *);
45 void nvif_vmm_put(struct nvif_vmm *, struct nvif_vma *);
46 int nvif_vmm_map(struct nvif_vmm *, u64 addr, u64 size, void *argv, u32 argc,
47 		 struct nvif_mem *, u64 offset);
48 int nvif_vmm_unmap(struct nvif_vmm *, u64);
49 
50 int nvif_vmm_raw_get(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift);
51 int nvif_vmm_raw_put(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift);
52 int nvif_vmm_raw_map(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift,
53 		     void *argv, u32 argc, struct nvif_mem *mem, u64 offset);
54 int nvif_vmm_raw_unmap(struct nvif_vmm *vmm, u64 addr, u64 size,
55 		       u8 shift, bool sparse);
56 int nvif_vmm_raw_sparse(struct nvif_vmm *vmm, u64 addr, u64 size, bool ref);
57 #endif
58