From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Colin Foster <colin.foster@in-advantage.com>,
Jakub Kicinski <kuba@kernel.org>, Sasha Levin <sashal@kernel.org>,
steve.glendinning@shawell.net, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 6.17-6.1] smsc911x: add second read of EEPROM mac when possible corruption seen
Date: Sat, 25 Oct 2025 11:55:34 -0400 [thread overview]
Message-ID: <20251025160905.3857885-103-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>
From: Colin Foster <colin.foster@in-advantage.com>
[ Upstream commit 69777753a8919b0b8313c856e707e1d1fe5ced85 ]
When the EEPROM MAC is read by way of ADDRH, it can return all 0s the
first time. Subsequent reads succeed.
This is fully reproduceable on the Phytec PCM049 SOM.
Re-read the ADDRH when this behaviour is observed, in an attempt to
correctly apply the EEPROM MAC address.
Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
Link: https://patch.msgid.link/20250903132610.966787-1-colin.foster@in-advantage.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES
- What changed
- In `drivers/net/ethernet/smsc/smsc911x.c:2162`,
`smsc911x_read_mac_address()` now re-reads the MAC high register
(`ADDRH`) once if the first read returns 0, then uses the second
value: `drivers/net/ethernet/smsc/smsc911x.c:2168`,
`drivers/net/ethernet/smsc/smsc911x.c:2174-2177`.
- The function still reads `ADDRL` once and programs `dev->dev_addr`
via `eth_hw_addr_set()`:
`drivers/net/ethernet/smsc/smsc911x.c:2169`,
`drivers/net/ethernet/smsc/smsc911x.c:2179-2185`.
- A trace message is added for visibility when the re-read path is
taken: `drivers/net/ethernet/smsc/smsc911x.c:2175`.
- Why it matters (user-visible bug)
- The commit fixes a real-world, reproducible issue where reading the
EEPROM-backed MAC via `ADDRH` can spuriously return all zeros on the
first attempt (commit message), leading to an incorrect MAC or
fallback to a random MAC during probe.
- This behavior is seen on the Phytec PCM049 SoM; without the fix,
users may get an invalid or non-persistent MAC at boot.
- Scope and containment
- Change is confined to a single driver and a single function
(`smsc911x_read_mac_address()`), only affecting initialization-time
MAC retrieval.
- Callers invoke this function under `mac_lock` (e.g., pre-reset save
path `drivers/net/ethernet/smsc/smsc911x.c:2308-2311`, and post-
registration selection path
`drivers/net/ethernet/smsc/smsc911x.c:2533-2547`), matching the
expectation of `smsc911x_mac_read()` that the lock is held
(`drivers/net/ethernet/smsc/smsc911x.c:492-520`).
- Safety and regression risk
- The re-read only occurs when `ADDRH` initially returns 0. If a
device legitimately has a MAC with 0 in the upper two bytes (ending
in “:00:00”), the second read is harmless and preserves the same
value.
- No timing changes beyond one extra register read in a rare path; no
sleeps are introduced; locking discipline remains unchanged.
- `smsc911x_mac_read()` returns `0xFFFFFFFF` on busy/error (not 0), so
the new check won’t mask those failures; the new logic specifically
addresses the “all zeros on first `ADDRH` read” quirk.
- No API, UAPI, or architectural changes; only driver-internal logic.
Minimal chance of regression.
- Impacted flows
- Early pre-reset MAC preservation when `SMSC911X_SAVE_MAC_ADDRESS` is
set: `drivers/net/ethernet/smsc/smsc911x.c:2308-2311`.
- Normal probe-time MAC selection when none is preconfigured:
`drivers/net/ethernet/smsc/smsc911x.c:2533-2559`, where
`smsc_get_mac(dev)` invokes the updated function
`drivers/net/ethernet/smsc/smsc911x.h:404`.
- Stable backport criteria
- Fixes an initialization-time correctness bug affecting real
hardware.
- Small, targeted change with trivial logic and very low risk.
- No new features or architectural shifts; contained to one driver
file.
- Improves reliability in a way users will notice (correct MAC vs.
random/invalid).
Given the user-visible bug, minimal risk, and tight scope, this is a
good candidate for stable backport.
drivers/net/ethernet/smsc/smsc911x.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 6ca290f7c0dfb..3ebd0664c697f 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -2162,10 +2162,20 @@ static const struct net_device_ops smsc911x_netdev_ops = {
static void smsc911x_read_mac_address(struct net_device *dev)
{
struct smsc911x_data *pdata = netdev_priv(dev);
- u32 mac_high16 = smsc911x_mac_read(pdata, ADDRH);
- u32 mac_low32 = smsc911x_mac_read(pdata, ADDRL);
+ u32 mac_high16, mac_low32;
u8 addr[ETH_ALEN];
+ mac_high16 = smsc911x_mac_read(pdata, ADDRH);
+ mac_low32 = smsc911x_mac_read(pdata, ADDRL);
+
+ /* The first mac_read in some setups can incorrectly read 0. Re-read it
+ * to get the full MAC if this is observed.
+ */
+ if (mac_high16 == 0) {
+ SMSC_TRACE(pdata, probe, "Re-read MAC ADDRH\n");
+ mac_high16 = smsc911x_mac_read(pdata, ADDRH);
+ }
+
addr[0] = (u8)(mac_low32);
addr[1] = (u8)(mac_low32 >> 8);
addr[2] = (u8)(mac_low32 >> 16);
--
2.51.0
next prev parent reply other threads:[~2025-10-25 16:14 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:53 ` [PATCH AUTOSEL 6.17-6.1] net: phy: fixed_phy: let fixed_phy_unregister free the phy_device Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-5.4] ipv6: np->rxpmtu race annotation Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-6.6] net: stmmac: Correctly handle Rx checksum offload errors Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-6.12] PCI/ERR: Update device error_state already after reset Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-6.1] selftests: net: replace sleeps in fcnal-test with waits Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-5.4] selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8 Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-6.12] bnxt_en: Add Hyper-V VF ID Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.4] selftests/net: Ensure assert() triggers in psock_tpacket.c Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.4] net: When removing nexthops, don't call synchronize_net if it is not necessary Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17] netlink: specs: fou: change local-v6/peer-v6 check Sasha Levin
2025-10-25 15:55 ` Sasha Levin [this message]
2025-10-28 12:53 ` [PATCH AUTOSEL 6.17-6.1] smsc911x: add second read of EEPROM mac when possible corruption seen Colin Foster
2025-11-04 13:55 ` Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.4] net: sh_eth: Disable WoL if system can not suspend Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17] bnxt_en: Add fw log trace support for 5731X/5741X chips Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.10] udp_tunnel: use netdev_warn() instead of netdev_WARN() Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] tcp: Update bind bucket state on port release Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17-6.1] net: bridge: Install FDB for bridge MAC on VLAN 0 Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] selftest: net: Fix error message if empty variable Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] net: phy: dp83640: improve phydev and driver removal handling Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] selftests: Disable dad for ipv6 in fcnal-test.sh Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-6.6] net: phy: clear link parameters on admin link down Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17] net: Prevent RPS table overwrite of active flows Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.10] r8169: set EEE speed down ratio to 1 Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] rds: Fix endianness annotation for RDS_MPATH_HASH Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-6.12] net: stmmac: est: Drop frames causing HLBS error Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-6.12] net: ipv4: allow directed broadcast routes to use dst hint Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-6.12] net: dsa: felix: support phy-mode = "10g-qxgmii" Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] net: ipv6: fix field-spanning memcpy warning in AH output Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-6.12] net: dsa: microchip: Set SPI as bus interface during reset for KSZ8463 Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17] net/mlx5e: Prevent entering switchdev mode with inconsistent netns Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-6.12] microchip: lan865x: add ndo_eth_ioctl handler to enable PHY ioctl support Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17] Octeontx2-af: Broadcast XON on all channels Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17] hinic3: Queue pair endianness improvements Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-6.12] tcp: use dst_dev_rcu() in tcp_fastopen_active_disable_ofo_check() Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17] selftests: net: lib.sh: Don't defer failed commands Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17] ptp_ocp: make ptp_ocp driver compatible with PTP_EXTTS_REQUEST2 Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-5.10] selftests: traceroute: Use require_command() Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-5.10] net: stmmac: Check stmmac_hw_setup() in stmmac_resume() Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-5.10] ipv6: Add sanity checks on ipv6_devconf.rpl_seg_enabled Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.1] net/mlx5e: Don't query FEC statistics when FEC is disabled Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] bng_en: make bnge_alloc_ring() self-unwind on failure Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-5.4] page_pool: Clamp pool size to max 16K pages Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] selftests: drv-net: hds: restore hds settings Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-6.12] selftests: traceroute: Return correct value on failure Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-5.4] bridge: Redirect to backup port when port is administratively down Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-6.12] net: devmem: expose tcp_recvmsg_locked errors Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] net: phy: clear EEE runtime state in PHY_HALTED/PHY_ERROR Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-6.12] selftests: mptcp: join: allow more time to send ADD_ADDR Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-5.10] net: phy: marvell: Fix 88e1510 downshift counter errata Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] selftests: net: make the dump test less sensitive to mem accounting Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-5.4] net: nfc: nci: Increase NCI_DATA_TIMEOUT to 3000 ms Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17] hinic3: Fix missing napi->dev in netif_queue_set_napi Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-5.4] selftests: Replace sleep with slowwait Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-6.12] inet_diag: annotate data-races in inet_diag_bc_sk() Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-5.15] page_pool: always add GFP_NOWARN for ATOMIC allocations Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-5.4] net/cls_cgroup: Fix task_get_classid() during qdisc run Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-5.15] ptp: Limit time setting of PTP clocks Sasha Levin
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=20251025160905.3857885-103-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=colin.foster@in-advantage.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=steve.glendinning@shawell.net \
/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;
as well as URLs for NNTP newsgroup(s).