Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2540c41c authored by Charan Teja Reddy's avatar Charan Teja Reddy Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarCharan Teja Reddy <charante@codeaurora.org>
parent e85bc8a8
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -2284,11 +2284,15 @@ 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;

	iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_S1_BYPASS,
					&s1_bypass);
	if (!s1_bypass)
		set_dma_ops(dev, &iommu_ops);
	return 0;
}
@@ -2323,7 +2327,20 @@ 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);

	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);