Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xtensa: nommu: set up cache and atomctl in initialize_mmu

initialize_mmu sets up atomctl SR which is needed for s32c1i to function
correctly even in noMMU configurations. It's also a good place to set up
caching attributes of physical memory.

Allow enabling INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX in noMMU
configurations for setting up atomctl and cache attributes.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>

+36 -2
-1
arch/xtensa/Kconfig
··· 191 191 192 192 config INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX 193 193 bool "Initialize Xtensa MMU inside the Linux kernel code" 194 - depends on MMU 195 194 default y 196 195 help 197 196 Earlier version initialized the MMU in the exception vector
+36 -1
arch/xtensa/include/asm/initialize_mmu.h
··· 26 26 #include <asm/pgtable.h> 27 27 #include <asm/vectors.h> 28 28 29 + #if XCHAL_HAVE_PTP_MMU 29 30 #define CA_BYPASS (_PAGE_CA_BYPASS | _PAGE_HW_WRITE | _PAGE_HW_EXEC) 30 31 #define CA_WRITEBACK (_PAGE_CA_WB | _PAGE_HW_WRITE | _PAGE_HW_EXEC) 32 + #else 33 + #define CA_WRITEBACK (0x4) 34 + #endif 35 + 36 + #ifndef XCHAL_SPANNING_WAY 37 + #define XCHAL_SPANNING_WAY 0 38 + #endif 31 39 32 40 #ifdef __ASSEMBLY__ 33 41 ··· 83 75 84 76 /* Step 1: invalidate mapping at 0x40000000..0x5FFFFFFF. */ 85 77 86 - movi a2, 0x40000006 78 + movi a2, 0x40000000 | XCHAL_SPANNING_WAY 87 79 idtlb a2 88 80 iitlb a2 89 81 isync ··· 160 152 161 153 #endif /* defined(CONFIG_MMU) && XCHAL_HAVE_PTP_MMU && 162 154 XCHAL_HAVE_SPANNING_WAY */ 155 + 156 + #if !defined(CONFIG_MMU) && XCHAL_HAVE_TLBS 157 + /* Enable data and instruction cache in the DEFAULT_MEMORY region 158 + * if the processor has DTLB and ITLB. 159 + */ 160 + 161 + movi a5, PLATFORM_DEFAULT_MEM_START | XCHAL_SPANNING_WAY 162 + movi a6, ~_PAGE_ATTRIB_MASK 163 + movi a7, CA_WRITEBACK 164 + movi a8, 0x20000000 165 + movi a9, PLATFORM_DEFAULT_MEM_SIZE 166 + j 2f 167 + 1: 168 + sub a9, a9, a8 169 + 2: 170 + rdtlb1 a3, a5 171 + ritlb1 a4, a5 172 + and a3, a3, a6 173 + and a4, a4, a6 174 + or a3, a3, a7 175 + or a4, a4, a7 176 + wdtlb a3, a5 177 + witlb a4, a5 178 + add a5, a5, a8 179 + bltu a8, a9, 1b 180 + 181 + #endif 163 182 164 183 .endm 165 184