Commit ce3aca04 authored by Kefeng Wang's avatar Kefeng Wang Committed by Palmer Dabbelt

riscv: Only initialize swiotlb when necessary

The SWIOTLB buffer is not needed unless the physical address space
is beyond the limit of dma, only initialize swiotlb when swiotlb_force
is true or not all system memory is DMA-able.

Also move the swiotlb_init() into mem_init().
Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
parent ae3d69bc
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <linux/of_fdt.h> #include <linux/of_fdt.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/sched/task.h> #include <linux/sched/task.h>
#include <linux/swiotlb.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/efi.h> #include <linux/efi.h>
#include <linux/crash_dump.h> #include <linux/crash_dump.h>
...@@ -295,10 +294,6 @@ void __init setup_arch(char **cmdline_p) ...@@ -295,10 +294,6 @@ void __init setup_arch(char **cmdline_p)
protect_kernel_linear_mapping_text_rodata(); protect_kernel_linear_mapping_text_rodata();
} }
#ifdef CONFIG_SWIOTLB
swiotlb_init(1);
#endif
#ifdef CONFIG_KASAN #ifdef CONFIG_KASAN
kasan_init(); kasan_init();
#endif #endif
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/memblock.h> #include <linux/memblock.h>
#include <linux/initrd.h> #include <linux/initrd.h>
#include <linux/swap.h> #include <linux/swap.h>
#include <linux/swiotlb.h>
#include <linux/sizes.h> #include <linux/sizes.h>
#include <linux/of_fdt.h> #include <linux/of_fdt.h>
#include <linux/of_reserved_mem.h> #include <linux/of_reserved_mem.h>
...@@ -109,6 +110,13 @@ void __init mem_init(void) ...@@ -109,6 +110,13 @@ void __init mem_init(void)
BUG_ON(!mem_map); BUG_ON(!mem_map);
#endif /* CONFIG_FLATMEM */ #endif /* CONFIG_FLATMEM */
#ifdef CONFIG_SWIOTLB
if (swiotlb_force == SWIOTLB_FORCE ||
max_pfn > PFN_DOWN(dma32_phys_limit))
swiotlb_init(1);
else
swiotlb_force = SWIOTLB_NO_FORCE;
#endif
high_memory = (void *)(__va(PFN_PHYS(max_low_pfn))); high_memory = (void *)(__va(PFN_PHYS(max_low_pfn)));
memblock_free_all(); memblock_free_all();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment