Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wadim Mueller" <wafgo01@gmail.com>
Cc: devicetree@vger.kernel.org, mfd@lists.linux.dev, robh@kernel.org,
	conor+dt@kernel.org, lee@kernel.org
Subject: Re: [RFC PATCH 2/6] ARM: bcm: Add brcm,bca-smp enable-method
Date: Fri, 04 Dec 2026 15:34:14 +0000	[thread overview]
Message-ID: <sashiko-outbox-250117@kernel.org> (raw)
In-Reply-To: <20261204151052.393800-3-wafgo01@gmail.com>

Thank you for your contribution! Sashiko AI review found 7 potential
issues to consider:
- [Medium] ARM: bcm: build failure when CONFIG_ARCH_BCMBCA_CORTEXA7=y
  and CONFIG_SMP=n
- [Medium] ARM: bcm: bca_boot_secondary() leaves bca_cpu_release armed
  on timeout
- [Medium] ARM: bcm: bca_boot_secondary() misses completion after final
  udelay()
- [Medium] ARM: bcm: bca_smp_prepare_cpus() leaves CPUs present on
  ioremap fail
- [Medium] ARM: bcm: bca_secondary_startup() holding pen spins uncached
  without wfe/sev
- [Medium] ARM: bcm: hardcoded MMIO boot address in
  bca_smp_prepare_cpus()
- [Low] ARM: bcm: bca_secondary_startup() holding pen spins without wfe
--

commit 6b1b8619c251291715fdb7b77a729a116d971e38
Author: Wadim Mueller <wafgo01@gmail.com>

ARM: bcm: Add brcm,bca-smp enable-method

This commit adds SMP bring-up support for BCMBCA Cortex-A7 SoCs booted
by CFE without PSCI, using a holding pen in assembly and a hardcoded
GPIO GeneralPurpose register for the secondary entry address.

> diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile
> index 6baedf4c63041..d13011a8d5f19 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

[Severity: Medium]
Does this break uniprocessor builds when CONFIG_ARCH_BCMBCA_CORTEXA7 is
enabled and CONFIG_SMP is disabled?

Neither ARCH_BCMBCA nor ARCH_BCMBCA_CORTEXA7 selects or depends on SMP.
With CONFIG_SMP=n, include/linux/smp.h does not include asm/smp.h, so
platsmp-bcmbca.c fails to compile, and secondary_startup in
arch/arm/kernel/head.S is not built, leaving an undefined reference from
headsmp-bcmbca.S.  These objects should also be gated on CONFIG_SMP.

> diff --git a/arch/arm/mach-bcm/headsmp-bcmbca.S b/arch/arm/mach-bcm/headsmp-bcmbca.S
> new file mode 100644
> index 0000000000000..9e7d462e857b1
> --- /dev/null
> +++ b/arch/arm/mach-bcm/headsmp-bcmbca.S

[ ... ]

> +pen:	ldr	r7, [r6]
> +	cmp	r7, r0
> +	bne	pen

[Severity: Medium]
Can unbooted secondary cores spin forever in this uncached loop and
saturate the memory bus?

When booting a 4-core BCM6755 with maxcpus=2 or nr_cpus=2, bringing up
CPU 1 wakes all secondary cores into bca_secondary_startup() with MMU and
caches off.  CPUs 2 and 3 are never released and issue continuous uncached
DRAM loads for the entire uptime, wasting power and bus bandwidth.

Adding .arch armv7-a and wfe here, paired with sev() after sync_cache_w()
in bca_write_cpu_release(), would avoid the busy spin.

> diff --git a/arch/arm/mach-bcm/platsmp-bcmbca.c b/arch/arm/mach-bcm/platsmp-bcmbca.c
> new file mode 100644
> index 0000000000000..e888a2a370678
> --- /dev/null
> +++ b/arch/arm/mach-bcm/platsmp-bcmbca.c

[ ... ]

> +#define BCA_SMP_BOOT_ADDR	0xff800568	/* GPIO->GeneralPurpose */

[Severity: Medium]
Should the secondary boot address come from Device Tree instead of being
hardcoded to 0xff800568 under the generic brcm,bca-smp enable-method?

Other BCMBCA SoCs such as bcm63138 place their peripheral and GPIO block
at different physical addresses, so hardcoding 0xff800568 would write the
startup vector to the wrong address on non-matching SoCs.  Merging DTS
files without a DT-provided address also locks in an incomplete ABI.

The standard cpu-release-addr property in bindings/arm/cpus.yaml (or a DT
register node, as used by the other arch/arm/mach-bcm/ SMP drivers) could
supply this address instead.

[ ... ]

> +/* 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);
> +}

[Severity: Low]
Should bca_write_cpu_release() emit dsb_sev() to pair with a wfe-based
holding pen?

Unlike arch/arm/mach-versatile/headsmp.S, which had to support ARMv6
without wfe/sev, CONFIG_ARCH_BCMBCA_CORTEXA7 targets ARMv7 Cortex-A7 where
wfe and dsb_sev() are always available.  Using them avoids active power
draw and bus traffic from waiting secondary cores.

[ ... ]

> +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));

[Severity: Medium]
Can bca_boot_secondary() return -ETIMEDOUT after the secondary CPU has
already cleared bca_cpu_release during the final udelay(10)?

CPU0                                  CPU1
bca_boot_secondary()
  raw_spin_lock(&bca_lock)
  ...
  released = (bca_cpu_release == -1)  /* false */
  udelay(10)
                                      bca_secondary_init()
                                        bca_write_cpu_release(-1)
                                        raw_spin_lock(&bca_lock)  /* waits */
  /* timeout expires, exits loop */
  raw_spin_unlock(&bca_lock)
  return -ETIMEDOUT
                                        raw_spin_unlock(&bca_lock)
                                      secondary_start_kernel()
                                        complete(&cpu_running)  <-- no waiter

Because __cpu_up() skips wait_for_completion_timeout(&cpu_running, ...) on
error, the static cpu_running completion stays signaled and causes the
next CPU bring-up to return prematurely and zero secondary_data while that
CPU is still booting.

Re-checking bca_cpu_release with smp_rmb() after the loop while bca_lock
is still held avoids this race.

> +
> +	raw_spin_unlock(&bca_lock);
> +
> +	return released ? 0 : -ETIMEDOUT;
> +}

[Severity: Medium]
Does the timeout path leave bca_cpu_release armed with the timed-out CPU's
MPIDR?

On error, __cpu_up() immediately zeroes secondary_data.  If the timed-out
core reaches bca_secondary_startup() later, it matches the stale value in
bca_cpu_release and branches to secondary_startup with NULL stack and
page-table pointers.

Calling bca_write_cpu_release(-1) before unlocking bca_lock when !released
disarms the holding pen.

> +
> +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);
> +}

[Severity: Medium]
If ioremap() fails here, won't bca_boot_secondary() still send wakeup IPIs
to secondary CPUs even though BCA_SMP_BOOT_ADDR was never programmed?

smp_prepare_cpus() marks all possible CPUs present before calling
smp_ops.smp_prepare_cpus().  Returning early leaves secondary CPUs in
cpu_present_mask, so they get woken to jump to whatever stale value is in
0xff800568 while boot stalls for HZ per core.

Calling init_cpu_present(cpumask_of(0)) on failure (like
bcm_smp_prepare_cpus() in arch/arm/mach-bcm/platsmp.c) avoids waking them.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204151052.393800-1-wafgo01@gmail.com?part=2

  reply	other threads:[~2026-12-04 15:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 15:10 [RFC PATCH 0/6] ARM: bcmbca: Add BCM47622 SMP and ASUS RT-AX56U Wadim Mueller
2026-12-04 15:10 ` [RFC PATCH 1/6] dt-bindings: arm: cpus: Add brcm,bca-smp enable-method Wadim Mueller
2026-12-04 15:10 ` [RFC PATCH 2/6] ARM: bcm: " Wadim Mueller
2026-12-04 15:34   ` sashiko-bot [this message]
2026-12-04 17:29   ` William Zhang
2026-12-04 15:10 ` [RFC PATCH 3/6] dt-bindings: mfd: brcm,twd: Add BCM47622 Wadim Mueller
2026-12-04 15:23   ` sashiko-bot
2026-12-04 15:10 ` [RFC PATCH 4/6] ARM: dts: broadcom: bcm47622: Add TWD, reboot, MDIO and SYSTEMPORT0 Wadim Mueller
2026-12-04 15:34   ` sashiko-bot
2026-12-04 17:45   ` Florian Fainelli
2026-12-04 15:10 ` [RFC PATCH 5/6] dt-bindings: arm: bcmbca: Add ASUS RT-AX56U Wadim Mueller
2026-12-04 15:17   ` sashiko-bot
2026-12-04 15:10 ` [RFC PATCH 6/6] ARM: dts: broadcom: " Wadim Mueller
2026-12-04 15:25   ` sashiko-bot
2026-12-04 18:01   ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-250117@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=mfd@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wafgo01@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox