]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: 8922a: set random mac if efuse contains zeroes
authorJose Ignacio Tornos Martinez <jtornosm@redhat.com>
Wed, 26 Nov 2025 09:18:56 +0000 (10:18 +0100)
committerPing-Ke Shih <pkshih@realtek.com>
Tue, 23 Dec 2025 03:42:38 +0000 (11:42 +0800)
I have some rtl8922ae devices with no permanent mac stored in efuse.

It could be properly saved and/or configured from user tools like
NetworkManager, but it would be desirable to be able to initialize it
somehow to get the device working by default.

So, in the same way as with other devices, if the mac address read from
efuse contains zeros, a random mac address is assigned to at least allow
operation, and the user is warned about this in case any action needs to
be considered.

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20251126091905.217951-1-jtornosm@redhat.com
drivers/net/wireless/realtek/rtw89/rtw8922a.c

index 4437279c554b096167072b33eb343b78e8f14004..4bcf20612a45538babd425b0fc48f08b0a506aa9 100644 (file)
@@ -636,16 +636,30 @@ static int rtw8922a_read_efuse_rf(struct rtw89_dev *rtwdev, u8 *log_map)
 static int rtw8922a_read_efuse(struct rtw89_dev *rtwdev, u8 *log_map,
                               enum rtw89_efuse_block block)
 {
+       struct rtw89_efuse *efuse = &rtwdev->efuse;
+       int ret;
+
        switch (block) {
        case RTW89_EFUSE_BLOCK_HCI_DIG_PCIE_SDIO:
-               return rtw8922a_read_efuse_pci_sdio(rtwdev, log_map);
+               ret = rtw8922a_read_efuse_pci_sdio(rtwdev, log_map);
+               break;
        case RTW89_EFUSE_BLOCK_HCI_DIG_USB:
-               return rtw8922a_read_efuse_usb(rtwdev, log_map);
+               ret = rtw8922a_read_efuse_usb(rtwdev, log_map);
+               break;
        case RTW89_EFUSE_BLOCK_RF:
-               return rtw8922a_read_efuse_rf(rtwdev, log_map);
+               ret = rtw8922a_read_efuse_rf(rtwdev, log_map);
+               break;
        default:
-               return 0;
+               ret = 0;
+               break;
+       }
+
+       if (!ret && is_zero_ether_addr(efuse->addr)) {
+               rtw89_info(rtwdev, "efuse mac address is zero, using random mac\n");
+               eth_random_addr(efuse->addr);
        }
+
+       return ret;
 }
 
 #define THM_TRIM_POSITIVE_MASK BIT(6)