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

Commit 313243aa authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'iommu-v4.15-rc7' of git://github.com/awilliam/linux-vfio

Pull IOMMU fixes from Alex Williamson:
 "Fixes via Will Deacon for arm-smmu-v3.

   - Fix duplicate Stream ID handling in arm-smmu-v3

   - Fix arm-smmu-v3 page table ops double free"

* tag 'iommu-v4.15-rc7' of git://github.com/awilliam/linux-vfio:
  iommu/arm-smmu-v3: Cope with duplicated Stream IDs
  iommu/arm-smmu-v3: Don't free page table ops twice
parents f84d595a 563b5cbe
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -1698,15 +1698,17 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain)
	domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap;
	domain->geometry.aperture_end = (1UL << ias) - 1;
	domain->geometry.force_aperture = true;
	smmu_domain->pgtbl_ops = pgtbl_ops;

	ret = finalise_stage_fn(smmu_domain, &pgtbl_cfg);
	if (ret < 0)
	if (ret < 0) {
		free_io_pgtable_ops(pgtbl_ops);

		return ret;
	}

	smmu_domain->pgtbl_ops = pgtbl_ops;
	return 0;
}

static __le64 *arm_smmu_get_step_for_sid(struct arm_smmu_device *smmu, u32 sid)
{
	__le64 *step;
@@ -1731,7 +1733,7 @@ static __le64 *arm_smmu_get_step_for_sid(struct arm_smmu_device *smmu, u32 sid)

static void arm_smmu_install_ste_for_dev(struct iommu_fwspec *fwspec)
{
	int i;
	int i, j;
	struct arm_smmu_master_data *master = fwspec->iommu_priv;
	struct arm_smmu_device *smmu = master->smmu;

@@ -1739,6 +1741,13 @@ static void arm_smmu_install_ste_for_dev(struct iommu_fwspec *fwspec)
		u32 sid = fwspec->ids[i];
		__le64 *step = arm_smmu_get_step_for_sid(smmu, sid);

		/* Bridged PCI devices may end up with duplicated IDs */
		for (j = 0; j < i; j++)
			if (fwspec->ids[j] == sid)
				break;
		if (j < i)
			continue;

		arm_smmu_write_strtab_ent(smmu, sid, step, &master->ste);
	}
}