Skip to contentSkip to conversation

MIPS: BCM63XX: add SMP support

PATCH In review Jonas Gorski 3 participants 7 messages Jun 18, 2013 – Jun 27, 2013 MIPS

lore
Share & tools
lore
#0 lore raw

v2 cover MIPS: BCM63XX: add SMP support

Most newer BCM63XX SoCs after BCM6358 use a BMIPS4350 CPU with SMP support. This patchset allows BCM6368 and BCM6362 to boot a SMP kernel (both tested, as well as (not yet upstreamed) BCM63268).

BCM6328 has its second core only in a few variants enabled, but this can be probed at runtime.

BCM6358 is intentionally skipped because it shares a single TLB for both cores/threads, which requires implementing locking for TLB accesses, and ain't nobody got time for that.

The internal interrupt controller supports routing IRQs to both CPUs, and support will be added in a later patchset. For now all hardware interrupts will go to CPU0.

Totally unscientific OpenSSL benchmarking shows a nice ~90% speed increase when enabling the second core.

No idea about the FIXME in 1/2, never had a problem with it so I left it in place as to have it documented.

Changes V1 -> V2:
* removed already applied patches
* added a check for SMP availability on BCM6328
* changed #ifdef FOO to if (IS_ENABLED(FOO))

Jonas Gorski (1):
MIPS: BCM63XX: Enable second core SMP on BCM6328 if available

Kevin Cernekee (1):
MIPS: BCM63XX: Add SMP support to prom.c

 arch/mips/bcm63xx/prom.c                          |   45 +++++++++++++++++++++
 arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h  |    2 +
 arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h |    7 ++++
 3 files changed, 54 insertions(+)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/2 MIPS: BCM63XX: Add SMP support to prom.c

From: Kevin Cernekee <[email protected]>

This involves two changes to the BSP code:

1) register_smp_ops() for BMIPS SMP

2) The CPU1 boot vector on some of the BCM63xx platforms conflicts with the special interrupt vector (IV). Move it to 0x8000_0380 at boot time, to resolve the conflict.

[[email protected]: moved SMP ops registration into ifdef guard,
changed ifdef guards to if (IS_ENABLED())]

---
V1 -> V2:
* changed ifdef guards to if (IS_ENABLED())

 arch/mips/bcm63xx/prom.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
arch/mips/bcm63xx/prom.c +41 -0
index fd69808..33ddc78 100644
@@ -8,7 +8,11 @@
 
 #include <linux/init.h>
 #include <linux/bootmem.h>
+#include <linux/smp.h>
 #include <asm/bootinfo.h>
+#include <asm/bmips.h>
+#include <asm/smp-ops.h>
+#include <asm/mipsregs.h>
 #include <bcm63xx_board.h>
 #include <bcm63xx_cpu.h>
 #include <bcm63xx_io.h>
@@ -52,6 +56,43 @@ void __init prom_init(void)
 
 	/* do low level board init */
 	board_prom_init();
+
+	if (IS_ENABLED(CONFIG_CPU_BMIPS4350) && IS_ENABLED(CONFIG_SMP)) {
+		/* set up SMP */
+		register_smp_ops(&bmips_smp_ops);
+
+		/*
+		 * BCM6328 might not have its second CPU enabled, while BCM6358
+		 * needs special handling for its shared TLB, so disable SMP
+		 * for now.
+		 */
+		if (BCMCPU_IS_6328()) {
+			bmips_smp_enabled = 0;
+		} else if (BCMCPU_IS_6358()) {
+			bmips_smp_enabled = 0;
+		}
+
+		if (!bmips_smp_enabled)
+			return;
+
+		/*
+		 * The bootloader has set up the CPU1 reset vector at
+		 * 0xa000_0200.
+		 * This conflicts with the special interrupt vector (IV).
+		 * The bootloader has also set up CPU1 to respond to the wrong
+		 * IPI interrupt.
+		 * Here we will start up CPU1 in the background and ask it to
+		 * reconfigure itself then go back to sleep.
+		 */
+		memcpy((void *)0xa0000200, &bmips_smp_movevec, 0x20);
+		__sync();
+		set_c0_cause(C_SW0);
+		cpumask_set_cpu(1, &bmips_booted_mask);
+
+		/*
+		 * FIXME: we really should have some sort of hazard barrier here
+		 */
+	}
 }
 
 void __init prom_free_prom_memory(void)
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [PATCH V2 1/2] MIPS: BCM63XX: Add SMP support to prom.c

Hello.

Quoted 25 lines · Jonas Gorski

From: Kevin Cernekee <[email protected]>

This involves two changes to the BSP code:

1) register_smp_ops() for BMIPS SMP

2) The CPU1 boot vector on some of the BCM63xx platforms conflicts with the special interrupt vector (IV). Move it to 0x8000_0380 at boot time, to resolve the conflict.

[[email protected]: moved SMP ops registration into ifdef guard,
changed ifdef guards to if (IS_ENABLED())]

---
V1 -> V2:
* changed ifdef guards to if (IS_ENABLED())

  arch/mips/bcm63xx/prom.c |   41 +++++++++++++++++++++++++++++++++++++++++
  1 file changed, 41 insertions(+)
arch/mips/bcm63xx/prom.c +0 -0
index fd69808..33ddc78 100644

[...]

Quoted 9 lines
arch/mips/bcm63xx/prom.c +5 -0
@@ -52,6 +56,43 @@ void __init prom_init(void)
 
  	/* do low level board init */
  	board_prom_init();
+
+	if (IS_ENABLED(CONFIG_CPU_BMIPS4350) && IS_ENABLED(CONFIG_SMP)) {
+		/* set up SMP */
+		register_smp_ops(&bmips_smp_ops);
+

arch/mips/bcm63xx/prom.c void __init prom_init(void) · line 73

Quoted 10 lines
arch/mips/bcm63xx/prom.c +10 -0
+		/*
+		 * BCM6328 might not have its second CPU enabled, while BCM6358
+		 * needs special handling for its shared TLB, so disable SMP
+		 * for now.
+		 */
+		if (BCMCPU_IS_6328()) {
+			bmips_smp_enabled = 0;
+		} else if (BCMCPU_IS_6358()) {
+			bmips_smp_enabled = 0;
+		}
    Doesn't scripts/checkpatch.pl complain here? You should not use {} 

on the single statement branches.

WBR, Sergei

#3 lore raw

Re: [PATCH V2 1/2] MIPS: BCM63XX: Add SMP support to prom.c

Hi Sergei,

Quoted 57 lines · Sergei Shtylyov

Hello.

Quoted 32 lines · Jonas Gorski

From: Kevin Cernekee <[email protected]>

This involves two changes to the BSP code:

1) register_smp_ops() for BMIPS SMP

2) The CPU1 boot vector on some of the BCM63xx platforms conflicts with the special interrupt vector (IV). Move it to 0x8000_0380 at boot time, to resolve the conflict.

[[email protected]: moved SMP ops registration into ifdef guard,
changed ifdef guards to if (IS_ENABLED())]

---
V1 -> V2:
* changed ifdef guards to if (IS_ENABLED())

  arch/mips/bcm63xx/prom.c |   41
+++++++++++++++++++++++++++++++++++++++++
  1 file changed, 41 insertions(+)
arch/mips/bcm63xx/prom.c +0 -0
index fd69808..33ddc78 100644

[...]

Quoted 17 lines
arch/mips/bcm63xx/prom.c +7 -0
@@ -52,6 +56,43 @@ void __init prom_init(void)
 
        /* do low level board init */
        board_prom_init();
+
+       if (IS_ENABLED(CONFIG_CPU_BMIPS4350) && IS_ENABLED(CONFIG_SMP)) {
+               /* set up SMP */
+               register_smp_ops(&bmips_smp_ops);
+
+               /*
+                * BCM6328 might not have its second CPU enabled, while

BCM6358
+ * needs special handling for its shared TLB, so disable
SMP

arch/mips/bcm63xx/prom.c +3 -0
+                * for now.
+                */
+               if (BCMCPU_IS_6328()) {
Quoted 8 lines

arch/mips/bcm63xx/prom.c void __init prom_init(void) · line 73

Quoted 4 lines
arch/mips/bcm63xx/prom.c +4 -0
+                       bmips_smp_enabled = 0;
+               } else if (BCMCPU_IS_6358()) {
+                       bmips_smp_enabled = 0;
+               }

Doesn't scripts/checkpatch.pl complain here? You should not use {} on
the single statement branches.

I left the braces intentionally there because Patch 2 adds code to the first branch, so I would have to add them in the next patch anyway. This way the changes of Patch 2 stays smaller and easier to review (and are limited to actual code changes).

Jonas

#4 lore raw

PATCH v2 2/2 MIPS: BCM63XX: Enable second core SMP on BCM6328 if available

In reply to Jonas Gorski

BCM6328 has a OTP which tells us if the second core is available.

---
 arch/mips/bcm63xx/prom.c                          |    6 +++++-
 arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h  |    2 ++
 arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h |    7 +++++++
 3 files changed, 14 insertions(+), 1 deletion(-)
arch/mips/bcm63xx/prom.c +5 -1
index 33ddc78..f9ef7f7 100644
@@ -67,7 +67,11 @@ void __init prom_init(void)
 		 * for now.
 		 */
 		if (BCMCPU_IS_6328()) {
-			bmips_smp_enabled = 0;
+			reg = bcm_readl(BCM_6328_OTP_BASE +
+					OTP_USER_BITS_6328_REG(3));
+
+			if (reg & OTP_6328_REG3_TP1_DISABLED)
+				bmips_smp_enabled = 0;
 		} else if (BCMCPU_IS_6358()) {
 			bmips_smp_enabled = 0;
 		}
arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h +2 -0
index 3362289..6a3020d 100644
@@ -235,6 +235,8 @@ enum bcm63xx_regs_set {
 #define BCM_6328_PCMDMAS_BASE		(0xdeadbeef)
 #define BCM_6328_RNG_BASE		(0xdeadbeef)
 #define BCM_6328_MISC_BASE		(0xb0001800)
+#define BCM_6328_OTP_BASE		(0xb0000600)
+
 /*
  * 6338 register sets base address
  */
arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h +7 -0
index 3203fe4..ec97aa8 100644
@@ -1434,4 +1434,11 @@
 
 #define PCIE_DEVICE_OFFSET		0x8000
 
+/*************************************************************************
+ * _REG relative to RSET_OTP
+ *************************************************************************/
+
+#define OTP_USER_BITS_6328_REG(i)	(0x20 + (i) * 4)
+#define   OTP_6328_REG3_TP1_DISABLED	BIT(9)
+
 #endif /* BCM63XX_REGS_H_ */
Signature · 1 line
1.7.10.4
#5 lore raw

Re: [PATCH V2 2/2] MIPS: BCM63XX: Enable second core SMP on BCM6328 if available

Quoted 1 line · Jonas Gorski

BCM6328 has a OTP which tells us if the second core is available.

Patch doesn't apply on top of my latest tree (more exactly, commit 426fe4812d09283a53b8294ae38c5a239eeee8ef) any more. Can you respin?

Thanks,

Ralf

#6 lore raw

Re: [PATCH V2 2/2] MIPS: BCM63XX: Enable second core SMP on BCM6328 if available

Quoted 4 lines · Ralf Baechle
Quoted 1 line

BCM6328 has a OTP which tells us if the second core is available.

Patch doesn't apply on top of my latest tree (more exactly, commit 426fe4812d09283a53b8294ae38c5a239eeee8ef) any more. Can you respin?

Seems that was a patch ordering problem. I can apply both patches of this series if I drop https://patchwork.linux-mips.org/patch/5356/.

Ralf