nouveau_svm.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. struct nouveau_svmm {
  9. struct mmu_notifier notifier;
  10. struct nouveau_vmm *vmm;
  11. struct {
  12. unsigned long start;
  13. unsigned long limit;
  14. } unmanaged;
  15. struct mutex mutex;
  16. };
  17. #if IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM)
  18. void nouveau_svm_init(struct nouveau_drm *);
  19. void nouveau_svm_fini(struct nouveau_drm *);
  20. void nouveau_svm_suspend(struct nouveau_drm *);
  21. void nouveau_svm_resume(struct nouveau_drm *);
  22. int nouveau_svmm_init(struct drm_device *, void *, struct drm_file *);
  23. void nouveau_svmm_fini(struct nouveau_svmm **);
  24. int nouveau_svmm_join(struct nouveau_svmm *, u64 inst);
  25. void nouveau_svmm_part(struct nouveau_svmm *, u64 inst);
  26. int nouveau_svmm_bind(struct drm_device *, void *, struct drm_file *);
  27. void nouveau_svmm_invalidate(struct nouveau_svmm *svmm, u64 start, u64 limit);
  28. u64 *nouveau_pfns_alloc(unsigned long npages);
  29. void nouveau_pfns_free(u64 *pfns);
  30. void nouveau_pfns_map(struct nouveau_svmm *svmm, struct mm_struct *mm,
  31. unsigned long addr, u64 *pfns, unsigned long npages);
  32. #else /* IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM) */
  33. static inline void nouveau_svm_init(struct nouveau_drm *drm) {}
  34. static inline void nouveau_svm_fini(struct nouveau_drm *drm) {}
  35. static inline void nouveau_svm_suspend(struct nouveau_drm *drm) {}
  36. static inline void nouveau_svm_resume(struct nouveau_drm *drm) {}
  37. static inline int nouveau_svmm_init(struct drm_device *device, void *p,
  38. struct drm_file *file)
  39. {
  40. return -ENOSYS;
  41. }
  42. static inline void nouveau_svmm_fini(struct nouveau_svmm **svmmp) {}
  43. static inline int nouveau_svmm_join(struct nouveau_svmm *svmm, u64 inst)
  44. {
  45. return 0;
  46. }
  47. static inline void nouveau_svmm_part(struct nouveau_svmm *svmm, u64 inst) {}
  48. static inline int nouveau_svmm_bind(struct drm_device *device, void *p,
  49. struct drm_file *file)
  50. {
  51. return -ENOSYS;
  52. }
  53. #endif /* IS_ENABLED(CONFIG_DRM_NOUVEAU_SVM) */
  54. #endif