Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ho Jie Feng <hjf3108@gmail.com>
To: "Florian Fainelli" <florian.fainelli@broadcom.com>,
	"Ray Jui" <rjui@broadcom.com>,
	"Scott Branden" <sbranden@broadcom.com>,
	"Broadcom internal kernel review list"
	<bcm-kernel-feedback-list@broadcom.com>,
	"Russell King" <linux@armlinux.org.uk>,
	"William Zhang" <william.zhang@broadcom.com>,
	"Anand Gore" <anand.gore@broadcom.com>,
	"Kursad Oney" <kursad.oney@broadcom.com>,
	"Rafał Miłecki" <rafal@milecki.pl>
Cc: Linus Walleij <linusw@kernel.org>,
	Ho Jie Feng <hjf3108@gmail.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] ARM: bcm: support more than two CPUs on BCMBCA
Date: Mon, 23 Nov 2026 22:22:00 +0800	[thread overview]
Message-ID: <20261123142203.3860616-3-hjf3108@gmail.com> (raw)
In-Reply-To: <20261123142203.3860616-1-hjf3108@gmail.com>

BCMBCA Cortex-A7 SoCs can have more than two cores, such as the
quad-core BCM6755. Extend the CFE SMP support to all secondary CPUs.

CFE parks every secondary CPU on the same mailbox, and the wakeup SGI
wakes all offline CPUs at once. Hold them in a pen and release them one
at a time.

Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
 arch/arm/mach-bcm/Makefile         |  1 +
 arch/arm/mach-bcm/bcmbca_headsmp.S | 26 +++++++++++++++++
 arch/arm/mach-bcm/bcmbca_smp.h     |  9 ++++++
 arch/arm/mach-bcm/board_bcmbca.c   | 46 ++++++++++++++++++++++++------
 4 files changed, 73 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-bcm/bcmbca_headsmp.S
 create mode 100644 arch/arm/mach-bcm/bcmbca_smp.h

diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile
index fcc4e0174a..c3cd2959bc 100644
--- a/arch/arm/mach-bcm/Makefile
+++ b/arch/arm/mach-bcm/Makefile
@@ -60,4 +60,5 @@ endif
 ifeq ($(CONFIG_ARCH_BCMBCA),y)
 obj-y				+= board_bcmbca.o
 obj-$(CONFIG_SMP)		+= bcm63xx_smp.o bcm63xx_pmb.o
+obj-$(CONFIG_SMP)		+= bcmbca_headsmp.o
 endif
diff --git a/arch/arm/mach-bcm/bcmbca_headsmp.S b/arch/arm/mach-bcm/bcmbca_headsmp.S
new file mode 100644
index 0000000000..3d0d0d97be
--- /dev/null
+++ b/arch/arm/mach-bcm/bcmbca_headsmp.S
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * All CPUs will wake up on an SGI. Wait in the holding pen until
+ * bcmbca_cpu_release matches the MPIDR.
+ *
+ * Based on arch/arm/mach-versatile/headsmp.S
+ */
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+
+	.arm
+ENTRY(bcmbca_secondary_startup)
+ ARM_BE8(setend	be)
+ THUMB(	badr	r9, 1f		)
+ THUMB(	bx	r9		)
+ THUMB(	.thumb			)
+ THUMB(1:			)
+	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
+ENDPROC(bcmbca_secondary_startup)
diff --git a/arch/arm/mach-bcm/bcmbca_smp.h b/arch/arm/mach-bcm/bcmbca_smp.h
new file mode 100644
index 0000000000..30055cf766
--- /dev/null
+++ b/arch/arm/mach-bcm/bcmbca_smp.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __BCMBCA_SMP_H
+#define __BCMBCA_SMP_H
+
+extern int bcmbca_cpu_release;
+
+void bcmbca_secondary_startup(void);
+
+#endif /* __BCMBCA_SMP_H */
diff --git a/arch/arm/mach-bcm/board_bcmbca.c b/arch/arm/mach-bcm/board_bcmbca.c
index 248b8bd776..1afba1d680 100644
--- a/arch/arm/mach-bcm/board_bcmbca.c
+++ b/arch/arm/mach-bcm/board_bcmbca.c
@@ -1,14 +1,20 @@
 // SPDX-License-Identifier: GPL-2.0-only
 // Copyright (C) 2024 Linus Walleij <linus.walleij@linaro.org>
 
+#include <linux/cache.h>
+#include <linux/cacheflush.h>
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/of.h>
 #include <linux/smp.h>
+#include <linux/units.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/smp_plat.h>
 
+#include "bcmbca_smp.h"
+
 #ifdef CONFIG_DEBUG_BCMBCA
 /* This is needed for LL-debug/earlyprintk/debug-macro.S */
 static struct map_desc bcmbca_io_desc[] __initdata = {
@@ -29,16 +35,28 @@ static void __init bcmbca_map_io(void)
 }
 
 #ifdef CONFIG_SMP
+int bcmbca_cpu_release __cacheline_aligned = -1;
+
+static void bcmbca_write_cpu_release(int val)
+{
+	WRITE_ONCE(bcmbca_cpu_release, val);
+	/* Order release write before cache clean and wakeup IPI */
+	smp_wmb();
+	sync_cache_w(&bcmbca_cpu_release);
+}
+
+static void bcmbca_secondary_init(unsigned int cpu)
+{
+	/* Let the primary processor know we're out of the pen */
+	bcmbca_write_cpu_release(-1);
+}
+
 static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
 	struct device_node *np;
 	void __iomem *mailbox;
 	u32 release_addr;
-	int ret;
-
-	/* CFE has already powered up CPU1 and left it waiting in WFI. */
-	if (cpu_logical_map(cpu) != 1)
-		return -EINVAL;
+	int release, ret;
 
 	np = of_get_cpu_node(cpu, NULL);
 	if (!np)
@@ -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));
 	iounmap(mailbox);
 
-	return 0;
+	bcmbca_write_cpu_release(cpu_logical_map(cpu));
+	arch_send_wakeup_ipi_mask(cpumask_of(cpu));
+
+	ret = read_poll_timeout_atomic(smp_load_acquire, release,
+				       release == -1, 10, USEC_PER_SEC, false,
+				       &bcmbca_cpu_release);
+	if (ret)
+		bcmbca_write_cpu_release(-1);
+
+	return ret;
 }
 
 static const struct smp_operations bcmbca_smp_ops __initconst = {
+	.smp_secondary_init = bcmbca_secondary_init,
 	.smp_boot_secondary = bcmbca_boot_secondary,
 };
 
-- 
2.53.0



  reply	other threads:[~2026-11-23 14:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 14:28 [PATCH 0/2] ARM: bcm: support more than two CPUs on BCMBCA Ho Jie Feng
2026-11-23 14:22 ` Ho Jie Feng [this message]
2026-11-23 14:34 ` [PATCH 1/2] dt-bindings: arm: cpus: Require cpu-release-addr on bca-smp secondaries Ho Jie Feng

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=20261123142203.3860616-3-hjf3108@gmail.com \
    --to=hjf3108@gmail.com \
    --cc=anand.gore@broadcom.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=kursad.oney@broadcom.com \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=rafal@milecki.pl \
    --cc=rjui@broadcom.com \
    --cc=sbranden@broadcom.com \
    --cc=william.zhang@broadcom.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