]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtl8xxxu: retry firmware download on error
authorSoeren Moch <smoch@web.de>
Mon, 27 Jan 2025 19:48:28 +0000 (20:48 +0100)
committerPing-Ke Shih <pkshih@realtek.com>
Mon, 3 Feb 2025 02:44:44 +0000 (10:44 +0800)
Occasionally there is an EPROTO error during firmware download.
This error is converted to EAGAIN in the download function.
But nobody tries again and so device probe fails.

Implement download retry to fix this.

This error was observed (and fix tested) on a tbs2910 board [1]
with an embedded RTL8188EU (0bda:8179) device behind a USB hub.

[1] arch/arm/boot/dts/nxp/imx/imx6q-tbs2910.dts

Signed-off-by: Soeren Moch <smoch@web.de>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250127194828.599379-1-smoch@web.de
drivers/net/wireless/realtek/rtl8xxxu/core.c

index 4ce0c05c5129102a1c9ebe87077dc96072889aa5..569856ca677f623e4688a0b7387ac3ac84ade23d 100644 (file)
@@ -860,9 +860,10 @@ rtl8xxxu_writeN(struct rtl8xxxu_priv *priv, u16 addr, u8 *buf, u16 len)
        return len;
 
 write_error:
-       dev_info(&udev->dev,
-                "%s: Failed to write block at addr: %04x size: %04x\n",
-                __func__, addr, blocksize);
+       if (rtl8xxxu_debug & RTL8XXXU_DEBUG_REG_WRITE)
+               dev_info(&udev->dev,
+                        "%s: Failed to write block at addr: %04x size: %04x\n",
+                        __func__, addr, blocksize);
        return -EAGAIN;
 }
 
@@ -4064,8 +4065,14 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
         */
        rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, fops->trxff_boundary);
 
-       ret = rtl8xxxu_download_firmware(priv);
-       dev_dbg(dev, "%s: download_firmware %i\n", __func__, ret);
+       for (int retry = 5; retry >= 0 ; retry--) {
+               ret = rtl8xxxu_download_firmware(priv);
+               dev_dbg(dev, "%s: download_firmware %i\n", __func__, ret);
+               if (ret != -EAGAIN)
+                       break;
+               if (retry)
+                       dev_dbg(dev, "%s: retry firmware download\n", __func__);
+       }
        if (ret)
                goto exit;
        ret = rtl8xxxu_start_firmware(priv);