xref: /linux/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/priv.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_MMU_PRIV_H__
3 #define __NVKM_MMU_PRIV_H__
4 #define nvkm_mmu(p) container_of((p), struct nvkm_mmu, subdev)
5 #include <subdev/mmu.h>
6 
7 int r535_mmu_new(const struct nvkm_mmu_func *hw, struct nvkm_device *, enum nvkm_subdev_type, int,
8 		 struct nvkm_mmu **);
9 
10 void nvkm_mmu_ctor(const struct nvkm_mmu_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
11 		   struct nvkm_mmu *);
12 int nvkm_mmu_new_(const struct nvkm_mmu_func *, struct nvkm_device *, enum nvkm_subdev_type, int,
13 		  struct nvkm_mmu **);
14 
15 struct nvkm_mmu_func {
16 	void (*dtor)(struct nvkm_mmu *);
17 	void (*init)(struct nvkm_mmu *);
18 
19 	u8  dma_bits;
20 
21 	struct {
22 		struct nvkm_sclass user;
23 	} mmu;
24 
25 	struct {
26 		struct nvkm_sclass user;
27 		int (*vram)(struct nvkm_mmu *, int type, u8 page, u64 size,
28 			    void *argv, u32 argc, struct nvkm_memory **);
29 		int (*umap)(struct nvkm_mmu *, struct nvkm_memory *, void *argv,
30 			    u32 argc, u64 *addr, u64 *size, struct nvkm_vma **);
31 	} mem;
32 
33 	struct {
34 		struct nvkm_sclass user;
35 		int (*ctor)(struct nvkm_mmu *, bool managed, u64 addr, u64 size,
36 			    void *argv, u32 argc, struct lock_class_key *,
37 			    const char *name, struct nvkm_vmm **);
38 		bool global;
39 		u32 pd_offset;
40 	} vmm;
41 
42 	const u8 *(*kind)(struct nvkm_mmu *, int *count, u8 *invalid);
43 	bool kind_sys;
44 
45 	int (*promote_vmm)(struct nvkm_vmm *);
46 };
47 
48 extern const struct nvkm_mmu_func nv04_mmu;
49 
50 const u8 *nv50_mmu_kind(struct nvkm_mmu *, int *count, u8 *invalid);
51 
52 const u8 *gf100_mmu_kind(struct nvkm_mmu *, int *count, u8 *invalid);
53 
54 const u8 *gm200_mmu_kind(struct nvkm_mmu *, int *, u8 *);
55 
56 struct nvkm_mmu_pt {
57 	union {
58 		struct nvkm_mmu_ptc *ptc;
59 		struct nvkm_mmu_ptp *ptp;
60 	};
61 	struct nvkm_memory *memory;
62 	bool sub;
63 	u16 base;
64 	u64 addr;
65 	struct list_head head;
66 };
67 
68 void nvkm_mmu_ptc_dump(struct nvkm_mmu *);
69 struct nvkm_mmu_pt *
70 nvkm_mmu_ptc_get(struct nvkm_mmu *, u32 size, u32 align, bool zero);
71 void nvkm_mmu_ptc_put(struct nvkm_mmu *, bool force, struct nvkm_mmu_pt **);
72 #endif
73