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

From: Jie Feng

Date: Tue Dec 01 2026 - 09:48:51 EST


On Tue, 1 Dec 2026 at 21:49, Linus Walleij <linusw@xxxxxxxxxx> wrote:
>
> Hi Jie,
>
> On Thu, Nov 26, 2026 at 4:06 AM Jie Feng <hjf3108@xxxxxxxxx> 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