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 void iommu_sva_free_pasid(struct mm_struct *mm);
13 struct mm_struct *iommu_sva_find(ioasid_t pasid);
20 #ifdef CONFIG_IOMMU_SVA_LIB
21 int iommu_queue_iopf(struct iommu_fault *fault, void *cookie);
23 int iopf_queue_add_device(struct iopf_queue *queue, struct device *dev);
24 int iopf_queue_remove_device(struct iopf_queue *queue,
26 int iopf_queue_flush_dev(struct device *dev);
27 struct iopf_queue *iopf_queue_alloc(const char *name);
28 void iopf_queue_free(struct iopf_queue *queue);
29 int iopf_queue_discard_partial(struct iopf_queue *queue);
31 #else /* CONFIG_IOMMU_SVA_LIB */
32 static inline int iommu_queue_iopf(struct iommu_fault *fault, void *cookie)
37 static inline int iopf_queue_add_device(struct iopf_queue *queue,
43 static inline int iopf_queue_remove_device(struct iopf_queue *queue,
49 static inline int iopf_queue_flush_dev(struct device *dev)
54 static inline struct iopf_queue *iopf_queue_alloc(const char *name)
59 static inline void iopf_queue_free(struct iopf_queue *queue)
63 static inline int iopf_queue_discard_partial(struct iopf_queue *queue)
67 #endif /* CONFIG_IOMMU_SVA_LIB */
68 #endif /* _IOMMU_SVA_LIB_H */