diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2018-08-12 09:01:40 -0400 |
---|---|---|
committer | Max Filippov <jcmvbkbc@gmail.com> | 2018-08-13 23:08:19 -0400 |
commit | 7bb516ca5424e12b42124fab2906b6da9c81ba9c (patch) | |
tree | 275dd23356eba62a81025221e23df3210a87a7be | |
parent | fec3259c9f747c039f90e99570540114c8d81a14 (diff) |
xtensa: rework noMMU cache attributes initialization
Marking default memory region as cached is not always sufficient and is
not flexible. Allow specifying cache attributes for the whole memory
address space with new config entry MEMMAP_CACHEATTR. Apply it after
cache initialization.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
-rw-r--r-- | arch/xtensa/Kconfig | 17 | ||||
-rw-r--r-- | arch/xtensa/configs/nommu_kc705_defconfig | 1 | ||||
-rw-r--r-- | arch/xtensa/include/asm/initialize_mmu.h | 42 | ||||
-rw-r--r-- | arch/xtensa/kernel/head.S | 2 |
4 files changed, 41 insertions, 21 deletions
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index d575e8701955..524b80722fd0 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig | |||
@@ -249,6 +249,23 @@ config INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX | |||
249 | 249 | ||
250 | If in doubt, say Y. | 250 | If in doubt, say Y. |
251 | 251 | ||
252 | config MEMMAP_CACHEATTR | ||
253 | hex "Cache attributes for the memory address space" | ||
254 | depends on !MMU | ||
255 | default 0x22222222 | ||
256 | help | ||
257 | These cache attributes are set up for noMMU systems. Each hex digit | ||
258 | specifies cache attributes for the corresponding 512MB memory | ||
259 | region: bits 0..3 -- for addresses 0x00000000..0x1fffffff, | ||
260 | bits 4..7 -- for addresses 0x20000000..0x3fffffff, and so on. | ||
261 | |||
262 | Cache attribute values are specific for the MMU type, so e.g. | ||
263 | for region protection MMUs: 2 is cache bypass, 4 is WB cached, | ||
264 | 1 is WT cached, f is illegal. For ful MMU: bit 0 makes it executable, | ||
265 | bit 1 makes it writable, bits 2..3 meaning is 0: cache bypass, | ||
266 | 1: WB cache, 2: WT cache, 3: special (c and e are illegal, f is | ||
267 | reserved). | ||
268 | |||
252 | config KSEG_PADDR | 269 | config KSEG_PADDR |
253 | hex "Physical address of the KSEG mapping" | 270 | hex "Physical address of the KSEG mapping" |
254 | depends on INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX && MMU | 271 | depends on INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX && MMU |
diff --git a/arch/xtensa/configs/nommu_kc705_defconfig b/arch/xtensa/configs/nommu_kc705_defconfig index 624f9b3a3878..610f622d3c84 100644 --- a/arch/xtensa/configs/nommu_kc705_defconfig +++ b/arch/xtensa/configs/nommu_kc705_defconfig | |||
@@ -33,6 +33,7 @@ CONFIG_XTENSA_VARIANT_CUSTOM_NAME="de212" | |||
33 | # CONFIG_XTENSA_VARIANT_MMU is not set | 33 | # CONFIG_XTENSA_VARIANT_MMU is not set |
34 | CONFIG_XTENSA_UNALIGNED_USER=y | 34 | CONFIG_XTENSA_UNALIGNED_USER=y |
35 | CONFIG_PREEMPT=y | 35 | CONFIG_PREEMPT=y |
36 | CONFIG_MEMMAP_CACHEATTR=0xfff2442f | ||
36 | # CONFIG_PCI is not set | 37 | # CONFIG_PCI is not set |
37 | CONFIG_XTENSA_PLATFORM_XTFPGA=y | 38 | CONFIG_XTENSA_PLATFORM_XTFPGA=y |
38 | CONFIG_CMDLINE_BOOL=y | 39 | CONFIG_CMDLINE_BOOL=y |
diff --git a/arch/xtensa/include/asm/initialize_mmu.h b/arch/xtensa/include/asm/initialize_mmu.h index 42410f253597..10e9852b2fb4 100644 --- a/arch/xtensa/include/asm/initialize_mmu.h +++ b/arch/xtensa/include/asm/initialize_mmu.h | |||
@@ -177,36 +177,36 @@ | |||
177 | #endif /* defined(CONFIG_MMU) && XCHAL_HAVE_PTP_MMU && | 177 | #endif /* defined(CONFIG_MMU) && XCHAL_HAVE_PTP_MMU && |
178 | XCHAL_HAVE_SPANNING_WAY */ | 178 | XCHAL_HAVE_SPANNING_WAY */ |
179 | 179 | ||
180 | #if !defined(CONFIG_MMU) && XCHAL_HAVE_TLBS && \ | 180 | .endm |
181 | (XCHAL_DCACHE_SIZE || XCHAL_ICACHE_SIZE) | 181 | |
182 | /* Enable data and instruction cache in the DEFAULT_MEMORY region | 182 | .macro initialize_cacheattr |
183 | * if the processor has DTLB and ITLB. | ||
184 | */ | ||
185 | 183 | ||
186 | movi a5, PLATFORM_DEFAULT_MEM_START | XCHAL_SPANNING_WAY | 184 | #if !defined(CONFIG_MMU) && XCHAL_HAVE_TLBS |
185 | #if CONFIG_MEMMAP_CACHEATTR == 0x22222222 && XCHAL_HAVE_PTP_MMU | ||
186 | #error Default MEMMAP_CACHEATTR of 0x22222222 does not work with full MMU. | ||
187 | #endif | ||
188 | |||
189 | movi a5, XCHAL_SPANNING_WAY | ||
187 | movi a6, ~_PAGE_ATTRIB_MASK | 190 | movi a6, ~_PAGE_ATTRIB_MASK |
188 | movi a7, CA_WRITEBACK | 191 | movi a4, CONFIG_MEMMAP_CACHEATTR |
189 | movi a8, 0x20000000 | 192 | movi a8, 0x20000000 |
190 | movi a9, PLATFORM_DEFAULT_MEM_SIZE | ||
191 | j 2f | ||
192 | 1: | 193 | 1: |
193 | sub a9, a9, a8 | ||
194 | 2: | ||
195 | #if XCHAL_DCACHE_SIZE | ||
196 | rdtlb1 a3, a5 | 194 | rdtlb1 a3, a5 |
195 | xor a3, a3, a4 | ||
197 | and a3, a3, a6 | 196 | and a3, a3, a6 |
198 | or a3, a3, a7 | 197 | xor a3, a3, a4 |
199 | wdtlb a3, a5 | 198 | wdtlb a3, a5 |
200 | #endif | 199 | ritlb1 a3, a5 |
201 | #if XCHAL_ICACHE_SIZE | 200 | xor a3, a3, a4 |
202 | ritlb1 a4, a5 | 201 | and a3, a3, a6 |
203 | and a4, a4, a6 | 202 | xor a3, a3, a4 |
204 | or a4, a4, a7 | 203 | witlb a3, a5 |
205 | witlb a4, a5 | 204 | |
206 | #endif | ||
207 | add a5, a5, a8 | 205 | add a5, a5, a8 |
208 | bltu a8, a9, 1b | 206 | srli a4, a4, 4 |
207 | bgeu a5, a8, 1b | ||
209 | 208 | ||
209 | isync | ||
210 | #endif | 210 | #endif |
211 | 211 | ||
212 | .endm | 212 | .endm |
diff --git a/arch/xtensa/kernel/head.S b/arch/xtensa/kernel/head.S index 9c4e9433e536..2f76118ecf62 100644 --- a/arch/xtensa/kernel/head.S +++ b/arch/xtensa/kernel/head.S | |||
@@ -181,6 +181,8 @@ ENTRY(_startup) | |||
181 | 181 | ||
182 | isync | 182 | isync |
183 | 183 | ||
184 | initialize_cacheattr | ||
185 | |||
184 | #ifdef CONFIG_HAVE_SMP | 186 | #ifdef CONFIG_HAVE_SMP |
185 | movi a2, CCON # MX External Register to Configure Cache | 187 | movi a2, CCON # MX External Register to Configure Cache |
186 | movi a3, 1 | 188 | movi a3, 1 |