From: netdev-bot+sashiko@kernel.org
To: irogers@google.com
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
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 [thread overview]
Message-ID: <179540977827.3135.7089774240645592681@kernel.org> (raw)
In-Reply-To: <20261122045326.19641-1-irogers@google.com>
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
prev parent reply other threads:[~2026-11-23 4:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 4:53 [PATCH net-next v2] tg3: Propagate PHY reset retry failures in tg3_phy_reset_5703_4_5() Ian Rogers
2026-11-23 4:56 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179540977827.3135.7089774240645592681@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=elkin@google.com \
--cc=irogers@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox