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

Commit e72526bb authored by Patrick Daly's avatar Patrick Daly
Browse files

iommu: arm-smmu: Fix dynamic domain context bank assignment



Fix an issue where the context bank for a dynamic domain is always set
to 0xFF. The expected call flow is:
0) iommu_domain_alloc()
1) iommu_domain_set_attr(DOMAIN_ATTR_DYNAMIC)
2) iommu_domain_set_attr(DOMAIN_ATTR_CONTEXT_BANK)
3) iommu_attach_device/group()

Change-Id: I134c2fdbea9d9efc7306d7dbe03abb5dae431371
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent a262fffa
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -3298,14 +3298,23 @@ static int arm_smmu_alloc_cb(struct iommu_domain *domain,
				struct device *dev)
{
	struct iommu_fwspec *fwspec = dev->iommu_fwspec;
	struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
	u32 i, idx;
	int cb = -EINVAL;
	bool dynamic;

	/* Dynamic domains must set cbndx through domain attribute */
	/*
	 * Dynamic domains have already set cbndx through domain attribute.
	 * Verify that they picked a valid value.
	 */
	dynamic = is_dynamic_domain(domain);
	if (dynamic)
		return INVALID_CBNDX;
	if (dynamic) {
		cb = smmu_domain->cfg.cbndx;
		if (cb < smmu->num_context_banks)
			return cb;
		else
			return -EINVAL;
	}

	mutex_lock(&smmu->stream_map_mutex);
	for_each_cfg_sme(fwspec, i, idx) {