86xx: Cleanup MP support
PATCH v4 1/3 86xx: Cleanup MP support
* Use CONFIG_MP instead of CONFIG_NUM_CPUS to match 85xx
* Introduce determine_mp_bootpg() helper. We'll need this to address a bug introduced in v2009.03 with 86xx MP booting. We have to make sure to reserve the region of memory used for the MP bootpg() so other u-boot code doesn't use it.
* Added dummy versions of cpu_reset(), cpu_status() & cpu_release() to allow cmd_mp.c to build and work. In the future we should look at implementing all these functions. This could be common w/85xx if we use spin tables on 86xx.
---
* Forgot to add include/asm-ppc/mp.h
board/freescale/mpc8641hpcn/mpc8641hpcn.c | 2 +- board/sbc8641d/sbc8641d.c | 2 +- cpu/mpc86xx/Makefile | 25 ++++++-------- cpu/mpc86xx/cpu_init.c | 2 +- cpu/mpc86xx/fdt.c | 14 ++------ cpu/mpc86xx/mp.c | 51 ++++++++++++++++++---------- cpu/mpc86xx/mp.h | 7 ---- cpu/mpc86xx/release.S | 2 - include/asm-ppc/mp.h | 31 +++++++++++++++++ include/configs/MPC8641HPCN.h | 1 + include/configs/sbc8641d.h | 1 + 11 files changed, 84 insertions(+), 54 deletions(-) delete mode 100644 cpu/mpc86xx/mp.h create mode 100644 include/asm-ppc/mp.h
board/freescale/mpc8641hpcn/mpc8641hpcn.c +1 -1
@@ -375,7 +375,7 @@ void board_reset(void) ; } -#if (CONFIG_NUM_CPUS >1 ) +#ifdef CONFIG_MP extern void cpu_mp_lmb_reserve (struct lmb *lmb);void board_lmb_reserve (struct lmb *lmb)
board/sbc8641d/sbc8641d.c +1 -1
@@ -414,7 +414,7 @@ void board_reset(void)#endif } -#if (CONFIG_NUM_CPUS >1 ) +#ifdef CONFIG_MP extern void cpu_mp_lmb_reserve (struct lmb *lmb);void board_lmb_reserve (struct lmb *lmb)
cpu/mpc86xx/Makefile +11 -14
@@ -29,26 +29,23 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(CPU).a START = start.o -SOBJS = cache.o -ifneq ($(CONFIG_NUM_CPUS),1) -COBJS-y += mp.o -SOBJS += release.o -endif -COBJS-y += traps.o +SOBJS-y += cache.o +SOBJS-$(CONFIG_MP) += release.o + COBJS-y += cpu.o COBJS-y += cpu_init.o -COBJS-y += speed.o -COBJS-y += interrupts.o - -COBJS-$(CONFIG_OF_LIBFDT) += fdt.o - -COBJS-$(CONFIG_MPC8641) += ddr-8641.o # 8610 & 8641 are identical w/regards to DDR COBJS-$(CONFIG_MPC8610) += ddr-8641.o +COBJS-$(CONFIG_MPC8641) += ddr-8641.o +COBJS-$(CONFIG_OF_LIBFDT) += fdt.o +COBJS-y += interrupts.o +COBJS-$(CONFIG_MP) += mp.o +COBJS-y += speed.o +COBJS-y += traps.o -SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS-y:.o=.c) -OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y)) +SRCS := $(START:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) +OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y)) START := $(addprefix $(obj),$(START)) all: $(obj).depend $(START) $(LIB)
cpu/mpc86xx/cpu_init.c +1 -1
@@ -31,7 +31,7 @@#include <mpc86xx.h> #include <asm/mmu.h> #include <asm/fsl_law.h> -#include "mp.h" +#include <asm/mp.h> void setup_bats (void );
cpu/mpc86xx/fdt.c +4 -10
@@ -9,15 +9,15 @@#include <common.h> #include <libfdt.h> #include <fdt_support.h> -#include "mp.h" +#include <asm/mp.h> DECLARE_GLOBAL_DATA_PTR ;void ft_cpu_setup (void *blob,bd_t *bd) { -#if (CONFIG_NUM_CPUS >1 ) +#ifdef CONFIG_MP int off; -u32 bootpg; +u32 bootpg =determine_mp_bootpg ();#endif do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
@@ -48,13 +48,7 @@ void ft_cpu_setup(void *blob, bd_t *bd) "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);#endif -#if (CONFIG_NUM_CPUS >1 ) -/* if we have 4G or more of memory, put the boot page at 4Gb-1M */ -if (gd->ram_size >0xfffff000 ) - bootpg =0xfff00000 ; -else - bootpg = gd->ram_size - (1024 *1024 ); - +#ifdef CONFIG_MP /* Reserve the boot page so OSes dont use it */ off =fdt_add_mem_rsv (blob, bootpg, (u64 )4096 );if (off <0 )
cpu/mpc86xx/mp.c +33 -18
75 lines not on this page · raw message
cpu/mpc86xx/mp.h deleted +0 -7
@@ -1,7 +0,0 @@ -#ifndef __MPC86XX_MP_H_ -#define __MPC86XX_MP_H_ - -void setup_mp (void ); -void cpu_mp_lmb_reserve (struct lmb *lmb); - -#endif
cpu/mpc86xx/release.S +0 -2
@@ -41,7 +41,6 @@ * Core 0 must copy this to a 1M aligned region and set BPTR * to point to it. */ -#if (CONFIG_NUM_CPUS > 1) .align 12 .globl __secondary_start_page __secondary_start_page:
@@ -166,4 +165,3 @@ invl2: blr /* Never Returns, Running in Linux Now */ -#endif
include/asm-ppc/mp.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright 2009 Freescale Semiconductor, Inc. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +*/ + +#ifndef _ASM_MP_H_ +#define _ASM_MP_H_ + +#include <lmb.h> + +void setup_mp (void ); +void cpu_mp_lmb_reserve (struct lmb *lmb); +u32 determine_mp_bootpg (void ); + +#endif +
include/configs/MPC8641HPCN.h +1 -0
@@ -36,6 +36,7 @@#define CONFIG_MPC86xx 1/* MPC86xx */ #define CONFIG_MPC8641 1/* MPC8641 specific */ #define CONFIG_MPC8641HPCN 1/* MPC8641HPCN board specific */ +#define CONFIG_MP 1/* support multiple processors */ #define CONFIG_NUM_CPUS 2/* Number of CPUs in the system */ #define CONFIG_LINUX_RESET_VEC 0x100/* Reset vector used by Linux */ /*#define CONFIG_PHYS_64BIT 1*/ /* Place devices in 36-bit space */
include/configs/sbc8641d.h +1 -0
@@ -40,6 +40,7 @@#define CONFIG_MPC86xx 1/* MPC86xx */ #define CONFIG_MPC8641 1/* MPC8641 specific */ #define CONFIG_SBC8641D 1/* SBC8641D board specific */ +#define CONFIG_MP 1/* support multiple processors */ #define CONFIG_NUM_CPUS 2/* Number of CPUs in the system */ #define CONFIG_LINUX_RESET_VEC 0x100/* Reset vector used by Linux */
Signature · 1 line
1.5.6.6
PATCH v4 2/3 85xx: Introduce determine_mp_bootpg() helper.
Match determine_mp_bootpg() that was added for 86xx. We need this to address a bug introduced in v2009.03 with 86xx MP booting. We have to make sure to reserve the region of memory used for the MP bootpg() so other u-boot code doesn't use it.
Also added a comment about how cpu_reset() is dealing w/an errata on early 85xx MP HW.
---
* identical to v3
cpu/mpc85xx/fdt.c | 9 ++------- cpu/mpc85xx/mp.c | 26 ++++++++++++-------------- cpu/mpc85xx/mp.h | 4 ++-- 3 files changed, 16 insertions(+), 23 deletions(-)
cpu/mpc85xx/fdt.c +2 -7
@@ -39,13 +39,8 @@ void ft_fixup_cpu(void *blob, u64 memory_limit) {int off;ulong spin_tbl_addr =get_spin_addr (); -u32 bootpg, id =get_my_id (); - -/* if we have 4G or more of memory, put the boot page at 4Gb-4k */ -if ((u64 )gd->ram_size >0xfffff000 ) - bootpg =0xfffff000 ; -else - bootpg = gd->ram_size -4096 ; +u32 bootpg =determine_mp_bootpg (); +u32 id =get_my_id (); off =fdt_node_offset_by_prop_value (blob,-1 ,"device_type" ,"cpu" ,4 );while (off != -FDT_ERR_NOTFOUND ) {
cpu/mpc85xx/mp.c +12 -14
@@ -38,6 +38,7 @@ int cpu_reset(int nr) {volatile ccsr_pic_t *pic = (void *)(CONFIG_SYS_MPC85xx_PIC_ADDR);out_be32 (&pic->pir,1 << nr); +/* the dummy read works around an errata on early 85xx MP PICs */ (void )in_be32 (&pic->pir);out_be32 (&pic->pir,0x0 );
@@ -112,6 +113,15 @@ int cpu_release(int nr, int argc, char *argv[])return 0 ; } +u32 determine_mp_bootpg (void ) +{ +/* if we have 4G or more of memory, put the boot page at 4Gb-4k */ +if ((u64 )gd->ram_size >0xfffff000 ) +return (0xfffff000 ); + +return (gd->ram_size -4096 ); +} +ulong get_spin_addr (void ) {extern ulong __secondary_start_page;
@@ -188,13 +198,7 @@ static void pq3_mp_up(unsigned long bootpg)void cpu_mp_lmb_reserve (struct lmb *lmb) { -u32 bootpg; - -/* if we have 4G or more of memory, put the boot page at 4Gb-4k */ -if ((u64 )gd->ram_size >0xfffff000 ) - bootpg =0xfffff000 ; -else - bootpg = gd->ram_size -4096 ; +u32 bootpg =determine_mp_bootpg ();lmb_reserve (lmb, bootpg,4096 ); }
@@ -203,13 +207,7 @@ void setup_mp(void) {extern ulong __secondary_start_page;ulong fixup = (ulong)&__secondary_start_page; -u32 bootpg; - -/* if we have 4G or more of memory, put the boot page at 4Gb-4k */ -if ((u64 )gd->ram_size >0xfffff000 ) - bootpg =0xfffff000 ; -else - bootpg = gd->ram_size -4096 ; +u32 bootpg =determine_mp_bootpg ();memcpy ((void *)bootpg, (void *)fixup,4096 );flush_cache (bootpg,4096 );
cpu/mpc85xx/mp.h +2 -2
@@ -1,10 +1,10 @@#ifndef __MPC85XX_MP_H_#define __MPC85XX_MP_H_ +#include <asm/mp.h> +ulong get_spin_addr (void ); -void setup_mp (void );u32 get_my_id (void ); -void cpu_mp_lmb_reserve (struct lmb *lmb);#define BOOT_ENTRY_ADDR_UPPER 0#define BOOT_ENTRY_ADDR_LOWER 1
Signature · 1 line
1.5.6.6
PATCH v4 3/3 85xx/86xx: Ensure MP boot page is not used
We had a bug on 86xx in which the boot page used to bring up secondary cores was being overwritten and used for the malloc region in u-boot.
We need to reserve the region of memory that the boot page is going to be put at so nothing uses it.
---
* identical to v3
lib_ppc/board.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)
lib_ppc/board.c +15 -0
@@ -79,6 +79,10 @@#include <asm/mmu.h> #endif +#ifdef CONFIG_MP +#include <asm/mp.h> +#endif +#ifdef CONFIG_SYS_UPDATE_FLASH_SIZE extern int update_flash_size (int flash_size);#endif
@@ -444,6 +448,17 @@ void board_init_f (ulong bootflag) addr =CONFIG_SYS_SDRAM_BASE +get_effective_memsize (); +#if defined(CONFIG_MP ) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500 )) +/* +* We need to make sure the location we intend to put secondary core +* boot code is reserved and not used by any part of u-boot +*/ +if (addr >determine_mp_bootpg ()) { + addr =determine_mp_bootpg (); +debug ("Reserving MP boot page to %08lx\n" , addr); + } +#endif +#ifdef CONFIG_LOGBUFFER #ifndef CONFIG_ALT_LB_ADDR /* reserve kernel log buffer */
Signature · 1 line
1.5.6.6