From: Xiang Chen <[email protected]>

Add a function iommu_domain_to_iova() to get iova_domain from iommu domain.

Signed-off-by: Xiang Chen <[email protected]>
---
 drivers/iommu/dma-iommu.c | 7 +++++++
 include/linux/dma-iommu.h | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 7bcdd12..a1431a9 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -54,6 +54,13 @@ struct iommu_dma_cookie {
 static DEFINE_STATIC_KEY_FALSE(iommu_deferred_attach_enabled);
 bool iommu_dma_forcedac __read_mostly;
 
+struct iova_domain *iommu_domain_to_iova(struct iommu_domain *domain)
+{
+       struct iommu_dma_cookie *cookie = domain->iova_cookie;
+
+       return &cookie->iovad;
+}
+
 static int __init iommu_dma_forcedac_setup(char *str)
 {
        int ret = kstrtobool(str, &iommu_dma_forcedac);
diff --git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h
index 6e75a2d..8577122 100644
--- a/include/linux/dma-iommu.h
+++ b/include/linux/dma-iommu.h
@@ -42,6 +42,8 @@ void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
 
 extern bool iommu_dma_forcedac;
 
+struct iova_domain *iommu_domain_to_iova(struct iommu_domain *domain);
+
 #else /* CONFIG_IOMMU_DMA */
 
 struct iommu_domain;
@@ -83,5 +85,9 @@ static inline void iommu_dma_get_resv_regions(struct device 
*dev, struct list_he
 {
 }
 
+struct iova_domain *iommu_domain_to_iova(struct iommu_domain *domain)
+{
+}
+
 #endif /* CONFIG_IOMMU_DMA */
 #endif /* __DMA_IOMMU_H */
-- 
2.8.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to