diff options
| -rw-r--r-- | arch/arm64/kernel/setup.c | 2 | ||||
| -rw-r--r-- | arch/arm64/mm/dma-mapping.c | 33 |
2 files changed, 33 insertions, 2 deletions
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 93e7df8968fe..7ec784653b29 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c | |||
| @@ -396,7 +396,7 @@ static int __init arm64_device_init(void) | |||
| 396 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | 396 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
| 397 | return 0; | 397 | return 0; |
| 398 | } | 398 | } |
| 399 | arch_initcall(arm64_device_init); | 399 | arch_initcall_sync(arm64_device_init); |
| 400 | 400 | ||
| 401 | static DEFINE_PER_CPU(struct cpu, cpu_data); | 401 | static DEFINE_PER_CPU(struct cpu, cpu_data); |
| 402 | 402 | ||
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 1f65963a9c04..c851eb44dc50 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c | |||
| @@ -22,8 +22,11 @@ | |||
| 22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
| 23 | #include <linux/dma-mapping.h> | 23 | #include <linux/dma-mapping.h> |
| 24 | #include <linux/dma-contiguous.h> | 24 | #include <linux/dma-contiguous.h> |
| 25 | #include <linux/of.h> | ||
| 26 | #include <linux/platform_device.h> | ||
| 25 | #include <linux/vmalloc.h> | 27 | #include <linux/vmalloc.h> |
| 26 | #include <linux/swiotlb.h> | 28 | #include <linux/swiotlb.h> |
| 29 | #include <linux/amba/bus.h> | ||
| 27 | 30 | ||
| 28 | #include <asm/cacheflush.h> | 31 | #include <asm/cacheflush.h> |
| 29 | 32 | ||
| @@ -305,17 +308,45 @@ struct dma_map_ops coherent_swiotlb_dma_ops = { | |||
| 305 | }; | 308 | }; |
| 306 | EXPORT_SYMBOL(coherent_swiotlb_dma_ops); | 309 | EXPORT_SYMBOL(coherent_swiotlb_dma_ops); |
| 307 | 310 | ||
| 311 | static int dma_bus_notifier(struct notifier_block *nb, | ||
| 312 | unsigned long event, void *_dev) | ||
| 313 | { | ||
| 314 | struct device *dev = _dev; | ||
| 315 | |||
| 316 | if (event != BUS_NOTIFY_ADD_DEVICE) | ||
| 317 | return NOTIFY_DONE; | ||
| 318 | |||
| 319 | if (of_property_read_bool(dev->of_node, "dma-coherent")) | ||
| 320 | set_dma_ops(dev, &coherent_swiotlb_dma_ops); | ||
| 321 | |||
| 322 | return NOTIFY_OK; | ||
| 323 | } | ||
| 324 | |||
| 325 | static struct notifier_block platform_bus_nb = { | ||
| 326 | .notifier_call = dma_bus_notifier, | ||
| 327 | }; | ||
| 328 | |||
| 329 | static struct notifier_block amba_bus_nb = { | ||
| 330 | .notifier_call = dma_bus_notifier, | ||
| 331 | }; | ||
| 332 | |||
| 308 | extern int swiotlb_late_init_with_default_size(size_t default_size); | 333 | extern int swiotlb_late_init_with_default_size(size_t default_size); |
| 309 | 334 | ||
| 310 | static int __init swiotlb_late_init(void) | 335 | static int __init swiotlb_late_init(void) |
| 311 | { | 336 | { |
| 312 | size_t swiotlb_size = min(SZ_64M, MAX_ORDER_NR_PAGES << PAGE_SHIFT); | 337 | size_t swiotlb_size = min(SZ_64M, MAX_ORDER_NR_PAGES << PAGE_SHIFT); |
| 313 | 338 | ||
| 339 | /* | ||
| 340 | * These must be registered before of_platform_populate(). | ||
| 341 | */ | ||
| 342 | bus_register_notifier(&platform_bus_type, &platform_bus_nb); | ||
| 343 | bus_register_notifier(&amba_bustype, &amba_bus_nb); | ||
| 344 | |||
| 314 | dma_ops = &noncoherent_swiotlb_dma_ops; | 345 | dma_ops = &noncoherent_swiotlb_dma_ops; |
| 315 | 346 | ||
| 316 | return swiotlb_late_init_with_default_size(swiotlb_size); | 347 | return swiotlb_late_init_with_default_size(swiotlb_size); |
| 317 | } | 348 | } |
| 318 | subsys_initcall(swiotlb_late_init); | 349 | arch_initcall(swiotlb_late_init); |
| 319 | 350 | ||
| 320 | #define PREALLOC_DMA_DEBUG_ENTRIES 4096 | 351 | #define PREALLOC_DMA_DEBUG_ENTRIES 4096 |
| 321 | 352 | ||
