]>
Commit | Line | Data |
---|---|---|
caab277b | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
0db2e5d1 RM |
2 | /* |
3 | * Copyright (C) 2014-2015 ARM Ltd. | |
0db2e5d1 RM |
4 | */ |
5 | #ifndef __DMA_IOMMU_H | |
6 | #define __DMA_IOMMU_H | |
7 | ||
185da893 | 8 | #include <linux/errno.h> |
8a22a3e1 | 9 | #include <linux/types.h> |
0db2e5d1 RM |
10 | |
11 | #ifdef CONFIG_IOMMU_DMA | |
461a6946 | 12 | #include <linux/dma-mapping.h> |
0db2e5d1 | 13 | #include <linux/iommu.h> |
44bb7e24 | 14 | #include <linux/msi.h> |
0db2e5d1 | 15 | |
0db2e5d1 RM |
16 | /* Domain management interface for IOMMU drivers */ |
17 | int iommu_get_dma_cookie(struct iommu_domain *domain); | |
fdbe574e | 18 | int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base); |
0db2e5d1 RM |
19 | void iommu_put_dma_cookie(struct iommu_domain *domain); |
20 | ||
21 | /* Setup call for arch DMA mapping code */ | |
06d60728 | 22 | void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size); |
0db2e5d1 | 23 | |
44bb7e24 | 24 | /* The DMA API isn't _quite_ the whole story, though... */ |
ece6e6f0 JG |
25 | /* |
26 | * iommu_dma_prepare_msi() - Map the MSI page in the IOMMU device | |
27 | * | |
28 | * The MSI page will be stored in @desc. | |
29 | * | |
30 | * Return: 0 on success otherwise an error describing the failure. | |
31 | */ | |
32 | int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr); | |
33 | ||
34 | /* Update the MSI message if required. */ | |
35 | void iommu_dma_compose_msi_msg(struct msi_desc *desc, | |
36 | struct msi_msg *msg); | |
37 | ||
273df963 | 38 | void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list); |
44bb7e24 | 39 | |
230309d0 TM |
40 | void iommu_dma_free_cpu_cached_iovas(unsigned int cpu, |
41 | struct iommu_domain *domain); | |
42 | ||
185da893 | 43 | #else /* CONFIG_IOMMU_DMA */ |
0db2e5d1 RM |
44 | |
45 | struct iommu_domain; | |
ece6e6f0 | 46 | struct msi_desc; |
44bb7e24 | 47 | struct msi_msg; |
4b1c8898 | 48 | struct device; |
0db2e5d1 | 49 | |
06d60728 CH |
50 | static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base, |
51 | u64 size) | |
0db2e5d1 | 52 | { |
0db2e5d1 RM |
53 | } |
54 | ||
55 | static inline int iommu_get_dma_cookie(struct iommu_domain *domain) | |
56 | { | |
57 | return -ENODEV; | |
58 | } | |
59 | ||
fdbe574e RM |
60 | static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base) |
61 | { | |
62 | return -ENODEV; | |
63 | } | |
64 | ||
0db2e5d1 RM |
65 | static inline void iommu_put_dma_cookie(struct iommu_domain *domain) |
66 | { | |
67 | } | |
68 | ||
ece6e6f0 JG |
69 | static inline int iommu_dma_prepare_msi(struct msi_desc *desc, |
70 | phys_addr_t msi_addr) | |
71 | { | |
72 | return 0; | |
73 | } | |
74 | ||
75 | static inline void iommu_dma_compose_msi_msg(struct msi_desc *desc, | |
76 | struct msi_msg *msg) | |
77 | { | |
78 | } | |
79 | ||
273df963 RM |
80 | static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list) |
81 | { | |
82 | } | |
83 | ||
230309d0 TM |
84 | static inline void iommu_dma_free_cpu_cached_iovas(unsigned int cpu, |
85 | struct iommu_domain *domain) | |
86 | { | |
87 | } | |
88 | ||
0db2e5d1 | 89 | #endif /* CONFIG_IOMMU_DMA */ |
0db2e5d1 | 90 | #endif /* __DMA_IOMMU_H */ |