aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/mm/dma-mapping.c
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2017-01-06 05:49:12 -0500
committerWill Deacon <will.deacon@arm.com>2017-01-23 10:05:40 -0500
commit4a8d8a14c0d08c2437cb80c05e88f6cc1ca3fb2c (patch)
tree1953df0df4a31478e6f95957b987903e405e45d9 /arch/arm64/mm/dma-mapping.c
parent829d2bd1339220b742e5e61a5f1975eb6f74cad3 (diff)
arm64: dma-mapping: Only swizzle DMA ops for IOMMU_DOMAIN_DMA
The arm64 DMA-mapping implementation sets the DMA ops to the IOMMU DMA ops if we detect that an IOMMU is present for the master and the DMA ranges are valid. In the case when the IOMMU domain for the device is not of type IOMMU_DOMAIN_DMA, then we have no business swizzling the ops, since we're not in control of the underlying address space. This patch leaves the DMA ops alone for masters attached to non-DMA IOMMU domains. Reviewed-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/mm/dma-mapping.c')
-rw-r--r--arch/arm64/mm/dma-mapping.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 1d7d5d2881db..0ec1ae933342 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -835,14 +835,21 @@ static bool do_iommu_attach(struct device *dev, const struct iommu_ops *ops,
835 * then the IOMMU core will have already configured a group for this 835 * then the IOMMU core will have already configured a group for this
836 * device, and allocated the default domain for that group. 836 * device, and allocated the default domain for that group.
837 */ 837 */
838 if (!domain || iommu_dma_init_domain(domain, dma_base, size, dev)) { 838 if (!domain)
839 pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n", 839 goto out_err;
840 dev_name(dev)); 840
841 return false; 841 if (domain->type == IOMMU_DOMAIN_DMA) {
842 if (iommu_dma_init_domain(domain, dma_base, size, dev))
843 goto out_err;
844
845 dev->archdata.dma_ops = &iommu_dma_ops;
842 } 846 }
843 847
844 dev->archdata.dma_ops = &iommu_dma_ops;
845 return true; 848 return true;
849out_err:
850 pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n",
851 dev_name(dev));
852 return false;
846} 853}
847 854
848static void queue_iommu_attach(struct device *dev, const struct iommu_ops *ops, 855static void queue_iommu_attach(struct device *dev, const struct iommu_ops *ops,