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 8#include <linux/mm_types.h> 9 10/* I/O Page fault */ 11struct device; 12struct iommu_fault; 13struct iopf_queue; 14 15#ifdef CONFIG_IOMMU_SVA 16int iommu_queue_iopf(struct iommu_fault *fault, void *cookie); 17 18int iopf_queue_add_device(struct iopf_queue *queue, struct device *dev); 19int iopf_queue_remove_device(struct iopf_queue *queue, 20 struct device *dev); 21int iopf_queue_flush_dev(struct device *dev); 22struct iopf_queue *iopf_queue_alloc(const char *name); 23void iopf_queue_free(struct iopf_queue *queue); 24int iopf_queue_discard_partial(struct iopf_queue *queue); 25enum iommu_page_response_code 26iommu_sva_handle_iopf(struct iommu_fault *fault, void *data); 27 28#else /* CONFIG_IOMMU_SVA */ 29static inline int iommu_queue_iopf(struct iommu_fault *fault, void *cookie) 30{ 31 return -ENODEV; 32} 33 34static inline int iopf_queue_add_device(struct iopf_queue *queue, 35 struct device *dev) 36{ 37 return -ENODEV; 38} 39 40static inline int iopf_queue_remove_device(struct iopf_queue *queue, 41 struct device *dev) 42{ 43 return -ENODEV; 44} 45 46static inline int iopf_queue_flush_dev(struct device *dev) 47{ 48 return -ENODEV; 49} 50 51static inline struct iopf_queue *iopf_queue_alloc(const char *name) 52{ 53 return NULL; 54} 55 56static inline void iopf_queue_free(struct iopf_queue *queue) 57{ 58} 59 60static inline int iopf_queue_discard_partial(struct iopf_queue *queue) 61{ 62 return -ENODEV; 63} 64 65static inline enum iommu_page_response_code 66iommu_sva_handle_iopf(struct iommu_fault *fault, void *data) 67{ 68 return IOMMU_PAGE_RESP_INVALID; 69} 70#endif /* CONFIG_IOMMU_SVA */ 71#endif /* _IOMMU_SVA_H */ 72