1 | #ifndef __NOUVEAU_SVM_H__ |
2 | #define __NOUVEAU_SVM_H__ |
3 | #include <nvif/os.h> |
4 | #include <linux/mmu_notifier.h> |
5 | struct drm_device; |
6 | struct drm_file; |
7 | struct nouveau_drm; |
8 | |
9 | struct nouveau_svmm { |
10 | struct mmu_notifier notifier; |
11 | struct nouveau_vmm *vmm; |
12 | struct { |
13 | unsigned long start; |
14 | unsigned long limit; |
15 | } unmanaged; |
16 | |
17 | struct mutex mutex; |
18 | }; |
19 | |
20 | #if IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM) |
21 | void nouveau_svm_init(struct nouveau_drm *); |
22 | void nouveau_svm_fini(struct nouveau_drm *); |
23 | void nouveau_svm_suspend(struct nouveau_drm *); |
24 | void nouveau_svm_resume(struct nouveau_drm *); |
25 | |
26 | int nouveau_svmm_init(struct drm_device *, void *, struct drm_file *); |
27 | void nouveau_svmm_fini(struct nouveau_svmm **); |
28 | int nouveau_svmm_join(struct nouveau_svmm *, u64 inst); |
29 | void nouveau_svmm_part(struct nouveau_svmm *, u64 inst); |
30 | int nouveau_svmm_bind(struct drm_device *, void *, struct drm_file *); |
31 | |
32 | void nouveau_svmm_invalidate(struct nouveau_svmm *svmm, u64 start, u64 limit); |
33 | u64 *nouveau_pfns_alloc(unsigned long npages); |
34 | void nouveau_pfns_free(u64 *pfns); |
35 | void nouveau_pfns_map(struct nouveau_svmm *svmm, struct mm_struct *mm, |
36 | unsigned long addr, u64 *pfns, unsigned long npages); |
37 | #else /* IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM) */ |
38 | static inline void nouveau_svm_init(struct nouveau_drm *drm) {} |
39 | static inline void nouveau_svm_fini(struct nouveau_drm *drm) {} |
40 | static inline void nouveau_svm_suspend(struct nouveau_drm *drm) {} |
41 | static inline void nouveau_svm_resume(struct nouveau_drm *drm) {} |
42 | |
43 | static inline int nouveau_svmm_init(struct drm_device *device, void *p, |
44 | struct drm_file *file) |
45 | { |
46 | return -ENOSYS; |
47 | } |
48 | |
49 | static inline void nouveau_svmm_fini(struct nouveau_svmm **svmmp) {} |
50 | |
51 | static inline int nouveau_svmm_join(struct nouveau_svmm *svmm, u64 inst) |
52 | { |
53 | return 0; |
54 | } |
55 | |
56 | static inline void nouveau_svmm_part(struct nouveau_svmm *svmm, u64 inst) {} |
57 | |
58 | static inline int nouveau_svmm_bind(struct drm_device *device, void *p, |
59 | struct drm_file *file) |
60 | { |
61 | return -ENOSYS; |
62 | } |
63 | #endif /* IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM) */ |
64 | #endif |
65 | |