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/iommu.h>
24
25int iommu_dma_init(void);
26
27
28int iommu_get_dma_cookie(struct iommu_domain *domain);
29void iommu_put_dma_cookie(struct iommu_domain *domain);
30
31
32int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, u64 size);
33
34
35int dma_direction_to_prot(enum dma_data_direction dir, bool coherent);
36
37
38
39
40
41struct page **iommu_dma_alloc(struct device *dev, size_t size,
42 gfp_t gfp, int prot, dma_addr_t *handle,
43 void (*flush_page)(struct device *, const void *, phys_addr_t));
44void iommu_dma_free(struct device *dev, struct page **pages, size_t size,
45 dma_addr_t *handle);
46
47int iommu_dma_mmap(struct page **pages, size_t size, struct vm_area_struct *vma);
48
49dma_addr_t iommu_dma_map_page(struct device *dev, struct page *page,
50 unsigned long offset, size_t size, int prot);
51int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg,
52 int nents, int prot);
53
54
55
56
57
58void iommu_dma_unmap_page(struct device *dev, dma_addr_t handle, size_t size,
59 enum dma_data_direction dir, struct dma_attrs *attrs);
60void iommu_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
61 enum dma_data_direction dir, struct dma_attrs *attrs);
62int iommu_dma_supported(struct device *dev, u64 mask);
63int iommu_dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
64
65#else
66
67struct iommu_domain;
68
69static inline int iommu_dma_init(void)
70{
71 return 0;
72}
73
74static inline int iommu_get_dma_cookie(struct iommu_domain *domain)
75{
76 return -ENODEV;
77}
78
79static inline void iommu_put_dma_cookie(struct iommu_domain *domain)
80{
81}
82
83#endif
84#endif
85#endif
86