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

Commit 099ee7c6 authored by Isaac J. Manjarres's avatar Isaac J. Manjarres
Browse files

arm64: mm: dma-mapping: Modify handling for S1 bypass initialization



Since IOMMU domains that use S1 bypass do not need to know about
the DMA window of the device, move the logic for setting the
correct DMA ops for S1 bypass to an earlier point in time.

Change-Id: Ie80a44d888b4a786ea01270bc656635e0a65cdc5
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent 7ac121f5
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -1056,18 +1056,14 @@ iommu_init_mapping(struct device *dev, struct dma_iommu_mapping *mapping)
static int arm_iommu_get_dma_cookie(struct device *dev,
				    struct dma_iommu_mapping *mapping)
{
	int s1_bypass = 0, is_fast = 0;
	int is_fast = 0;
	int err = 0;

	mutex_lock(&iommu_dma_init_mutex);

	iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_S1_BYPASS,
					&s1_bypass);
	iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_FAST, &is_fast);

	if (s1_bypass)
		mapping->ops = &arm64_swiotlb_dma_ops;
	else if (is_fast)
	if (is_fast)
		err = fast_smmu_init_mapping(dev, mapping);
	else
		err = iommu_init_mapping(dev, mapping);
@@ -1135,17 +1131,22 @@ static void arm_iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size)
	struct iommu_domain *domain;
	struct iommu_group *group;
	struct dma_iommu_mapping mapping = {0};
	int s1_bypass;

	group = dev->iommu_group;
	if (!group)
		return;

	arm_iommu_get_dma_window(dev, &dma_base, &size);

	domain = iommu_get_domain_for_dev(dev);
	if (!domain)
		return;

	iommu_domain_get_attr(domain, DOMAIN_ATTR_S1_BYPASS, &s1_bypass);
	if (s1_bypass)
		return;

	arm_iommu_get_dma_window(dev, &dma_base, &size);

	/* Allow iommu-debug to call arch_setup_dma_ops to reconfigure itself */
	if (domain->type != IOMMU_DOMAIN_DMA &&
	    !of_device_is_compatible(dev->of_node, "iommu-debug-test")) {