From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796398457; b=hna5E0u635rKFOtPsQJuD5rZg6VsdGGFgo00sakPVATihVXi9CLmTpc5D+iW3IWDwzK6 Egi13tdJdjiUv4kpa4fwtA4gS6CuvhRCpp9A8D5to5043naRBqBp4J7N80L9Taozf5aja 4SgqkgcfjvwHMsFTQRI0vhwGM+FW2lgiaYZAuK2a7uiwoNbFVplcJ0NSZh8p15nLzksW/ FWV8OTO9CUQ5OsrbLz/rH9h/wM8R3cqcZg29iNbia6r52ZR+qBkeDVEaf9h0N/SF/slfc cPH94IuwwGb8yhG6xeUNpfkFpSK7rHBOuk7EAgBOlf8I30PXrbZotbLI18yPRLXmb8g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796398457; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=fKm2I/no9mrUGPbUk9YWq6WFoIBwFdhaE11hwqUaLSY=; b=J0Tn3+HEHnnQ7U8hJT9+dqYLr+BYOQ3U/X+ucHqW+EdG8cne1qGaVcxysWOWejgtxcGA 6xz2K3lMpITJwAYMWGwm1/GUdGuV3HI25J+njOlvdOIthUUjlzzSy2sJYIwqH/zGWqwUW UGMntl+DDHiysyXzg3WvMHR4yGlnQOp26sqmyjOR5GHU09tyhNloO08CzhB2z4PfapIxD loElYBnCWd3BFVzBV4KhAUOt8BUlPH24OW3aCTQHaxcMv2NWZmZo7IpQq+TPdPJumuk5v enjr/aSz70vtlB/ayHKS4acYfJsuOzlqfYahVAJWQFzoZ1Y7czHBCmsGHc6JihQKEQQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JFVr6rJj; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 044ED606A322; Fri, 4 Dec 2026 15:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JFVr6rJj Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F5581F000CE; Fri, 4 Dec 2026 15:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796398456; bh=fKm2I/no9mrUGPbUk9YWq6WFoIBwFdhaE11hwqUaLSY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JFVr6rJjnJ8K58NwaedagusVk/Ict8lrRXN9r38mnzP8QGWiq5I86rh97WkLZEy4j dBpAtIkMc/YJsxcaBXa0CZZjHda6GZq245kWHoBIK5tmwh6pfrRqTNzOrYkCf2HD8f QOHx8bitYdUbVFzt7/i/soCwBK6wN6m3KCT+4huC6uohg/iqpSwxINKx/7NpfEFg1e XiC+PCcxHc8wqGdLxpWmv71R3ZEBxNkUz2ffFpgs7tuG6/eNEbiv8k+x2+scr2c/b/ 6x3ex2JxZKeJGTvMhVLjI5RilJKOUX8GcIrxzAzAK0cf39Hx+tKvQRGujygsmw75Qf ULsA6uCbrIQVA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH 2/6] ARM: bcm: Add brcm,bca-smp enable-method Reply-To: sashiko-reviews@lists.linux.dev To: "Wadim Mueller" Cc: devicetree@vger.kernel.org, mfd@lists.linux.dev, robh@kernel.org, conor+dt@kernel.org, lee@kernel.org In-Reply-To: <20261204151052.393800-3-wafgo01@gmail.com> References: <20261204151052.393800-1-wafgo01@gmail.com> <20261204151052.393800-3-wafgo01@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 15:34:14 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 7 potential issues to consider: - [Medium] ARM: bcm: build failure when CONFIG_ARCH_BCMBCA_CORTEXA7=3Dy and CONFIG_SMP=3Dn - [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 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) +=3D board_bcmbca.o > obj-$(CONFIG_SMP) +=3D bcm63xx_smp.o bcm63xx_pmb.o > +obj-$(CONFIG_ARCH_BCMBCA_CORTEXA7) +=3D 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=3Dn, 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/heads= mp-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=3D2 or nr_cpus=3D2, 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/plats= mp-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 =3D jiffies + HZ; > + do { > + smp_rmb(); /* pairs with bca_write_cpu_release() */ > + released =3D READ_ONCE(bca_cpu_release) =3D=3D -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 =3D (bca_cpu_release =3D=3D -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 wait= er 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 =3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204151052.3938= 00-1-wafgo01@gmail.com?part=3D2