[PATCH] LoongArch: Increase ARCH_DMA_MINALIGN to 16

From: Huacai Chen
Date: Wed Mar 26 2025 - 06:24:55 EST


ARCH_DMA_MINALIGN is 1 by default, but some LoongArch-specific devices
(such as APBDMA) require 16 bytes alignment. When the data buffer length
is too small, the hardware may make an error writing cacheline. Thus, it
is dangerous to allocate a small memory buffer for DMA. It's always safe
to define ARCH_DMA_MINALIGN as L1_CACHE_BYTES but unnecessary (kmalloc()
need small memory objects). Therefore, just increase it to 16.

Cc: stable@xxxxxxxxxxxxxxx
Tested-by: Binbin Zhou <zhoubinbin@xxxxxxxxxxx>
Signed-off-by: Huacai Chen <chenhuacai@xxxxxxxxxxx>
---
arch/loongarch/include/asm/cache.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/loongarch/include/asm/cache.h b/arch/loongarch/include/asm/cache.h
index 1b6d09617199..aa622c754414 100644
--- a/arch/loongarch/include/asm/cache.h
+++ b/arch/loongarch/include/asm/cache.h
@@ -8,6 +8,8 @@
#define L1_CACHE_SHIFT CONFIG_L1_CACHE_SHIFT
#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)

+#define ARCH_DMA_MINALIGN (16)
+
#define __read_mostly __section(".data..read_mostly")

#endif /* _ASM_CACHE_H */
--
2.47.1