]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
arm64: dma-mapping: Only swizzle DMA ops for IOMMU_DOMAIN_DMA
authorWill Deacon <will.deacon@arm.com>
Fri, 6 Jan 2017 10:49:12 +0000 (10:49 +0000)
committerWill Deacon <will.deacon@arm.com>
Mon, 23 Jan 2017 15:05:40 +0000 (15:05 +0000)
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>
arch/arm64/mm/dma-mapping.c

index 1d7d5d2881db7c190069fb095f53c42f28855e23..0ec1ae9333426f2a5e60e73fdac925dd53e8ba3e 100644 (file)
@@ -835,14 +835,21 @@ static bool do_iommu_attach(struct device *dev, const struct iommu_ops *ops,
         * then the IOMMU core will have already configured a group for this
         * device, and allocated the default domain for that group.
         */
-       if (!domain || iommu_dma_init_domain(domain, dma_base, size, dev)) {
-               pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n",
-                       dev_name(dev));
-               return false;
+       if (!domain)
+               goto out_err;
+
+       if (domain->type == IOMMU_DOMAIN_DMA) {
+               if (iommu_dma_init_domain(domain, dma_base, size, dev))
+                       goto out_err;
+
+               dev->archdata.dma_ops = &iommu_dma_ops;
        }
 
-       dev->archdata.dma_ops = &iommu_dma_ops;
        return true;
+out_err:
+       pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n",
+                dev_name(dev));
+       return false;
 }
 
 static void queue_iommu_attach(struct device *dev, const struct iommu_ops *ops,