Skip to content

Commit 563b5cb

Browse files
rmurphy-armwildea01
authored andcommitted
iommu/arm-smmu-v3: Cope with duplicated Stream IDs
For PCI devices behind an aliasing PCIe-to-PCI/X bridge, the bridge alias to DevFn 0.0 on the subordinate bus may match the original RID of the device, resulting in the same SID being present in the device's fwspec twice. This causes trouble later in arm_smmu_write_strtab_ent() when we wind up visiting the STE a second time and find it already live. Avoid the issue by giving arm_smmu_install_ste_for_dev() the cleverness to skip over duplicates. It seems mildly counterintuitive compared to preventing the duplicates from existing in the first place, but since the DT and ACPI probe paths build their fwspecs differently, this is actually the cleanest and most self-contained way to deal with it. Cc: <[email protected]> Fixes: 8f78515 ("iommu/arm-smmu: Implement of_xlate() for SMMUv3") Reported-by: Tomasz Nowicki <[email protected]> Tested-by: Tomasz Nowicki <[email protected]> Tested-by: Jayachandran C. <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 57d72e1 commit 563b5cb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/iommu/arm-smmu-v3.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,14 +1733,21 @@ static __le64 *arm_smmu_get_step_for_sid(struct arm_smmu_device *smmu, u32 sid)
17331733

17341734
static void arm_smmu_install_ste_for_dev(struct iommu_fwspec *fwspec)
17351735
{
1736-
int i;
1736+
int i, j;
17371737
struct arm_smmu_master_data *master = fwspec->iommu_priv;
17381738
struct arm_smmu_device *smmu = master->smmu;
17391739

17401740
for (i = 0; i < fwspec->num_ids; ++i) {
17411741
u32 sid = fwspec->ids[i];
17421742
__le64 *step = arm_smmu_get_step_for_sid(smmu, sid);
17431743

1744+
/* Bridged PCI devices may end up with duplicated IDs */
1745+
for (j = 0; j < i; j++)
1746+
if (fwspec->ids[j] == sid)
1747+
break;
1748+
if (j < i)
1749+
continue;
1750+
17441751
arm_smmu_write_strtab_ent(smmu, sid, step, &master->ste);
17451752
}
17461753
}

0 commit comments

Comments
 (0)