Re: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA

From: Jie Feng

Date: Wed Nov 25 2026 - 22:06:35 EST


Hi Linus,

On Thu, 26 Nov 2026 at 05:01, Linus Walleij <linusw@xxxxxxxxxx> 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@xxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxx/
>
> > 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