Merge branch 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
[linux-2.6-microblaze.git] / drivers / iommu / iommu-sva-lib.h
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
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);
14
15 /* I/O Page fault */
16 struct device;
17 struct iommu_fault;
18 struct iopf_queue;
19
20 #ifdef CONFIG_IOMMU_SVA_LIB
21 int iommu_queue_iopf(struct iommu_fault *fault, void *cookie);
22
23 int iopf_queue_add_device(struct iopf_queue *queue, struct device *dev);
24 int iopf_queue_remove_device(struct iopf_queue *queue,
25                              struct device *dev);
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);
30
31 #else /* CONFIG_IOMMU_SVA_LIB */
32 static inline int iommu_queue_iopf(struct iommu_fault *fault, void *cookie)
33 {
34         return -ENODEV;
35 }
36
37 static inline int iopf_queue_add_device(struct iopf_queue *queue,
38                                         struct device *dev)
39 {
40         return -ENODEV;
41 }
42
43 static inline int iopf_queue_remove_device(struct iopf_queue *queue,
44                                            struct device *dev)
45 {
46         return -ENODEV;
47 }
48
49 static inline int iopf_queue_flush_dev(struct device *dev)
50 {
51         return -ENODEV;
52 }
53
54 static inline struct iopf_queue *iopf_queue_alloc(const char *name)
55 {
56         return NULL;
57 }
58
59 static inline void iopf_queue_free(struct iopf_queue *queue)
60 {
61 }
62
63 static inline int iopf_queue_discard_partial(struct iopf_queue *queue)
64 {
65         return -ENODEV;
66 }
67 #endif /* CONFIG_IOMMU_SVA_LIB */
68 #endif /* _IOMMU_SVA_LIB_H */