]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: mach: specify alignment topology 23492/head
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sat, 23 May 2026 10:59:39 +0000 (12:59 +0200)
committerMarkus Stockhausen <markus.stockhausen@gmx.de>
Thu, 28 May 2026 19:02:24 +0000 (21:02 +0200)
The kernel has two helper defines that guide about hardware
characteristics.

MIPS_L1_CACHE_SHIFT defines the cache line sizes (1<<x) of the
target. It defaults to 5 - so it is assumed that the device has
a cache line size of 32 bytes. This is not true for MIPS 4KEc
cores that are driving the RTL838x SOCs. These cores have 16
byte cache line sizes. Adapt the CONFIG properties for this
target to match the hardware.

ARCH_DMA_MINALIGN definies the alignment for memory allocations.
Other than its name suggests on MIPS devices that have non
coherent DMA kmalloc() respects this configuration. This ensures
that no normal memory is corrupted by DMA blocks that share the
same cache line.

The default for this is 128 bytes. And kernel states itself
"Total overkill for most systems but need as a safe default. Set
this one if any device in the system might do non-coherent DMA".

Realtek devices use non coherent DMA so they are affected by the
setting of ARCH_DMA_MINALIGN. Set this to cache line size for
all devices to reduce memory waste.

Link: https://github.com/openwrt/openwrt/pull/23492
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
target/linux/realtek/files-6.18/arch/mips/include/asm/mach-rtl-otto/kmalloc.h [new file with mode: 0644]
target/linux/realtek/patches-6.18/300-mips-add-rtl838x-platform.patch
target/linux/realtek/rtl838x/config-6.18

diff --git a/target/linux/realtek/files-6.18/arch/mips/include/asm/mach-rtl-otto/kmalloc.h b/target/linux/realtek/files-6.18/arch/mips/include/asm/mach-rtl-otto/kmalloc.h
new file mode 100644 (file)
index 0000000..7bf463a
--- /dev/null
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_MACH_RTL_OTTO_KMALLOC_H
+#define __ASM_MACH_RTL_OTTO_KMALLOC_H
+
+#define ARCH_DMA_MINALIGN      L1_CACHE_BYTES
+
+#endif /* __ASM_MACH_RTL_OTTO_KMALLOC_H */
index 7115255fba1017c62e5b7b165aed5664213b74db..bbaf09104358502b98ae6676c1e8ef87c8752a16 100644 (file)
@@ -52,7 +52,7 @@ Submitted-by: Birger Koblitz <git@birger-koblitz.de>
  
  config SGI_IP22
        bool "SGI IP22 (Indy/Indigo2)"
-@@ -1056,6 +1057,36 @@ config FIT_IMAGE_FDT_EPM5
+@@ -1056,6 +1057,37 @@ config FIT_IMAGE_FDT_EPM5
          from Mobileye in the FIT kernel image.
          This requires u-boot on the platform.
  
@@ -61,6 +61,7 @@ Submitted-by: Birger Koblitz <git@birger-koblitz.de>
 +      depends on MACH_REALTEK_RTL
 +      select CPU_SUPPORTS_CPUFREQ
 +      select MIPS_EXTERNAL_TIMER
++      select MIPS_L1_CACHE_SHIFT_4
 +
 +config RTL839X
 +      bool "Realtek RTL839X based platforms"
index 714417e555d60f17d5fd13e575870c58da1f7acb..97c450830424ccf4fc042e1579f7efb98051f119 100644 (file)
@@ -144,7 +144,8 @@ CONFIG_MIPS_ASID_SHIFT=0
 # CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set
 CONFIG_MIPS_CMDLINE_FROM_DTB=y
 CONFIG_MIPS_EXTERNAL_TIMER=y
-CONFIG_MIPS_L1_CACHE_SHIFT=5
+CONFIG_MIPS_L1_CACHE_SHIFT=4
+CONFIG_MIPS_L1_CACHE_SHIFT_4=y
 # CONFIG_MIPS_NO_APPENDED_DTB is not set
 CONFIG_MIPS_RAW_APPENDED_DTB=y
 CONFIG_MIPS_SPRAM=y