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

Commit f208388f authored by Swathi Sridhar's avatar Swathi Sridhar
Browse files

iommu : arm-smmu : Fetch right SID in qsmmuv500_iova_to_phys_hard



Introduce a new field is_debug_domain in iommu_domain
structure to distinguish a domain which belongs to a
test device from a domain which belongs to an actual device.
Pick the SID from the iommu domain's fwspec, if is_debug_domain
is set to true i.e during trigger-fault or ECATS.
Pick the SID from the corresponding frsynra register if
is_debug_domain is set to false.

Change-Id: I7c6614afe3afc82906c2b8cd446d3b55385a66d1
Signed-off-by: default avatarSwathi Sridhar <swatsrid@codeaurora.org>
parent 452becbf
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -4776,12 +4776,31 @@ static phys_addr_t qsmmuv500_iova_to_phys_hard(
{
	u16 sid;
	struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
	struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
	struct arm_smmu_device *smmu = smmu_domain->smmu;
	struct iommu_fwspec *fwspec;
	void __iomem *gr1_base;
	u32 frsynra;


	/* Select a sid */
	/* Check to see if the domain is associated with the test
	 * device. If the domain belongs to the test device, then
	 * pick the SID from fwspec.
	 */
	if (domain->is_debug_domain) {
		fwspec = smmu_domain->dev->iommu_fwspec;
		sid    = (u16)fwspec->ids[0];
	} else {

		/* If the domain belongs to an actual device, read
		 * SID from the corresponding frsynra register
		 */
		gr1_base = ARM_SMMU_GR1(smmu);
		frsynra  = readl_relaxed(gr1_base +
				ARM_SMMU_GR1_CBFRSYNRA(cfg->cbndx));
		frsynra &= CBFRSYNRA_SID_MASK;
		sid      = frsynra;
	}
	return qsmmuv500_iova_to_phys(domain, iova, sid);
}

+4 −0
Original line number Diff line number Diff line
@@ -1272,6 +1272,8 @@ static int iommu_debug_attach_do_attach(struct iommu_debug_device *ddev,
		return -ENOMEM;
	}

	ddev->domain->is_debug_domain = true;

	if (is_secure && iommu_domain_set_attr(ddev->domain,
					       DOMAIN_ATTR_SECURE_VMID,
					       &val)) {
@@ -1327,6 +1329,8 @@ static ssize_t __iommu_debug_dma_attach_write(struct file *file,
		if (!dma_mapping)
			goto out;

		dma_mapping->domain->is_debug_domain = true;

		if (arm_iommu_attach_device(dev, dma_mapping))
			goto out_release_mapping;
		pr_err("Attached\n");
+1 −0
Original line number Diff line number Diff line
@@ -1266,6 +1266,7 @@ static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus,
	domain->type = type;
	/* Assume all sizes by default; the driver may override this later */
	domain->pgsize_bitmap  = bus->iommu_ops->pgsize_bitmap;
	domain->is_debug_domain = false;

	return domain;
}
+1 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ struct iommu_domain {
	void *handler_token;
	struct iommu_domain_geometry geometry;
	void *iova_cookie;
	bool is_debug_domain;
};

enum iommu_cap {