0001
0002
0003
0004
0005 #ifndef __DMA_IOMMU_H
0006 #define __DMA_IOMMU_H
0007
0008 #include <linux/errno.h>
0009 #include <linux/types.h>
0010
0011 #ifdef CONFIG_IOMMU_DMA
0012 #include <linux/dma-mapping.h>
0013 #include <linux/iommu.h>
0014 #include <linux/msi.h>
0015
0016
0017 int iommu_get_dma_cookie(struct iommu_domain *domain);
0018 int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base);
0019 void iommu_put_dma_cookie(struct iommu_domain *domain);
0020
0021
0022 void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit);
0023 int iommu_dma_init_fq(struct iommu_domain *domain);
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr);
0034
0035
0036 void iommu_dma_compose_msi_msg(struct msi_desc *desc,
0037 struct msi_msg *msg);
0038
0039 void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list);
0040
0041 void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
0042 struct iommu_domain *domain);
0043
0044 extern bool iommu_dma_forcedac;
0045
0046 #else
0047
0048 struct iommu_domain;
0049 struct msi_desc;
0050 struct msi_msg;
0051 struct device;
0052
0053 static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base,
0054 u64 dma_limit)
0055 {
0056 }
0057
0058 static inline int iommu_dma_init_fq(struct iommu_domain *domain)
0059 {
0060 return -EINVAL;
0061 }
0062
0063 static inline int iommu_get_dma_cookie(struct iommu_domain *domain)
0064 {
0065 return -ENODEV;
0066 }
0067
0068 static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
0069 {
0070 return -ENODEV;
0071 }
0072
0073 static inline void iommu_put_dma_cookie(struct iommu_domain *domain)
0074 {
0075 }
0076
0077 static inline int iommu_dma_prepare_msi(struct msi_desc *desc,
0078 phys_addr_t msi_addr)
0079 {
0080 return 0;
0081 }
0082
0083 static inline void iommu_dma_compose_msi_msg(struct msi_desc *desc,
0084 struct msi_msg *msg)
0085 {
0086 }
0087
0088 static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
0089 {
0090 }
0091
0092 #endif
0093 #endif