Re: [RFC PATCH 2/6] ARM: bcm: Add brcm,bca-smp enable-method
From: William Zhang
Date: Fri Dec 04 2026 - 12:29:46 EST
Hi Wadim,
This smp enable method was already added by Linus recently:
https://lore.kernel.org/all/20261105-genexis-xg6846-smp-v7-3-rc1-v5-2-4103df2588d3@xxxxxxxxxx/
Thanks,
William
On Fri, Dec 4, 2026 at 7:11 AM Wadim Mueller <wafgo01@xxxxxxxxx> wrote:
>
> CFE without secure firmware does not provide PSCI. It keeps the
> secondary cores in WFI and on wakeup they jump to the address in the
> GPIO GeneralPurpose register (0xff800568).
>
> All cores wake up together, so use a holding pen like mach-versatile.
>
> Tested on BCM6755 (ASUS RT-AX56U).
>
> Signed-off-by: Wadim Mueller <wafgo01@xxxxxxxxx>
> ---
> arch/arm/mach-bcm/Makefile | 1 +
> arch/arm/mach-bcm/headsmp-bcmbca.S | 36 ++++++++++++++
> arch/arm/mach-bcm/platsmp-bcmbca.c | 79 ++++++++++++++++++++++++++++++
> 3 files changed, 116 insertions(+)
> create mode 100644 arch/arm/mach-bcm/headsmp-bcmbca.S
> create mode 100644 arch/arm/mach-bcm/platsmp-bcmbca.c
>
> diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile
> index 6baedf4c6..d13011a8d 100644
> --- a/arch/arm/mach-bcm/Makefile
> +++ b/arch/arm/mach-bcm/Makefile
> @@ -60,4 +60,5 @@ endif
> ifeq ($(CONFIG_ARCH_BCMBCA),y)
> obj-$(CONFIG_DEBUG_BCMBCA) += board_bcmbca.o
> obj-$(CONFIG_SMP) += bcm63xx_smp.o bcm63xx_pmb.o
> +obj-$(CONFIG_ARCH_BCMBCA_CORTEXA7) += platsmp-bcmbca.o headsmp-bcmbca.o
> endif
> diff --git a/arch/arm/mach-bcm/headsmp-bcmbca.S b/arch/arm/mach-bcm/headsmp-bcmbca.S
> new file mode 100644
> index 000000000..9e7d462e8
> --- /dev/null
> +++ b/arch/arm/mach-bcm/headsmp-bcmbca.S
> @@ -0,0 +1,36 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (c) 2003 ARM Limited (holding pen from mach-versatile)
> + * All Rights Reserved
> + */
> +#include <linux/linkage.h>
> +#include <linux/init.h>
> +#include <asm/assembler.h>
> +
> +/*
> + * Entry point for secondary CPUs on BCMBCA (CFE, no PSCI).
> + * This provides a "holding pen" into which all secondary cores are held
> + * until we're ready for them to initialise.
> + */
> +ENTRY(bca_secondary_startup)
> + ARM_BE8(setend be)
> + mrc p15, 0, r0, c0, c0, 5
> + bic r0, #0xff000000
> + adr r4, 1f
> + ldmia r4, {r5, r6}
> + sub r4, r4, r5
> + add r6, r6, r4
> +pen: ldr r7, [r6]
> + cmp r7, r0
> + bne pen
> +
> + /*
> + * we've been released from the holding pen: secondary_stack
> + * should now contain the SVC stack for this core
> + */
> + b secondary_startup
> +
> + .align
> +1: .long .
> + .long bca_cpu_release
> +ENDPROC(bca_secondary_startup)
> diff --git a/arch/arm/mach-bcm/platsmp-bcmbca.c b/arch/arm/mach-bcm/platsmp-bcmbca.c
> new file mode 100644
> index 000000000..e888a2a37
> --- /dev/null
> +++ b/arch/arm/mach-bcm/platsmp-bcmbca.c
> @@ -0,0 +1,79 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * SMP for BCMBCA Cortex-A7 SoCs booted by CFE without PSCI.
> + *
> + * CFE keeps the secondary cores in WFI. On wakeup all of them jump to the
> + * address in GPIO GeneralPurpose register, so we hold them in a pen.
> + */
> +
> +#include <linux/cacheflush.h>
> +#include <linux/delay.h>
> +#include <linux/init.h>
> +#include <linux/io.h>
> +#include <linux/jiffies.h>
> +#include <linux/smp.h>
> +
> +#include <asm/smp_plat.h>
> +
> +#define BCA_SMP_BOOT_ADDR 0xff800568 /* GPIO->GeneralPurpose */
> +
> +asmlinkage void bca_secondary_startup(void);
> +int bca_cpu_release = -1;
> +static DEFINE_RAW_SPINLOCK(bca_lock);
> +
> +/* pen runs with caches off */
> +static void bca_write_cpu_release(int val)
> +{
> + WRITE_ONCE(bca_cpu_release, val);
> + smp_wmb(); /* before cache clean */
> + sync_cache_w(&bca_cpu_release);
> +}
> +
> +static void bca_secondary_init(unsigned int cpu)
> +{
> + bca_write_cpu_release(-1);
> +
> + raw_spin_lock(&bca_lock);
> + raw_spin_unlock(&bca_lock);
> +}
> +
> +static int bca_boot_secondary(unsigned int cpu, struct task_struct *idle)
> +{
> + unsigned long timeout;
> + int released;
> +
> + raw_spin_lock(&bca_lock);
> +
> + bca_write_cpu_release(cpu_logical_map(cpu));
> + arch_send_wakeup_ipi_mask(cpumask_of(cpu));
> +
> + timeout = jiffies + HZ;
> + do {
> + smp_rmb(); /* pairs with bca_write_cpu_release() */
> + released = READ_ONCE(bca_cpu_release) == -1;
> + if (released)
> + break;
> + udelay(10);
> + } while (time_before(jiffies, timeout));
> +
> + raw_spin_unlock(&bca_lock);
> +
> + return released ? 0 : -ETIMEDOUT;
> +}
> +
> +static void __init bca_smp_prepare_cpus(unsigned int max_cpus)
> +{
> + void __iomem *reg = ioremap(BCA_SMP_BOOT_ADDR, 4);
> +
> + if (WARN_ON(!reg))
> + return;
> + writel(__pa_symbol(bca_secondary_startup), reg);
> + iounmap(reg);
> +}
> +
> +static const struct smp_operations bca_smp_ops __initconst = {
> + .smp_prepare_cpus = bca_smp_prepare_cpus,
> + .smp_secondary_init = bca_secondary_init,
> + .smp_boot_secondary = bca_boot_secondary,
> +};
> +CPU_METHOD_OF_DECLARE(bca_smp, "brcm,bca-smp", &bca_smp_ops);
> --
> 2.56.1
>
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature