1 /* SPDX-License-Identifier: GPL-2.0 */
3 * SVA library for IOMMU drivers
5 #ifndef _IOMMU_SVA_LIB_H
6 #define _IOMMU_SVA_LIB_H
8 #include <linux/ioasid.h>
9 #include <linux/mm_types.h>
11 int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t max);
12 struct mm_struct *iommu_sva_find(ioasid_t pasid);
19 #ifdef CONFIG_IOMMU_SVA
20 int iommu_queue_iopf(struct iommu_fault *fault, void *cookie);
22 int iopf_queue_add_device(struct iopf_queue *queue, struct device *dev);
23 int iopf_queue_remove_device(struct iopf_queue *queue,
25 int iopf_queue_flush_dev(struct device *dev);
26 struct iopf_queue *iopf_queue_alloc(const char *name);
27 void iopf_queue_free(struct iopf_queue *queue);
28 int iopf_queue_discard_partial(struct iopf_queue *queue);
30 #else /* CONFIG_IOMMU_SVA */
31 static inline int iommu_queue_iopf(struct iommu_fault *fault, void *cookie)
36 static inline int iopf_queue_add_device(struct iopf_queue *queue,
42 static inline int iopf_queue_remove_device(struct iopf_queue *queue,
48 static inline int iopf_queue_flush_dev(struct device *dev)
53 static inline struct iopf_queue *iopf_queue_alloc(const char *name)
58 static inline void iopf_queue_free(struct iopf_queue *queue)
62 static inline int iopf_queue_discard_partial(struct iopf_queue *queue)
66 #endif /* CONFIG_IOMMU_SVA */
67 #endif /* _IOMMU_SVA_LIB_H */