* [PATCH 0/2] ARM: bcm: support more than two CPUs on BCMBCA
@ 2026-11-23 14:28 Ho Jie Feng
2026-11-23 14:22 ` [PATCH 2/2] " Ho Jie Feng
2026-11-23 14:34 ` [PATCH 1/2] dt-bindings: arm: cpus: Require cpu-release-addr on bca-smp secondaries Ho Jie Feng
0 siblings, 2 replies; 14+ messages in thread
From: Ho Jie Feng @ 2026-11-23 14:28 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Florian Fainelli,
Ray Jui, Scott Branden, Broadcom internal kernel review list,
Russell King, William Zhang, Anand Gore, Kursad Oney,
Rafał Miłecki, Lorenzo Pieralisi, devicetree,
linux-kernel, linux-arm-kernel
This series extends BCMBCA SMP bring-up to SoCs with more than two
cores, such as:
- triple-core BCM63178/BCM6855
- quad-core BCM47622/BCM6755
Tested on BCM6755, a quad-core Cortex-A7 BCMBCA SoC.
Ho Jie Feng (2):
dt-bindings: arm: cpus: Require cpu-release-addr on bca-smp
secondaries
ARM: bcm: support more than two CPUs on BCMBCA
.../devicetree/bindings/arm/cpus.yaml | 6 +--
arch/arm/mach-bcm/Makefile | 1 +
arch/arm/mach-bcm/bcmbca_headsmp.S | 26 +++++++++++
arch/arm/mach-bcm/bcmbca_smp.h | 9 ++++
arch/arm/mach-bcm/board_bcmbca.c | 46 +++++++++++++++----
5 files changed, 76 insertions(+), 12 deletions(-)
create mode 100644 arch/arm/mach-bcm/bcmbca_headsmp.S
create mode 100644 arch/arm/mach-bcm/bcmbca_smp.h
base-commit: 21f8531821461fa0c05e4605c01d8d56d28b514e
--
2.53.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-11-23 14:28 [PATCH 0/2] ARM: bcm: support more than two CPUs on BCMBCA Ho Jie Feng @ 2026-11-23 14:22 ` Ho Jie Feng 2026-11-25 18:47 ` William Zhang 2026-11-25 21:00 ` Linus Walleij 2026-11-23 14:34 ` [PATCH 1/2] dt-bindings: arm: cpus: Require cpu-release-addr on bca-smp secondaries Ho Jie Feng 1 sibling, 2 replies; 14+ messages in thread From: Ho Jie Feng @ 2026-11-23 14:22 UTC (permalink / raw) To: Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, William Zhang, Anand Gore, Kursad Oney, Rafał Miłecki Cc: Linus Walleij, Ho Jie Feng, linux-arm-kernel, linux-kernel BCMBCA Cortex-A7 SoCs can have more than two cores, such as the quad-core BCM6755. Extend the CFE SMP support to all secondary CPUs. CFE parks every secondary CPU on the same mailbox, and the wakeup SGI wakes all offline CPUs at once. Hold them in a pen and release them one at a time. Signed-off-by: Ho Jie Feng <hjf3108@gmail.com> --- arch/arm/mach-bcm/Makefile | 1 + arch/arm/mach-bcm/bcmbca_headsmp.S | 26 +++++++++++++++++ arch/arm/mach-bcm/bcmbca_smp.h | 9 ++++++ arch/arm/mach-bcm/board_bcmbca.c | 46 ++++++++++++++++++++++++------ 4 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 arch/arm/mach-bcm/bcmbca_headsmp.S create mode 100644 arch/arm/mach-bcm/bcmbca_smp.h diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile index fcc4e0174a..c3cd2959bc 100644 --- a/arch/arm/mach-bcm/Makefile +++ b/arch/arm/mach-bcm/Makefile @@ -60,4 +60,5 @@ endif ifeq ($(CONFIG_ARCH_BCMBCA),y) obj-y += board_bcmbca.o obj-$(CONFIG_SMP) += bcm63xx_smp.o bcm63xx_pmb.o +obj-$(CONFIG_SMP) += bcmbca_headsmp.o endif diff --git a/arch/arm/mach-bcm/bcmbca_headsmp.S b/arch/arm/mach-bcm/bcmbca_headsmp.S new file mode 100644 index 0000000000..3d0d0d97be --- /dev/null +++ b/arch/arm/mach-bcm/bcmbca_headsmp.S @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * All CPUs will wake up on an SGI. Wait in the holding pen until + * bcmbca_cpu_release matches the MPIDR. + * + * Based on arch/arm/mach-versatile/headsmp.S + */ +#include <linux/linkage.h> +#include <asm/assembler.h> + + .arm +ENTRY(bcmbca_secondary_startup) + ARM_BE8(setend be) + THUMB( badr r9, 1f ) + THUMB( bx r9 ) + THUMB( .thumb ) + THUMB(1: ) + mrc p15, 0, r0, c0, c0, 5 + bic r0, #0xff000000 + adr_l r6, bcmbca_cpu_release +pen: ldr r7, [r6] + cmp r7, r0 + bne pen + + b secondary_startup +ENDPROC(bcmbca_secondary_startup) diff --git a/arch/arm/mach-bcm/bcmbca_smp.h b/arch/arm/mach-bcm/bcmbca_smp.h new file mode 100644 index 0000000000..30055cf766 --- /dev/null +++ b/arch/arm/mach-bcm/bcmbca_smp.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __BCMBCA_SMP_H +#define __BCMBCA_SMP_H + +extern int bcmbca_cpu_release; + +void bcmbca_secondary_startup(void); + +#endif /* __BCMBCA_SMP_H */ diff --git a/arch/arm/mach-bcm/board_bcmbca.c b/arch/arm/mach-bcm/board_bcmbca.c index 248b8bd776..1afba1d680 100644 --- a/arch/arm/mach-bcm/board_bcmbca.c +++ b/arch/arm/mach-bcm/board_bcmbca.c @@ -1,14 +1,20 @@ // SPDX-License-Identifier: GPL-2.0-only // Copyright (C) 2024 Linus Walleij <linus.walleij@linaro.org> +#include <linux/cache.h> +#include <linux/cacheflush.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/of.h> #include <linux/smp.h> +#include <linux/units.h> #include <asm/mach/arch.h> #include <asm/mach/map.h> #include <asm/smp_plat.h> +#include "bcmbca_smp.h" + #ifdef CONFIG_DEBUG_BCMBCA /* This is needed for LL-debug/earlyprintk/debug-macro.S */ static struct map_desc bcmbca_io_desc[] __initdata = { @@ -29,16 +35,28 @@ static void __init bcmbca_map_io(void) } #ifdef CONFIG_SMP +int bcmbca_cpu_release __cacheline_aligned = -1; + +static void bcmbca_write_cpu_release(int val) +{ + WRITE_ONCE(bcmbca_cpu_release, val); + /* Order release write before cache clean and wakeup IPI */ + smp_wmb(); + sync_cache_w(&bcmbca_cpu_release); +} + +static void bcmbca_secondary_init(unsigned int cpu) +{ + /* Let the primary processor know we're out of the pen */ + bcmbca_write_cpu_release(-1); +} + static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle) { struct device_node *np; void __iomem *mailbox; u32 release_addr; - int ret; - - /* CFE has already powered up CPU1 and left it waiting in WFI. */ - if (cpu_logical_map(cpu) != 1) - return -EINVAL; + int release, ret; np = of_get_cpu_node(cpu, NULL); if (!np) @@ -58,17 +76,27 @@ static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle) /* * The CFE stub reads GPIO GeneralPurpose after an interrupt and * branches to it in ARM state. Clear any Thumb function pointer - * tag and complete the MMIO write before sending the wakeup IPI. + * tag and complete the MMIO write before opening the pen and + * sending the wakeup IPI. */ - writel(__pa_symbol(secondary_startup_arm) & ~1, mailbox); + writel(__pa_symbol(bcmbca_secondary_startup) & ~1, mailbox); dsb(sy); - arch_send_wakeup_ipi_mask(cpumask_of(cpu)); iounmap(mailbox); - return 0; + bcmbca_write_cpu_release(cpu_logical_map(cpu)); + arch_send_wakeup_ipi_mask(cpumask_of(cpu)); + + ret = read_poll_timeout_atomic(smp_load_acquire, release, + release == -1, 10, USEC_PER_SEC, false, + &bcmbca_cpu_release); + if (ret) + bcmbca_write_cpu_release(-1); + + return ret; } static const struct smp_operations bcmbca_smp_ops __initconst = { + .smp_secondary_init = bcmbca_secondary_init, .smp_boot_secondary = bcmbca_boot_secondary, }; -- 2.53.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-11-23 14:22 ` [PATCH 2/2] " Ho Jie Feng @ 2026-11-25 18:47 ` William Zhang 2026-11-26 3:13 ` Jie Feng 2026-11-25 21:00 ` Linus Walleij 1 sibling, 1 reply; 14+ messages in thread From: William Zhang @ 2026-11-25 18:47 UTC (permalink / raw) To: Ho Jie Feng Cc: Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, Anand Gore, Kursad Oney, Rafał Miłecki, Linus Walleij, linux-arm-kernel, linux-kernel [-- Attachment #1: Type: text/plain, Size: 6157 bytes --] Hi Ho Jie, On Mon, Nov 23, 2026 at 6:22 AM Ho Jie Feng <hjf3108@gmail.com> wrote: > > BCMBCA Cortex-A7 SoCs can have more than two cores, such as the > quad-core BCM6755. Extend the CFE SMP support to all secondary CPUs. > > CFE parks every secondary CPU on the same mailbox, and the wakeup SGI > wakes all offline CPUs at once. Hold them in a pen and release them one > at a time. > > Signed-off-by: Ho Jie Feng <hjf3108@gmail.com> > --- > arch/arm/mach-bcm/Makefile | 1 + > arch/arm/mach-bcm/bcmbca_headsmp.S | 26 +++++++++++++++++ > arch/arm/mach-bcm/bcmbca_smp.h | 9 ++++++ > arch/arm/mach-bcm/board_bcmbca.c | 46 ++++++++++++++++++++++++------ > 4 files changed, 73 insertions(+), 9 deletions(-) > create mode 100644 arch/arm/mach-bcm/bcmbca_headsmp.S > create mode 100644 arch/arm/mach-bcm/bcmbca_smp.h > > diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile > index fcc4e0174a..c3cd2959bc 100644 > --- a/arch/arm/mach-bcm/Makefile > +++ b/arch/arm/mach-bcm/Makefile > @@ -60,4 +60,5 @@ endif > ifeq ($(CONFIG_ARCH_BCMBCA),y) > obj-y += board_bcmbca.o > obj-$(CONFIG_SMP) += bcm63xx_smp.o bcm63xx_pmb.o > +obj-$(CONFIG_SMP) += bcmbca_headsmp.o > endif > diff --git a/arch/arm/mach-bcm/bcmbca_headsmp.S b/arch/arm/mach-bcm/bcmbca_headsmp.S > new file mode 100644 > index 0000000000..3d0d0d97be > --- /dev/null > +++ b/arch/arm/mach-bcm/bcmbca_headsmp.S > @@ -0,0 +1,26 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * All CPUs will wake up on an SGI. Wait in the holding pen until > + * bcmbca_cpu_release matches the MPIDR. > + * > + * Based on arch/arm/mach-versatile/headsmp.S > + */ > +#include <linux/linkage.h> > +#include <asm/assembler.h> > + > + .arm > +ENTRY(bcmbca_secondary_startup) > + ARM_BE8(setend be) > + THUMB( badr r9, 1f ) > + THUMB( bx r9 ) > + THUMB( .thumb ) > + THUMB(1: ) > + mrc p15, 0, r0, c0, c0, 5 > + bic r0, #0xff000000 > + adr_l r6, bcmbca_cpu_release > +pen: ldr r7, [r6] > + cmp r7, r0 > + bne pen > + It is better to invalidate the L1 cache for the secondary cpus regardless of whether the bl does that or not. > + b secondary_startup > +ENDPROC(bcmbca_secondary_startup) > diff --git a/arch/arm/mach-bcm/bcmbca_smp.h b/arch/arm/mach-bcm/bcmbca_smp.h > new file mode 100644 > index 0000000000..30055cf766 > --- /dev/null > +++ b/arch/arm/mach-bcm/bcmbca_smp.h > @@ -0,0 +1,9 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +#ifndef __BCMBCA_SMP_H > +#define __BCMBCA_SMP_H > + > +extern int bcmbca_cpu_release; > + > +void bcmbca_secondary_startup(void); > + > +#endif /* __BCMBCA_SMP_H */ > diff --git a/arch/arm/mach-bcm/board_bcmbca.c b/arch/arm/mach-bcm/board_bcmbca.c > index 248b8bd776..1afba1d680 100644 > --- a/arch/arm/mach-bcm/board_bcmbca.c > +++ b/arch/arm/mach-bcm/board_bcmbca.c > @@ -1,14 +1,20 @@ > // SPDX-License-Identifier: GPL-2.0-only > // Copyright (C) 2024 Linus Walleij <linus.walleij@linaro.org> > > +#include <linux/cache.h> > +#include <linux/cacheflush.h> > #include <linux/io.h> > +#include <linux/iopoll.h> > #include <linux/of.h> > #include <linux/smp.h> > +#include <linux/units.h> > > #include <asm/mach/arch.h> > #include <asm/mach/map.h> > #include <asm/smp_plat.h> > > +#include "bcmbca_smp.h" > + > #ifdef CONFIG_DEBUG_BCMBCA > /* This is needed for LL-debug/earlyprintk/debug-macro.S */ > static struct map_desc bcmbca_io_desc[] __initdata = { > @@ -29,16 +35,28 @@ static void __init bcmbca_map_io(void) > } > > #ifdef CONFIG_SMP > +int bcmbca_cpu_release __cacheline_aligned = -1; > + > +static void bcmbca_write_cpu_release(int val) > +{ > + WRITE_ONCE(bcmbca_cpu_release, val); > + /* Order release write before cache clean and wakeup IPI */ > + smp_wmb(); > + sync_cache_w(&bcmbca_cpu_release); > +} > + > +static void bcmbca_secondary_init(unsigned int cpu) > +{ > + /* Let the primary processor know we're out of the pen */ > + bcmbca_write_cpu_release(-1); > +} > + > static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle) > { > struct device_node *np; > void __iomem *mailbox; > u32 release_addr; > - int ret; > - > - /* CFE has already powered up CPU1 and left it waiting in WFI. */ > - if (cpu_logical_map(cpu) != 1) > - return -EINVAL; > + int release, ret; > > np = of_get_cpu_node(cpu, NULL); > if (!np) > @@ -58,17 +76,27 @@ static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle) > /* > * The CFE stub reads GPIO GeneralPurpose after an interrupt and > * branches to it in ARM state. Clear any Thumb function pointer > - * tag and complete the MMIO write before sending the wakeup IPI. > + * tag and complete the MMIO write before opening the pen and > + * sending the wakeup IPI. > */ > - writel(__pa_symbol(secondary_startup_arm) & ~1, mailbox); > + writel(__pa_symbol(bcmbca_secondary_startup) & ~1, mailbox); > dsb(sy); > - arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > iounmap(mailbox); > > - return 0; > + bcmbca_write_cpu_release(cpu_logical_map(cpu)); > + arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > + > + ret = read_poll_timeout_atomic(smp_load_acquire, release, > + release == -1, 10, USEC_PER_SEC, false, > + &bcmbca_cpu_release); > + if (ret) > + bcmbca_write_cpu_release(-1); > + > + return ret; > } > > static const struct smp_operations bcmbca_smp_ops __initconst = { > + .smp_secondary_init = bcmbca_secondary_init, > .smp_boot_secondary = bcmbca_boot_secondary, > }; > > -- > 2.53.0 > [-- Attachment #2: S/MIME Cryptographic Signature --] [-- Type: application/pkcs7-signature, Size: 5473 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-11-25 18:47 ` William Zhang @ 2026-11-26 3:13 ` Jie Feng 0 siblings, 0 replies; 14+ messages in thread From: Jie Feng @ 2026-11-26 3:13 UTC (permalink / raw) To: William Zhang Cc: Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, Anand Gore, Kursad Oney, Rafał Miłecki, Linus Walleij, linux-arm-kernel, linux-kernel Hi William, On Thu, 26 Nov 2026 at 02:48, William Zhang <william.zhang@broadcom.com> wrote: > > Hi Ho Jie, > On Mon, Nov 23, 2026 at 6:22 AM Ho Jie Feng <hjf3108@gmail.com> wrote: > > > > BCMBCA Cortex-A7 SoCs can have more than two cores, such as the > > quad-core BCM6755. Extend the CFE SMP support to all secondary CPUs. > > > > CFE parks every secondary CPU on the same mailbox, and the wakeup SGI > > wakes all offline CPUs at once. Hold them in a pen and release them one > > at a time. > > > > Signed-off-by: Ho Jie Feng <hjf3108@gmail.com> > > --- > > arch/arm/mach-bcm/Makefile | 1 + > > arch/arm/mach-bcm/bcmbca_headsmp.S | 26 +++++++++++++++++ > > arch/arm/mach-bcm/bcmbca_smp.h | 9 ++++++ > > arch/arm/mach-bcm/board_bcmbca.c | 46 ++++++++++++++++++++++++------ > > 4 files changed, 73 insertions(+), 9 deletions(-) > > create mode 100644 arch/arm/mach-bcm/bcmbca_headsmp.S > > create mode 100644 arch/arm/mach-bcm/bcmbca_smp.h > > > > diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile > > index fcc4e0174a..c3cd2959bc 100644 > > --- a/arch/arm/mach-bcm/Makefile > > +++ b/arch/arm/mach-bcm/Makefile > > @@ -60,4 +60,5 @@ endif > > ifeq ($(CONFIG_ARCH_BCMBCA),y) > > obj-y += board_bcmbca.o > > obj-$(CONFIG_SMP) += bcm63xx_smp.o bcm63xx_pmb.o > > +obj-$(CONFIG_SMP) += bcmbca_headsmp.o > > endif > > diff --git a/arch/arm/mach-bcm/bcmbca_headsmp.S b/arch/arm/mach-bcm/bcmbca_headsmp.S > > new file mode 100644 > > index 0000000000..3d0d0d97be > > --- /dev/null > > +++ b/arch/arm/mach-bcm/bcmbca_headsmp.S > > @@ -0,0 +1,26 @@ > > +/* SPDX-License-Identifier: GPL-2.0-only */ > > +/* > > + * All CPUs will wake up on an SGI. Wait in the holding pen until > > + * bcmbca_cpu_release matches the MPIDR. > > + * > > + * Based on arch/arm/mach-versatile/headsmp.S > > + */ > > +#include <linux/linkage.h> > > +#include <asm/assembler.h> > > + > > + .arm > > +ENTRY(bcmbca_secondary_startup) > > + ARM_BE8(setend be) > > + THUMB( badr r9, 1f ) > > + THUMB( bx r9 ) > > + THUMB( .thumb ) > > + THUMB(1: ) > > + mrc p15, 0, r0, c0, c0, 5 > > + bic r0, #0xff000000 > > + adr_l r6, bcmbca_cpu_release > > +pen: ldr r7, [r6] > > + cmp r7, r0 > > + bne pen > > + > It is better to invalidate the L1 cache for the secondary cpus > regardless of whether the bl does that or not. If I'm not wrong, this will eventually end up in __v7_ca7mp_setup which calls do_invalidate_l1? https://elixir.bootlin.com/linux/v7.4-rc1/source/arch/arm/mm/proc-v7.S#L301 Best regards, Jie Feng ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-11-23 14:22 ` [PATCH 2/2] " Ho Jie Feng 2026-11-25 18:47 ` William Zhang @ 2026-11-25 21:00 ` Linus Walleij 2026-11-26 3:05 ` Jie Feng 1 sibling, 1 reply; 14+ messages in thread From: Linus Walleij @ 2026-11-25 21:00 UTC (permalink / raw) To: Ho Jie Feng Cc: Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, William Zhang, Anand Gore, Kursad Oney, Rafał Miłecki, linux-arm-kernel, linux-kernel Hi Ho Jie, thanks for your patch! It's nice to see others building on this idea, for a while I thought I was the only person in the world who care about BCMBCA upstream. On Mon, Nov 23, 2026 at 3:22 PM Ho Jie Feng <hjf3108@gmail.com> wrote: > +++ b/arch/arm/mach-bcm/bcmbca_headsmp.S > +#include <linux/linkage.h> > +#include <asm/assembler.h> > + > + .arm > +ENTRY(bcmbca_secondary_startup) > + ARM_BE8(setend be) Are you aware about any people booting these platforms in big endian? I don't think that works, just skip this. > + THUMB( badr r9, 1f ) > + THUMB( bx r9 ) > + THUMB( .thumb ) > + THUMB(1: ) This code is for the CPU to switch from thumb mode to ARM mode if it was booting in thumb mode. Does this actually happen in practice? Else you can skip this too. It just looks overly cautious. Also the ordinary secondary_startup_arm does the same things already! > + mrc p15, 0, r0, c0, c0, 5 > + bic r0, #0xff000000 > + adr_l r6, bcmbca_cpu_release > +pen: ldr r7, [r6] > + cmp r7, r0 > + bne pen > + > + b secondary_startup And why are you first spinning on the GPIO address and then spinning again in this "pen" (as a place for livestock, such as CPUs ;) it was added to mach-versatile to work around a CPU bug in early silicon. As Russell King writes in 2018: https://lore.kernel.org/linux-arm-kernel/20181213175952.GC26090@n2100.armlinux.org.uk/ > The "pen_release" thing was created for ARM Ltd development platforms > where there was no way to individually control secondary CPUs leaving > the boot loader - they all jumped to whatever physical code address > was supplied at the same time. This made it necessary for _these_ > platforms to have a "holding pen" for the CPUs while the kernel > initialised. The "pen" is only needed if all CPUs jump to that address at the same time. I don't think the BCMBCA platforms do that because you send one IPI to each CPU? So I would skip this assembly completely... I don't understand why you're doing this other than copy/paste? > @@ -58,17 +76,27 @@ static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle) > /* > * The CFE stub reads GPIO GeneralPurpose after an interrupt and > * branches to it in ARM state. Clear any Thumb function pointer > - * tag and complete the MMIO write before sending the wakeup IPI. > + * tag and complete the MMIO write before opening the pen and > + * sending the wakeup IPI. > */ > - writel(__pa_symbol(secondary_startup_arm) & ~1, mailbox); > + writel(__pa_symbol(bcmbca_secondary_startup) & ~1, mailbox); > dsb(sy); > - arch_send_wakeup_ipi_mask(cpumask_of(cpu)); Have you actually tested *not* changing this code and see if all CPUs just come up? It should just send each CPU in order to secondary_startup_arm like we want? Yours, Linus Walleij ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-11-25 21:00 ` Linus Walleij @ 2026-11-26 3:05 ` Jie Feng 2026-11-27 2:49 ` William Zhang 2026-12-01 13:48 ` Linus Walleij 0 siblings, 2 replies; 14+ messages in thread From: Jie Feng @ 2026-11-26 3:05 UTC (permalink / raw) To: Linus Walleij Cc: Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, William Zhang, Anand Gore, Kursad Oney, Rafał Miłecki, linux-arm-kernel, linux-kernel Hi Linus, On Thu, 26 Nov 2026 at 05:01, Linus Walleij <linusw@kernel.org> wrote: > > Hi Ho Jie, > > thanks for your patch! It's nice to see others building on this > idea, for a while I thought I was the only person in the world > who care about BCMBCA upstream. I'm also trying to boot OpenWrt on a BCMBCA router and already got many things working. Going to send the dts upstream soon. > On Mon, Nov 23, 2026 at 3:22 PM Ho Jie Feng <hjf3108@gmail.com> wrote: > > > +++ b/arch/arm/mach-bcm/bcmbca_headsmp.S > > > +#include <linux/linkage.h> > > +#include <asm/assembler.h> > > + > > + .arm > > +ENTRY(bcmbca_secondary_startup) > > + ARM_BE8(setend be) > > Are you aware about any people booting these platforms > in big endian? I don't think that works, just skip this. > > > + THUMB( badr r9, 1f ) > > + THUMB( bx r9 ) > > + THUMB( .thumb ) > > + THUMB(1: ) > > This code is for the CPU to switch from thumb mode to > ARM mode if it was booting in thumb mode. Does this > actually happen in practice? Else you can skip this too. > It just looks overly cautious. I am not very familiar with how bcmbca is used. Since these kernels can be booted by CFE and I do not know what kinds of CFEs or bootloaders are there, I left that in. > Also the ordinary secondary_startup_arm does the same things already! > > > + mrc p15, 0, r0, c0, c0, 5 > > + bic r0, #0xff000000 > > + adr_l r6, bcmbca_cpu_release > > +pen: ldr r7, [r6] > > + cmp r7, r0 > > + bne pen > > + > > + b secondary_startup > > And why are you first spinning on the GPIO address > and then spinning again in this "pen" (as a place for > livestock, such as CPUs ;) it was added to mach-versatile > to work around a CPU bug in early silicon. > > As Russell King writes in 2018: > https://lore.kernel.org/linux-arm-kernel/20181213175952.GC26090@n2100.armlinux.org.uk/ > > > The "pen_release" thing was created for ARM Ltd development platforms > > where there was no way to individually control secondary CPUs leaving > > the boot loader - they all jumped to whatever physical code address > > was supplied at the same time. This made it necessary for _these_ > > platforms to have a "holding pen" for the CPUs while the kernel > > initialised. > > The "pen" is only needed if all CPUs jump to that address at the same > time. I don't think the BCMBCA platforms do that because you send > one IPI to each CPU? I can experiment with that. > So I would skip this assembly completely... > I don't understand why you're doing this other > than copy/paste? > This is obtained from the vendor source code where there is also a holding pen: https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/platsmp.c https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/plat-ca9mp-headsmp.S > > @@ -58,17 +76,27 @@ static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle) > > /* > > * The CFE stub reads GPIO GeneralPurpose after an interrupt and > > * branches to it in ARM state. Clear any Thumb function pointer > > - * tag and complete the MMIO write before sending the wakeup IPI. > > + * tag and complete the MMIO write before opening the pen and > > + * sending the wakeup IPI. > > */ > > - writel(__pa_symbol(secondary_startup_arm) & ~1, mailbox); > > + writel(__pa_symbol(bcmbca_secondary_startup) & ~1, mailbox); > > dsb(sy); > > - arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > > Have you actually tested *not* changing this code and see if > all CPUs just come up? It should just send each CPU in order to > secondary_startup_arm like we want? I traced the code to drivers/irqchip/irq-gic.c, since arch_send_wakeup_ipi_mask will eventually end up there. - Line 1248-1253 every gic_cpu_map[] entry is set to 0xff https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/irqchip/irq-gic.c#L1253 - Line 836, 845 the driver ORs the map, so IPI get sent to all secondary CPUs https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/irqchip/irq-gic.c#L836 Since this platform is booted by the CFE and not using PSCI, I decided to use the vendor source code since it looks like the safest option. > Yours, > Linus Walleij Best regards, Jie Feng ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-11-26 3:05 ` Jie Feng @ 2026-11-27 2:49 ` William Zhang 2026-11-30 15:12 ` Jie Feng 2026-12-01 13:48 ` Linus Walleij 1 sibling, 1 reply; 14+ messages in thread From: William Zhang @ 2026-11-27 2:49 UTC (permalink / raw) To: Jie Feng Cc: Linus Walleij, Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, Anand Gore, Kursad Oney, Rafał Miłecki, linux-arm-kernel, linux-kernel [-- Attachment #1: Type: text/plain, Size: 5720 bytes --] Hi Jie, On Wed, Nov 25, 2026 at 7:06 PM Jie Feng <hjf3108@gmail.com> wrote: > > Hi Linus, > > On Thu, 26 Nov 2026 at 05:01, Linus Walleij <linusw@kernel.org> wrote: > > > > Hi Ho Jie, > > > > thanks for your patch! It's nice to see others building on this > > idea, for a while I thought I was the only person in the world > > who care about BCMBCA upstream. > I'm also trying to boot OpenWrt on a BCMBCA router and already got > many things working. Going to send the dts upstream soon. > > > On Mon, Nov 23, 2026 at 3:22 PM Ho Jie Feng <hjf3108@gmail.com> wrote: > > > > > +++ b/arch/arm/mach-bcm/bcmbca_headsmp.S > > > > > +#include <linux/linkage.h> > > > +#include <asm/assembler.h> > > > + > > > + .arm > > > +ENTRY(bcmbca_secondary_startup) > > > + ARM_BE8(setend be) > > > > Are you aware about any people booting these platforms > > in big endian? I don't think that works, just skip this. > > > > > + THUMB( badr r9, 1f ) > > > + THUMB( bx r9 ) > > > + THUMB( .thumb ) > > > + THUMB(1: ) > > > > This code is for the CPU to switch from thumb mode to > > ARM mode if it was booting in thumb mode. Does this > > actually happen in practice? Else you can skip this too. > > It just looks overly cautious. > I am not very familiar with how bcmbca is used. Since these kernels > can be booted by CFE and I do not know what kinds of CFEs or > bootloaders are there, I left that in. Neither CFE nor u-boot bootloader on these chips use thumb mode. > > > Also the ordinary secondary_startup_arm does the same things already! > > > > > + mrc p15, 0, r0, c0, c0, 5 > > > + bic r0, #0xff000000 > > > + adr_l r6, bcmbca_cpu_release > > > +pen: ldr r7, [r6] > > > + cmp r7, r0 > > > + bne pen > > > + > > > + b secondary_startup > > > > And why are you first spinning on the GPIO address > > and then spinning again in this "pen" (as a place for > > livestock, such as CPUs ;) it was added to mach-versatile > > to work around a CPU bug in early silicon. > > > > As Russell King writes in 2018: > > https://lore.kernel.org/linux-arm-kernel/20181213175952.GC26090@n2100.armlinux.org.uk/ > > > > > The "pen_release" thing was created for ARM Ltd development platforms > > > where there was no way to individually control secondary CPUs leaving > > > the boot loader - they all jumped to whatever physical code address > > > was supplied at the same time. This made it necessary for _these_ > > > platforms to have a "holding pen" for the CPUs while the kernel > > > initialised. > > BCMBCA SoC is not subject to this silicon bug. > > The "pen" is only needed if all CPUs jump to that address at the same > > time. I don't think the BCMBCA platforms do that because you send > > one IPI to each CPU? > I can experiment with that. > > > So I would skip this assembly completely... > > I don't understand why you're doing this other > > than copy/paste? > > > This is obtained from the vendor source code where there is also a holding pen: > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/platsmp.c > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/plat-ca9mp-headsmp.S > > > > > @@ -58,17 +76,27 @@ static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle) > > > /* > > > * The CFE stub reads GPIO GeneralPurpose after an interrupt and > > > * branches to it in ARM state. Clear any Thumb function pointer > > > - * tag and complete the MMIO write before sending the wakeup IPI. > > > + * tag and complete the MMIO write before opening the pen and > > > + * sending the wakeup IPI. > > > */ > > > - writel(__pa_symbol(secondary_startup_arm) & ~1, mailbox); > > > + writel(__pa_symbol(bcmbca_secondary_startup) & ~1, mailbox); > > > dsb(sy); > > > - arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > > > > Have you actually tested *not* changing this code and see if > > all CPUs just come up? It should just send each CPU in order to > > secondary_startup_arm like we want? > I traced the code to drivers/irqchip/irq-gic.c, since > arch_send_wakeup_ipi_mask will eventually end up there. > > - Line 1248-1253 every gic_cpu_map[] entry is set to 0xff > https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/irqchip/irq-gic.c#L1253 > - Line 836, 845 the driver ORs the map, so IPI get sent to all secondary CPUs > https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/irqchip/irq-gic.c#L836 > > Since this platform is booted by the CFE and not using PSCI, I decided > to use the vendor source code since it looks like the safest option. > The Asus-Merlin code you referenced is not too old and it supports PSCI by default with u-boot instead of CFE. See psci node in this dts: https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/dts/ip/bcm_cortexA7_quad.dtsi If Asus-Merlin still uses CFE, it is fine but the plat-ca9mp-headsmp.S code for non-PSCI CFE boot is bit out of date, although it still works. However, we don't use it in our production which uses PSCI. It should be replaced by kernel existing secondary_startup_arm function as Linus suggested and should work. And you correctly pointed out that it also covers the l1 cache invalid. > > Yours, > > Linus Walleij > > Best regards, > Jie Feng [-- Attachment #2: S/MIME Cryptographic Signature --] [-- Type: application/pkcs7-signature, Size: 5473 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-11-27 2:49 ` William Zhang @ 2026-11-30 15:12 ` Jie Feng 2026-11-30 15:22 ` Jie Feng 0 siblings, 1 reply; 14+ messages in thread From: Jie Feng @ 2026-11-30 15:12 UTC (permalink / raw) To: William Zhang Cc: Linus Walleij, Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, Anand Gore, Kursad Oney, Rafał Miłecki, linux-arm-kernel, linux-kernel Hi William, On Fri, 27 Nov 2026 at 10:49, William Zhang <william.zhang@broadcom.com> wrote: > > Hi Jie, > > On Wed, Nov 25, 2026 at 7:06 PM Jie Feng <hjf3108@gmail.com> wrote: > > > > Hi Linus, > > > > On Thu, 26 Nov 2026 at 05:01, Linus Walleij <linusw@kernel.org> wrote: > > > > > > Hi Ho Jie, > > > > > > thanks for your patch! It's nice to see others building on this > > > idea, for a while I thought I was the only person in the world > > > who care about BCMBCA upstream. > > I'm also trying to boot OpenWrt on a BCMBCA router and already got > > many things working. Going to send the dts upstream soon. > > > > > On Mon, Nov 23, 2026 at 3:22 PM Ho Jie Feng <hjf3108@gmail.com> wrote: > > > > > > > +++ b/arch/arm/mach-bcm/bcmbca_headsmp.S > > > > > > > +#include <linux/linkage.h> > > > > +#include <asm/assembler.h> > > > > + > > > > + .arm > > > > +ENTRY(bcmbca_secondary_startup) > > > > + ARM_BE8(setend be) > > > > > > Are you aware about any people booting these platforms > > > in big endian? I don't think that works, just skip this. > > > > > > > + THUMB( badr r9, 1f ) > > > > + THUMB( bx r9 ) > > > > + THUMB( .thumb ) > > > > + THUMB(1: ) > > > > > > This code is for the CPU to switch from thumb mode to > > > ARM mode if it was booting in thumb mode. Does this > > > actually happen in practice? Else you can skip this too. > > > It just looks overly cautious. > > I am not very familiar with how bcmbca is used. Since these kernels > > can be booted by CFE and I do not know what kinds of CFEs or > > bootloaders are there, I left that in. > Neither CFE nor u-boot bootloader on these chips use thumb mode. W > > > > > Also the ordinary secondary_startup_arm does the same things already! > > > > > > > + mrc p15, 0, r0, c0, c0, 5 > > > > + bic r0, #0xff000000 > > > > + adr_l r6, bcmbca_cpu_release > > > > +pen: ldr r7, [r6] > > > > + cmp r7, r0 > > > > + bne pen > > > > + > > > > + b secondary_startup > > > > > > And why are you first spinning on the GPIO address > > > and then spinning again in this "pen" (as a place for > > > livestock, such as CPUs ;) it was added to mach-versatile > > > to work around a CPU bug in early silicon. > > > > > > As Russell King writes in 2018: > > > https://lore.kernel.org/linux-arm-kernel/20181213175952.GC26090@n2100.armlinux.org.uk/ > > > > > > > The "pen_release" thing was created for ARM Ltd development platforms > > > > where there was no way to individually control secondary CPUs leaving > > > > the boot loader - they all jumped to whatever physical code address > > > > was supplied at the same time. This made it necessary for _these_ > > > > platforms to have a "holding pen" for the CPUs while the kernel > > > > initialised. > > > > BCMBCA SoC is not subject to this silicon bug. > > > > The "pen" is only needed if all CPUs jump to that address at the same > > > time. I don't think the BCMBCA platforms do that because you send > > > one IPI to each CPU? > > I can experiment with that. > > > > > So I would skip this assembly completely... > > > I don't understand why you're doing this other > > > than copy/paste? > > > > > This is obtained from the vendor source code where there is also a holding pen: > > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/platsmp.c > > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/plat-ca9mp-headsmp.S > > > > > > > > @@ -58,17 +76,27 @@ static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle) > > > > /* > > > > * The CFE stub reads GPIO GeneralPurpose after an interrupt and > > > > * branches to it in ARM state. Clear any Thumb function pointer > > > > - * tag and complete the MMIO write before sending the wakeup IPI. > > > > + * tag and complete the MMIO write before opening the pen and > > > > + * sending the wakeup IPI. > > > > */ > > > > - writel(__pa_symbol(secondary_startup_arm) & ~1, mailbox); > > > > + writel(__pa_symbol(bcmbca_secondary_startup) & ~1, mailbox); > > > > dsb(sy); > > > > - arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > > > > > > Have you actually tested *not* changing this code and see if > > > all CPUs just come up? It should just send each CPU in order to > > > secondary_startup_arm like we want? > > I traced the code to drivers/irqchip/irq-gic.c, since > > arch_send_wakeup_ipi_mask will eventually end up there. > > > > - Line 1248-1253 every gic_cpu_map[] entry is set to 0xff > > https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/irqchip/irq-gic.c#L1253 > > - Line 836, 845 the driver ORs the map, so IPI get sent to all secondary CPUs > > https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/irqchip/irq-gic.c#L836 > > > > Since this platform is booted by the CFE and not using PSCI, I decided > > to use the vendor source code since it looks like the safest option. > > > The Asus-Merlin code you referenced is not too old and it supports > PSCI by default with u-boot instead of CFE. See psci node in this dts: > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/dts/ip/bcm_cortexA7_quad.dtsi > > If Asus-Merlin still uses CFE, it is fine but the > plat-ca9mp-headsmp.S code for non-PSCI CFE boot is bit out of date, > although it still works. However, we don't use it in our production > which uses PSCI. > It should be replaced by kernel existing secondary_startup_arm > function as Linus suggested and should work. And you correctly pointed > out that it also covers the l1 cache invalid. The router I have uses CFE as the bootloader and there is no PSCI in there. The CFE wakes all of the secondary CPUs and parks them, and sending an IPI will get them out of it. Calling arch_send_wakeup_ipi_mask will wake up all the secondary CPUs, due to the cpu map being 0xff. Sending individual IPIs does work, but requires bypassing irq-gic and probing registers directly. I didn't think that would be accepted upstream. Vendor source includes source code to power up CPUs from reset in the bootloader, but those registers are not accessible, probably only available to the CFE before it drops down to the non secure level. I am not sure how to solve this without a holding pen. Best regards, Jie Feng ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-11-30 15:12 ` Jie Feng @ 2026-11-30 15:22 ` Jie Feng 0 siblings, 0 replies; 14+ messages in thread From: Jie Feng @ 2026-11-30 15:22 UTC (permalink / raw) To: William Zhang Cc: Linus Walleij, Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, Anand Gore, Kursad Oney, Rafał Miłecki, linux-arm-kernel, linux-kernel On Mon, 30 Nov 2026 at 23:12, Jie Feng <hjf3108@gmail.com> wrote: > > Hi William, > > On Fri, 27 Nov 2026 at 10:49, William Zhang <william.zhang@broadcom.com> wrote: > > > > Hi Jie, > > > > On Wed, Nov 25, 2026 at 7:06 PM Jie Feng <hjf3108@gmail.com> wrote: > > > > > > Hi Linus, > > > > > > On Thu, 26 Nov 2026 at 05:01, Linus Walleij <linusw@kernel.org> wrote: > > > > > > > > Hi Ho Jie, > > > > > > > > thanks for your patch! It's nice to see others building on this > > > > idea, for a while I thought I was the only person in the world > > > > who care about BCMBCA upstream. > > > I'm also trying to boot OpenWrt on a BCMBCA router and already got > > > many things working. Going to send the dts upstream soon. > > > > > > > On Mon, Nov 23, 2026 at 3:22 PM Ho Jie Feng <hjf3108@gmail.com> wrote: > > > > > > > > > +++ b/arch/arm/mach-bcm/bcmbca_headsmp.S > > > > > > > > > +#include <linux/linkage.h> > > > > > +#include <asm/assembler.h> > > > > > + > > > > > + .arm > > > > > +ENTRY(bcmbca_secondary_startup) > > > > > + ARM_BE8(setend be) > > > > > > > > Are you aware about any people booting these platforms > > > > in big endian? I don't think that works, just skip this. > > > > > > > > > + THUMB( badr r9, 1f ) > > > > > + THUMB( bx r9 ) > > > > > + THUMB( .thumb ) > > > > > + THUMB(1: ) > > > > > > > > This code is for the CPU to switch from thumb mode to > > > > ARM mode if it was booting in thumb mode. Does this > > > > actually happen in practice? Else you can skip this too. > > > > It just looks overly cautious. > > > I am not very familiar with how bcmbca is used. Since these kernels > > > can be booted by CFE and I do not know what kinds of CFEs or > > > bootloaders are there, I left that in. > > Neither CFE nor u-boot bootloader on these chips use thumb mode. > W Typo, I meant to type Will fix in v2 > > > > > > > Also the ordinary secondary_startup_arm does the same things already! > > > > > > > > > + mrc p15, 0, r0, c0, c0, 5 > > > > > + bic r0, #0xff000000 > > > > > + adr_l r6, bcmbca_cpu_release > > > > > +pen: ldr r7, [r6] > > > > > + cmp r7, r0 > > > > > + bne pen > > > > > + > > > > > + b secondary_startup > > > > > > > > And why are you first spinning on the GPIO address > > > > and then spinning again in this "pen" (as a place for > > > > livestock, such as CPUs ;) it was added to mach-versatile > > > > to work around a CPU bug in early silicon. > > > > > > > > As Russell King writes in 2018: > > > > https://lore.kernel.org/linux-arm-kernel/20181213175952.GC26090@n2100.armlinux.org.uk/ > > > > > > > > > The "pen_release" thing was created for ARM Ltd development platforms > > > > > where there was no way to individually control secondary CPUs leaving > > > > > the boot loader - they all jumped to whatever physical code address > > > > > was supplied at the same time. This made it necessary for _these_ > > > > > platforms to have a "holding pen" for the CPUs while the kernel > > > > > initialised. > > > > > > BCMBCA SoC is not subject to this silicon bug. > > > > > > The "pen" is only needed if all CPUs jump to that address at the same > > > > time. I don't think the BCMBCA platforms do that because you send > > > > one IPI to each CPU? > > > I can experiment with that. > > > > > > > So I would skip this assembly completely... > > > > I don't understand why you're doing this other > > > > than copy/paste? > > > > > > > This is obtained from the vendor source code where there is also a holding pen: > > > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/platsmp.c > > > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/plat-ca9mp-headsmp.S > > > > > > > > > > > @@ -58,17 +76,27 @@ static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle) > > > > > /* > > > > > * The CFE stub reads GPIO GeneralPurpose after an interrupt and > > > > > * branches to it in ARM state. Clear any Thumb function pointer > > > > > - * tag and complete the MMIO write before sending the wakeup IPI. > > > > > + * tag and complete the MMIO write before opening the pen and > > > > > + * sending the wakeup IPI. > > > > > */ > > > > > - writel(__pa_symbol(secondary_startup_arm) & ~1, mailbox); > > > > > + writel(__pa_symbol(bcmbca_secondary_startup) & ~1, mailbox); > > > > > dsb(sy); > > > > > - arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > > > > > > > > Have you actually tested *not* changing this code and see if > > > > all CPUs just come up? It should just send each CPU in order to > > > > secondary_startup_arm like we want? > > > I traced the code to drivers/irqchip/irq-gic.c, since > > > arch_send_wakeup_ipi_mask will eventually end up there. > > > > > > - Line 1248-1253 every gic_cpu_map[] entry is set to 0xff > > > https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/irqchip/irq-gic.c#L1253 > > > - Line 836, 845 the driver ORs the map, so IPI get sent to all secondary CPUs > > > https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/irqchip/irq-gic.c#L836 > > > > > > Since this platform is booted by the CFE and not using PSCI, I decided > > > to use the vendor source code since it looks like the safest option. > > > > > The Asus-Merlin code you referenced is not too old and it supports > > PSCI by default with u-boot instead of CFE. See psci node in this dts: > > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/dts/ip/bcm_cortexA7_quad.dtsi > > > > If Asus-Merlin still uses CFE, it is fine but the > > plat-ca9mp-headsmp.S code for non-PSCI CFE boot is bit out of date, > > although it still works. However, we don't use it in our production > > which uses PSCI. > > It should be replaced by kernel existing secondary_startup_arm > > function as Linus suggested and should work. And you correctly pointed > > out that it also covers the l1 cache invalid. > The router I have uses CFE as the bootloader and there is no PSCI in > there. The CFE wakes all of the secondary CPUs and parks them, and > sending an IPI will get them out of it. Calling > arch_send_wakeup_ipi_mask will wake up all the secondary CPUs, due to > the cpu map being 0xff. > Sending individual IPIs does work, but requires bypassing irq-gic and > probing registers directly. I didn't think that would be accepted > upstream. > Vendor source includes source code to power up CPUs from reset in the > bootloader, but those registers are not accessible, probably only > available to the CFE before it drops down to the non secure level. > I am not sure how to solve this without a holding pen. > > Best regards, > Jie Feng ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-11-26 3:05 ` Jie Feng 2026-11-27 2:49 ` William Zhang @ 2026-12-01 13:48 ` Linus Walleij 2026-12-01 14:48 ` Jie Feng 1 sibling, 1 reply; 14+ messages in thread From: Linus Walleij @ 2026-12-01 13:48 UTC (permalink / raw) To: Jie Feng Cc: Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, William Zhang, Anand Gore, Kursad Oney, Rafał Miłecki, linux-arm-kernel, linux-kernel Hi Jie, On Thu, Nov 26, 2026 at 4:06 AM Jie Feng <hjf3108@gmail.com> wrote: > This is obtained from the vendor source code where there is also a holding pen: > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/platsmp.c > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/plat-ca9mp-headsmp.S (...) > > > @@ -58,17 +76,27 @@ static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle) > > > /* > > > * The CFE stub reads GPIO GeneralPurpose after an interrupt and > > > * branches to it in ARM state. Clear any Thumb function pointer > > > - * tag and complete the MMIO write before sending the wakeup IPI. > > > + * tag and complete the MMIO write before opening the pen and > > > + * sending the wakeup IPI. > > > */ > > > - writel(__pa_symbol(secondary_startup_arm) & ~1, mailbox); > > > + writel(__pa_symbol(bcmbca_secondary_startup) & ~1, mailbox); > > > dsb(sy); > > > - arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > > > > Have you actually tested *not* changing this code and see if > > all CPUs just come up? It should just send each CPU in order to > > secondary_startup_arm like we want? > I traced the code to drivers/irqchip/irq-gic.c, since > arch_send_wakeup_ipi_mask will eventually end up there. Yes? And it wakes up the secondary core targeted by that IPI, right? > Since this platform is booted by the CFE and not using PSCI, I decided > to use the vendor source code since it looks like the safest option. Don't trust the vendor code. The vendor code has signs of cargo-cult programming, and you are carrying it further. https://en.wikipedia.org/wiki/Cargo_cult_programming Try my approach instead. If you don't understand what I want you to try I can send a patch for you to test. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-12-01 13:48 ` Linus Walleij @ 2026-12-01 14:48 ` Jie Feng 2026-12-01 15:26 ` Linus Walleij 0 siblings, 1 reply; 14+ messages in thread From: Jie Feng @ 2026-12-01 14:48 UTC (permalink / raw) To: Linus Walleij Cc: Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, William Zhang, Anand Gore, Kursad Oney, Rafał Miłecki, linux-arm-kernel, linux-kernel On Tue, 1 Dec 2026 at 21:49, Linus Walleij <linusw@kernel.org> wrote: > > Hi Jie, > > On Thu, Nov 26, 2026 at 4:06 AM Jie Feng <hjf3108@gmail.com> wrote: > > > This is obtained from the vendor source code where there is also a holding pen: > > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/platsmp.c > > https://github.com/Asuswrt-Merlin/asuswrt-merlin.ng/blob/main/release/src-rt-5.04axhnd.675x/kernel/linux-4.19/arch/arm/plat-bcm63xx/plat-ca9mp-headsmp.S > (...) > > > > @@ -58,17 +76,27 @@ static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle) > > > > /* > > > > * The CFE stub reads GPIO GeneralPurpose after an interrupt and > > > > * branches to it in ARM state. Clear any Thumb function pointer > > > > - * tag and complete the MMIO write before sending the wakeup IPI. > > > > + * tag and complete the MMIO write before opening the pen and > > > > + * sending the wakeup IPI. > > > > */ > > > > - writel(__pa_symbol(secondary_startup_arm) & ~1, mailbox); > > > > + writel(__pa_symbol(bcmbca_secondary_startup) & ~1, mailbox); > > > > dsb(sy); > > > > - arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > > > > > > Have you actually tested *not* changing this code and see if > > > all CPUs just come up? It should just send each CPU in order to > > > secondary_startup_arm like we want? > > I traced the code to drivers/irqchip/irq-gic.c, since > > arch_send_wakeup_ipi_mask will eventually end up there. > > Yes? And it wakes up the secondary core targeted by that IPI, > right? And all the other secondary cores too. arch_send_wakeup_ipi_mask(CPU1) wakes up CPU2 and CPU3. I tested what you had suggested, write secondary_startup_arm into the mailbox before the IPI and the router crashed on boot up. The reason is because irq-gic's gic_cpu_map is 0xff, so IPIs get sent to all CPUs. I am not sure how to solve this without a holding pen, or bypassing irq-gic directly writing to the GIC registers. > > Since this platform is booted by the CFE and not using PSCI, I decided > > to use the vendor source code since it looks like the safest option. > > Don't trust the vendor code. The vendor code has signs of cargo-cult > programming, and you are carrying it further. > https://en.wikipedia.org/wiki/Cargo_cult_programming > > Try my approach instead. Keeping writel(__pa_symbol(secondary_startup_arm) & ~1, mailbox); crashes the router immediately, because all secondary cores get out of the WFI loop and run secondary_startup_arm immediately. > If you don't understand what I want you to try I can send > a patch for you to test. Sure thing. > Yours, > Linus Walleij ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-12-01 14:48 ` Jie Feng @ 2026-12-01 15:26 ` Linus Walleij 2026-12-02 12:02 ` Marc Zyngier 0 siblings, 1 reply; 14+ messages in thread From: Linus Walleij @ 2026-12-01 15:26 UTC (permalink / raw) To: Jie Feng, Marc Zyngier Cc: Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, William Zhang, Anand Gore, Kursad Oney, Rafał Miłecki, linux-arm-kernel, linux-kernel On Tue, Dec 1, 2026 at 3:49 PM Jie Feng <hjf3108@gmail.com> wrote: > > Yes? And it wakes up the secondary core targeted by that IPI, > > right? > And all the other secondary cores too. arch_send_wakeup_ipi_mask(CPU1) > wakes up CPU2 and CPU3. Aha OK that's unfortunate :( > I tested what you had suggested, write > secondary_startup_arm into the mailbox before the IPI and the router > crashed on boot up. > The reason is because irq-gic's gic_cpu_map is 0xff, so IPIs get sent > to all CPUs. I am not sure how to solve this without a holding pen, or > bypassing irq-gic directly writing to the GIC registers. Actually I think it is 0xfe when we get here. irq-gic.c initializes each gic_cpu_map[] entry to 0xff, but CPU0 then discovers its own interface bit from the banked GICD_ITARGETSR0–7 registers and clears it from every other entry. But yes it has the same effect that IPIs from CPU0 will get broadcast to CPU1, 2, 3. The idea is for CPU1 to mask itself from the mask once it starts, and if the IPI has the effect of sending a broadcast to all three secondary CPUs this causes problems of course :/ We ask Marc Zyngier what is going on here and how to fix it. Marc is there a good way to direct IPIs to a specific CPU for secondary CPU startup in the arm,cortex-a7-gic? Or do we need to use the "pen" method of putting the three CPUs to a spin wait? Yours, Linus Walleij ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA 2026-12-01 15:26 ` Linus Walleij @ 2026-12-02 12:02 ` Marc Zyngier 0 siblings, 0 replies; 14+ messages in thread From: Marc Zyngier @ 2026-12-02 12:02 UTC (permalink / raw) To: Linus Walleij Cc: Jie Feng, Florian Fainelli, Ray Jui, Scott Branden, Broadcom internal kernel review list, Russell King, William Zhang, Anand Gore, Kursad Oney, Rafał Miłecki, linux-arm-kernel, linux-kernel On Tue, 01 Dec 2026 15:26:06 +0000, Linus Walleij <linusw@kernel.org> wrote: > > On Tue, Dec 1, 2026 at 3:49 PM Jie Feng <hjf3108@gmail.com> wrote: > > > > Yes? And it wakes up the secondary core targeted by that IPI, > > > right? > > > And all the other secondary cores too. arch_send_wakeup_ipi_mask(CPU1) > > wakes up CPU2 and CPU3. > > Aha OK that's unfortunate :( > > > I tested what you had suggested, write > > secondary_startup_arm into the mailbox before the IPI and the router > > crashed on boot up. > > The reason is because irq-gic's gic_cpu_map is 0xff, so IPIs get sent > > to all CPUs. I am not sure how to solve this without a holding pen, or > > bypassing irq-gic directly writing to the GIC registers. > > Actually I think it is 0xfe when we get here. > irq-gic.c initializes each gic_cpu_map[] entry to 0xff, but CPU0 then > discovers its own interface bit from the banked GICD_ITARGETSR0–7 > registers and clears it from every other entry. > > But yes it has the same effect that IPIs from CPU0 will get broadcast > to CPU1, 2, 3. The idea is for CPU1 to mask itself from the mask > once it starts, and if the IPI has the effect of sending a broadcast > to all three secondary CPUs this causes problems of course :/ > > We ask Marc Zyngier what is going on here and how > to fix it. > > Marc is there a good way to direct IPIs to a specific CPU for > secondary CPU startup in the arm,cortex-a7-gic? Or do we need > to use the "pen" method of putting the three CPUs to a spin wait? The main issue here is that this is using the GIC driver to talk to CPUs that the GIC driver doesn't know about yet, and this results in the wrong behaviour. Not exactly surprising. We avoided this particular pitfall on arm64 by not using interrupts at all for our "spin-table" method, and instead relying on data being written at specific addresses with a WFE/SEV pairing. I think your best bet is to generate the SGI as a raw access to the GIC, without involving the driver. This also means that this code must know about the matching of the GIC view of a CPU and the CPU you actually want to boot (the equivalent of gic_cpu_map[]). Thanks, M. -- Without deviation from the norm, progress is not possible. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/2] dt-bindings: arm: cpus: Require cpu-release-addr on bca-smp secondaries 2026-11-23 14:28 [PATCH 0/2] ARM: bcm: support more than two CPUs on BCMBCA Ho Jie Feng 2026-11-23 14:22 ` [PATCH 2/2] " Ho Jie Feng @ 2026-11-23 14:34 ` Ho Jie Feng 1 sibling, 0 replies; 14+ messages in thread From: Ho Jie Feng @ 2026-11-23 14:34 UTC (permalink / raw) To: Rafał Miłecki, Anand Gore, Broadcom internal kernel review list, Kursad Oney, Ray Jui, Russell King, Scott Branden, linux-arm-kernel On BCMBCA SoCs with more than two cores, CFE parks all secondary CPUs on the same mailbox. Extend the brcm,bca-smp schema requirement so cpu-release-addr is required on all secondary CPUs, not just CPU1. Signed-off-by: Ho Jie Feng <hjf3108@gmail.com> --- Documentation/devicetree/bindings/arm/cpus.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/cpus.yaml b/Documentation/devicetree/bindings/arm/cpus.yaml index b83c7785f6..0b7dbc75ae 100644 --- a/Documentation/devicetree/bindings/arm/cpus.yaml +++ b/Documentation/devicetree/bindings/arm/cpus.yaml @@ -492,15 +492,15 @@ allOf: $ref: /schemas/types.yaml#/definitions/uint32 description: Physical address of the 32-bit MMIO mailbox read by CFE after - a wakeup interrupt. Required on CPU1, which CFE leaves in - a holding pen. The kernel writes the ARM-state entry address + a wakeup interrupt. Required on secondary CPUs, which CFE leaves + in a holding pen. The kernel writes the ARM-state entry address before sending the interrupt. CPU0 is already running. if: properties: reg: items: - items: - - const: 1 + - minimum: 1 then: required: - cpu-release-addr -- 2.53.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-12-02 12:02 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-23 14:28 [PATCH 0/2] ARM: bcm: support more than two CPUs on BCMBCA Ho Jie Feng 2026-11-23 14:22 ` [PATCH 2/2] " Ho Jie Feng 2026-11-25 18:47 ` William Zhang 2026-11-26 3:13 ` Jie Feng 2026-11-25 21:00 ` Linus Walleij 2026-11-26 3:05 ` Jie Feng 2026-11-27 2:49 ` William Zhang 2026-11-30 15:12 ` Jie Feng 2026-11-30 15:22 ` Jie Feng 2026-12-01 13:48 ` Linus Walleij 2026-12-01 14:48 ` Jie Feng 2026-12-01 15:26 ` Linus Walleij 2026-12-02 12:02 ` Marc Zyngier 2026-11-23 14:34 ` [PATCH 1/2] dt-bindings: arm: cpus: Require cpu-release-addr on bca-smp secondaries Ho Jie Feng
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox