Skip to contentSkip to conversation

ARM: shmobile: CMA prototype test code for Koelsch

PATCH New Magnus Damm 1 participant 1 message May 28, 2014

Subsystems (4)
lore
Share & tools
lore

Magnus Damm

author maintainer
#0 lore raw

PATCH 1/1 ARM: shmobile: CMA prototype test code for Koelsch

From: Magnus Damm <[email protected]>

This is some basic prototype code that uses CMA to reserve a 256 MiB physically contiguous memory window at 0x7000000 on the Koelsch board.

Through some hackish test code it then allocates several 16MiB chunks with 16MiB alignment from the CMA window.

The following kernel configuration parameters are required:
CONFIG_CMA=y
CONFIG_DMA_CMA=y

A couple of notes about known short comings:
- The default CMA area is overriden - a new CMA area should be added instead
- NULL is passed as struct device * - the driver model should be used
- The test is allocating 15 times to keep some space in the default CMA area

For information about the DMA API and the DMA attributes, please see:
Documentation/DMA-API-HOWTO.txt
Documentation/DMA-API.txt
Documentation/DMA-attributes.txt

Not for upstream merge. Written to show how CMA can be used to reserve and allocate memory.

Not-Yet-Signed-off-by Magnus Damm <[email protected]>

---

 arch/arm/mach-shmobile/Makefile                  |    2 
 arch/arm/mach-shmobile/board-koelsch-reference.c |   11 ++++
 arch/arm/mach-shmobile/cma-test.c                |   58 ++++++++++++++++++++++
 3 files changed, 70 insertions(+), 1 deletion(-)
arch/arm/mach-shmobile/Makefile +1 -1
@@ -5,7 +5,7 @@
 ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/arch/arm/mach-shmobile/include
 
 # Common objects
-obj-y				:= timer.o console.o
+obj-y				:= timer.o console.o cma-test.o
 
 # CPU objects
 obj-$(CONFIG_ARCH_SH7372)	+= setup-sh7372.o intc-sh7372.o
arch/arm/mach-shmobile/board-koelsch-reference.c +11 -0
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/of_platform.h>
 #include <linux/platform_data/rcar-du.h>
+#include <linux/dma-contiguous.h>
 #include <mach/clock.h>
 #include <mach/common.h>
 #include <mach/irqs.h>
@@ -101,6 +102,15 @@ static void __init koelsch_add_standard_
 	koelsch_add_du_device();
 }
 
+static void __init koelsch_reserve(void)
+{
+#ifdef CONFIG_DMA_CMA
+	/* override default CMA area */
+	dma_contiguous_reserve_area(0x10000000, 0x70000000, 0xffffffff,
+				    &dma_contiguous_default_area);
+#endif
+}
+
 static const char * const koelsch_boards_compat_dt[] __initconst = {
 	"renesas,koelsch",
 	"renesas,koelsch-reference",
@@ -110,6 +120,7 @@ static const char * const koelsch_boards
 DT_MACHINE_START(KOELSCH_DT, "koelsch")
 	.smp		= smp_ops(r8a7791_smp_ops),
 	.init_early	= shmobile_init_delay,
+	.reserve        = koelsch_reserve,
 	.init_time	= rcar_gen2_timer_init,
 	.init_machine	= koelsch_add_standard_devices,
 	.init_late	= shmobile_init_late,
arch/arm/mach-shmobile/cma-test.c new file +58 -0

58 lines not on this page · raw message