iommu-sva.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * SVA library for IOMMU drivers
  4. */
  5. #ifndef _IOMMU_SVA_H
  6. #define _IOMMU_SVA_H
  7. #include <linux/ioasid.h>
  8. #include <linux/mm_types.h>
  9. int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t max);
  10. struct mm_struct *iommu_sva_find(ioasid_t pasid);
  11. /* I/O Page fault */
  12. struct device;
  13. struct iommu_fault;
  14. struct iopf_queue;
  15. #ifdef CONFIG_IOMMU_SVA
  16. int iommu_queue_iopf(struct iommu_fault *fault, void *cookie);
  17. int iopf_queue_add_device(struct iopf_queue *queue, struct device *dev);
  18. int iopf_queue_remove_device(struct iopf_queue *queue,
  19. struct device *dev);
  20. int iopf_queue_flush_dev(struct device *dev);
  21. struct iopf_queue *iopf_queue_alloc(const char *name);
  22. void iopf_queue_free(struct iopf_queue *queue);
  23. int iopf_queue_discard_partial(struct iopf_queue *queue);
  24. enum iommu_page_response_code
  25. iommu_sva_handle_iopf(struct iommu_fault *fault, void *data);
  26. #else /* CONFIG_IOMMU_SVA */
  27. static inline int iommu_queue_iopf(struct iommu_fault *fault, void *cookie)
  28. {
  29. return -ENODEV;
  30. }
  31. static inline int iopf_queue_add_device(struct iopf_queue *queue,
  32. struct device *dev)
  33. {
  34. return -ENODEV;
  35. }
  36. static inline int iopf_queue_remove_device(struct iopf_queue *queue,
  37. struct device *dev)
  38. {
  39. return -ENODEV;
  40. }
  41. static inline int iopf_queue_flush_dev(struct device *dev)
  42. {
  43. return -ENODEV;
  44. }
  45. static inline struct iopf_queue *iopf_queue_alloc(const char *name)
  46. {
  47. return NULL;
  48. }
  49. static inline void iopf_queue_free(struct iopf_queue *queue)
  50. {
  51. }
  52. static inline int iopf_queue_discard_partial(struct iopf_queue *queue)
  53. {
  54. return -ENODEV;
  55. }
  56. static inline enum iommu_page_response_code
  57. iommu_sva_handle_iopf(struct iommu_fault *fault, void *data)
  58. {
  59. return IOMMU_PAGE_RESP_INVALID;
  60. }
  61. #endif /* CONFIG_IOMMU_SVA */
  62. #endif /* _IOMMU_SVA_H */