powerpc/mpc86xx: Fix BAT register setup
cover powerpc/mpc86xx: Fix BAT register setup
This set of 2 patches fixes the BAT register setup on mpc86xx. Currently, we overwrite a BAT register while running out of it which is dangerous and can cause problems like the system going into the weeds.
The first patch cleans up the SRIO config information used for setup of the SRIO BAT registers - there were duplicate defines there. The second changes the method used for setting up BATs to disable translation while we do the setup.
We have tested this on mpc8641, and I believe it is safe for the other 86xx platforms like the sbc, but I'd appreciate input.
Cheers,
Becky
arch/powerpc/cpu/mpc86xx/cpu_init.c | 28 -------- arch/powerpc/cpu/mpc86xx/start.S | 69 ++++++++++++++++++- include/configs/MPC8641HPCN.h | 128 ++++++++++++++++++++--------------- include/mpc86xx.h | 1 + 4 files changed, 142 insertions(+), 84 deletions(-)
PATCH 1/2 powerpc/mpc8641hpcn: fix SRIO BAT config
There were duplicate (and conflicting) defines for the BATs used to cover SRIO. Drop the bogus set.
--- include/configs/MPC8641HPCN.h | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
include/configs/MPC8641HPCN.h +0 -5
@@ -515,11 +515,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy); | BATU_VS | BATU_VP)#define CONFIG_SYS_IBAT2L (BAT_PHYS_ADDR(CONFIG_SYS_SRIO1_MEM_PHYS) \ | BATL_PP_RW | BATL_CACHEINHIBIT) - -#define CONFIG_SYS_DBAT2L (CONFIG_SYS_SRIO1_MEM_PHYS | BATL_PP_RW \ - | BATL_CACHEINHIBIT | BATL_GUARDEDSTORAGE) -#define CONFIG_SYS_DBAT2U (CONFIG_SYS_SRIO1_MEM_PHYS | BATU_BL_512M | BATU_VS | BATU_VP) -#define CONFIG_SYS_IBAT2L (CONFIG_SYS_SRIO1_MEM_PHYS | BATL_PP_RW | BATL_CACHEINHIBIT)#define CONFIG_SYS_IBAT2U CONFIG_SYS_DBAT2U#endif
Signature · 1 line
1.5.6.5
PATCH 2/2 powerpc/mpc86xx: Disable translation for BAT setup
We really shouldn't be overwriting bat registers with translation enabled, especially when we're executing code using one of them for translating the current instruction stream. Instead, disable address translation while doing the final BAT setup.
In order to do this, setup_bats has to move back to asm code, because we require translation to be enabled to have a stack for C code. The yucky thing about that is that the assembler doesn't like ULL so we have to switch to using HIGH/LOW pairs for physical addresses that are > 32 bits in length.
--- arch/powerpc/cpu/mpc86xx/cpu_init.c | 28 -------- arch/powerpc/cpu/mpc86xx/start.S | 69 +++++++++++++++++++- include/configs/MPC8641HPCN.h | 123 +++++++++++++++++++++-------------- include/mpc86xx.h | 1 + 4 files changed, 142 insertions(+), 79 deletions(-)
arch/powerpc/cpu/mpc86xx/cpu_init.c +0 -28
@@ -35,7 +35,6 @@#include <asm/mp.h> extern void srio_init (void ); -void setup_bats (void );DECLARE_GLOBAL_DATA_PTR ;
@@ -91,33 +90,6 @@ int cpu_init_r(void)return 0 ; } -/* Set up BAT registers */ -void setup_bats (void ) -{ -#if defined(CONFIG_SYS_DBAT0U ) && defined(CONFIG_SYS_DBAT0L ) -write_bat (DBAT0 ,CONFIG_SYS_DBAT0U ,CONFIG_SYS_DBAT0L ); -#endif -#if defined(CONFIG_SYS_IBAT0U ) && defined(CONFIG_SYS_IBAT0L ) -write_bat (IBAT0 ,CONFIG_SYS_IBAT0U ,CONFIG_SYS_IBAT0L ); -#endif -write_bat (DBAT1 ,CONFIG_SYS_DBAT1U ,CONFIG_SYS_DBAT1L ); -write_bat (IBAT1 ,CONFIG_SYS_IBAT1U ,CONFIG_SYS_IBAT1L ); -write_bat (DBAT2 ,CONFIG_SYS_DBAT2U ,CONFIG_SYS_DBAT2L ); -write_bat (IBAT2 ,CONFIG_SYS_IBAT2U ,CONFIG_SYS_IBAT2L ); -write_bat (DBAT3 ,CONFIG_SYS_DBAT3U ,CONFIG_SYS_DBAT3L ); -write_bat (IBAT3 ,CONFIG_SYS_IBAT3U ,CONFIG_SYS_IBAT3L ); -write_bat (DBAT4 ,CONFIG_SYS_DBAT4U ,CONFIG_SYS_DBAT4L ); -write_bat (IBAT4 ,CONFIG_SYS_IBAT4U ,CONFIG_SYS_IBAT4L ); -write_bat (DBAT5 ,CONFIG_SYS_DBAT5U ,CONFIG_SYS_DBAT5L ); -write_bat (IBAT5 ,CONFIG_SYS_IBAT5U ,CONFIG_SYS_IBAT5L ); -write_bat (DBAT6 ,CONFIG_SYS_DBAT6U ,CONFIG_SYS_DBAT6L ); -write_bat (IBAT6 ,CONFIG_SYS_IBAT6U ,CONFIG_SYS_IBAT6L ); -write_bat (DBAT7 ,CONFIG_SYS_DBAT7U ,CONFIG_SYS_DBAT7L ); -write_bat (IBAT7 ,CONFIG_SYS_IBAT7U ,CONFIG_SYS_IBAT7L ); - -return ; -} -#ifdef CONFIG_ADDR_MAP /* Initialize address mapping array */ void init_addr_map (void )
arch/powerpc/cpu/mpc86xx/start.S +68 -1
79 lines not on this page · raw message
include/configs/MPC8641HPCN.h +73 -50
251 lines not on this page · raw message
include/mpc86xx.h +1 -0
@@ -84,6 +84,7 @@ static __inline__ unsigned long get_l2cr (void) }void setup_ddr_bat (phys_addr_t dram_size); +extern void setup_bats (void );#endif /* _ASMLANGUAGE */ #endif /* __MPC86xx_H__ */
Signature · 1 line
1.5.6.5
Kumar Gala
AppliedPATCH 2/2 powerpc/mpc86xx: Disable translation for BAT setup
Quoted 11 lines · Becky Bruce
We really shouldn't be overwriting bat registers with translation enabled, especially when we're executing code using one of them for translating the current instruction stream. Instead, disable address translation while doing the final BAT setup.
In order to do this,
setup_batshas to move back to asm code, because we require translation to be enabled to have a stack for C code. The yucky thing about that is that the assembler doesn't like ULL so we have to switch to using HIGH/LOW pairs for physical addresses that are > 32 bits in length.
Quoted 8 lines
Signed-off-by Becky Bruce <[email protected]>Acked-by York Sun <[email protected]>---
arch/powerpc/cpu/mpc86xx/cpu_init.c | 28 -------- arch/powerpc/cpu/mpc86xx/start.S | 69 +++++++++++++++++++- include/configs/MPC8641HPCN.h | 123 +++++++++++++++++++++-------------- include/mpc86xx.h | 1 + 4 files changed, 142 insertions(+), 79 deletions(-)
applied to 85xx
- k
Kumar Gala
AppliedPATCH 1/2 powerpc/mpc8641hpcn: fix SRIO BAT config
In reply to Becky BruceQuoted 7 lines · Becky Bruce
There were duplicate (and conflicting) defines for the BATs used to cover SRIO. Drop the bogus set.
Signed-off-by Becky Bruce <[email protected]>---
include/configs/MPC8641HPCN.h| 5 -----1 files changed, 0 insertions(+), 5 deletions(-)
applied to 85xx
- k