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