]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smsc911x: add second read of EEPROM mac when possible corruption seen
authorColin Foster <colin.foster@in-advantage.com>
Wed, 3 Sep 2025 13:26:10 +0000 (08:26 -0500)
committerJakub Kicinski <kuba@kernel.org>
Fri, 5 Sep 2025 02:09:44 +0000 (19:09 -0700)
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>
drivers/net/ethernet/smsc/smsc911x.c

index 6ca290f7c0dfb57abdacd7dc508cdd536a4c49a4..3ebd0664c697f7e9b6426359eb18f056375f0dac 100644 (file)
@@ -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);