[PATCH 2/6] ARM mmu: introduce dma_alloc, dma_free

Marc Kleine-Budde mkl at pengutronix.de
Tue Jun 19 08:36:27 EDT 2012


dma_alloc() allocates memory aligned to cache lines. We have to use
cache line aligned buffers if a driver calls dma_inv_range on the
buffer. Add dma_free() for documentation reasons, too.

Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 arch/arm/include/asm/dma.h |    8 ++++++++
 arch/arm/include/asm/mmu.h |   10 ++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/dma.h

diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h
new file mode 100644
index 0000000..cb9cd1b
--- /dev/null
+++ b/arch/arm/include/asm/dma.h
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2012 by Marc Kleine-Budde <mkl at pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#include <asm/mmu.h>
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index f5ae7a8..cc3529f 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -23,6 +23,16 @@ static inline void setup_dma_coherent(unsigned long offset)
 {
 }
 
+static inline void *dma_alloc(size_t size)
+{
+	return xmemalign(64, size);
+}
+
+static inline void dma_free(void *mem)
+{
+	free(mem);
+}
+
 #ifdef CONFIG_MMU
 void *dma_alloc_coherent(size_t size);
 void dma_free_coherent(void *mem, size_t size);
-- 
1.7.4.1




More information about the barebox mailing list