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

Commit fa24b0cb authored by Jeremy Gebben's avatar Jeremy Gebben Committed by Patrick Daly
Browse files

iommu/arm-smmu: Tear down domain context if attach fails



Currently we're leaving domains half-initialized after a
partially-successful attach.  Fix this by destroying the domain in the
error path. This should allow another second attach_dev() call to
potentially succeed.

This differs from the upstream implementation in that upstream seems to
expect a call to domain_free() after a failed attach_dev(). Without
this call flow, an error in alloc_io_pgtable_ops() will cause a bit
from the context bank bitmask to be leaked.

Additionally, do not ignore errors from request_irq().

Change-Id: I36c529ed4974c01fba96088b6f57a8e82b350252
Signed-off-by: default avatarJeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent cd9f07a9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -465,6 +465,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
					      dma_addr_t iova);
static phys_addr_t arm_smmu_iova_to_phys_hard_no_halt(
	struct iommu_domain *domain, dma_addr_t iova);
static void arm_smmu_destroy_domain_context(struct iommu_domain *domain);

static struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom)
{
@@ -1168,6 +1169,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
		dev_err(smmu->dev, "failed to request context IRQ %d (%u)\n",
			cfg->irptndx, irq);
		cfg->irptndx = INVALID_IRPTNDX;
		goto out_clear_smmu;
	}

	mutex_unlock(&smmu_domain->init_mutex);
@@ -1177,6 +1179,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
	return 0;

out_clear_smmu:
	arm_smmu_destroy_domain_context(domain);
	smmu_domain->smmu = NULL;
out_unlock:
	mutex_unlock(&smmu_domain->init_mutex);