armv8: Include <linux/types.h> in mmu.h
PATCH 1/3 armv8: Include <linux/types.h> in mmu.h
Import missing definition of type u64.
--- arch/arm/include/asm/armv8/mmu.h | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/include/asm/armv8/mmu.h +3 -0
@@ -104,6 +104,9 @@#define TCR_EL3_RSVD (1 << 31 | 1 << 23)#ifndef __ASSEMBLY__ + +#include <linux/types.h> +static inline void set_ttbr_tcr_mair (int el,u64 table,u64 tcr,u64 attr) { asmvolatile ("dsb sy" );
Signature · 1 line
2.35.1.1021.g381101b075-goog
PATCH 2/3 armv8: Drop support for non-MEMORY_ATTRIBUTES MAIR
Remove the ability for caller code to set MAIR through set_ttbr_tcr_mair() as that doesn't seem to be used nor necessary given that the register is typically initialized once to a compile-time constant, MEMORY_ATTRIBUTES, to be used by the hardware as a byte array to be indexed through the 3-bit attribute entry in PTEs (see MT_NORMAL and MT_DEVICE_*). As those attribute offsets are themselves CPP macros, it is very unlikely for U-Boot to start dynamically defining the value of MAIR at runtime.
For now, keep setting the register from within the function so that no functional change should be expected.
--- arch/arm/cpu/armv8/cache_v8.c | 3 +-- arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 9 +++------ arch/arm/include/asm/armv8/mmu.h | 4 +++- 3 files changed, 7 insertions(+), 9 deletions(-)
arch/arm/cpu/armv8/cache_v8.c +1 -2
@@ -415,8 +415,7 @@ __weak void mmu_setup(void)setup_all_pgtables (); el =current_el (); -set_ttbr_tcr_mair (el, gd->arch.tlb_addr,get_tcr (el,NULL ,NULL ), -MEMORY_ATTRIBUTES ); +set_ttbr_tcr (el, gd->arch.tlb_addr,get_tcr (el,NULL ,NULL ));/* enable the mmu */ set_sctlr (get_sctlr () |CR_M );
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +3 -6
@@ -451,10 +451,8 @@ static inline void early_mmu_setup(void)setup_pgtables ();/* point TTBR to the new table */ -set_ttbr_tcr_mair (el, gd->arch.tlb_addr, -get_tcr (el,NULL ,NULL ) & - ~(TCR_ORGN_MASK |TCR_IRGN_MASK ), -MEMORY_ATTRIBUTES ); +set_ttbr_tcr (el, gd->arch.tlb_addr,get_tcr (el,NULL ,NULL ) + & ~(TCR_ORGN_MASK |TCR_IRGN_MASK ));set_sctlr (get_sctlr () |CR_M ); }
@@ -607,8 +605,7 @@ static inline void final_mmu_setup(void)invalidate_icache_all ();/* point TTBR to the new table */ -set_ttbr_tcr_mair (el, gd->arch.tlb_addr,get_tcr (el,NULL ,NULL ), -MEMORY_ATTRIBUTES ); +set_ttbr_tcr (el, gd->arch.tlb_addr,get_tcr (el,NULL ,NULL ));set_sctlr (get_sctlr () |CR_M ); }
arch/arm/include/asm/armv8/mmu.h +3 -1
@@ -107,8 +107,10 @@#include <linux/types.h> -static inline void set_ttbr_tcr_mair (int el,u64 table,u64 tcr,u64 attr) +static inline void set_ttbr_tcr (int el,u64 table,u64 tcr) { +const u64 attr =MEMORY_ATTRIBUTES ; + asmvolatile ("dsb sy" );if (el ==1 ) { asmvolatile ("msr ttbr0_el1, %0" : :"r" (table) :"memory" );
Signature · 1 line
2.35.1.1021.g381101b075-goog
PATCH 3/3 armv8: Initialize MAIR in early boot
In reply to Pierre-Clément TosiAs the register is initialized to a constant value, it can be set at any point before the MMU has been enabled. Instead of waiting until the very last moment to do so, initialize it during early boot, when we initialize other system registers. This ensures it is valid at any point once the C runtime is up.
--- arch/arm/cpu/armv8/Kconfig | 6 ++++++ arch/arm/cpu/armv8/start.S | 12 ++++++++++++ arch/arm/include/asm/armv8/mmu.h | 5 ----- 3 files changed, 18 insertions(+), 5 deletions(-)
arch/arm/cpu/armv8/Kconfig +6 -0
@@ -31,6 +31,12 @@ config ARMV8_SET_SMPEN it can be safely enabled when EL2/EL3 initialized SMPEN bit or when CPU implementation doesn't include that register. +config ARMV8_SET_MAIR + bool "Initialize the MAIR to its constant value out of boot" + default y if !SYS_DISABLE_DCACHE_OPS + help + Say Y here to set MAIR_ELx (MEMORY_ATTRIBUTES), needed by the MMU. + config ARMV8_SPIN_TABLE bool "Support spin-table enable method" depends on ARMV8_MULTIENTRY && OF_LIBFDT
arch/arm/cpu/armv8/start.S +12 -0
@@ -135,6 +135,18 @@ pie_fixup_done: msr cpacr_el1, x0 /* Enable FP/SIMD */ 0: +#ifdef CONFIG_ARMV8_SET_MAIR + ldr x2, =(MEMORY_ATTRIBUTES) + switch_el x1, 3f, 2f, 1f + b 0f +3: msr mair_el3, x2 + b 0f +2: msr mair_el2, x2 + b 0f +1: msr mair_el1, x2 +0: +#endif + #ifdef COUNTER_FREQUENCY branch_if_not_highest_el x0, 4f ldr x0, =COUNTER_FREQUENCY
arch/arm/include/asm/armv8/mmu.h +0 -5
@@ -109,21 +109,16 @@static inline void set_ttbr_tcr (int el,u64 table,u64 tcr) { -const u64 attr =MEMORY_ATTRIBUTES ; - asmvolatile ("dsb sy" );if (el ==1 ) { asmvolatile ("msr ttbr0_el1, %0" : :"r" (table) :"memory" ); asmvolatile ("msr tcr_el1, %0" : :"r" (tcr) :"memory" ); - asmvolatile ("msr mair_el1, %0" : :"r" (attr) :"memory" ); }else if (el ==2 ) { asmvolatile ("msr ttbr0_el2, %0" : :"r" (table) :"memory" ); asmvolatile ("msr tcr_el2, %0" : :"r" (tcr) :"memory" ); - asmvolatile ("msr mair_el2, %0" : :"r" (attr) :"memory" ); }else if (el ==3 ) { asmvolatile ("msr ttbr0_el3, %0" : :"r" (table) :"memory" ); asmvolatile ("msr tcr_el3, %0" : :"r" (tcr) :"memory" ); - asmvolatile ("msr mair_el3, %0" : :"r" (attr) :"memory" ); }else {hang (); }
Signature · 1 line
2.35.1.1021.g381101b075-goog
Re: [PATCH 3/3] armv8: Initialize MAIR in early boot
Quoted 6 lines · Pierre-Clément Tosi
As the register is initialized to a constant value, it can be set at any point before the MMU has been enabled. Instead of waiting until the very last moment to do so, initialize it during early boot, when we initialize other system registers. This ensures it is valid at any point once the C runtime is up.
Quoted 7 lines
Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Tom Rini <[email protected]>--- arch/arm/cpu/armv8/Kconfig | 6 ++++++ arch/arm/cpu/armv8/start.S | 12 ++++++++++++ arch/arm/include/asm/armv8/mmu.h | 5 ----- 3 files changed, 18 insertions(+), 5 deletions(-)
This makes a number of platforms such as:
px30-core-ctouch2-of10-px30 px30-core-ctouch2-px30 px30-core-edimm2.2-px30 odroid-go2 evb-px30 firefly-px30 fail to build due to size increase.
Signature · 1 line
Tom