🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20717

Re: [PATCH net-next v2] tg3: Propagate PHY reset retry failures in tg3_phy_reset_5703_4_5()

#20717
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 04:56
160 lines
13173 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

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

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).

- [High] The new post-loop `if (err) return err;` in
  tg3_phy_reset_5703_4_5()…
- [Medium] The commit message says the new post-loop `if (err) return
  err;` makes "dead MDIO hardware fail probe cleanly via…

--

tg3: Propagate PHY reset retry failures in tg3_phy_reset_5703_4_5()

This patch stores the return value of both tg3_readphy() calls in the
retry loop of tg3_phy_reset_5703_4_5(). If the loop ends without
success, the function now returns that error. It also zero-initializes
phy9_orig to silence a Clang -Wconditional-uninitialized warning.

> Record err on both tg3_readphy() calls and return err if the retry
> loop finishes with an error so dead MDIO hardware fails probe cleanly
> via tg3_phy_probe(), and zero-initialize phy9_orig since Clang's

[Severity: Medium]
Is this description accurate? In tg3_get_invariants(), an error from
tg3_phy_probe() is logged and probe keeps going:

drivers/net/ethernet/broadcom/tg3.c:tg3_get_invariants() {
    ...
	err = tg3_phy_probe(tp);
	if (err) {
		dev_err(&tp->pdev->dev, "phy probe failed, err %d\n", err);
		/* ... but do not return immediately ... */
		tg3_mdio_fini(tp);
	}
    ...
}

So the netdev is still registered.

Dead MDIO also looks like it is caught before the retry loop runs.
tg3_phy_reset() already returns -EBUSY when the MII_BMSR reads fail:

	err  = tg3_readphy(tp, MII_BMSR, &val);
	err |= tg3_readphy(tp, MII_BMSR, &val);
	if (err != 0)
		return -EBUSY;

tg3_bmcr_reset() at the top of the loop also returns -EBUSY on any BMCR
write or read failure.

That leaves tg3_phy_write_and_check_testpat() failing ten times as the
main case that now gets propagated. This includes the readback mismatch
branch, which is only reached after the MDIO reads succeeded:

			if (low != test_pat[chan][i] ||
			    high != test_pat[chan][i+1]) {
				tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000b);
				tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4001);
				tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4005);

				return -EBUSY;
			}

Before this patch, that error was overwritten by
err = tg3_phy_reset_chanpat(tp) and so was effectively tolerated.

At probe time, the new error makes tg3_phy_probe() return straight after
tg3_phy_reset(). That skips tg3_phy_set_wirespeed() and the
tg3_phy_autoneg_cfg() / BMCR_ANENABLE | BMCR_ANRESTART setup, but the
device still registers.

Could the commit message describe this behavior change instead?

> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index 95827df4cf6a1..4d375328621cc 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c

[ ... ]

> @@ -2587,6 +2589,9 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
>  			break;
>  	} while (--retries);
>  
> +	if (err)
> +		return err;
> +
>  	err = tg3_phy_reset_chanpat(tp);
>  	if (err)
>  		return err;

[Severity: High]
Can this early return leave the BCM5703/5704/5705 PHY in its DSP test
configuration?

Before the test pattern check, the loop sets the PHY up like this:

		reg32 |= 0x3000;
		tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
		...
		tg3_writephy(tp, MII_BMCR,
			     BMCR_FULLDPLX | BMCR_SPEED1000);
		...
		tg3_writephy(tp, MII_CTRL1000,
			     CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER);

		err = tg3_phy_toggle_auxctl_smdsp(tp, true);
		...
		/* Block the PHY control access.  */
		tg3_phydsp_write(tp, 0x8005, 0x0800);

Before this patch, the code after the loop always ran and undid this
setup:

	tg3_phydsp_write(tp, 0x8005, 0x0000);
	...
	tg3_phy_toggle_auxctl_smdsp(tp, false);

	tg3_writephy(tp, MII_CTRL1000, phy9_orig);
	...
	reg32 &= ~0x3000;
	tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);

The new return skips all of this in two cases.
tg3_phy_write_and_check_testpat() may fail on all ten iterations, or the
MII_TG3_EXT_CTRL or MII_CTRL1000 read may fail on the last iteration.
tg3_phy_reset() then passes the error up and skips its out: errata
fixups.

Most callers ignore the return value of tg3_phy_reset(). For example,
tg3_reset_hw() does:

	if (reset_phy)
		tg3_phy_reset(tp);

tg3_setup_copper_phy() and tg3_set_eee() do the same. On those paths the
driver carries on as if the reset worked.

Later autoneg setup rewrites BMCR, ADVERTISE and CTRL1000. However,
nothing else on the 5703/4/5 path appears to clear the 0x3000 bits in
MII_TG3_EXT_CTRL or unblock DSP 0x8005.

Would the interface then come up with the PHY transmitter disabled and
unable to get a link?

In the test pattern mismatch case the MDIO bus is working, so the
skipped restore writes would have reached the PHY. Could the restore
sequence run first and the function return err afterwards? Another
option is to keep the old fall-through for the mismatch case.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122045326.19641-1-irogers%40google.com
Technical Details
Message-ID: <179540977827.3135.7089774240645592681@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369035-linux-kernel-netdev=dewy.ru
References: <20261122045326.19641-1-irogers@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369035-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2] tg3: Propagate PHY reset retry failures in
 tg3_phy_reset_5703_4_5()
Date: Mon, 23 Nov 2026 04:56:18 +0000
Organization: Usenet Network
Message-ID: <179540977827.3135.7089774240645592681@kernel.org>
References: <20261122045326.19641-1-irogers@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3792871"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Q53GsQvr3iqWoeOSzb2lrRQe/GU= sha256:9Vlr5sahK67+6P0lc9/LOLl8SgaK36puY9gFJpOLrQc=
	sha1:d4/zCMaqtPrQrJVkkY/4oaMQAWk= sha256:Tgh6sV8QSOf4btwtLrGZNxP4RbNCr9p3pq3ZLzk8eX0=
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 717BC125D8E; Mon, 23 Nov 2026 07:56:46 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, 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 p1WGNeZAHCrK;
	Mon, 23 Nov 2026 07:56:38 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-369035-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 7C410125D8D; Mon, 23 Nov 2026 07:56:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id F2B456021AB; Mon, 23 Nov 2026 04:56:26 +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=1795409786;
	b=EXxLQ9WOuVJxG83saeY1ifCn3zfQXYO+iePYBRra+LOan9SfLq94EZ5Lld68MtuviFe6
	 8U4V1BGHXFcHmtqyI/dnmqrULdXVouo9+mzo+ULkYPauNqei6L5f9cmFjXGCmtW6GeLpI
	 CJI+6O3weEvZd7oyUrOaI30hvdc0A3evnGNCtHXl4HPOCEvR4qM3C9fiK+jhumNvP4UEv
	 L8bj7JD22M77Yv2dqSjevX8ABEwSsD8tQiV5PBhzOIAmdx2yBavflCbCVntIBqafMZAdJ
	 q4itRvCG4xMSv0OiITSSNmjISg7ookBTh5P0ELfDYQJbXNyqWjST8n141qT8tuuBKJg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795409786;
	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=UIG2FhqvVZg8GqYMeF+rDHlTbJXwBkD1569qBzasF1c=;
	b=vFBZTBFB9IEGfNehvo/fTMuxs6v2njyabfKgQjtXSeKoQAWbHryQVlBwL5h/TJ5r4VS4
	 Mcd4N60fWyYLs/0HVGge9eru0wlP2kFR8zpk92UnpwGS7astaOasW7HvGkR8h1THLX2by
	 g42hQiduURBu09vY3TKRpYy12lMdTFqn67NAKny0MzV8WR6+C7aHmFKeFtPIOKmFHg1hu
	 3X7AS96IIbVD4+srdZ8B+dl5ywhSAPDlg9wJTBkF0PDGlAHaCWHuUjRj007jIC3bS/la/
	 U7VyL0VboWxdkEK9BDNgAAuatJkf3wkQTPGtdpG2YDkGfl5+rr3cZRAV3QYsvOirUVA==
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=b3LQ80h5;
	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 5520F606A32A;
	Mon, 23 Nov 2026 04:56:26 +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=b3LQ80h5
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=1795409780;
	b=wE7Rn13RlmQUpwvhS2zaTln2t5+7fkU7FzQc3S/wWaJoYRpREdODiQjUrUN6hsUBI535
	 cNvqy56HxQMhicle5GJtUxUcrJzwp/Gc/95ElTfsczfu16NjiocJLBw9bMoTqsRDT+r9B
	 skjeogk9vjr0xQJN0GR3Re/MDWGcE64nPI7AOqFB10kDrNp6l4dBa27e5uFca4Mo/p6qT
	 X+e+HnuvbK1jnJ8fZrAzkTnEBwLedq87CMgF6NQuTZ5p7nhj7gYseOZpLk+SFqOUjXDW0
	 gpGo+B6T80tp/jkBqlbbKneeMTeRh3wlo81Dt98RpnzNr5MGQD/yEgHtXfPU7xQh8WA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795409780;
	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=UIG2FhqvVZg8GqYMeF+rDHlTbJXwBkD1569qBzasF1c=;
	b=4k/WJqPr5TN9i3ylGPCXz2sR5XMgVM/CrBEZ7ZT9D1IUGD61WE2mY0Rjo3bDrHKet6Ql
	 Xlpp6ygOEWB1Z6vbVpE94Spi0wToPJTOAzkcc2IQ0o51ESEHT+6ST8iJSa4UuTPKIhXoh
	 6kLu7PQrI820aEkbvjsg/PYRfzhVxAgLFqxEl2mKDG6CmqdooiVtAgU6YpPIvsPpmiXcu
	 qtxPjndMHKe4o/QigWIkg9BbEEAPSomMfiN9q71DspfhH2cujWeaDcMQpCK1cRF4HK0gG
	 zkLdEPsasFapvO94RK79P/VHxELySt5wzq8fstaUhOKLysrHNQQJP7455w3qApQxoTQ==
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=b3LQ80h5;
	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 7109D606A31E;
	Mon, 23 Nov 2026 04:56:20 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD84D1F000C6;
	Mon, 23 Nov 2026 04:56:18 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795409779;
	bh=UIG2FhqvVZg8GqYMeF+rDHlTbJXwBkD1569qBzasF1c=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=b3LQ80h5WECh0NRW+66bzA1M06CZo48I+KvPUvbcph+44tdAcFuYxvCnYQ9qypngR
	 VpgyWaNjROV0zkUi/WGuyWHQMfTolp5KAPVyaZP1naA1btnCYb3Dq/AVc/nrDm6KeS
	 DlFvE9ObeqRK0H8FoYVNp95fN2Nd9hAhGWTXDOoV5qaX39s0cDVifhXzIuAlvjlctg
	 EJVrXR80ggtEt1hEOPAdR+24YVzaPoWhiYIPEilcqu2vVaHdFA2iQvZaMLpbbC90FO
	 JNtUpwqh8qR9ZF7GzW3oM4614SY8zMaTGruYE/qyFnZpkQkgxWaF9ggUlQWB+u182T
	 2Y3g3n67n1GDg==
X-Cc: pavan.chebbi@broadcom.com, michael.chan@broadcom.com,
 andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org, llvm@lists.linux.dev, elkin@google.com
X-In-Reply-To: <20261122045326.19641-1-irogers@google.com>
X-sashiko-severity: High
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