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