[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191113122407.1171-3-laurentiu.tudor@nxp.com>
Date: Wed, 13 Nov 2019 12:24:21 +0000
From: Laurentiu Tudor <laurentiu.tudor@....com>
To: "hch@....de" <hch@....de>,
"robin.murphy@....com" <robin.murphy@....com>,
"joro@...tes.org" <joro@...tes.org>,
Ioana Ciocoi Radulescu <ruxandra.radulescu@....com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"iommu@...ts.linux-foundation.org" <iommu@...ts.linux-foundation.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Ioana Ciornei <ioana.ciornei@....com>
CC: Leo Li <leoyang.li@....com>,
Diana Madalina Craciun <diana.craciun@....com>,
"davem@...emloft.net" <davem@...emloft.net>,
Madalin Bucur <madalin.bucur@....com>,
Camelia Alexandra Groza <camelia.groza@....com>,
Laurentiu Tudor <laurentiu.tudor@....com>
Subject: [PATCH v3 2/4] iommu/dma: wire-up new dma map op .get_virt_addr
From: Laurentiu Tudor <laurentiu.tudor@....com>
Add an implementation of the newly introduced dma map op in the
generic DMA IOMMU generic glue layer and wire it up.
Signed-off-by: Laurentiu Tudor <laurentiu.tudor@....com>
---
drivers/iommu/dma-iommu.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index f321279baf9e..98742c1451ce 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -1091,6 +1091,18 @@ static unsigned long iommu_dma_get_merge_boundary(struct device *dev)
return (1UL << __ffs(domain->pgsize_bitmap)) - 1;
}
+static void *iommu_dma_get_virt_addr(struct device *dev, dma_addr_t dma_handle)
+{
+ struct iommu_domain *domain = iommu_get_dma_domain(dev);
+ phys_addr_t phys;
+
+ phys = iommu_iova_to_phys(domain, dma_handle);
+ if (phys)
+ return phys_to_virt(phys);
+
+ return NULL;
+}
+
static const struct dma_map_ops iommu_dma_ops = {
.alloc = iommu_dma_alloc,
.free = iommu_dma_free,
@@ -1107,6 +1119,7 @@ static const struct dma_map_ops iommu_dma_ops = {
.map_resource = iommu_dma_map_resource,
.unmap_resource = iommu_dma_unmap_resource,
.get_merge_boundary = iommu_dma_get_merge_boundary,
+ .get_virt_addr = iommu_dma_get_virt_addr,
};
/*
--
2.17.1
Powered by blists - more mailing lists