xref: /linux/drivers/gpu/drm/nouveau/include/nvif/vmm.h (revision a1c613ae4c322ddd58d5a8539dbfba2a0380a8c0)
1920d2b5eSBen Skeggs #ifndef __NVIF_VMM_H__
2920d2b5eSBen Skeggs #define __NVIF_VMM_H__
3920d2b5eSBen Skeggs #include <nvif/object.h>
4920d2b5eSBen Skeggs struct nvif_mem;
5920d2b5eSBen Skeggs struct nvif_mmu;
6920d2b5eSBen Skeggs 
7*6b252cf4SDanilo Krummrich enum nvif_vmm_type {
8*6b252cf4SDanilo Krummrich 	UNMANAGED,
9*6b252cf4SDanilo Krummrich 	MANAGED,
10*6b252cf4SDanilo Krummrich 	RAW,
11*6b252cf4SDanilo Krummrich };
12*6b252cf4SDanilo Krummrich 
13920d2b5eSBen Skeggs enum nvif_vmm_get {
14920d2b5eSBen Skeggs 	ADDR,
15920d2b5eSBen Skeggs 	PTES,
16920d2b5eSBen Skeggs 	LAZY
17920d2b5eSBen Skeggs };
18920d2b5eSBen Skeggs 
19920d2b5eSBen Skeggs struct nvif_vma {
20920d2b5eSBen Skeggs 	u64 addr;
21920d2b5eSBen Skeggs 	u64 size;
22920d2b5eSBen Skeggs };
23920d2b5eSBen Skeggs 
24920d2b5eSBen Skeggs struct nvif_vmm {
25920d2b5eSBen Skeggs 	struct nvif_object object;
26920d2b5eSBen Skeggs 	u64 start;
27920d2b5eSBen Skeggs 	u64 limit;
28920d2b5eSBen Skeggs 
29920d2b5eSBen Skeggs 	struct {
30920d2b5eSBen Skeggs 		u8 shift;
31920d2b5eSBen Skeggs 		bool sparse:1;
32920d2b5eSBen Skeggs 		bool vram:1;
33920d2b5eSBen Skeggs 		bool host:1;
34920d2b5eSBen Skeggs 		bool comp:1;
35920d2b5eSBen Skeggs 	} *page;
36920d2b5eSBen Skeggs 	int page_nr;
37920d2b5eSBen Skeggs };
38920d2b5eSBen Skeggs 
39*6b252cf4SDanilo Krummrich int nvif_vmm_ctor(struct nvif_mmu *, const char *name, s32 oclass,
40*6b252cf4SDanilo Krummrich 		  enum nvif_vmm_type, u64 addr, u64 size, void *argv, u32 argc,
41*6b252cf4SDanilo Krummrich 		  struct nvif_vmm *);
4245faf3d7SBen Skeggs void nvif_vmm_dtor(struct nvif_vmm *);
43920d2b5eSBen Skeggs int nvif_vmm_get(struct nvif_vmm *, enum nvif_vmm_get, bool sparse,
44920d2b5eSBen Skeggs 		 u8 page, u8 align, u64 size, struct nvif_vma *);
45920d2b5eSBen Skeggs void nvif_vmm_put(struct nvif_vmm *, struct nvif_vma *);
46920d2b5eSBen Skeggs int nvif_vmm_map(struct nvif_vmm *, u64 addr, u64 size, void *argv, u32 argc,
47920d2b5eSBen Skeggs 		 struct nvif_mem *, u64 offset);
48920d2b5eSBen Skeggs int nvif_vmm_unmap(struct nvif_vmm *, u64);
49*6b252cf4SDanilo Krummrich 
50*6b252cf4SDanilo Krummrich int nvif_vmm_raw_get(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift);
51*6b252cf4SDanilo Krummrich int nvif_vmm_raw_put(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift);
52*6b252cf4SDanilo Krummrich int nvif_vmm_raw_map(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift,
53*6b252cf4SDanilo Krummrich 		     void *argv, u32 argc, struct nvif_mem *mem, u64 offset);
54*6b252cf4SDanilo Krummrich int nvif_vmm_raw_unmap(struct nvif_vmm *vmm, u64 addr, u64 size,
55*6b252cf4SDanilo Krummrich 		       u8 shift, bool sparse);
56*6b252cf4SDanilo Krummrich int nvif_vmm_raw_sparse(struct nvif_vmm *vmm, u64 addr, u64 size, bool ref);
57920d2b5eSBen Skeggs #endif
58