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

riscv: Enable CMA support

riscv has selected HAVE_DMA_CONTIGUOUS, but doesn't call
dma_contiguous_reserve().  This calls dma_contiguous_reserve(), which
enables CMA.
Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
parent ae386e9d
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/of_fdt.h> #include <linux/of_fdt.h>
#include <linux/libfdt.h> #include <linux/libfdt.h>
#include <linux/set_memory.h> #include <linux/set_memory.h>
#include <linux/dma-map-ops.h>
#include <asm/fixmap.h> #include <asm/fixmap.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
...@@ -41,13 +42,14 @@ struct pt_alloc_ops { ...@@ -41,13 +42,14 @@ struct pt_alloc_ops {
#endif #endif
}; };
static phys_addr_t dma32_phys_limit __ro_after_init;
static void __init zone_sizes_init(void) static void __init zone_sizes_init(void)
{ {
unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
#ifdef CONFIG_ZONE_DMA32 #ifdef CONFIG_ZONE_DMA32
max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit);
(unsigned long) PFN_PHYS(max_low_pfn)));
#endif #endif
max_zone_pfns[ZONE_NORMAL] = max_low_pfn; max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
...@@ -185,6 +187,7 @@ void __init setup_bootmem(void) ...@@ -185,6 +187,7 @@ void __init setup_bootmem(void)
max_pfn = PFN_DOWN(memblock_end_of_DRAM()); max_pfn = PFN_DOWN(memblock_end_of_DRAM());
max_low_pfn = max_pfn; max_low_pfn = max_pfn;
dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn));
set_max_mapnr(max_low_pfn); set_max_mapnr(max_low_pfn);
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
...@@ -198,6 +201,7 @@ void __init setup_bootmem(void) ...@@ -198,6 +201,7 @@ void __init setup_bootmem(void)
memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va)); memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va));
early_init_fdt_scan_reserved_mem(); early_init_fdt_scan_reserved_mem();
dma_contiguous_reserve(dma32_phys_limit);
memblock_allow_resize(); memblock_allow_resize();
memblock_dump_all(); memblock_dump_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