[PATCH][Bionic] iommu/arm-smmu-v3: Cope with duplicated Stream IDs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH][Bionic] iommu/arm-smmu-v3: Cope with duplicated Stream IDs

dann frazier-4
From: Robin Murphy <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1741975

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: <[hidden email]>
Fixes: 8f78515425da ("iommu/arm-smmu: Implement of_xlate() for SMMUv3")
Reported-by: Tomasz Nowicki <[hidden email]>
Tested-by: Tomasz Nowicki <[hidden email]>
Tested-by: Jayachandran C. <[hidden email]>
Signed-off-by: Robin Murphy <[hidden email]>
Signed-off-by: Will Deacon <[hidden email]>
(cherry picked from commit 563b5cbe334e9503ab2b234e279d500fc4f76018)
Signed-off-by: dann frazier <[hidden email]>
---
 drivers/iommu/arm-smmu-v3.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index e67ba6c40faf..d2e17d3396a2 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -1644,7 +1644,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;
 
@@ -1652,6 +1652,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);
  }
 }
--
2.15.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

NAK: [PATCH][Bionic] iommu/arm-smmu-v3: Cope with duplicated Stream IDs

Seth Forshee
On Mon, Jan 08, 2018 at 12:58:09PM -0700, dann frazier wrote:

> From: Robin Murphy <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/bugs/1741975
>
> 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: <[hidden email]>
> Fixes: 8f78515425da ("iommu/arm-smmu: Implement of_xlate() for SMMUv3")
> Reported-by: Tomasz Nowicki <[hidden email]>
> Tested-by: Tomasz Nowicki <[hidden email]>
> Tested-by: Jayachandran C. <[hidden email]>
> Signed-off-by: Robin Murphy <[hidden email]>
> Signed-off-by: Will Deacon <[hidden email]>
> (cherry picked from commit 563b5cbe334e9503ab2b234e279d500fc4f76018)
> Signed-off-by: dann frazier <[hidden email]>

Not a nak on the merits of the patch, however bionic already got this
patch from upstream stable so this patch is not needed.

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team