Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Robin Murphy and committed by
Joerg Roedel
f6810c15 b913efe7

+48 -106
+2 -44
drivers/iommu/arm-smmu-v3.c
··· 2763 2763 .probe = arm_smmu_device_probe, 2764 2764 .remove = arm_smmu_device_remove, 2765 2765 }; 2766 + module_platform_driver(arm_smmu_driver); 2766 2767 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); 2811 2769 2812 2770 MODULE_DESCRIPTION("IOMMU API for ARM architected SMMUv3 implementations"); 2813 2771 MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>");
+46 -62
drivers/iommu/arm-smmu.c
··· 2077 2077 return 0; 2078 2078 } 2079 2079 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 + 2080 2097 static int arm_smmu_device_probe(struct platform_device *pdev) 2081 2098 { 2082 2099 struct resource *res; ··· 2199 2182 arm_smmu_device_reset(smmu); 2200 2183 arm_smmu_test_smr_masks(smmu); 2201 2184 2202 - /* Oh, for a proper bus abstraction */ 2203 - if (!iommu_present(&platform_bus_type)) 2204 - bus_set_iommu(&platform_bus_type, &arm_smmu_ops); 2205 - #ifdef CONFIG_ARM_AMBA 2206 - if (!iommu_present(&amba_bustype)) 2207 - bus_set_iommu(&amba_bustype, &arm_smmu_ops); 2208 - #endif 2209 - #ifdef CONFIG_PCI 2210 - if (!iommu_present(&pci_bus_type)) { 2211 - pci_request_acs(); 2212 - bus_set_iommu(&pci_bus_type, &arm_smmu_ops); 2213 - } 2214 - #endif 2185 + /* 2186 + * For ACPI and generic DT bindings, an SMMU will be probed before 2187 + * any device which might need it, so we want the bus ops in place 2188 + * ready to handle default domain setup as soon as any SMMU exists. 2189 + */ 2190 + if (!using_legacy_binding) 2191 + arm_smmu_bus_init(); 2192 + 2215 2193 return 0; 2216 2194 } 2195 + 2196 + /* 2197 + * With the legacy DT binding in play, though, we have no guarantees about 2198 + * probe order, but then we're also not doing default domains, so we can 2199 + * delay setting bus ops until we're sure every possible SMMU is ready, 2200 + * and that way ensure that no add_device() calls get missed. 2201 + */ 2202 + static int arm_smmu_legacy_bus_init(void) 2203 + { 2204 + if (using_legacy_binding) 2205 + arm_smmu_bus_init(); 2206 + return 0; 2207 + } 2208 + device_initcall_sync(arm_smmu_legacy_bus_init); 2217 2209 2218 2210 static int arm_smmu_device_remove(struct platform_device *pdev) 2219 2211 { ··· 2247 2221 .probe = arm_smmu_device_probe, 2248 2222 .remove = arm_smmu_device_remove, 2249 2223 }; 2224 + module_platform_driver(arm_smmu_driver); 2250 2225 2251 - static int __init arm_smmu_init(void) 2252 - { 2253 - static bool registered; 2254 - int ret = 0; 2255 - 2256 - if (!registered) { 2257 - ret = platform_driver_register(&arm_smmu_driver); 2258 - registered = !ret; 2259 - } 2260 - return ret; 2261 - } 2262 - 2263 - static void __exit arm_smmu_exit(void) 2264 - { 2265 - return platform_driver_unregister(&arm_smmu_driver); 2266 - } 2267 - 2268 - subsys_initcall(arm_smmu_init); 2269 - module_exit(arm_smmu_exit); 2270 - 2271 - static int __init arm_smmu_of_init(struct device_node *np) 2272 - { 2273 - int ret = arm_smmu_init(); 2274 - 2275 - if (ret) 2276 - return ret; 2277 - 2278 - if (!of_platform_device_create(np, NULL, platform_bus_type.dev_root)) 2279 - return -ENODEV; 2280 - 2281 - return 0; 2282 - } 2283 - IOMMU_OF_DECLARE(arm_smmuv1, "arm,smmu-v1", arm_smmu_of_init); 2284 - IOMMU_OF_DECLARE(arm_smmuv2, "arm,smmu-v2", arm_smmu_of_init); 2285 - IOMMU_OF_DECLARE(arm_mmu400, "arm,mmu-400", arm_smmu_of_init); 2286 - IOMMU_OF_DECLARE(arm_mmu401, "arm,mmu-401", arm_smmu_of_init); 2287 - IOMMU_OF_DECLARE(arm_mmu500, "arm,mmu-500", arm_smmu_of_init); 2288 - IOMMU_OF_DECLARE(cavium_smmuv2, "cavium,smmu-v2", arm_smmu_of_init); 2289 - 2290 - #ifdef CONFIG_ACPI 2291 - static int __init arm_smmu_acpi_init(struct acpi_table_header *table) 2292 - { 2293 - if (iort_node_match(ACPI_IORT_NODE_SMMU)) 2294 - return arm_smmu_init(); 2295 - 2296 - return 0; 2297 - } 2298 - IORT_ACPI_DECLARE(arm_smmu, ACPI_SIG_IORT, arm_smmu_acpi_init); 2299 - #endif 2226 + IOMMU_OF_DECLARE(arm_smmuv1, "arm,smmu-v1", NULL); 2227 + IOMMU_OF_DECLARE(arm_smmuv2, "arm,smmu-v2", NULL); 2228 + IOMMU_OF_DECLARE(arm_mmu400, "arm,mmu-400", NULL); 2229 + IOMMU_OF_DECLARE(arm_mmu401, "arm,mmu-401", NULL); 2230 + IOMMU_OF_DECLARE(arm_mmu500, "arm,mmu-500", NULL); 2231 + IOMMU_OF_DECLARE(cavium_smmuv2, "cavium,smmu-v2", NULL); 2300 2232 2301 2233 MODULE_DESCRIPTION("IOMMU API for ARM architected SMMU implementations"); 2302 2234 MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>");