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

Commit ef027fed authored by Charan Teja Reddy's avatar Charan Teja Reddy
Browse files

arm: dma-mapping: don't attach the clients to smmu device by default



When SMMU master call arch_setup_dma_ops after SMMU initialization, it
tries to attach a CB to this device. And later, the same master tries to
create mapping and attach a CB to the same device as part of their code.
Avoid this.
This is aligned to the 64bit implementation.

Change-Id: I880e74919236658570cf84bac04d52d4ffd997e3
Signed-off-by: default avatarCharan Teja Reddy <charante@codeaurora.org>
parent 1eb51a0c
Loading
Loading
Loading
Loading
+21 −9
Original line number Diff line number Diff line
@@ -2470,10 +2470,21 @@ static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
				    const struct iommu_ops *iommu)
{
	struct dma_iommu_mapping *mapping;
	struct iommu_domain *domain;

	if (!iommu)
		return false;

	/*
	 * Adding this to not to attach to smmu device by default as any way
	 * clients call the arm_iommu_create_mapping() in their use cases.
	 */
	domain = iommu_get_domain_for_dev(dev);

	if (!domain)
		return false;

	if (domain->type == IOMMU_DOMAIN_DMA) {
		mapping = arm_iommu_create_mapping(dev->bus, dma_base, size);
		if (IS_ERR(mapping)) {
			pr_warn("Failed to create %llu-byte IOMMU mapping for device %s\n",
@@ -2487,6 +2498,7 @@ static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
			arm_iommu_release_mapping(mapping);
			return false;
		}
	}

	return true;
}