Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[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 struct mm_struct *iommu_sva_find(ioasid_t pasid);
13
14 /* I/O Page fault */
15 struct device;
16 struct iommu_fault;
17 struct iopf_queue;
18
19 #ifdef CONFIG_IOMMU_SVA
20 int iommu_queue_iopf(struct iommu_fault *fault, void *cookie);
21
22 int iopf_queue_add_device(struct iopf_queue *queue, struct device *dev);
23 int iopf_queue_remove_device(struct iopf_queue *queue,
24                              struct device *dev);
25 int iopf_queue_flush_dev(struct device *dev);
26 struct iopf_queue *iopf_queue_alloc(const char *name);
27 void iopf_queue_free(struct iopf_queue *queue);
28 int iopf_queue_discard_partial(struct iopf_queue *queue);
29
30 #else /* CONFIG_IOMMU_SVA */
31 static inline int iommu_queue_iopf(struct iommu_fault *fault, void *cookie)
32 {
33         return -ENODEV;
34 }
35
36 static inline int iopf_queue_add_device(struct iopf_queue *queue,
37                                         struct device *dev)
38 {
39         return -ENODEV;
40 }
41
42 static inline int iopf_queue_remove_device(struct iopf_queue *queue,
43                                            struct device *dev)
44 {
45         return -ENODEV;
46 }
47
48 static inline int iopf_queue_flush_dev(struct device *dev)
49 {
50         return -ENODEV;
51 }
52
53 static inline struct iopf_queue *iopf_queue_alloc(const char *name)
54 {
55         return NULL;
56 }
57
58 static inline void iopf_queue_free(struct iopf_queue *queue)
59 {
60 }
61
62 static 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 */