From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] dma: define compile-time ARCH_DMA_MINALIGN constant for all archs
Date: Mon, 25 Nov 2024 16:30:03 +0100 [thread overview]
Message-ID: <20241125153003.708512-1-a.fatoum@pengutronix.de> (raw)
DMA_ALIGNMENT is not a compile-time constant on MIPS. This didn't bother
us so far, but will when we need to use it as argument to __aligned().
Let's additionally define ARCH_DMA_MINALIGN like Linux does and require
that all architectures define it to a compile-time constant if
DMA_ALIGNMENT isn't one.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/mips/include/asm/dma.h | 2 ++
arch/openrisc/include/asm/cache.h | 14 ++------------
arch/openrisc/include/asm/dma.h | 6 +++++-
include/dma.h | 4 ++++
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/arch/mips/include/asm/dma.h b/arch/mips/include/asm/dma.h
index 2ae75f047bd7..e5c8abd0bf1e 100644
--- a/arch/mips/include/asm/dma.h
+++ b/arch/mips/include/asm/dma.h
@@ -19,6 +19,8 @@
#define DMA_ALIGNMENT \
max(current_cpu_data.dcache.linesz, current_cpu_data.scache.linesz)
+#define ARCH_DMA_MINALIGN 128
+
struct device;
#define dma_alloc_coherent dma_alloc_coherent
diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
index 5dee26b190e1..4bba6923b1e8 100644
--- a/arch/openrisc/include/asm/cache.h
+++ b/arch/openrisc/include/asm/cache.h
@@ -16,6 +16,8 @@
#ifndef __ASM_OPENRISC_CACHE_H_
#define __ASM_OPENRISC_CACHE_H_
+#include <asm/dma.h>
+
void flush_dcache_range(unsigned long addr, unsigned long stop);
void invalidate_dcache_range(unsigned long addr, unsigned long stop);
void flush_cache(unsigned long addr, unsigned long size);
@@ -28,16 +30,4 @@ void dcache_disable(void);
void icache_enable(void);
void icache_disable(void);
-/*
- * Valid L1 data cache line sizes for the OpenRISC architecture are
- * 16 and 32 bytes.
- * If the board configuration has not specified one we default to the
- * largest of these values for alignment of DMA buffers.
- */
-#ifdef CONFIG_SYS_CACHELINE_SIZE
-#define ARCH_DMA_MINALIGN CONFIG_SYS_CACHELINE_SIZE
-#else
-#define ARCH_DMA_MINALIGN 32
-#endif
-
#endif /* __ASM_OPENRISC_CACHE_H_ */
diff --git a/arch/openrisc/include/asm/dma.h b/arch/openrisc/include/asm/dma.h
index 27d269f49182..090e01cb7e44 100644
--- a/arch/openrisc/include/asm/dma.h
+++ b/arch/openrisc/include/asm/dma.h
@@ -8,6 +8,10 @@
#ifndef __ASM_DMA_H
#define __ASM_DMA_H
-/* empty */
+/*
+ * Valid L1 data cache line sizes for the OpenRISC architecture are
+ * 16 and 32 bytes.
+ */
+#define DMA_ALIGNMENT 32
#endif /* __ASM_DMA_H */
diff --git a/include/dma.h b/include/dma.h
index 53cb50b707f4..1f650aecb950 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -22,6 +22,10 @@
#define DMA_ALIGNMENT 32
#endif
+#ifndef ARCH_DMA_MINALIGN
+#define ARCH_DMA_MINALIGN DMA_ALIGNMENT
+#endif
+
#ifdef CONFIG_HAS_DMA
void *dma_alloc(size_t size);
void *dma_zalloc(size_t size);
--
2.39.5
reply other threads:[~2024-11-25 15:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241125153003.708512-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox