Skip to contentSkip to conversation

86xx: Cleanup MP support

PATCH New Kumar Gala 2 participants 10 messages Apr 1, 2009

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/1 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.

---
 board/freescale/mpc8641hpcn/mpc8641hpcn.c |    2 +-
 board/sbc8641d/sbc8641d.c                 |    2 +-
 cpu/mpc85xx/mp.h                          |    1 +
 cpu/mpc86xx/Makefile                      |    7 ++--
 cpu/mpc86xx/fdt.c                         |   12 ++-----
 cpu/mpc86xx/mp.c                          |   47 ++++++++++++++++++----------
 cpu/mpc86xx/mp.h                          |    1 +
 cpu/mpc86xx/release.S                     |    2 -
 include/configs/MPC8641HPCN.h             |    1 +
 include/configs/sbc8641d.h                |    1 +
 10 files changed, 42 insertions(+), 34 deletions(-)
board/freescale/mpc8641hpcn/mpc8641hpcn.c +1 -1
index 1e35dfa..ef0095a 100644
@@ -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
index fc1f07d..9f69638 100644
@@ -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/mpc85xx/mp.h +1 -0
index 4329286..b06707f 100644
@@ -5,6 +5,7 @@ ulong get_spin_addr(void);
 void setup_mp(void);
 u32 get_my_id(void);
 void cpu_mp_lmb_reserve(struct lmb *lmb);
+u32 determine_bootpg(void);
 
 #define BOOT_ENTRY_ADDR_UPPER	0
 #define BOOT_ENTRY_ADDR_LOWER	1
cpu/mpc86xx/Makefile +3 -4
index 34a9755..f1af64e 100644
@@ -31,10 +31,9 @@ LIB	= $(obj)lib$(CPU).a
 START	= start.o
 SOBJS	= cache.o
 
-ifneq ($(CONFIG_NUM_CPUS),1)
-COBJS-y += mp.o
-SOBJS += release.o
-endif
+SOBJS-$(CONFIG_MP) += release.o
+SOBJS	+= $(SOBJS-y)
+COBJS-$(CONFIG_MP) += mp.o
 COBJS-y	+= traps.o
 COBJS-y	+= cpu.o
 COBJS-y	+= cpu_init.o
cpu/mpc86xx/fdt.c +3 -9
index 383b06b..ee2eb0b 100644
@@ -15,9 +15,9 @@ 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 +30 -17

68 lines not on this page · raw message

cpu/mpc86xx/mp.h +1 -0
index 886e0c8..5471ef7 100644
@@ -3,5 +3,6 @@
 
 void setup_mp(void);
 void cpu_mp_lmb_reserve(struct lmb *lmb);
+u32 determine_mp_bootpg(void);
 
 #endif
cpu/mpc86xx/release.S +0 -2
index 95efbb4..67a6f2b 100644
@@ -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/configs/MPC8641HPCN.h +1 -0
index 9d66101..d8042fb 100644
@@ -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
index 1008812..ef0f627 100644
@@ -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
author
#1 lore raw

PATCH 1/1 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.

---
 cpu/mpc85xx/fdt.c |    9 ++-------
 cpu/mpc85xx/mp.c  |   25 +++++++++++--------------
 cpu/mpc85xx/mp.h  |    2 +-
 3 files changed, 14 insertions(+), 22 deletions(-)
cpu/mpc85xx/fdt.c +2 -7
index 2d36c24..26a8f48 100644
@@ -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 +11 -14
index 3338c1a..8ddd81d 100644
@@ -112,6 +112,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 +197,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 +206,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 +1 -1
index b06707f..71423ef 100644
@@ -5,7 +5,7 @@ ulong get_spin_addr(void);
 void setup_mp(void);
 u32 get_my_id(void);
 void cpu_mp_lmb_reserve(struct lmb *lmb);
-u32 determine_bootpg(void);
+u32 determine_mp_bootpg(void);
 
 #define BOOT_ENTRY_ADDR_UPPER	0
 #define BOOT_ENTRY_ADDR_LOWER	1
Signature · 1 line
1.5.6.6
author
#2 lore raw

PATCH 1/1 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.

---
 lib_ppc/board.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
lib_ppc/board.c +13 -0
index 3b93e4e..6eeca02 100644
@@ -79,6 +79,10 @@
 #include <asm/mmu.h>
 #endif
 
+#ifdef CONFIG_MP
+extern u32 determine_mp_bootpg(void);
+#endif
+
 #ifdef CONFIG_SYS_UPDATE_FLASH_SIZE
 extern int update_flash_size (int flash_size);
 #endif
@@ -444,6 +448,15 @@ 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
author
#3 lore raw

PATCH 1/1 85xx/86xx: Ensure MP boot page is not used

Quoted 10 lines · Kumar Gala

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.

---
lib_ppc/board.c | 13 +++++++++++++

1 files changed, 13 insertions(+), 0 deletions(-)

Wolfgang,

This patch depends on the other two. If you ack this one I can send all three via the 85xx git tree.

- k

#4 lore raw

PATCH 1/1 85xx/86xx: Ensure MP boot page is not used

In reply to Kumar Gala
Quoted 7 lines · Kumar Gala

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.

Quoted 44 lines

---
lib_ppc/board.c | 13 +++++++++++++

1 files changed, 13 insertions(+), 0 deletions(-)
lib_ppc/board.c +13 -0
index 3b93e4e..6eeca02 100644
@@ -79,6 +79,10 @@
 #include <asm/mmu.h>
 #endif
 
+#ifdef CONFIG_MP
+extern u32 determine_mp_bootpg(void);
+#endif
+
 #ifdef CONFIG_SYS_UPDATE_FLASH_SIZE
 extern int update_flash_size (int flash_size);
 #endif
@@ -444,6 +448,15 @@ 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 · 6 lines
1.5.6.6

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
#5 lore raw

PATCH 1/1 85xx: Introduce determine_mp_bootpg() helper.

In reply to Kumar Gala
Quoted 72 lines · Kumar Gala

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.

---

cpu/mpc85xx/fdt.c |    9 ++-------
cpu/mpc85xx/mp.c  |   25 +++++++++++--------------
cpu/mpc85xx/mp.h  |    2 +-
3 files changed, 14 insertions(+), 22 deletions(-)
cpu/mpc85xx/fdt.c +2 -7
index 2d36c24..26a8f48 100644
@@ -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 +10 -7
index 3338c1a..8ddd81d 100644
@@ -112,6 +112,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 +197,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 +206,7 @@ void setup_mp(void)
 {
 	extern ulong __secondary_start_page;
 	ulong fixup = (ulong)&__secondary_start_page;

cpu/mpc85xx/mp.c void setup_mp(void) · line 211

Quoted 10 lines
cpu/mpc85xx/mp.c +1 -7
-	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);

Same somments apply about defining BOOTPG_ALIGN as in the other patch. And is there a PAGE_SIZE or something somewhere? We're using 4096 which is a bit stupid. I know, you didn't introduce that code, but it seems easy to clean it up now. If you don't want to bother, let me know and I'll post a follow-on.

cpu/mpc85xx/mp.h ulong get_spin_addr(void); · line 8

Quoted 12 lines
cpu/mpc85xx/mp.c +0 -0
 	flush_cache(bootpg, 4096);
cpu/mpc85xx/mp.h +1 -1
index b06707f..71423ef 100644
@@ -5,7 +5,7 @@ ulong get_spin_addr(void);
 void setup_mp(void);
 u32 get_my_id(void);
 void cpu_mp_lmb_reserve(struct lmb *lmb);
-u32 determine_bootpg(void);
+u32 determine_mp_bootpg(void);

This hunk is bogus - the previous change should never have been there.

Otherwise, looks good.

-B

author
#6 lore raw

PATCH 1/1 85xx: Introduce determine_mp_bootpg() helper.

Quoted 13 lines · Becky Bruce
Quoted 13 lines
cpu/mpc85xx/mp.c +1 -7
@@ -203,13 +206,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();
 
Quoted 7 lines

cpu/mpc85xx/mp.c void setup_mp(void) · line 211

Quoted 1 line
cpu/mpc85xx/mp.c +0 -0
 	memcpy((void *)bootpg, (void *)fixup, 4096);

Same somments apply about defining BOOTPG_ALIGN as in the other patch. And is there a PAGE_SIZE or something somewhere? We're using 4096 which is a bit stupid. I know, you didn't introduce that code, but it seems easy to clean it up now. If you don't want to bother, let me know and I'll post a follow-on.

As I said on the 86xx patch, when someone re-factors the code an adds spin table support for 86xx than we should deal with this.

Quoted 5 lines
Quoted 5 lines
cpu/mpc85xx/mp.c +0 -0
 	flush_cache(bootpg, 4096);
cpu/mpc85xx/mp.h +0 -0
index b06707f..71423ef 100644
Quoted 8 lines

cpu/mpc85xx/mp.h ulong get_spin_addr(void); · line 8

Quoted 6 lines
cpu/mpc85xx/mp.h +1 -1
@@ -5,7 +5,7 @@ ulong get_spin_addr(void);
 void setup_mp(void);
 u32 get_my_id(void);
 void cpu_mp_lmb_reserve(struct lmb *lmb);
-u32 determine_bootpg(void);
+u32 determine_mp_bootpg(void);

This hunk is bogus - the previous change should never have been there.

fixed.

- k

#7 lore raw

PATCH 1/1 86xx: Cleanup MP support

In reply to Kumar Gala
Quoted 7 lines · Kumar Gala

* 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.

Excellent - thanks for doing this!

Quoted 49 lines

---

board/freescale/mpc8641hpcn/mpc8641hpcn.c |    2 +-
board/sbc8641d/sbc8641d.c                 |    2 +-
cpu/mpc85xx/mp.h                          |    1 +
cpu/mpc86xx/Makefile                      |    7 ++--
cpu/mpc86xx/fdt.c                         |   12 ++-----
cpu/mpc86xx/mp.c                          |   47 +++++++++++++++++ 
+----------
cpu/mpc86xx/mp.h                          |    1 +
cpu/mpc86xx/release.S                     |    2 -
include/configs/MPC8641HPCN.h             |    1 +
include/configs/sbc8641d.h                |    1 +
10 files changed, 42 insertions(+), 34 deletions(-)
board/ renamed from board/freescale/mpc8641hpcn/mpc8641hpcn.c +0 -0

freescale/mpc8641hpcn/mpc8641hpcn.c
index 1e35dfa..ef0095a 100644

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
index fc1f07d..9f69638 100644
@@ -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/mpc85xx/mp.h +0 -0
index 4329286..b06707f 100644

cpu/mpc85xx/mp.h ulong get_spin_addr(void); · line 8

Quoted 4 lines
cpu/mpc85xx/mp.h +1 -0
@@ -5,6 +5,7 @@ ulong get_spin_addr(void);
 void setup_mp(void);
 u32 get_my_id(void);
 void cpu_mp_lmb_reserve(struct lmb *lmb);
+u32 determine_bootpg(void);

This hunk is bogus - it's wrong, and doesn't belong in this patch, anyway.

Quoted 74 lines
cpu/mpc85xx/mp.h +0 -0
 #define BOOT_ENTRY_ADDR_UPPER	0
 #define BOOT_ENTRY_ADDR_LOWER	1
cpu/mpc86xx/Makefile +0 -0
index 34a9755..f1af64e 100644
@@ -31,10 +31,9 @@ LIB	= $(obj)lib$(CPU).a

START = start.o
SOBJS = cache.o

cpu/mpc86xx/Makefile +3 -4
-ifneq ($(CONFIG_NUM_CPUS),1)
-COBJS-y += mp.o
-SOBJS += release.o
-endif
+SOBJS-$(CONFIG_MP) += release.o
+SOBJS	+= $(SOBJS-y)
+COBJS-$(CONFIG_MP) += mp.o

COBJS-y += traps.o
COBJS-y += cpu.o
COBJS-y += cpu_init.o

cpu/mpc86xx/fdt.c +3 -9
index 383b06b..ee2eb0b 100644
@@ -15,9 +15,9 @@ 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 +11 -2
index 5014401..b4c6b79 100644
@@ -8,16 +8,39 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if (CONFIG_NUM_CPUS > 1)
-void cpu_mp_lmb_reserve(struct lmb *lmb)
+int cpu_reset(int nr)
+{
+	volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
+	volatile ccsr_pic_t *pic = &immr->im_pic;
+	out_be32(&pic->pir, 1 << nr);
+	(void)in_be32(&pic->pir);
+	out_be32(&pic->pir, 0x0);
+
+	return 0;
+}
+

cpu/mpc86xx/mp.c line 30

Quoted 10 lines
cpu/mpc86xx/mp.c +8 -1
+int cpu_status(int nr)
+{
+	return 1;
+}
+
+int cpu_release(int nr, int argc, char *argv[])
 {
-	u32 bootpg;
+	return 1;
+}

Should probably add comments as to why these do nothing right now....

cpu/mpc86xx/mp.c line 38

Quoted 12 lines
cpu/mpc86xx/mp.c +5 -3
+u32 determine_mp_bootpg(void)
+{
 	/* if we have 4G or more of memory, put the boot page at 4Gb-1M */
 	if ((u64)gd->ram_size > 0xfffff000)
-		bootpg = 0xfff00000;
-	else
-		bootpg = gd->ram_size - (1024 * 1024);
+		return (0xfff00000);
+
+	return (gd->ram_size - (1024 * 1024));

Seems like we might want to define a BOOTPG_ALIGN somewhere, even if it's just at the top of this file for the moment. At some point(later is fine) we need to talk about creating a common spot for code like this, because once there's BOOTPG_ALIGN defined, this code could be common between 85xx/86xx. (There's other code in this file that could likely be made common between platforms.... so I consider that a future item, not something that should affect the acceptance of this patch).

<snip>

Cheers,
B

author
#8 lore raw

PATCH 1/1 86xx: Cleanup MP support

Quoted 4 lines
Quoted 4 lines
cpu/mpc85xx/mp.h +0 -0
index 4329286..b06707f 100644
Quoted 8 lines

cpu/mpc85xx/mp.h ulong get_spin_addr(void); · line 8

Quoted 5 lines
cpu/mpc85xx/mp.h +1 -0
@@ -5,6 +5,7 @@ ulong get_spin_addr(void);
 void setup_mp(void);
 u32 get_my_id(void);
 void cpu_mp_lmb_reserve(struct lmb *lmb);
+u32 determine_bootpg(void);

This hunk is bogus - it's wrong, and doesn't belong in this patch, anyway.

oops, thought I had caught that.

Quoted 30 lines
Quoted 30 lines
cpu/mpc85xx/mp.h +0 -0
 #define BOOT_ENTRY_ADDR_UPPER	0
 #define BOOT_ENTRY_ADDR_LOWER	1
 
cpu/mpc86xx/mp.c +15 -2
index 5014401..b4c6b79 100644
@@ -8,16 +8,39 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if (CONFIG_NUM_CPUS > 1)
-void cpu_mp_lmb_reserve(struct lmb *lmb)
+int cpu_reset(int nr)
+{
+	volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
+	volatile ccsr_pic_t *pic = &immr->im_pic;
+	out_be32(&pic->pir, 1 << nr);
+	(void)in_be32(&pic->pir);
+	out_be32(&pic->pir, 0x0);
+
+	return 0;
+}
+
+int cpu_status(int nr)
+{
+	return 1;
+}
Quoted 8 lines

cpu/mpc86xx/mp.c line 30

Quoted 6 lines
cpu/mpc86xx/mp.c +4 -1
+
+int cpu_release(int nr, int argc, char *argv[])
 {
-	u32 bootpg;
+	return 1;
+}

Should probably add comments as to why these do nothing right now....

will do.

Quoted 11 lines

cpu/mpc86xx/mp.c line 38

Quoted 10 lines
cpu/mpc86xx/mp.c +5 -3
+u32 determine_mp_bootpg(void)
+{
 	/* if we have 4G or more of memory, put the boot page at 4Gb-1M */
 	if ((u64)gd->ram_size > 0xfffff000)
-		bootpg = 0xfff00000;
-	else
-		bootpg = gd->ram_size - (1024 * 1024);
+		return (0xfff00000);
+
+	return (gd->ram_size - (1024 * 1024));
Quoted 8 lines

Seems like we might want to define a BOOTPG_ALIGN somewhere, even if it's just at the top of this file for the moment. At some point(later is fine) we need to talk about creating a common spot for code like this, because once there's BOOTPG_ALIGN defined, this code could be common between 85xx/86xx. (There's other code in this file that could likely be made common between platforms.... so I consider that a future item, not something that should affect the acceptance of this patch).

I don't plan on adding BOOTPG_ALIGN at this point. I agree that some of this code is common and get be refactored into cpu/mpc8xxx/ but I leave that for a future patch and will let that patch deal w/ BOOTPG_ALIGN.

- k

#9 lore raw

PATCH 1/1 86xx: Cleanup MP support

Quoted 76 lines · Kumar Gala
Quoted 4 lines
Quoted 4 lines
cpu/mpc85xx/mp.h +0 -0
index 4329286..b06707f 100644
Quoted 8 lines

cpu/mpc85xx/mp.h ulong get_spin_addr(void); · line 8

Quoted 5 lines
cpu/mpc85xx/mp.h +1 -0
@@ -5,6 +5,7 @@ ulong get_spin_addr(void);
 void setup_mp(void);
 u32 get_my_id(void);
 void cpu_mp_lmb_reserve(struct lmb *lmb);
+u32 determine_bootpg(void);

This hunk is bogus - it's wrong, and doesn't belong in this patch, anyway.

oops, thought I had caught that.

Quoted 30 lines
Quoted 30 lines
cpu/mpc85xx/mp.h +0 -0
 #define BOOT_ENTRY_ADDR_UPPER	0
 #define BOOT_ENTRY_ADDR_LOWER	1
 
cpu/mpc86xx/mp.c +15 -2
index 5014401..b4c6b79 100644
@@ -8,16 +8,39 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if (CONFIG_NUM_CPUS > 1)
-void cpu_mp_lmb_reserve(struct lmb *lmb)
+int cpu_reset(int nr)
+{
+	volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
+	volatile ccsr_pic_t *pic = &immr->im_pic;
+	out_be32(&pic->pir, 1 << nr);
+	(void)in_be32(&pic->pir);
+	out_be32(&pic->pir, 0x0);
+
+	return 0;
+}
+
+int cpu_status(int nr)
+{
+	return 1;
+}
Quoted 8 lines

cpu/mpc86xx/mp.c line 30

Quoted 6 lines
cpu/mpc86xx/mp.c +4 -1
+
+int cpu_release(int nr, int argc, char *argv[])
 {
-	u32 bootpg;
+	return 1;
+}

Should probably add comments as to why these do nothing right now....

will do.

Quoted 11 lines

cpu/mpc86xx/mp.c line 38

Quoted 10 lines
cpu/mpc86xx/mp.c +5 -3
+u32 determine_mp_bootpg(void)
+{
 	/* if we have 4G or more of memory, put the boot page at 4Gb-1M */
 	if ((u64)gd->ram_size > 0xfffff000)
-		bootpg = 0xfff00000;
-	else
-		bootpg = gd->ram_size - (1024 * 1024);
+		return (0xfff00000);
+
+	return (gd->ram_size - (1024 * 1024));
Quoted 8 lines

Seems like we might want to define a BOOTPG_ALIGN somewhere, even if it's just at the top of this file for the moment. At some point(later is fine) we need to talk about creating a common spot for code like this, because once there's BOOTPG_ALIGN defined, this code could be common between 85xx/86xx. (There's other code in this file that could likely be made common between platforms.... so I consider that a future item, not something that should affect the acceptance of this patch).

Quoted 4 lines

I don't plan on adding BOOTPG_ALIGN at this point. I agree that some of this code is common and get be refactored into cpu/mpc8xxx/ but I leave that for a future patch and will let that patch deal w/ BOOTPG_ALIGN.

That's fine with me - I have that on my todo list :) If you get to it first, woohoo :)

-B

Quoted 3 lines

- k