[PATCH RFC] MIPS: allow boards to reserve per-device CMA memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a hook which is called before the bootmem allocator is told about
CMA reserved memory, so that boards can register per-device CMA
areas with dma_declare_contiguous().
---
dma_declare_contiguous() doesn't work any other way (initcalls, ...).
Any other suggestions welcome!

The idea is to reserve 64mb in the upper 128mb for the lcd controller,
and 32mb in the lower 128mb for the video decoder.
In the plat_mem_setup() callback the board can set the plat_reserve_mem hook
to a void function which calls dma_declare_contiguous() or other CMA
functions.

Suggestions welcome!


 arch/mips/include/asm/bootinfo.h | 5 +++++
 arch/mips/kernel/setup.c         | 9 +++++++++
 2 files changed, 14 insertions(+)

diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
index b603804..1fc1f67 100644
--- a/arch/mips/include/asm/bootinfo.h
+++ b/arch/mips/include/asm/bootinfo.h
@@ -132,6 +132,11 @@ extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
  */
 extern void plat_mem_setup(void);
 
+/*
+ * optional hook to reserve CMA memory for devices
+ */
+extern void (*plat_reserve_mem)(void);
+
 #ifdef CONFIG_SWIOTLB
 /*
  * Optional platform hook to call swiotlb_setup().
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 35b8316..b55a9f3 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -38,6 +38,8 @@
 #include <asm/smp-ops.h>
 #include <asm/prom.h>
 
+extern void db1300_reserve_mem(void);
+
 struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly;
 
 EXPORT_SYMBOL(cpu_data);
@@ -71,6 +73,8 @@ char __initdata arcs_cmdline[COMMAND_LINE_SIZE];
 static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
 #endif
 
+void (*plat_reserve_mem)(void) __initdata = NULL;
+
 /*
  * mips_io_port_base is the begin of the address space to which x86 style
  * I/O ports are mapped.
@@ -678,7 +682,12 @@ static void __init arch_mem_init(char **cmdline_p)
 	plat_swiotlb_setup();
 	paging_init();
 
+	/* allocate default CMA area */
 	dma_contiguous_reserve(PFN_PHYS(max_low_pfn));
+	/* allow platforms to reserve CMA memory for devices */
+	if (plat_reserve_mem)
+		plat_reserve_mem();
+	
 	/* Tell bootmem about cma reserved memblock section */
 	for_each_memblock(reserved, reg)
 		if (reg->size != 0)
-- 
2.5.1





[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux