0001
0002
0003
0004
0005 #ifndef _IOMMU_SVA_LIB_H
0006 #define _IOMMU_SVA_LIB_H
0007
0008 #include <linux/ioasid.h>
0009 #include <linux/mm_types.h>
0010
0011 int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t max);
0012 struct mm_struct *iommu_sva_find(ioasid_t pasid);
0013
0014
0015 struct device;
0016 struct iommu_fault;
0017 struct iopf_queue;
0018
0019 #ifdef CONFIG_IOMMU_SVA
0020 int iommu_queue_iopf(struct iommu_fault *fault, void *cookie);
0021
0022 int iopf_queue_add_device(struct iopf_queue *queue, struct device *dev);
0023 int iopf_queue_remove_device(struct iopf_queue *queue,
0024 struct device *dev);
0025 int iopf_queue_flush_dev(struct device *dev);
0026 struct iopf_queue *iopf_queue_alloc(const char *name);
0027 void iopf_queue_free(struct iopf_queue *queue);
0028 int iopf_queue_discard_partial(struct iopf_queue *queue);
0029
0030 #else
0031 static inline int iommu_queue_iopf(struct iommu_fault *fault, void *cookie)
0032 {
0033 return -ENODEV;
0034 }
0035
0036 static inline int iopf_queue_add_device(struct iopf_queue *queue,
0037 struct device *dev)
0038 {
0039 return -ENODEV;
0040 }
0041
0042 static inline int iopf_queue_remove_device(struct iopf_queue *queue,
0043 struct device *dev)
0044 {
0045 return -ENODEV;
0046 }
0047
0048 static inline int iopf_queue_flush_dev(struct device *dev)
0049 {
0050 return -ENODEV;
0051 }
0052
0053 static inline struct iopf_queue *iopf_queue_alloc(const char *name)
0054 {
0055 return NULL;
0056 }
0057
0058 static inline void iopf_queue_free(struct iopf_queue *queue)
0059 {
0060 }
0061
0062 static inline int iopf_queue_discard_partial(struct iopf_queue *queue)
0063 {
0064 return -ENODEV;
0065 }
0066 #endif
0067 #endif