Article View: linux.kernel.netdev
Article #27551Re: [PATCH net-next v2 4/4] net: phy: broadcom: Recover BCM54210E from aborted cable tests
From: netdev-bot+sashiko
Date: Sun, 06 Dec 2026 00:07
Date: Sun, 06 Dec 2026 00:07
248 lines
16929 bytes
16929 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 3 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] bcm54210e_soft_reset() (drivers/net/phy/broadcom.c) adds a
BMCR_RESET through genphy_soft_reset() to every cable-test abort on…
- [Medium] net: phy: broadcom: bcm54210e_soft_reset() falsely clears
phydev->suspended
- [Medium] net: phy: broadcom: bcm54210e_soft_reset() drops unpolled PHY
stats counters
- [Low] Any error inside bcm54210e_soft_reset()
(drivers/net/phy/broadcom.c) is returned to phy_init_hw().
--
net: phy: broadcom: Recover BCM54210E from aborted cable tests
This patch adds a five second timeout to the BCM54210E cable test. It also
adds a .soft_reset callback that resets the PHY through genphy_soft_reset()
when phy_init_hw() runs while the state is still PHY_CABLETEST. When WoL is
enabled, the WoL filter registers, WoL interrupt mask and TOP_MISC_LED_CTL
are saved before the reset and restored after it.
> diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
> index 19b97beb8be8d..3b32c15e4dd60 100644
> --- a/drivers/net/phy/broadcom.c
> +++ b/drivers/net/phy/broadcom.c
[ ... ]
> +static int bcm54210e_soft_reset(struct phy_device *phydev)
> +{
> + static const u16 wol_regs[] = {
> + BCM54XX_WOL_MPD_DATA1(0), BCM54XX_WOL_MPD_DATA1(1),
> + BCM54XX_WOL_MPD_DATA1(2), BCM54XX_WOL_MPD_DATA2(0),
> + BCM54XX_WOL_MPD_DATA2(1), BCM54XX_WOL_MPD_DATA2(2),
> + BCM54XX_WOL_MASK(0), BCM54XX_WOL_MASK(1), BCM54XX_WOL_MASK(2),
> + BCM54XX_WOL_INT_MASK, BCM54XX_TOP_MISC_LED_CTL,
> + };
[Severity: Medium]
What happens to the PTP timestamping configuration across this reset?
The commit message says "A soft reset may clear register settings outside
config_init()", and this list covers the WoL and LED registers. It does
not cover the PTP expansion registers that bcm_ptp_hwtstamp_set() programs
at runtime:
drivers/net/phy/bcm-phy-ptp.c:bcm_ptp_hwtstamp_set() {
...
bcm_phy_write_exp(priv->phydev, TX_EVENT_MODE, mode);
...
bcm_phy_write_exp(priv->phydev, RX_EVENT_MODE, mode);
bcm_phy_write_exp(priv->phydev, SLICE_CTRL, ctrl);
if (ctrl & SLICE_TX_EN)
bcm_phy_write_exp(priv->phydev, TX_TS_CAPTURE, TX_TS_CAP_EN);
...
}
PTP is only attached to PHY_ID_BCM54210E, the same device that now gets
the reset. After the reset, config_init() runs
bcm54xx_config_init()->bcm54xx_ptp_config_init()->bcm_ptp_config_init().
That path only writes NSE_CTRL, TIME_SYNC, DPLL_SELECT, TIMECODE_CTRL,
SHADOW_CTRL and SYNC_IN_DIVIDER.
priv->hwts_rx and priv->tx_type in struct bcm_ptp_private survive the
reset. So bcm_ptp_rxtstamp() and bcm_ptp_txtstamp() keep treating
timestamping as enabled.
If BMCR_RESET clears these registers, would TX timestamp requests sit in
tx_queue until they expire? Would RX PTP frames arrive without inserted
timestamps, with no error reported?
Before this patch the BCM54210E entry had no .soft_reset, so phy_init_hw()
on the abort path never reset the chip.
The LED routing has a smaller version of the same gap. TOP_MISC_LED_CTL is
only preserved when BCM54XX_WOL_EN is set. bcm_phy_set_wol() with
wolopts == 0 clears WOL_EN but leaves BCM54XX_LED4_SEL_INTR set in
TOP_MISC_LED_CTL. Is that LED setting expected to be lost in that case?
> + u16 wol_values[ARRAY_SIZE(wol_regs)];
> + int wol_ctl, ret;
> + unsigned int i;
[ ... ]
> + wol_ctl = bcm_phy_read_exp(phydev, BCM54XX_WOL_MAIN_CTL);
> + if (wol_ctl < 0)
> + return wol_ctl;
> +
> + /* Preserve the programmed wake filters and interrupt routing. */
> + if (wol_ctl & BCM54XX_WOL_EN) {
> + for (i = 0; i < ARRAY_SIZE(wol_regs); i++) {
> + ret = bcm_phy_read_exp(phydev, wol_regs[i]);
> + if (ret < 0)
> + return ret;
> +
> + wol_values[i] = ret;
> + }
> + }
> +
> + ret = genphy_soft_reset(phydev);
> + if (ret < 0) {
> + phydev_err(phydev, "Failed to reset PHY after cable test: %d\n",
> + ret);
> + return ret;
> + }
[Severity: Medium]
Are the PHY error and LPI counters lost across this reset?
The counters behind bcm54xx_get_stats() are clear-on-read in the
PHY. They only reach priv->stats when bcm_phy_update_stats_shadow()
runs, which is why bcm54xx_suspend() flushes them before powering
down:
drivers/net/phy/broadcom.c:bcm54xx_suspend() {
...
mutex_lock(&phydev->lock);
bcm_phy_update_stats_shadow(phydev, priv->stats);
mutex_unlock(&phydev->lock);
...
}
bcm54210e_soft_reset() calls genphy_soft_reset() without a similar
flush. Anything counted since the last ethtool -S read is then
discarded. That happens on every aborted cable test:
- on the new -ETIMEDOUT path,
- on a status read error,
- on phy_stop() during the test.
In the phy_stop() case, phy_abort_cable_test() runs phy_init_hw()
before phy_suspend() reaches bcm54xx_suspend(). The flush there
runs only after the counters are already gone.
Should the reset path call bcm_phy_update_stats_shadow() on
priv->stats before genphy_soft_reset()? The abort path already runs
with phydev->lock held, so it could not take the lock the way
bcm54xx_suspend() does.
[Severity: Low]
What state is the PHY left in if one of these error returns is taken?
phy_init_hw() returns as soon as soft_reset() fails. That skips
config_init(), config_intr() and the autonomous EEE re-apply:
drivers/net/phy/phy_device.c:phy_init_hw() {
...
if (phydev->drv->soft_reset) {
ret = phydev->drv->soft_reset(phydev);
if (ret < 0)
return ret;
...
}
phy_abort_cable_test() only logs the error. _phy_state_machine() then
moves to PHY_UP and starts aneg anyway:
drivers/net/phy/phy.c:phy_abort_cable_test() {
...
err = phy_init_hw(phydev);
if (err)
phydev_err(phydev, "Error while aborting cable test");
}
Suppose the bcm_phy_read_exp() of BCM54XX_WOL_MAIN_CTL fails, or a read of
one of the saved WoL registers fails. The function then returns before
genphy_soft_reset() runs.
Would that leave the ECD engine running, with APD still cleared by
bcm54xx_cable_test_start()? The state has already left PHY_CABLETEST, so
the new timeout in bcm54xx_cable_test_get_status() can no longer catch it.
Before this patch the abort path always reached config_init().
Now suppose genphy_soft_reset() fails after BMCR_RESET was written, for
example on a phy_poll_reset() timeout. Or one of the WoL restore writes
fails after a successful reset. Either way the PHY is left at reset
defaults.
Would the RGMII delays, ECR/IMR interrupt masking, LED and PTP setup then
stay unapplied while phylib carries on into autonegotiation?
> +
> + if (!(wol_ctl & BCM54XX_WOL_EN))
> + return 0;
[Severity: Medium]
Does adding a .soft_reset that is a no-op outside PHY_CABLETEST
change what phy_init_hw() assumes about the power state?
Before this patch the BCM54210E entry had no .soft_reset, so
phy_init_hw() never touched phydev->suspended. Now every
phy_init_hw() call takes the soft_reset branch. Once the callback
returns >= 0, the flag is cleared unconditionally:
drivers/net/phy/phy_device.c:phy_init_hw() {
...
if (phydev->drv->soft_reset) {
ret = phydev->drv->soft_reset(phydev);
if (ret < 0)
return ret;
phydev->suspended = 0;
}
...
}
That relies on BMCR_RESET having cleared BMCR_PDOWN. Outside
PHY_CABLETEST, bcm54210e_soft_reset() returns 0 without writing
BMCR. A PHY that bcm54xx_suspend() powered down then stays in
BMCR_PDOWN (and IDDQ if configured) while phydev->suspended reads 0.
Several callers run phy_init_hw() on a suspended PHY without a
guaranteed phy_resume() afterwards:
- bcmgenet_resume() calls phy_init_hw() before bcmgenet_init_dma()
and only calls phy_resume() conditionally. GENET is the MAC paired
with this PHY on the Raspberry Pi 4 and CM4.
- ave_resume() skips phy_resume() when the interface is down.
- mdio_bus_phy_resume() and phy_attach_direct() can fail between
phy_init_hw() and phy_resume().
With the flag out of sync, phylink_prepare_resume() would skip
phy_resume() while RXC is still stopped by BMCR_PDOWN. phy_suspend()
would also run bcm54xx_suspend() again on a PHY that is already
down. That repeats the stats shadow update and the
BCM54XX_WOL_INT_STATUS read while the PHY is powered down.
Could the cable test reset be done somewhere that does not report
a reset to phylib when none happened? One option might be the start
of bcm54xx_config_init() when phydev->state is PHY_CABLETEST.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204233633.3790143-1-florian.fainelli%40broadcom.com
Technical Details
Message-ID:
<179651565647.3148.14123507342197810039@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378186-linux-kernel-netdev=dewy.ruReferences:
<20261204233633.3790143-5-florian.fainelli@broadcom.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378186-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v2 4/4] net: phy: broadcom: Recover BCM54210E from aborted cable tests Date: Sun, 06 Dec 2026 00:07:36 +0000 Organization: Usenet Network Message-ID: <179651565647.3148.14123507342197810039@kernel.org> References: <20261204233633.3790143-5-florian.fainelli@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3148149"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:7ODmZj7hAc0GQwal0hsYFHNw1S8= sha256:49BWQAnP7r7GO3zDoy5XEeEwD0Utb3NaDi4h2vs9Y7w= sha1:4clfCaoxtK/qvZI9MP+peLn4R44= sha256:7InaWcdyVxKS0kPVSQ1eWBGC6q3eAvXiV1LraD8Vpoo= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 37E21117F00; Sun, 6 Dec 2026 03:08:00 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.54 X-Spam-Status: No, score=-3.54 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6JKTDWPPOHyJ; Sun, 6 Dec 2026 03:07:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-378186-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 336C9117EFA; Sun, 6 Dec 2026 03:07:46 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id EF26B33F87; Sun, 6 Dec 2026 00:07:38 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796515658; b=krYBOAlJhJaQzncioU8ZaNp6IR14bBk6cWdQ0vtBr90EJs2M1K+K7mlqDnxfOEHW2gUk BEJCe3v5CeJyNJOCcOrwTOaiQPulckZFPlkvm9/HolgVoKfGFa7L/v+PeNKlGFjDV3i88 6wXGOInY7Y4Cr/+yHC5RbryN0jh2iyLkU5OBBLVBoYRzsPvKGC/I5/KWY4Ri7PKzfm1I4 K42RK9Rd+MINcTF/P91VkTWsflX0DWwXQVb92FBzdPQQH285RFqEyWj/jbNJ4RYB+nw0J k4XZmSoz191X3vwGDsIa+H2iYC3vwvQZaUHVzjvO/uYxG5IvhBdWJPBPCdtZEHuTStQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796515658; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=PYMkVFzcExSqb2rn4ir+ifTQpEO/IaDt7kTdHcMW2jo=; b=4j6ygRVzmzcmk9+GhukHBBs+LJszWDquSjrNCHqXkTaSzwFrWkzoBBmP4L9bOmkrN6/E /1Q4WqitACmr/i9m7QTvDeEbUhjt2yLeg7wiDEQn4xEJByECSqZiVXE1Ws4LGbtTOOoEW kCXTeDCEdM3jL5eBwSdbf8UaDNO9RhfHmKfMr0swT81xQvhvU1T9gqJeHmj9XmhaUv3xf X74OPzDFKCSjuwP/rQSKOVsv7ZX9jGrHXGvmO99xczM9W0bqZvVa1W8B9q+bnRKMy+X8k 8zdZx8DUvi+NDtSF0XQXNrQ/nsooQe/TpqHHpU2LSfEcpTe+T0SOihAto4rW85Y8QPg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RJpjLnGb; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEFAA606A32F; Sun, 6 Dec 2026 00:07:38 +0000 (UTC) X-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=RJpjLnGb X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796515657; b=K/vQTheIE2ztAkYk3xE6mirVlTVPcXyBFdB0gMlAG+O4k4Gt7bj8hh8f+ScOvisIyKr1 f519VeYQXlbfmvHbKoCB+ebq+MfxHc/s0jLHcRqv0dx0H9/fxtTg8xux5xD5881kXnnbf aRDWNjc6/Exnlh0W/iGogMin92s0HTpH+f82yRq2MbFGbTZduY/my33emyTmQmeWbW8Bm E47G7CfR1719MuebYfXZDqZ9KN8Ghf4IBWpkEKyq36yVI0YZQ7mcvkfhPZHPWewrCD7aC pDWHi1VyQWuMm14hXI1MDxEgl0lAcMv0k3q3mcRTkJtAWr3jTxmG45ZC3eEoB4MVWFA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796515657; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=PYMkVFzcExSqb2rn4ir+ifTQpEO/IaDt7kTdHcMW2jo=; b=iUVX6fQY+VYltaNtarJgpLxlGQhsWBW8H7zij194slRWGELfLSRkZy6nxNMXnipphbye VnmOBldKggvX6X+z4FTazo0xwIEuY5ziQUgjj6fiurUOaLnwGmyO0Bah3gaXO9T3ou/b3 eo9lwk93bTHWIPmFxAuJTVTJPiZAYeGO8Cu9aCcwMpNVaITzwPuposiB57Dh1WlxNQ0SC pthHwfhilzebSunPTbQkxU0JonZduxTiMERb16dQvcq0JgfArgd9SbAHO3862OdIofk2g IlWcMFLHQxDG904MsY/soHR06zn+YXvY7uwCxiweCq0yva8VCBmHvA5skZPla5Tcjag== X-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=RJpjLnGb; arc=none smtp.remote-ip=100.103.45.18 X-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 DDEEB606A332 for <netdev@vger.kernel.org>; Sun, 6 Dec 2026 00:07:37 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1B071F0093B; Sun, 6 Dec 2026 00:07:36 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796515657; bh=PYMkVFzcExSqb2rn4ir+ifTQpEO/IaDt7kTdHcMW2jo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=RJpjLnGb+TBf5aXtki7pzn9aAz+iuIBtyhTUcE876quS8zyOgnZEDBdTbxPXNuoGw VlXKIgx/49xIJbbUCONtupHV+7uzC93qNJyjXZF2sdavCYSp5nBRFrKhlhGBE5cPJp 6Noqq6uiRlk43aUP3FUqPCRF4MgtIwekNVfV/SPgUtIlzTSQm1/bpw35rC6MCAzN/L Gs7oF7NK/leggWHd4e+qNfjCYyB33BMi/Tks9rc2r+ErI1zrtQo6fyveS5koj3+PlV bf8MS2dLuvKA6URM1OTUR1DaqVQRyKcdLSE+ywSPm6JFPVgszTpCdYDGX8RXtZlDB5 RXKt59OQkdmhA== X-Cc: netdev@vger.kernel.org, nb@tipi-net.de, bcm-kernel-feedback-list@broadcom.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com X-In-Reply-To: <20261204233633.3790143-5-florian.fainelli@broadcom.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-Received-Bytes: 16617