1
1

realtek: mach: specify alignment topology

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>
This commit is contained in:
Markus Stockhausen 2026-05-23 12:59:39 +02:00
parent 0324d9e4e0
commit fc61e795ee
3 changed files with 11 additions and 2 deletions

View File

@ -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 */

View File

@ -52,7 +52,7 @@ Submitted-by: Birger Koblitz <git@birger-koblitz.de>
config SGI_IP22 config SGI_IP22
bool "SGI IP22 (Indy/Indigo2)" 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. from Mobileye in the FIT kernel image.
This requires u-boot on the platform. This requires u-boot on the platform.
@ -61,6 +61,7 @@ Submitted-by: Birger Koblitz <git@birger-koblitz.de>
+ depends on MACH_REALTEK_RTL + depends on MACH_REALTEK_RTL
+ select CPU_SUPPORTS_CPUFREQ + select CPU_SUPPORTS_CPUFREQ
+ select MIPS_EXTERNAL_TIMER + select MIPS_EXTERNAL_TIMER
+ select MIPS_L1_CACHE_SHIFT_4
+ +
+config RTL839X +config RTL839X
+ bool "Realtek RTL839X based platforms" + bool "Realtek RTL839X based platforms"

View File

@ -144,7 +144,8 @@ CONFIG_MIPS_ASID_SHIFT=0
# CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set # CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set
CONFIG_MIPS_CMDLINE_FROM_DTB=y CONFIG_MIPS_CMDLINE_FROM_DTB=y
CONFIG_MIPS_EXTERNAL_TIMER=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_NO_APPENDED_DTB is not set
CONFIG_MIPS_RAW_APPENDED_DTB=y CONFIG_MIPS_RAW_APPENDED_DTB=y
CONFIG_MIPS_SPRAM=y CONFIG_MIPS_SPRAM=y