Skip to content

Commit f6810c1

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu/arm-smmu: Clean up early-probing workarounds
Now that the appropriate ordering is enforced via probe-deferral of masters in core code, rip it all out and bask in the simplicity. Tested-by: Hanjun Guo <hanjun.guo@linaro.org> Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Robin Murphy <robin.murphy@arm.com> [Sricharan: Rebased on top of ACPI IORT SMMU series] Signed-off-by: Sricharan R <sricharan@codeaurora.org> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent b913efe commit f6810c1

File tree

2 files changed

+49
-107
lines changed

2 files changed

+49
-107
lines changed

drivers/iommu/arm-smmu-v3.c

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,51 +2763,9 @@ static struct platform_driver arm_smmu_driver = {
27632763
.probe = arm_smmu_device_probe,
27642764
.remove = arm_smmu_device_remove,
27652765
};
2766+
module_platform_driver(arm_smmu_driver);
27662767

2767-
static int __init arm_smmu_init(void)
2768-
{
2769-
static bool registered;
2770-
int ret = 0;
2771-
2772-
if (!registered) {
2773-
ret = platform_driver_register(&arm_smmu_driver);
2774-
registered = !ret;
2775-
}
2776-
return ret;
2777-
}
2778-
2779-
static void __exit arm_smmu_exit(void)
2780-
{
2781-
return platform_driver_unregister(&arm_smmu_driver);
2782-
}
2783-
2784-
subsys_initcall(arm_smmu_init);
2785-
module_exit(arm_smmu_exit);
2786-
2787-
static int __init arm_smmu_of_init(struct device_node *np)
2788-
{
2789-
int ret = arm_smmu_init();
2790-
2791-
if (ret)
2792-
return ret;
2793-
2794-
if (!of_platform_device_create(np, NULL, platform_bus_type.dev_root))
2795-
return -ENODEV;
2796-
2797-
return 0;
2798-
}
2799-
IOMMU_OF_DECLARE(arm_smmuv3, "arm,smmu-v3", arm_smmu_of_init);
2800-
2801-
#ifdef CONFIG_ACPI
2802-
static int __init acpi_smmu_v3_init(struct acpi_table_header *table)
2803-
{
2804-
if (iort_node_match(ACPI_IORT_NODE_SMMU_V3))
2805-
return arm_smmu_init();
2806-
2807-
return 0;
2808-
}
2809-
IORT_ACPI_DECLARE(arm_smmu_v3, ACPI_SIG_IORT, acpi_smmu_v3_init);
2810-
#endif
2768+
IOMMU_OF_DECLARE(arm_smmuv3, "arm,smmu-v3", NULL);
28112769

28122770
MODULE_DESCRIPTION("IOMMU API for ARM architected SMMUv3 implementations");
28132771
MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>");

drivers/iommu/arm-smmu.c

Lines changed: 47 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,6 +2077,23 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev,
20772077
return 0;
20782078
}
20792079

2080+
static void arm_smmu_bus_init(void)
2081+
{
2082+
/* Oh, for a proper bus abstraction */
2083+
if (!iommu_present(&platform_bus_type))
2084+
bus_set_iommu(&platform_bus_type, &arm_smmu_ops);
2085+
#ifdef CONFIG_ARM_AMBA
2086+
if (!iommu_present(&amba_bustype))
2087+
bus_set_iommu(&amba_bustype, &arm_smmu_ops);
2088+
#endif
2089+
#ifdef CONFIG_PCI
2090+
if (!iommu_present(&pci_bus_type)) {
2091+
pci_request_acs();
2092+
bus_set_iommu(&pci_bus_type, &arm_smmu_ops);
2093+
}
2094+
#endif
2095+
}
2096+
20802097
static int arm_smmu_device_probe(struct platform_device *pdev)
20812098
{
20822099
struct resource *res;
@@ -2182,21 +2199,30 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
21822199
arm_smmu_device_reset(smmu);
21832200
arm_smmu_test_smr_masks(smmu);
21842201

2185-
/* Oh, for a proper bus abstraction */
2186-
if (!iommu_present(&platform_bus_type))
2187-
bus_set_iommu(&platform_bus_type, &arm_smmu_ops);
2188-
#ifdef CONFIG_ARM_AMBA
2189-
if (!iommu_present(&amba_bustype))
2190-
bus_set_iommu(&amba_bustype, &arm_smmu_ops);
2191-
#endif
2192-
#ifdef CONFIG_PCI
2193-
if (!iommu_present(&pci_bus_type)) {
2194-
pci_request_acs();
2195-
bus_set_iommu(&pci_bus_type, &arm_smmu_ops);
2196-
}
2197-
#endif
2202+
/*
2203+
* For ACPI and generic DT bindings, an SMMU will be probed before
2204+
* any device which might need it, so we want the bus ops in place
2205+
* ready to handle default domain setup as soon as any SMMU exists.
2206+
*/
2207+
if (!using_legacy_binding)
2208+
arm_smmu_bus_init();
2209+
2210+
return 0;
2211+
}
2212+
2213+
/*
2214+
* With the legacy DT binding in play, though, we have no guarantees about
2215+
* probe order, but then we're also not doing default domains, so we can
2216+
* delay setting bus ops until we're sure every possible SMMU is ready,
2217+
* and that way ensure that no add_device() calls get missed.
2218+
*/
2219+
static int arm_smmu_legacy_bus_init(void)
2220+
{
2221+
if (using_legacy_binding)
2222+
arm_smmu_bus_init();
21982223
return 0;
21992224
}
2225+
device_initcall_sync(arm_smmu_legacy_bus_init);
22002226

22012227
static int arm_smmu_device_remove(struct platform_device *pdev)
22022228
{
@@ -2221,56 +2247,14 @@ static struct platform_driver arm_smmu_driver = {
22212247
.probe = arm_smmu_device_probe,
22222248
.remove = arm_smmu_device_remove,
22232249
};
2224-
2225-
static int __init arm_smmu_init(void)
2226-
{
2227-
static bool registered;
2228-
int ret = 0;
2229-
2230-
if (!registered) {
2231-
ret = platform_driver_register(&arm_smmu_driver);
2232-
registered = !ret;
2233-
}
2234-
return ret;
2235-
}
2236-
2237-
static void __exit arm_smmu_exit(void)
2238-
{
2239-
return platform_driver_unregister(&arm_smmu_driver);
2240-
}
2241-
2242-
subsys_initcall(arm_smmu_init);
2243-
module_exit(arm_smmu_exit);
2244-
2245-
static int __init arm_smmu_of_init(struct device_node *np)
2246-
{
2247-
int ret = arm_smmu_init();
2248-
2249-
if (ret)
2250-
return ret;
2251-
2252-
if (!of_platform_device_create(np, NULL, platform_bus_type.dev_root))
2253-
return -ENODEV;
2254-
2255-
return 0;
2256-
}
2257-
IOMMU_OF_DECLARE(arm_smmuv1, "arm,smmu-v1", arm_smmu_of_init);
2258-
IOMMU_OF_DECLARE(arm_smmuv2, "arm,smmu-v2", arm_smmu_of_init);
2259-
IOMMU_OF_DECLARE(arm_mmu400, "arm,mmu-400", arm_smmu_of_init);
2260-
IOMMU_OF_DECLARE(arm_mmu401, "arm,mmu-401", arm_smmu_of_init);
2261-
IOMMU_OF_DECLARE(arm_mmu500, "arm,mmu-500", arm_smmu_of_init);
2262-
IOMMU_OF_DECLARE(cavium_smmuv2, "cavium,smmu-v2", arm_smmu_of_init);
2263-
2264-
#ifdef CONFIG_ACPI
2265-
static int __init arm_smmu_acpi_init(struct acpi_table_header *table)
2266-
{
2267-
if (iort_node_match(ACPI_IORT_NODE_SMMU))
2268-
return arm_smmu_init();
2269-
2270-
return 0;
2271-
}
2272-
IORT_ACPI_DECLARE(arm_smmu, ACPI_SIG_IORT, arm_smmu_acpi_init);
2273-
#endif
2250+
module_platform_driver(arm_smmu_driver);
2251+
2252+
IOMMU_OF_DECLARE(arm_smmuv1, "arm,smmu-v1", NULL);
2253+
IOMMU_OF_DECLARE(arm_smmuv2, "arm,smmu-v2", NULL);
2254+
IOMMU_OF_DECLARE(arm_mmu400, "arm,mmu-400", NULL);
2255+
IOMMU_OF_DECLARE(arm_mmu401, "arm,mmu-401", NULL);
2256+
IOMMU_OF_DECLARE(arm_mmu500, "arm,mmu-500", NULL);
2257+
IOMMU_OF_DECLARE(cavium_smmuv2, "cavium,smmu-v2", NULL);
22742258

22752259
MODULE_DESCRIPTION("IOMMU API for ARM architected SMMU implementations");
22762260
MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>");

0 commit comments

Comments
 (0)