Skip to content

Commit da81558

Browse files
Kefeng Wangpalmer-dabbelt
authored andcommitted
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: Kefeng Wang <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent ae386e9 commit da81558

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/riscv/mm/init.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/of_fdt.h>
1414
#include <linux/libfdt.h>
1515
#include <linux/set_memory.h>
16+
#include <linux/dma-map-ops.h>
1617

1718
#include <asm/fixmap.h>
1819
#include <asm/tlbflush.h>
@@ -41,13 +42,14 @@ struct pt_alloc_ops {
4142
#endif
4243
};
4344

45+
static phys_addr_t dma32_phys_limit __ro_after_init;
46+
4447
static void __init zone_sizes_init(void)
4548
{
4649
unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
4750

4851
#ifdef CONFIG_ZONE_DMA32
49-
max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G,
50-
(unsigned long) PFN_PHYS(max_low_pfn)));
52+
max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit);
5153
#endif
5254
max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
5355

@@ -185,6 +187,7 @@ void __init setup_bootmem(void)
185187

186188
max_pfn = PFN_DOWN(memblock_end_of_DRAM());
187189
max_low_pfn = max_pfn;
190+
dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn));
188191
set_max_mapnr(max_low_pfn);
189192

190193
#ifdef CONFIG_BLK_DEV_INITRD
@@ -198,6 +201,7 @@ void __init setup_bootmem(void)
198201
memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va));
199202

200203
early_init_fdt_scan_reserved_mem();
204+
dma_contiguous_reserve(dma32_phys_limit);
201205
memblock_allow_resize();
202206
memblock_dump_all();
203207
}

0 commit comments

Comments
 (0)