[PATCH v2] ARM: bcm: Send the BCMBCA CFE wakeup SGI directly

Linus Walleij linusw at kernel.org
Wed Dec 2 13:23:28 PST 2026


The GICv2 driver learns a CPU's target bit when that CPU starts.
Before then, its provisional target mask can address multiple CPU
interfaces. CFE wakes the secondary when an interrupt arrives, so
use an explicit target for this first SGI.

Map the Cortex-A7 GIC distributor using the CPU node's interrupt
parent in DeviceTree. Use the core ID from MPIDR affinity level 0 as
the target bit in the integrated Cortex-A7 GIC. Keep the barrier that
completes the CFE mailbox write before sending SGI 0 to that target.

Suggested-by: Marc Zyngier <maz at kernel.org>
Link: https://lore.kernel.org/linux-arm-kernel/20261123142203.3860616-3-hjf3108@gmail.com/
Fixes: db4d1458f203 ("ARM: bcm: Add CFE SMP support for BCMBCA")
Tested-by: Ho Jie Feng <hjf3108 at gmail.com>
Signed-off-by: Linus Walleij <linusw at kernel.org>
---
An LLM assisted in authoring the patch.
---
Changes in v2:
- Remove the CPU1-only wakeup restriction.
- Collect Jie's Tested-by.
- Derive the SGI target from MPIDR affinity level 0. Should mean not
  difference since BCMBCA doesn't use the cluster bits, but better
  safe than sorry.
- Link to v1: https://patch.msgid.link/20261202-bcmbca-smp-gicv2-v1-1-782c02982a7c@kernel.org
---
 arch/arm/mach-bcm/board_bcmbca.c | 46 ++++++++++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-bcm/board_bcmbca.c b/arch/arm/mach-bcm/board_bcmbca.c
index 248b8bd77645..e85dd48f3cca 100644
--- a/arch/arm/mach-bcm/board_bcmbca.c
+++ b/arch/arm/mach-bcm/board_bcmbca.c
@@ -1,10 +1,15 @@
 // SPDX-License-Identifier: GPL-2.0-only
 // Copyright (C) 2024 Linus Walleij <linus.walleij at linaro.org>
 
+#include <linux/bits.h>
 #include <linux/io.h>
+#include <linux/irqchip/arm-gic.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 #include <linux/smp.h>
 
+#include <asm/cputype.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/smp_plat.h>
@@ -29,15 +34,19 @@ static void __init bcmbca_map_io(void)
 }
 
 #ifdef CONFIG_SMP
+#define BCMBCA_GIC_CPU_IFS	8
+#define BCMBCA_SGIR_TARGET_SHIFT	16
+#define BCMBCA_WAKEUP_SGI	0
+
 static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
-	struct device_node *np;
-	void __iomem *mailbox;
+	unsigned int gic_cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(cpu), 0);
+	struct device_node *np, *gic_node;
+	void __iomem *mailbox, *gic_dist;
 	u32 release_addr;
 	int ret;
 
-	/* CFE has already powered up CPU1 and left it waiting in WFI. */
-	if (cpu_logical_map(cpu) != 1)
+	if (gic_cpu >= BCMBCA_GIC_CPU_IFS)
 		return -EINVAL;
 
 	np = of_get_cpu_node(cpu, NULL);
@@ -45,15 +54,30 @@ static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle)
 		return -ENODEV;
 
 	ret = of_property_read_u32(np, "cpu-release-addr", &release_addr);
-	of_node_put(np);
 	if (ret) {
+		of_node_put(np);
 		pr_err("CPU%u: missing or invalid cpu-release-addr property\n", cpu);
 		return ret;
 	}
 
+	gic_node = of_irq_find_parent(np);
+	of_node_put(np);
+	if (!of_device_is_compatible(gic_node, "arm,cortex-a7-gic") ||
+	    !of_device_is_available(gic_node)) {
+		of_node_put(gic_node);
+		return -ENODEV;
+	}
+
+	gic_dist = of_iomap(gic_node, 0);
+	of_node_put(gic_node);
+	if (!gic_dist)
+		return -ENOMEM;
+
 	mailbox = ioremap(release_addr, sizeof(u32));
-	if (!mailbox)
+	if (!mailbox) {
+		iounmap(gic_dist);
 		return -ENOMEM;
+	}
 
 	/*
 	 * The CFE stub reads GPIO GeneralPurpose after an interrupt and
@@ -62,8 +86,16 @@ static int bcmbca_boot_secondary(unsigned int cpu, struct task_struct *idle)
 	 */
 	writel(__pa_symbol(secondary_startup_arm) & ~1, mailbox);
 	dsb(sy);
-	arch_send_wakeup_ipi_mask(cpumask_of(cpu));
+
+	/*
+	 * The integrated Cortex-A7 GIC uses the hardware core ID as its
+	 * target bit. Linux has yet to discover the secondary's GIC target.
+	 * Use SGI 0, the same interrupt as the ARM GICv2 wakeup IPI.
+	 */
+	writel_relaxed(BIT(BCMBCA_SGIR_TARGET_SHIFT + gic_cpu) | BCMBCA_WAKEUP_SGI,
+		       gic_dist + GIC_DIST_SOFTINT);
 	iounmap(mailbox);
+	iounmap(gic_dist);
 
 	return 0;
 }

---
base-commit: 21f8531821461fa0c05e4605c01d8d56d28b514e
change-id: 20261202-bcmbca-smp-gicv2-535b6d4c72cf

Best regards,
--  
Linus Walleij <linusw at kernel.org>




More information about the linux-arm-kernel mailing list