diff options
| author | Charan Teja Reddy <charante@codeaurora.org> | 2016-12-07 18:40:57 +0530 |
|---|---|---|
| committer | Charan Teja Reddy <charante@codeaurora.org> | 2016-12-08 19:11:55 +0530 |
| commit | 55889f2e5f9155de1bb7ae21d5413d5986c413ce (patch) | |
| tree | 8dcacdbef4395729882811c6792562f11b0a34ee | |
| parent | 69352ff8b46b11f98bf37f82534a82222466eadd (diff) | |
arm: dma_mapping: Support for DOMAIN_ATTR_S1_BYPASS attribute
For iommus which do not use stage1 translation, stage2 may not be aware
of the device's dma_mask requirements. Choose the dma_ops such that
allocations are made within the dma_mask region and bounce buffers are
used as necessary.
Change-Id: I63ae3ff9e5ab608892d12db7a813264d234699ee
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
| -rw-r--r-- | arch/arm/mm/dma-mapping.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 723e3925dc84..48836eba4ab7 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -2160,12 +2160,16 @@ int arm_iommu_attach_device(struct device *dev, struct dma_iommu_mapping *mapping) { int err; + int s1_bypass = 0; err = __arm_iommu_attach_device(dev, mapping); if (err) return err; - set_dma_ops(dev, &iommu_ops); + iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_S1_BYPASS, + &s1_bypass); + if (!s1_bypass) + set_dma_ops(dev, &iommu_ops); return 0; } EXPORT_SYMBOL_GPL(arm_iommu_attach_device); @@ -2199,8 +2203,21 @@ static void __arm_iommu_detach_device(struct device *dev) */ void arm_iommu_detach_device(struct device *dev) { + struct dma_iommu_mapping *mapping; + int s1_bypass = 0; + + mapping = to_dma_iommu_mapping(dev); + if (!mapping) { + dev_warn(dev, "Not attached\n"); + return; + } + __arm_iommu_detach_device(dev); - set_dma_ops(dev, NULL); + + iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_S1_BYPASS, + &s1_bypass); + if (!s1_bypass) + set_dma_ops(dev, NULL); } EXPORT_SYMBOL_GPL(arm_iommu_detach_device); |
