summaryrefslogtreecommitdiff
path: root/include/dma.h
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-06-19 06:50:45 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-06-24 08:53:47 +0200
commitd5536e6006baa40076dfd27ffce49d5bc54736b0 (patch)
tree84892a318b2d464ed866643ece18f9569bbea381 /include/dma.h
parent3a62463a4954a26ac3ec92550308ed3cbc3b3e05 (diff)
downloadbarebox-d5536e6006baa40076dfd27ffce49d5bc54736b0.tar.gz
dma: allocate 32-byte aligned buffers by default
If dma_alloc() is really used for streaming-dma between cache-incoherent masters, it should return cache-line aligned buffers, so we don't risk invalidating shared cache lines. Bump up the default alignment to 32-bytes. This doesn't affect ARM, as it defines its own implementation with 64-byte buffers. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619045055.779-20-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/dma.h')
-rw-r--r--include/dma.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/dma.h b/include/dma.h
index 1b1cb3a407..90f9254ea8 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -8,6 +8,7 @@
#include <malloc.h>
#include <xfuncs.h>
+#include <linux/kernel.h>
#include <dma-dir.h>
#include <asm/dma.h>
@@ -15,10 +16,14 @@
#define DMA_ADDRESS_BROKEN NULL
+#ifndef DMA_ALIGNMENT
+#define DMA_ALIGNMENT 32
+#endif
+
#ifndef dma_alloc
static inline void *dma_alloc(size_t size)
{
- return xmalloc(size);
+ return xmemalign(DMA_ALIGNMENT, ALIGN(size, DMA_ALIGNMENT));
}
#endif