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

From: Jie Feng

Date: Mon Nov 30 2026 - 10:23:25 EST


On Mon, 30 Nov 2026 at 23:12, Jie Feng <hjf3108@xxxxxxxxx> wrote:
>
> Hi William,
>
> On Fri, 27 Nov 2026 at 10:49, William Zhang <william.zhang@xxxxxxxxxxxx> wrote:
> >
> > Hi Jie,
> >
> > On Wed, Nov 25, 2026 at 7:06 PM Jie Feng <hjf3108@xxxxxxxxx> wrote:
> > >
> > > 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.
> > 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@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.
> > > >
> > 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