diff --git a/drivers/iommu/arm/arm-smmu-v3/virt-arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/virt-arm-smmu-v3.c index f068e33a8883..e2ed3a8c787a 100644 --- a/drivers/iommu/arm/arm-smmu-v3/virt-arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/virt-arm-smmu-v3.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "../../dma-iommu.h" #define MSI_IOVA_BASE 0x8000000 @@ -814,6 +815,14 @@ static struct iommu_ops virt_arm_smmu_ops = { } }; +static void virt_arm_smmu_iommu_pcie_device_probe(void *data, struct iommu_device *iommu, + struct bus_type *bus, bool *skip) +{ + if (iommu != (struct iommu_device *)data) + return; + *skip = strcmp(bus->name, "pci"); +} + static int virt_arm_smmu_device_probe(struct platform_device *pdev) { int ret; @@ -838,6 +847,10 @@ static int virt_arm_smmu_device_probe(struct platform_device *pdev) "virt-smmuv3"); if (ret) return ret; + + register_trace_android_vh_bus_iommu_probe(virt_arm_smmu_iommu_pcie_device_probe, + (void *)&smmu->iommu); + ret = iommu_device_register(&smmu->iommu, &virt_arm_smmu_ops, dev); if (ret) { dev_err(dev, "Failed to register iommu\n"); diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 46a25a8eb74e..1afedab727e3 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -3499,6 +3500,17 @@ static void arm_smmu_rmr_install_bypass_smr(struct arm_smmu_device *smmu) iort_put_rmr_sids(dev_fwnode(smmu->dev), &rmr_list); } +/* skip pcie iommu bus probe if smmuv2 and smmuv3 both enabled. */ +#if IS_ENABLED(CONFIG_ARM_PARAVIRT_SMMU_V3) +static void arm_smmu_iommu_pcie_device_probe(void *data, struct iommu_device *iommu, + struct bus_type *bus, bool *skip) +{ + if (iommu != (struct iommu_device *)data) + return; + *skip = !strcmp(bus->name, "pci"); +} +#endif + static int arm_smmu_device_probe(struct platform_device *pdev) { struct resource *res; @@ -3633,6 +3645,11 @@ static int arm_smmu_device_probe(struct platform_device *pdev) goto out_power_off; } + #if IS_ENABLED(CONFIG_ARM_PARAVIRT_SMMU_V3) + if (of_find_compatible_node(NULL, NULL, "arm,virt-smmu-v3")) + register_trace_android_vh_bus_iommu_probe(arm_smmu_iommu_pcie_device_probe, + (void *)&smmu->iommu); + #endif err = iommu_device_register(&smmu->iommu, &arm_smmu_ops.iommu_ops, dev); if (err) { dev_err(dev, "Failed to register iommu\n");