From: Ian Rogers <irogers@google.com>
To: Pavan Chebbi <pavan.chebbi@broadcom.com>,
Michael Chan <michael.chan@broadcom.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Elkin Cruz <elkin@google.com>,
Ian Rogers <irogers@google.com>
Subject: [PATCH net-next v2] tg3: Propagate PHY reset retry failures in tg3_phy_reset_5703_4_5()
Date: Sat, 21 Nov 2026 20:53:26 -0800 [thread overview]
Message-ID: <20261122045326.19641-1-irogers@google.com> (raw)
In tg3_phy_reset_5703_4_5(), the 10-iteration retry loop discards the
return value of both tg3_readphy() calls on continue and never checks
err after the loop terminates. If MDIO reads fail across all 10
retries, phy9_orig is never initialized before being written back to
MII_CTRL1000; if tg3_phy_write_and_check_testpat() fails across all 10
retries, the function silently continues as if the PHY test pattern
succeeded.
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
value-insensitive -Wconditional-uninitialized check does not correlate
the earlier continue on err != 0 with the post-loop 'if (err)' check.
Found via Clang -Wconditional-uninitialized on an x86_64 allyesconfig
build with AI coding assistant help. Verified by building
drivers/net/ethernet/broadcom/tg3.o with LLVM=1 W=1 (-Werror) and
-Wconditional-uninitialized; not runtime-tested on BCM5703/5704/5705
hardware.
Signed-off-by: Ian Rogers <irogers@google.com>
---
Notes:
v2:
- Target net-next and drop the Fixes tag (Andrew Lunn).
- Also zero-initialize phy9_orig so Clang's value-insensitive
-Wconditional-uninitialized check sees no uninitialized CFG path across
the earlier 'continue'.
v1: https://lore.kernel.org/r/20261119171021.1535172-1-irogers@google.com
drivers/net/ethernet/broadcom/tg3.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 95827df4cf6a..4d375328621c 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -2544,7 +2544,7 @@ static int tg3_phy_reset_chanpat(struct tg3 *tp)
static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
{
- u32 reg32, phy9_orig;
+ u32 reg32, phy9_orig = 0;
int retries, do_phy_reset, err;
retries = 10;
@@ -2558,7 +2558,8 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
}
/* Disable transmitter and interrupt. */
- if (tg3_readphy(tp, MII_TG3_EXT_CTRL, ®32))
+ err = tg3_readphy(tp, MII_TG3_EXT_CTRL, ®32);
+ if (err)
continue;
reg32 |= 0x3000;
@@ -2569,7 +2570,8 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
BMCR_FULLDPLX | BMCR_SPEED1000);
/* Set to master mode. */
- if (tg3_readphy(tp, MII_CTRL1000, &phy9_orig))
+ err = tg3_readphy(tp, MII_CTRL1000, &phy9_orig);
+ if (err)
continue;
tg3_writephy(tp, MII_CTRL1000,
@@ -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;
--
2.56.1.750.gf70dc682cf-goog
next reply other threads:[~2026-11-22 4:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 4:53 Ian Rogers [this message]
2026-11-23 4:56 ` [PATCH net-next v2] tg3: Propagate PHY reset retry failures in tg3_phy_reset_5703_4_5() netdev-bot+sashiko
2026-11-25 0:40 ` Ian Rogers
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=20261122045326.19641-1-irogers@google.com \
--to=irogers@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=elkin@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.