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=1796515657; b=K/vQTheIE2ztAkYk3xE6mirVlTVPcXyBFdB0gMlAG+O4k4Gt7bj8hh8f+ScOvisIyKr1 f519VeYQXlbfmvHbKoCB+ebq+MfxHc/s0jLHcRqv0dx0H9/fxtTg8xux5xD5881kXnnbf aRDWNjc6/Exnlh0W/iGogMin92s0HTpH+f82yRq2MbFGbTZduY/my33emyTmQmeWbW8Bm E47G7CfR1719MuebYfXZDqZ9KN8Ghf4IBWpkEKyq36yVI0YZQ7mcvkfhPZHPWewrCD7aC pDWHi1VyQWuMm14hXI1MDxEgl0lAcMv0k3q3mcRTkJtAWr3jTxmG45ZC3eEoB4MVWFA== 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== 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 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 ; Sun, 6 Dec 2026 00:07:37 +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=RJpjLnGb Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1B071F0093B; Sun, 6 Dec 2026 00:07:36 +0000 (UTC) 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== Subject: Re: [PATCH net-next v2 4/4] net: phy: broadcom: Recover BCM54210E from aborted cable tests From: netdev-bot+sashiko@kernel.org To: florian.fainelli@broadcom.com 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 Date: Sun, 06 Dec 2026 00:07:36 +0000 Message-ID: <179651565647.3148.14123507342197810039@kernel.org> In-Reply-To: <20261204233633.3790143-5-florian.fainelli@broadcom.com> References: <20261204233633.3790143-5-florian.fainelli@broadcom.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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