]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tg3: replace placeholder MAC address with device property
authorPaul SAGE <paul.sage@42.fr>
Sat, 14 Mar 2026 21:54:30 +0000 (03:24 +0530)
committerJakub Kicinski <kuba@kernel.org>
Tue, 17 Mar 2026 03:22:29 +0000 (20:22 -0700)
On some systems (e.g. iMac 20,1 with BCM57766), the tg3 driver reads
a default placeholder mac address (00:10:18:00:00:00) from the
mailbox. The correct value on those systems are stored in the
'local-mac-address' property.

This patch, detect the default value and tries to retrieve
the correct address from the device_get_mac_address
function instead.

The patch has been tested on two different systems:
- iMac 20,1 (BCM57766) model which use the local-mac-address property
- iMac 13,2 (BCM57766) model which can use the mailbox,
    NVRAM or MAC control registers

Tested-by: Rishon Jonathan R <mithicalaviator85@gmail.com>
Co-developed-by: Vincent MORVAN <vinc@42.fr>
Signed-off-by: Vincent MORVAN <vinc@42.fr>
Signed-off-by: Paul SAGE <paul.sage@42.fr>
Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20260314215432.3589-1-atharvatiwarilinuxdev@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/tg3.c

index 2328fce336447eb4a796f9300ccc0ab536ff0a35..21a5dd342724423afd90d92c3beec18634767f10 100644 (file)
@@ -17029,6 +17029,13 @@ static int tg3_get_invariants(struct tg3 *tp, const struct pci_device_id *ent)
        return err;
 }
 
+static int tg3_is_default_mac_address(u8 *addr)
+{
+       static const u8 default_mac_address[ETH_ALEN] = { 0x00, 0x10, 0x18, 0x00, 0x00, 0x00 };
+
+       return ether_addr_equal(default_mac_address, addr);
+}
+
 static int tg3_get_device_address(struct tg3 *tp, u8 *addr)
 {
        u32 hi, lo, mac_offset;
@@ -17102,6 +17109,10 @@ static int tg3_get_device_address(struct tg3 *tp, u8 *addr)
 
        if (!is_valid_ether_addr(addr))
                return -EINVAL;
+
+       if (tg3_is_default_mac_address(addr))
+               return device_get_mac_address(&tp->pdev->dev, addr);
+
        return 0;
 }