iommu/arm-smmu: Clean up bus_set_iommu()
authorRobin Murphy <robin.murphy@arm.com>
Mon, 15 Aug 2022 16:20:08 +0000 (17:20 +0100)
committerJoerg Roedel <jroedel@suse.de>
Wed, 7 Sep 2022 12:26:13 +0000 (14:26 +0200)
Stop calling bus_set_iommu() since it's now unnecessary. With device
probes now replayed for every IOMMU instance registration, the whole
sorry ordering workaround for legacy DT bindings goes too, hooray!

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/f7aaad3e479a78623a6942ed46937249168b55bd.1660572783.git.robin.murphy@arm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/arm/arm-smmu/arm-smmu.c

index 8039c8b..4049980 100644 (file)
@@ -37,7 +37,6 @@
 #include <linux/ratelimit.h>
 #include <linux/slab.h>
 
-#include <linux/amba/bus.h>
 #include <linux/fsl/mc.h>
 
 #include "arm-smmu.h"
@@ -93,8 +92,6 @@ static struct platform_driver arm_smmu_driver;
 static struct iommu_ops arm_smmu_ops;
 
 #ifdef CONFIG_ARM_SMMU_LEGACY_DT_BINDINGS
-static int arm_smmu_bus_init(struct iommu_ops *ops);
-
 static struct device_node *dev_get_dev_node(struct device *dev)
 {
        if (dev_is_pci(dev)) {
@@ -180,20 +177,6 @@ static int arm_smmu_register_legacy_master(struct device *dev,
        kfree(sids);
        return err;
 }
-
-/*
- * With the legacy DT binding in play, we have no guarantees about
- * probe order, but then we're also not doing default domains, so we can
- * delay setting bus ops until we're sure every possible SMMU is ready,
- * and that way ensure that no probe_device() calls get missed.
- */
-static int arm_smmu_legacy_bus_init(void)
-{
-       if (using_legacy_binding)
-               return arm_smmu_bus_init(&arm_smmu_ops);
-       return 0;
-}
-device_initcall_sync(arm_smmu_legacy_bus_init);
 #else
 static int arm_smmu_register_legacy_master(struct device *dev,
                                           struct arm_smmu_device **smmu)
@@ -2015,52 +1998,6 @@ static int arm_smmu_device_dt_probe(struct arm_smmu_device *smmu,
        return 0;
 }
 
-static int arm_smmu_bus_init(struct iommu_ops *ops)
-{
-       int err;
-
-       /* Oh, for a proper bus abstraction */
-       if (!iommu_present(&platform_bus_type)) {
-               err = bus_set_iommu(&platform_bus_type, ops);
-               if (err)
-                       return err;
-       }
-#ifdef CONFIG_ARM_AMBA
-       if (!iommu_present(&amba_bustype)) {
-               err = bus_set_iommu(&amba_bustype, ops);
-               if (err)
-                       goto err_reset_platform_ops;
-       }
-#endif
-#ifdef CONFIG_PCI
-       if (!iommu_present(&pci_bus_type)) {
-               err = bus_set_iommu(&pci_bus_type, ops);
-               if (err)
-                       goto err_reset_amba_ops;
-       }
-#endif
-#ifdef CONFIG_FSL_MC_BUS
-       if (!iommu_present(&fsl_mc_bus_type)) {
-               err = bus_set_iommu(&fsl_mc_bus_type, ops);
-               if (err)
-                       goto err_reset_pci_ops;
-       }
-#endif
-       return 0;
-
-err_reset_pci_ops: __maybe_unused;
-#ifdef CONFIG_PCI
-       bus_set_iommu(&pci_bus_type, NULL);
-#endif
-err_reset_amba_ops: __maybe_unused;
-#ifdef CONFIG_ARM_AMBA
-       bus_set_iommu(&amba_bustype, NULL);
-#endif
-err_reset_platform_ops: __maybe_unused;
-       bus_set_iommu(&platform_bus_type, NULL);
-       return err;
-}
-
 static void arm_smmu_rmr_install_bypass_smr(struct arm_smmu_device *smmu)
 {
        struct list_head rmr_list;
@@ -2225,7 +2162,8 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
        err = iommu_device_register(&smmu->iommu, &arm_smmu_ops, dev);
        if (err) {
                dev_err(dev, "Failed to register iommu\n");
-               goto err_sysfs_remove;
+               iommu_device_sysfs_remove(&smmu->iommu);
+               return err;
        }
 
        platform_set_drvdata(pdev, smmu);
@@ -2247,24 +2185,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
                pm_runtime_enable(dev);
        }
 
-       /*
-        * For ACPI and generic DT bindings, an SMMU will be probed before
-        * any device which might need it, so we want the bus ops in place
-        * ready to handle default domain setup as soon as any SMMU exists.
-        */
-       if (!using_legacy_binding) {
-               err = arm_smmu_bus_init(&arm_smmu_ops);
-               if (err)
-                       goto err_unregister_device;
-       }
-
        return 0;
-
-err_unregister_device:
-       iommu_device_unregister(&smmu->iommu);
-err_sysfs_remove:
-       iommu_device_sysfs_remove(&smmu->iommu);
-       return err;
 }
 
 static int arm_smmu_device_remove(struct platform_device *pdev)
@@ -2277,7 +2198,6 @@ static int arm_smmu_device_remove(struct platform_device *pdev)
        if (!bitmap_empty(smmu->context_map, ARM_SMMU_MAX_CBS))
                dev_notice(&pdev->dev, "disabling translation\n");
 
-       arm_smmu_bus_init(NULL);
        iommu_device_unregister(&smmu->iommu);
        iommu_device_sysfs_remove(&smmu->iommu);