Merge tag 'mips_6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
[linux-2.6-block.git] / drivers / iommu / iommu-sva.h
CommitLineData
cfc78dfd
JPB
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * SVA library for IOMMU drivers
4 */
757636ed
LB
5#ifndef _IOMMU_SVA_H
6#define _IOMMU_SVA_H
cfc78dfd 7
cfc78dfd
JPB
8#include <linux/mm_types.h>
9
fc36479d
JPB
10/* I/O Page fault */
11struct device;
12struct iommu_fault;
13struct iopf_queue;
14
7ba56472 15#ifdef CONFIG_IOMMU_SVA
fc36479d
JPB
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);
8cc93159
LB
25enum iommu_page_response_code
26iommu_sva_handle_iopf(struct iommu_fault *fault, void *data);
fc36479d 27
7ba56472 28#else /* CONFIG_IOMMU_SVA */
fc36479d
JPB
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}
8cc93159
LB
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}
7ba56472 70#endif /* CONFIG_IOMMU_SVA */
757636ed 71#endif /* _IOMMU_SVA_H */