1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2014-2015 ARM Ltd.
8 #include <linux/errno.h>
9 #include <linux/types.h>
11 #ifdef CONFIG_IOMMU_DMA
12 #include <linux/dma-mapping.h>
13 #include <linux/iommu.h>
14 #include <linux/msi.h>
16 /* Domain management interface for IOMMU drivers */
17 int iommu_get_dma_cookie(struct iommu_domain *domain);
18 int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base);
19 void iommu_put_dma_cookie(struct iommu_domain *domain);
21 /* Setup call for arch DMA mapping code */
22 void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit);
23 int iommu_dma_init_fq(struct iommu_domain *domain);
25 /* The DMA API isn't _quite_ the whole story, though... */
27 * iommu_dma_prepare_msi() - Map the MSI page in the IOMMU device
29 * The MSI page will be stored in @desc.
31 * Return: 0 on success otherwise an error describing the failure.
33 int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr);
35 /* Update the MSI message if required. */
36 void iommu_dma_compose_msi_msg(struct msi_desc *desc,
39 void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list);
41 void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
42 struct iommu_domain *domain);
44 extern bool iommu_dma_forcedac;
46 #else /* CONFIG_IOMMU_DMA */
53 static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base,
58 static inline int iommu_dma_init_fq(struct iommu_domain *domain)
63 static inline int iommu_get_dma_cookie(struct iommu_domain *domain)
68 static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
73 static inline void iommu_put_dma_cookie(struct iommu_domain *domain)
77 static inline int iommu_dma_prepare_msi(struct msi_desc *desc,
83 static inline void iommu_dma_compose_msi_msg(struct msi_desc *desc,
88 static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
92 #endif /* CONFIG_IOMMU_DMA */
93 #endif /* __DMA_IOMMU_H */