@@ -2077,6 +2077,23 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev,
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 ;
@@ -2182,21 +2199,30 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
2182
2199
arm_smmu_device_reset (smmu );
2183
2200
arm_smmu_test_smr_masks (smmu );
2184
2201
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 ();
2198
2223
return 0 ;
2199
2224
}
2225
+ device_initcall_sync (arm_smmu_legacy_bus_init );
2200
2226
2201
2227
static int arm_smmu_device_remove (struct platform_device * pdev )
2202
2228
{
@@ -2221,56 +2247,14 @@ static struct platform_driver arm_smmu_driver = {
2221
2247
.probe = arm_smmu_device_probe ,
2222
2248
.remove = arm_smmu_device_remove ,
2223
2249
};
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 );
2274
2258
2275
2259
MODULE_DESCRIPTION ("IOMMU API for ARM architected SMMU implementations" );
2276
2260
MODULE_AUTHOR ("Will Deacon <will.deacon@arm.com>" );
0 commit comments