85xx: CONFIG_MP Boot Page Translation update
PATCH v2 1/2 85xx: CONFIG_MP Boot Page Translation update
Previously, when CONFIG_MP was defined Boot Page Translation was unconditionally enabled and secondary cores were put in a spin loop at address 0xfffff000. The 0xfffffxxx address range (ie the Boot Page) was being remapped to SDRAM via the BPTR register.
This change puts secondary cores into spin loops at their 'true' address in SDRAM and doesn't require Boot Page Translation to always be enabled. The main advantage of this change is that Boot Page Translation can be disabled after the secondary cores are brought up which allows the memory region at 0xfffffxxx to be used for other peripherals, etc.
By default, Boot Page Translation remains enabled while U-Boot executes. A new CONFIG_MPC8xxx_DISABLE_BPTR define has been added which causes Boot Page Translation to be disabled for those boards which wish to use the 0xfffffxxx address range as part of their normal memory map.
---
Changes since v1:
- Use clrbits_be32() instead of in/out_be32()
This is very similar to "85xx: Fix mapping of 0xfffffxxx when CONFIG_MP" The 2 differences are:
- Boot page translation is only disabled when CONFIG_MPC8xxx_DISABLT_BPTR is defined.
- Instead of zeroing out BPTR when disabling translation, this patch only disables translation, but maintins the translation address. This should make it easier to properly re-enable translation if need be.
cpu/mpc85xx/mp.c | 22 ++++++++++++++++++++--
cpu/mpc85xx/release.S | 30 +++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 7 deletions(-)
cpu/mpc85xx/mp.c +20 -2
@@ -129,7 +129,7 @@ ulong get_spin_addr(void)ulong addr = (ulong )&__spin_table - (ulong )&__secondary_start_page; - addr +=0xfffff000 ; + addr +=determine_mp_bootpg ();return addr; }
@@ -137,7 +137,8 @@ ulong get_spin_addr(void)static void pq3_mp_up (unsigned long bootpg) {u32 up, cpu_up_mask, whoami; -u32 *table = (u32 *)get_spin_addr (); +/* The table is at 0xfffffxxx due to boot page translation below */ +u32 *table = (u32 *)(0xfffff000 |get_spin_addr ());volatile u32 bpcr;volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
@@ -146,6 +147,8 @@ static void pq3_mp_up(unsigned long bootpg)int timeout =10 ; whoami =in_be32 (&pic->whoami); + +/* Translate 0xfffffxxx 'bootpg' address range to SDRAM */ out_be32 (&ecm->bptr,0x80000000 | (bootpg >>12 ));/* disable time base at the platform */
@@ -194,6 +197,17 @@ static void pq3_mp_up(unsigned long bootpg) devdisr &= ~(MPC85xx_DEVDISR_TB0 | MPC85xx_DEVDISR_TB1);out_be32 (&gur->devdisr, devdisr); + +#ifdef CONFIG_MPC8xxx_DISABLE_BPTR +/* +* Disabling Boot Page Translation allows the memory region 0xfffff000 +* to 0xffffffff to be used normally. Leaving Boot Page Translation +* enabled remaps 0xfffff000 to SDRAM which makes that memory region +* unusable for normal operation but it does allow OSes to easily +* reset a processor core to put it back into U-Boot's spinloop. +*/ +clrbits_be32 (&ecm->bptr,0x80000000 ); +#endif }void cpu_mp_lmb_reserve (struct lmb *lmb)
@@ -206,9 +220,13 @@ void cpu_mp_lmb_reserve(struct lmb *lmb)void setup_mp (void ) {extern ulong __secondary_start_page; +extern ulong __bootpg_addr;ulong fixup = (ulong)&__secondary_start_page;u32 bootpg =determine_mp_bootpg (); +/* Store the bootpg's SDRAM address for use by secondary CPU cores */ + __bootpg_addr = bootpg; +memcpy ((void *)bootpg, (void *)fixup,4096 );flush_cache (bootpg,4096 );
cpu/mpc85xx/release.S +25 -5
@@ -114,23 +114,38 @@ __secondary_start_page: stw r3,ENTRY_R6_UPPER(r10) stw r3,ENTRY_R6_LOWER(r10) + /* load r13 with the address of the 'bootpg' in SDRAM */ + lis r13,toreset(__bootpg_addr)@h + ori r13,r13,toreset(__bootpg_addr)@l + lwz r13,0(r13) + /* setup mapping for AS = 1, and jump there */ lis r11,(MAS0_TLBSEL(1)|MAS0_ESEL(1))@h mtspr SPRN_MAS0,r11 lis r11,(MAS1_VALID|MAS1_IPROT)@h ori r11,r11,(MAS1_TS|MAS1_TSIZE(BOOKE_PAGESZ_4K))@l mtspr SPRN_MAS1,r11 - lis r11,(0xfffff000|MAS2_I)@h - ori r11,r11,(0xfffff000|MAS2_I)@l + oris r11,r13,(MAS2_I)@h + ori r11,r13,(MAS2_I)@l mtspr SPRN_MAS2,r11 - lis r11,(0xfffff000|MAS3_SX|MAS3_SW|MAS3_SR)@h - ori r11,r11,(0xfffff000|MAS3_SX|MAS3_SW|MAS3_SR)@l + oris r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@h + ori r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@l mtspr SPRN_MAS3,r11 tlbwe bl 1f 1: mflr r11 - addi r11,r11,28 + /* + * OR in 0xfff to create a mask of the bootpg SDRAM address. We use + * this mask to fixup the cpu spin table and the address that we want + * to jump to, eg change them from 0xfffffxxx to 0x7ffffxxx if the + * bootpg is at 0x7ffff000 in SDRAM. + */ + ori r13,r13,0xfff + and r11, r11, r13 + and r10, r10, r13 + + addi r11,r11,(2f-1b) mfmsr r13 ori r12,r13,MSR_IS|MSR_DS at l
@@ -200,6 +215,11 @@ __secondary_start_page: mtspr SPRN_SRR1,r13 rfi + /* Allocate some space for the SDRAM address of the bootpg */ + .globl __bootpg_addr +__bootpg_addr: + .long 0 + .align L1_CACHE_SHIFT .globl __spin_table __spin_table:
Signature · 1 line
1.6.2.1
PATCH v2 2/2 xpedite5370: Enable MP support
Also, disable Boot Page Translation after the secondary core is enabled so that the 0xfffff000-0xffffffff memory region can still be utilized for flash similar to other X-ES boards
--- include/configs/XPEDITE5370.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
include/configs/XPEDITE5370.h +2 -0
@@ -34,6 +34,8 @@#define CONFIG_E500 1/* BOOKE e500 family */ #define CONFIG_MPC85xx 1/* MPC8540/60/55/41/48 */ #define CONFIG_MPC8572 1 +#define CONFIG_MP +#define CONFIG_MPC8xxx_DISABLE_BPTR/* Disable boot page translation */ #define CONFIG_XPEDITE5370 1#define CONFIG_SYS_BOARD_NAME "XPedite5370"#define CONFIG_NUM_CPUS 2/* 2 Cores */
Signature · 1 line
1.6.2.1
PATCH v2 1/2 85xx: CONFIG_MP Boot Page Translation update
In reply to Peter TyserQuoted 48 lines · Peter Tyser
Previously, when
CONFIG_MPwas defined Boot Page Translation was unconditionally enabled and secondary cores were put in a spin loop at address0xfffff000. The 0xfffffxxx address range (ie the Boot Page) was
being remapped to SDRAM via the BPTR register.This change puts secondary cores into spin loops at their 'true' address
in SDRAM and doesn't require Boot Page Translation to always be enabled.
The main advantage of this change is that Boot Page Translation can be disabled after the secondary cores are brought up which allows the memory region at 0xfffffxxx to be used for other peripherals, etc.By default, Boot Page Translation remains enabled while U-Boot executes.
A newCONFIG_MPC8xxx_DISABLE_BPTRdefine has been added which causes Boot Page Translation to be disabled for those boards which wish to use
the 0xfffffxxx address range as part of their normal memory map.Signed-off-by Peter Tyser <[email protected]>---
Changes since v1:
- Useclrbits_be32()instead of in/out_be32()This is very similar to "85xx: Fix mapping of 0xfffffxxx when
CONFIG_MP"
The 2 differences are:- Boot page translation is only disabled when
CONFIG_MPC8xxx_DISABLT_BPTR
is defined.- Instead of zeroing out BPTR when disabling translation, this patch only disables translation, but maintins the translation address. This should make it easier to properly re-enable translation if need be.
cpu/mpc85xx/mp.c | 22 ++++++++++++++++++++-- cpu/mpc85xx/release.S | 30 +++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 7 deletions(-)cpu/mpc85xx/mp.c +0
-0
cpu/mpc85xx/mp.c ulong get_spin_addr(void) · line 132
Quoted 5 lines
cpu/mpc85xx/mp.c +1
-1@@ -129,7 +129,7 @@ ulong get_spin_addr(void)ulong addr = (ulong )&__spin_table - (ulong )&__secondary_start_page; - addr +=0xfffff000 ; + addr +=determine_mp_bootpg ();
changing this has some issues. We expect the the address that the spin table is at to be marked cache-inhibited.
Quoted 120 lines
cpu/mpc85xx/mp.c +2
-1return addr; }@@ -137,7 +137,8 @@ ulong get_spin_addr(void)static void pq3_mp_up (unsigned long bootpg) {u32 up, cpu_up_mask, whoami; -u32 *table = (u32 *)get_spin_addr (); +/* The table is at 0xfffffxxx due to boot page translation below */ +u32 *table = (u32 *)(0xfffff000 |get_spin_addr ());volatile u32 bpcr;volatile ccsr_local_ecm_t *ecm = (void *) (CONFIG_SYS_MPC85xx_ECM_ADDR);volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);cpu/mpc85xx/mp.c +6
-0@@ -146,6 +147,8 @@ static void pq3_mp_up(unsigned long bootpg)int timeout =10 ; whoami =in_be32 (&pic->whoami); + +/* Translate 0xfffffxxx 'bootpg' address range to SDRAM */ out_be32 (&ecm->bptr,0x80000000 | (bootpg >>12 ));/* disable time base at the platform */ @@ -194,6 +197,17 @@ static void pq3_mp_up(unsigned long bootpg) devdisr &= ~(MPC85xx_DEVDISR_TB0 | MPC85xx_DEVDISR_TB1);out_be32 (&gur->devdisr, devdisr); + +#ifdef CONFIG_MPC8xxx_DISABLE_BPTR +/* +* Disabling Boot Page Translation allows the memory region
0xfffff000cpu/mpc85xx/mp.c +7
-0+* to 0xffffffff to be used normally. Leaving Boot Page Translation +* enabled remaps 0xfffff000 to SDRAM which makes that memory region +* unusable for normal operation but it does allow OSes to easily +* reset a processor core to put it back into U-Boot's spinloop. +*/ +clrbits_be32 (&ecm->bptr,0x80000000 ); +#endif }
void
cpu_mp_lmb_reserve(struct lmb *lmb)cpu/mpc85xx/mp.c +4
-0@@ -206,9 +220,13 @@ void cpu_mp_lmb_reserve(struct lmb *lmb)void setup_mp (void ) {extern ulong __secondary_start_page; +extern ulong __bootpg_addr;ulong fixup = (ulong)&__secondary_start_page;u32 bootpg =determine_mp_bootpg (); +/* Store the bootpg's SDRAM address for use by secondary CPU cores */ + __bootpg_addr = bootpg; +memcpy ((void *)bootpg, (void *)fixup,4096 );flush_cache (bootpg,4096 );cpu/mpc85xx/release.S +9
-4@@ -114,23 +114,38 @@ __secondary_start_page: stw r3,ENTRY_R6_UPPER(r10) stw r3,ENTRY_R6_LOWER(r10) + /* load r13 with the address of the 'bootpg' in SDRAM */ + lis r13,toreset(__bootpg_addr)@h + ori r13,r13,toreset(__bootpg_addr)@l + lwz r13,0(r13) + /* setup mapping for AS = 1, and jump there */ lis r11,(MAS0_TLBSEL(1)|MAS0_ESEL(1))@h mtspr SPRN_MAS0,r11 lis r11,(MAS1_VALID|MAS1_IPROT)@h ori r11,r11,(MAS1_TS|MAS1_TSIZE(BOOKE_PAGESZ_4K))@l mtspr SPRN_MAS1,r11 - lis r11,(0xfffff000|MAS2_I)@h - ori r11,r11,(0xfffff000|MAS2_I)@l + oris r11,r13,(MAS2_I)@h + ori r11,r13,(MAS2_I)@l mtspr SPRN_MAS2,r11 - lis r11,(0xfffff000|MAS3_SX|MAS3_SW|MAS3_SR)@h - ori r11,r11,(0xfffff000|MAS3_SX|MAS3_SW|MAS3_SR)@l + oris r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@h + ori r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@l mtspr SPRN_MAS3,r11 tlbwe bl 1f1: mflr r11
cpu/mpc85xx/release.S +3
-1- addi r11,r11,28 + /* + * OR in 0xfff to create a mask of the bootpg SDRAM address. We use + * this mask to fixup the cpu spin table and the address that wewant
cpu/mpc85xx/release.S +8
-0+ * to jump to, eg change them from 0xfffffxxx to 0x7ffffxxx if the + * bootpg is at 0x7ffff000 in SDRAM. + */ + ori r13,r13,0xfff + and r11, r11, r13 + and r10, r10, r13 + + addi r11,r11,(2f-1b)mfmsr r13 ori r12,r13,MSR_IS|MSR_DS at lcpu/mpc85xx/release.S +5
-0@@ -200,6 +215,11 @@ __secondary_start_page: mtspr SPRN_SRR1,r13 rfi + /* Allocate some space for the SDRAM address of the bootpg */ + .globl __bootpg_addr +__bootpg_addr: + .long 0 + .align L1_CACHE_SHIFT .globl __spin_table
__spin_table:Signature · 1 line
1.6.2.1
PATCH v2 1/2 85xx: CONFIG_MP Boot Page Translation update
Quoted 7 lines
Quoted 7 lines
cpu/mpc85xx/mp.c +0
-0@@ -129,7 +129,7 @@ ulong get_spin_addr(void)
Quoted 7 lines
cpu/mpc85xx/mp.c ulong get_spin_addr(void) · line 132
Quoted 4 lines
cpu/mpc85xx/mp.c +1
-1ulong addr = (ulong )&__spin_table - (ulong )&__secondary_start_page; - addr +=0xfffff000 ; + addr +=determine_mp_bootpg ();changing this has some issues. We expect the the address that the spin table is at to be marked cache-inhibited.
The secondary cores will be running with the spin table in cache-inhibited memory and it looks like Linux accesses the spin table after ioremapping it, so that flow looks OK.
I assumed the e500 Coherency Module will ensure that the cpu_status() function should also be OK as is.
It looks like I should have added 2 cache flushes to U-Boot's cpu_release(), like:
cpu/mpc85xx/mp.c +3 -1
@@ -106,9 +106,11 @@ int cpu_release(int nr, int argc, char *argv[]) table[BOOT_ENTRY_ADDR_UPPER ] = (u32)(boot_addr >>32 );/* ensure all table updates complete before final address write */ -eieio (); +ppcDcbf ((unsigned long )table); + asm("msync" ); table[BOOT_ENTRY_ADDR_LOWER ] = (u32)(boot_addr &0xffffffff ); +ppcDcbf ((unsigned long )table);return 0 ; }
I'll resubmit with the change above, let me know if I'm off base.
Thanks,
Peter
PATCH v2 1/2 85xx: CONFIG_MP Boot Page Translation update
Quoted 42 lines · Peter Tyser
Quoted 7 lines
Quoted 7 lines
cpu/mpc85xx/mp.c +0
-0@@ -129,7 +129,7 @@ ulong get_spin_addr(void)Quoted 7 lines
cpu/mpc85xx/mp.c ulong get_spin_addr(void) · line 132
Quoted 4 lines
cpu/mpc85xx/mp.c +1
-1ulong addr = (ulong )&__spin_table - (ulong )&__secondary_start_page; - addr +=0xfffff000 ; + addr +=determine_mp_bootpg ();changing this has some issues. We expect the the address that the spin table is at to be marked cache-inhibited.
The secondary cores will be running with the spin table in cache-inhibited memory and it looks like Linux accesses the spin table after ioremapping it, so that flow looks OK.
I assumed the e500 Coherency Module will ensure that the
cpu_status()function should also be OK as is.It looks like I should have added 2 cache flushes to U-Boot's
cpu_release(), like:cpu/mpc85xx/mp.c +0
-0@@ -106,9 +106,11 @@ int cpu_release(int nr, int argc, char *argv[]) table[BOOT_ENTRY_ADDR_UPPER ] = (u32)(boot_addr >>32 );/* ensure all table updates complete before final address write */
cpu/mpc85xx/mp.c +3
-1-eieio (); +ppcDcbf ((unsigned long )table); + asm("msync" ); table[BOOT_ENTRY_ADDR_LOWER ] = (u32)(boot_addr &0xffffffff ); +ppcDcbf ((unsigned long )table);return 0 ;}
Quoted 1 line
I'll resubmit with the change above, let me know if I'm off base.
There's another issue with this, its possible that the location in memory is not mapped in the TLBs. We typically max out @ 2G of DDR mapped (via the TLBs). So what happens if we have 3G of DDR.
- k
PATCH v2 1/2 85xx: CONFIG_MP Boot Page Translation update
Quoted 41 lines · Kumar Gala
Quoted 39 lines · Peter Tyser
Quoted 7 lines
Quoted 7 lines
cpu/mpc85xx/mp.c +0
-0@@ -129,7 +129,7 @@ ulong get_spin_addr(void)Quoted 7 lines
cpu/mpc85xx/mp.c ulong get_spin_addr(void) · line 132
Quoted 4 lines
cpu/mpc85xx/mp.c +1
-1ulong addr = (ulong )&__spin_table - (ulong )&__secondary_start_page; - addr +=0xfffff000 ; + addr +=determine_mp_bootpg ();changing this has some issues. We expect the the address that the spin table is at to be marked cache-inhibited.
The secondary cores will be running with the spin table in cache-inhibited memory and it looks like Linux accesses the spin table after ioremapping it, so that flow looks OK.
I assumed the e500 Coherency Module will ensure that the
cpu_status()function should also be OK as is.It looks like I should have added 2 cache flushes to U-Boot's
cpu_release(), like:cpu/mpc85xx/mp.c +0
-0@@ -106,9 +106,11 @@ int cpu_release(int nr, int argc, char *argv[]) table[BOOT_ENTRY_ADDR_UPPER ] = (u32)(boot_addr >>32 );/* ensure all table updates complete before final address write */
cpu/mpc85xx/mp.c +3
-1-eieio (); +ppcDcbf ((unsigned long )table); + asm("msync" ); table[BOOT_ENTRY_ADDR_LOWER ] = (u32)(boot_addr &0xffffffff ); +ppcDcbf ((unsigned long )table);
Quoted 8 lines
Quoted 4 lines
return 0; }I'll resubmit with the change above, let me know if I'm off base.
There's another issue with this, its possible that the location in memory is not mapped in the TLBs. We typically max out @ 2G of DDR mapped (via the TLBs). So what happens if we have 3G of DDR.
Ick... I hope to have some spare time in the next few days and will look into fixing this patch up then.
Thanks,
Peter