1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef __DMA_IOMMU_H
17#define __DMA_IOMMU_H
18
19#ifdef __KERNEL__
20#include <asm/errno.h>
21
22#ifdef CONFIG_IOMMU_DMA
23#include <linux/dma-mapping.h>
24#include <linux/iommu.h>
25#include <linux/msi.h>
26
27int iommu_dma_init(void);
28
29
30int iommu_get_dma_cookie(struct iommu_domain *domain);
31int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base);
32void iommu_put_dma_cookie(struct iommu_domain *domain);
33
34
35int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base,
36 u64 size, struct device *dev);
37
38
39int dma_info_to_prot(enum dma_data_direction dir, bool coherent,
40 unsigned long attrs);
41
42
43
44
45
46struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp,
47 unsigned long attrs, int prot, dma_addr_t *handle,
48 void (*flush_page)(struct device *, const void *, phys_addr_t));
49void iommu_dma_free(struct device *dev, struct page **pages, size_t size,
50 dma_addr_t *handle);
51
52int iommu_dma_mmap(struct page **pages, size_t size, struct vm_area_struct *vma);
53
54dma_addr_t iommu_dma_map_page(struct device *dev, struct page *page,
55 unsigned long offset, size_t size, int prot);
56int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg,
57 int nents, int prot);
58
59
60
61
62
63void iommu_dma_unmap_page(struct device *dev, dma_addr_t handle, size_t size,
64 enum dma_data_direction dir, unsigned long attrs);
65void iommu_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
66 enum dma_data_direction dir, unsigned long attrs);
67dma_addr_t iommu_dma_map_resource(struct device *dev, phys_addr_t phys,
68 size_t size, enum dma_data_direction dir, unsigned long attrs);
69void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle,
70 size_t size, enum dma_data_direction dir, unsigned long attrs);
71int iommu_dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
72
73
74void iommu_dma_map_msi_msg(int irq, struct msi_msg *msg);
75void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list);
76
77#else
78
79struct iommu_domain;
80struct msi_msg;
81struct device;
82
83static inline int iommu_dma_init(void)
84{
85 return 0;
86}
87
88static inline int iommu_get_dma_cookie(struct iommu_domain *domain)
89{
90 return -ENODEV;
91}
92
93static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
94{
95 return -ENODEV;
96}
97
98static inline void iommu_put_dma_cookie(struct iommu_domain *domain)
99{
100}
101
102static inline void iommu_dma_map_msi_msg(int irq, struct msi_msg *msg)
103{
104}
105
106static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
107{
108}
109
110#endif
111#endif
112#endif
113