🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26646

Re: [PATCH net-next 3/3] net: phy: broadcom: Time out a stuck cable test

#26646
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 01:29
189 lines
14855 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

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] The patch resets the PHY only in the timeout branch of
  bcm54xx_cable_test_get_status() (drivers/net/phy/broadcom.c:1523),…
- [Low] The timeout branch in bcm54xx_cable_test_get_status()
  (drivers/net/phy/broadcom.c:1523) adds a runtime BMCR_RESET for…
- [Low] When a cable test times out, bcm54xx_cable_test_get_status()
  (drivers/net/phy/broadcom.c:1515-1526) resets the PHY with…

--

net: phy: broadcom: Time out a stuck cable test

This commit adds a 5 second timeout to bcm54xx_cable_test_get_status().
If the ECD run has not finished by then, the PHY is soft-reset and
-ETIMEDOUT is returned, so phylib aborts the test and reruns
config_init().

> diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
> index 19b97beb8be8d..776a88caae9ba 100644
> --- a/drivers/net/phy/broadcom.c
> +++ b/drivers/net/phy/broadcom.c

[ ... ]

> @@ -1486,21 +1491,40 @@ static int bcm54xx_cable_test_start(struct phy_device *phydev)

[ ... ]

>  static int bcm54xx_cable_test_get_status(struct phy_device *phydev,
>  					 bool *finished)
>  {
> +	struct bcm54xx_phy_priv *priv = phydev->priv;
>  	int ret;
>  
>  	ret = bcm_phy_cable_test_get_status(phydev, finished);
> -	if (ret < 0 || !*finished)
> +	if (ret < 0)
>  		return ret;
>  
> +	if (!*finished) {
> +		if (time_before(jiffies, priv->cable_test_timeout))
> +			return 0;
> +
> +		/* A stuck ECD run cannot be stopped through ECD_CTRL, only a
> +		 * reset gets the PHY back. phylib reruns config_init() when
> +		 * it aborts the test.
> +		 */
> +		genphy_soft_reset(phydev);

[Severity: Medium]
Is this the only place that resets the PHY after an ECD run has started?
Only the polling state machine reaches it, and only after the 5 second
timeout expires.

Two other paths in drivers/net/phy/phy.c leave PHY_CABLETEST. The first
is phy_stop(), for example "ip link set dev X down" while a test is
running:

	if (phydev->state == PHY_CABLETEST) {
		phy_abort_cable_test(phydev);
		netif_testing_off(dev);
	}

The second is _phy_state_machine(), when cable_test_get_status() takes
the ret < 0 path above:

		err = phydev->drv->cable_test_get_status(phydev, &finished);
		if (err) {
			phy_abort_cable_test(phydev);
			netif_testing_off(dev);
			state_work = PHY_STATE_WORK_ANEG;
			phydev->state = PHY_UP;
			break;
		}

phy_abort_cable_test() only calls ethnl_cable_test_finished() and
phy_init_hw(). The BCM54210E entry in broadcom_drivers[] has no
.soft_reset callback, so phy_init_hw() skips the reset and goes straight
to bcm54xx_config_init().

bcm54xx_config_init() then calls bcm54xx_adjust_rxrefclk(). That sets
BCM54XX_SHD_APD_EN again when clk125 is disabled or
PHY_BRCM_AUTO_PWRDWN_ENABLE is set. At that point ECD_CTRL still has RUN
and BREAK_LINK set from _bcm_phy_cable_test_start().

The comment in bcm54xx_cable_test_start() says an ECD run never finishes
on a line without energy while auto power-down is enabled. The new
comment here says only a reset clears a stuck run.

Could aborting a test partway through therefore create the same stuck
state this patch tries to recover from?

After the abort the state is PHY_UP or PHY_HALTED. Nothing polls
cable_test_get_status() again, so this timeout never fires.

On the phy_stop() path with WoL enabled, bcm54xx_suspend() returns
before it writes BMCR_PDOWN:

	if (phydev->wol_enabled)
		return bcm54xx_set_wakeup_irq(phydev, true);

bcm54xx_resume() soft-resets only when PHY_BRCM_IDDQ_SUSPEND is set. A
down/up cycle would therefore not clear the stuck run either. The error
path goes straight to PHY_UP without any suspend.

This depends on two hardware behaviours I could not verify. One is that
the ECD run stays stuck through config_init() with APD re-enabled. The
other is that the later BMCR writes from config_aneg do not clear it.

Could the reset go somewhere that every abort passes through? One option
is ".soft_reset = genphy_soft_reset" in the BCM54210E entry. Another is
a reset in bcm54xx_config_init() when ECD_CTRL still reads in progress.

[Severity: Low]
Can this reset wipe state that config_init() does not restore? The
comment says phylib reruns config_init() when it aborts the test. That
is true, through phy_abort_cable_test()->phy_init_hw()->
bcm54xx_config_init(). But config_init() only restores the settings it
makes itself.

An earlier commit in this series, "net: phy: broadcom: Implement cable
test initialization", left the soft reset out of the reference ECD
sequence for exactly this reason:

drivers/net/phy/bcm-phy-lib.c:__bcm_phy_cable_test_init() {
    ...
	/* Disable ECD to load parameters. Note that the reference sequence
	 * soft-resets the PHY first, but that is only needed for the Broadcom
	 * DVT process and would discard the configuration done at
	 * config_init() time.
	 */
    ...
}

Wake-on-LAN, for example, is written directly to hardware by
bcm54xx_phy_set_wol()->bcm_phy_set_wol(), and no copy is kept.
bcm54xx_config_init() only reads and acknowledges
BCM54XX_WOL_INT_STATUS.

Suppose BMCR_RESET clears the WoL registers on BCM54210E. Would WoL set
with "ethtool -s ethX wol g" then stop working after a timed-out cable
test, with no message, while the kernel still reports it as enabled?

I could not confirm this on the hardware. bcm54xx_resume() already
soft-resets on PHY_BRCM_IDDQ_SUSPEND platforms without reprogramming
WoL, which may mean the registers survive a reset.

The commit message also doesn't mention this side effect of the reset.
Could it be added?

> +
> +		return -ETIMEDOUT;
> +	}

[Severity: Low]
Should this timeout branch log something? The return value of
genphy_soft_reset() is ignored, and nothing is printed.

_phy_state_machine() handles -ETIMEDOUT by calling
phy_abort_cable_test(). That sends the notification created by
ethnl_cable_test_alloc() with ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED
and no pair results, and phylib then drops the error code.

As a result, "ethtool --cable-test" reports a completed test with no
results. Nothing in dmesg says the ECD run hung or that the PHY was
reset.

Would a phydev_warn() here help? The commit message also doesn't say
what the user sees in this case.

> +
>  	/* Put auto power-down back the way config_init() left it */
>  	bcm54xx_adjust_rxrefclk(phydev);

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203004802.85707-1-florian.fainelli%40broadcom.com
Technical Details
Message-ID: <179634776897.3146.1850367010981287121@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376953-linux-kernel-netdev=dewy.ru
References: <20261203004802.85707-4-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!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376953-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 3/3] net: phy: broadcom: Time out a stuck cable test
Date: Fri, 04 Dec 2026 01:29:28 +0000
Organization: Usenet Network
Message-ID: <179634776897.3146.1850367010981287121@kernel.org>
References: <20261203004802.85707-4-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="2647543"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:g2Irt/dNjemKejibJyxkQNfzpw8= sha256:KgMZu1xkCdUfqTfH4mYWmhcsQYyRSvZZ5Chyhzn+8mM=
	sha1:lYX5XRLl8LoN8DWevzrAE54b+Fo= sha256:8DibBw5jyLmxI3gszRJUPFLqwKL6AI9UlTz7xjW1h3Q=
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 1E93D114472; Fri,  4 Dec 2026 04:29:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.739
X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.24, 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,
	URIBL_BLOCKED=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 3fLosQAI2O02;
	Fri,  4 Dec 2026 04:29:44 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376953-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 2FA07117A9D; Fri,  4 Dec 2026 04:29:35 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 042E324043; Fri,  4 Dec 2026 01:29:34 +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=1796347771;
	b=vrdEZXjIBD0XOM7VD13N88vHXwxFKUKbxbYGp39q3fa6S2Jakb7hA9/g8hyny3OxMA6e
	 E7CSgSWMZmRqPXxzpx2QJiiL7aAdrqm+WVsW7EAWhk5M0wkoJVFu1TiWwkOn04+gMNI3H
	 +mFIL3+nnvt9wM+zrr3TocUoxcpLOMzQ0DqqzGzYwhxDMGqY/s1Pk2iH+vOgxBhAi+OWl
	 cB3wWf8byzJpef6UbJBgC3NlPYD2H5kSoRMZ9VK2S7VelBdrO1uELtMC7gWYWBZtnrRI+
	 iFRLDrznaNSnUh1yBKKqJ6ISxlvnO/N1OuOBPpntm8eIeCRjielJ+cxzGhWjSiTUglw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796347771;
	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=GSSxlDFSMf3+zUdDmDP8uGZTosAyBJ5wcF4qfZuCl58=;
	b=DpdMhNMiEonagzEioytu0ars0qLajEwwR1cttBjc9i38j9uE7Xi8oBc5yB7fEsQ1ERlU
	 E1o47yYgreyaZeAlxnX4ovNfnZK/bn28FisWytI+cMpnRsWGAeqZMCJP6htAFfLb64fi3
	 j6If885VCcLL2IFlSBjsinmy4TGPzD6wCXYCPyPy7/T6MrRvZXdOb9LBlSXxk9xbUS9ft
	 tGd8c1aTC9xlZokRXIpcpVdtiACahiHR1fksJjpycWE7nqEenEkMBqKY9rJixs08j8K/b
	 NEHzfPwmpRhuKBY9e4l4PGTZPYRpTH+b29QtYVeBjeTnk0UE+1TpGL0aUaJojXCkgBg==
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=anV+LcSL;
	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 03F8E606A339;
	Fri,  4 Dec 2026 01:29:31 +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=anV+LcSL
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=1796347770;
	b=N8wpvf7sshrjwxX2oYRrWDmNjt8ILxJdl72/KYrDr3YrR1AVdHkABymKDkf9yj6l2oSx
	 d3wljBXFkj2xnReHg6ogSC5ItWt3PP64ovZart16re6uKkBoXvEfYCyqbHB2Mdpmz06fT
	 kAPTR1A07WSYrw70IdGkJ+NPhL7pw/ipEgKB2fajysjGG9Q2R8YO9fPG7PXjQBPcOdlYz
	 POtMOCFLb5UDCnGJzp7TXL9detZApLWclTyAWZ8KgLamoZJehgKXbm6/ybQGuQE9iN3Bi
	 vtlXE7rl23aDhjztXmUtIcDDw47H1/lE1py3L5s7GrJMoPOUpbKxg3d9eTskSYhjJlw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796347770;
	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=GSSxlDFSMf3+zUdDmDP8uGZTosAyBJ5wcF4qfZuCl58=;
	b=rDxa9u3AgyIuEw9uhYzNtF10aZd0qATkQTA1GPwGG/zwNTXRwI1V5hRQS+ZM467jLtl9
	 AnhFgcEYWVs1d+m4aIdGX3fBHLelupQhRgJw8EebYrAt5MA6SN99iEJThAECRpLWSasPD
	 6zSUGPnxw2/EyFk9Vdz07BVEpB7rN8djZLnFJK4WowPB2Uh40JkkxEoegg+672dnMcSj2
	 XTZa04ewo3AyjGTtQ3cnJ9GuRqucqh2QyONv2vPXZlAF3XooPltVBaoFEaeAmUoxGyrbl
	 5WhCrpDrdFxVybFJgOMfRAbZzwgDp5590ME4wTMaBSuZBb3vDJHa/qnSy3ZkbGXlC+Q==
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=anV+LcSL;
	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 268F7606A33F
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 01:29:30 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62B531F00897;
	Fri,  4 Dec 2026 01:29:29 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796347770;
	bh=GSSxlDFSMf3+zUdDmDP8uGZTosAyBJ5wcF4qfZuCl58=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=anV+LcSLOn1juGyxy3quaDKOsU02V9nmm71DrlO1wA32czQPO6XQvkavikL21cT1M
	 f/UP3wNnBXBlkJLpfZIzgEopsRnfQ0J6bJPj1wmB+7RgDXN2K/5lgMIF2N5QsP6mk1
	 QjLFzl5ytuEoKWquuXZS8VDhxkfJGxRRE3CD+GLw/dEDon19MOaaCPcM9DGn3h9OvZ
	 E5zbpu79qINz8o/d6zbVArLO2R48z4m/GMjdyTEXEtT5ZIPUDnTlaGpgz9iweacXWT
	 W6CVije7MWMqEk0fAJdCKSq21C928g7+/XYfscS47ywh9U7Qnp5qcsW3xAoGxqa1Gc
	 hstSL9i/S869w==
X-Cc: netdev@vger.kernel.org, nb@tipi-net.de, f.fainelli@gmail.com,
 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: <20261203004802.85707-4-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