xref: /linux/drivers/gpu/drm/nouveau/nouveau_svm.h (revision 7203ca412fc8e8a0588e9adc0f777d3163f8dff3)
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 		      unsigned int page_shift);
38 #else /* IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM) */
nouveau_svm_init(struct nouveau_drm * drm)39 static inline void nouveau_svm_init(struct nouveau_drm *drm) {}
nouveau_svm_fini(struct nouveau_drm * drm)40 static inline void nouveau_svm_fini(struct nouveau_drm *drm) {}
nouveau_svm_suspend(struct nouveau_drm * drm)41 static inline void nouveau_svm_suspend(struct nouveau_drm *drm) {}
nouveau_svm_resume(struct nouveau_drm * drm)42 static inline void nouveau_svm_resume(struct nouveau_drm *drm) {}
43 
nouveau_svmm_init(struct drm_device * device,void * p,struct drm_file * file)44 static inline int nouveau_svmm_init(struct drm_device *device, void *p,
45 				    struct drm_file *file)
46 {
47 	return -ENOSYS;
48 }
49 
nouveau_svmm_fini(struct nouveau_svmm ** svmmp)50 static inline void nouveau_svmm_fini(struct nouveau_svmm **svmmp) {}
51 
nouveau_svmm_join(struct nouveau_svmm * svmm,u64 inst)52 static inline int nouveau_svmm_join(struct nouveau_svmm *svmm, u64 inst)
53 {
54 	return 0;
55 }
56 
nouveau_svmm_part(struct nouveau_svmm * svmm,u64 inst)57 static inline void nouveau_svmm_part(struct nouveau_svmm *svmm, u64 inst) {}
58 
nouveau_svmm_bind(struct drm_device * device,void * p,struct drm_file * file)59 static inline int nouveau_svmm_bind(struct drm_device *device, void *p,
60 				    struct drm_file *file)
61 {
62 	return -ENOSYS;
63 }
64 #endif /* IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM) */
65 #endif
66