wifi: rtw88: usb: Reduce control message timeout to 500 ms
PATCH v2 1/2 wifi: rtw88: usb: Reduce control message timeout to 500 ms
RTL8811AU stops responding during the firmware download on some systems:
[ 809.256440] rtw_8821au 5-2.1:1.0: Firmware version 42.4.0, H2C version 0 [ 812.759142] rtw_8821au 5-2.1:1.0 wlp48s0f4u2u1: renamed from wlan0 [ 837.315388] rtw_8821au 1-4:1.0: write register 0x1ef4 failed with -110 [ 867.524259] rtw_8821au 1-4:1.0: write register 0x1ef8 failed with -110 [ 868.930976] rtw_8821au 5-2.1:1.0 wlp48s0f4u2u1: entered promiscuous mode [ 897.730952] rtw_8821au 1-4:1.0: write register 0x1efc failed with -110
Each write takes 30 seconds to fail because that's the timeout currently used for control messages in rtw_usb_write().
In this scenario the firmware download takes at least 2000 seconds. Because this is done from the USB probe function, the long delay makes other things in the system hang.
Reduce the timeout to 500 ms. This is the value used by the official USB wifi drivers from Realtek.
Of course this only makes things hang for ~30 seconds instead of ~30 minutes. It doesn't fix the firmware download.
Tested with RTL8822CU, RTL8812BU, RTL8811CU, RTL8814AU, RTL8811AU, RTL8812AU, RTL8821AU, RTL8723DU.
---
v2:
- Add Acked-by.
--- drivers/net/wireless/realtek/rtw88/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/usb.c +1 -1
@@ -139,7 +139,7 @@ static void rtw_usb_write(struct rtw_dev *rtwdev, u32 addr, u32 val, int len) ret =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ),RTW_USB_CMD_REQ ,RTW_USB_CMD_WRITE , - addr,0 , data, len,30000 ); + addr,0 , data, len,500 );if (ret <0 && ret != -ENODEV && count++ <4 )rtw_err (rtwdev,"write register 0x%x failed with %d\n" , addr, ret);
Signature · 1 line
2.49.0
PATCH v2 2/2 wifi: rtw88: usb: Upload the firmware in bigger chunks
RTL8811AU stops responding during the firmware download on some systems:
[ 809.256440] rtw_8821au 5-2.1:1.0: Firmware version 42.4.0, H2C version 0 [ 812.759142] rtw_8821au 5-2.1:1.0 wlp48s0f4u2u1: renamed from wlan0 [ 837.315388] rtw_8821au 1-4:1.0: write register 0x1ef4 failed with -110 [ 867.524259] rtw_8821au 1-4:1.0: write register 0x1ef8 failed with -110 [ 868.930976] rtw_8821au 5-2.1:1.0 wlp48s0f4u2u1: entered promiscuous mode [ 897.730952] rtw_8821au 1-4:1.0: write register 0x1efc failed with -110
Maybe it takes too long when writing the firmware 4 bytes at a time.
Write 196 bytes at a time for RTL8821AU, RTL8811AU, and RTL8812AU, and 254 bytes at a time for RTL8723DU. These are the sizes used in their official drivers. Tested with all these chips.
---
v2:
- Use FW_START_ADDR_LEGACY instead of FW_8192C_START_ADDRESS.
- Add Acked-by.
--- drivers/net/wireless/realtek/rtw88/hci.h | 8 ++++ drivers/net/wireless/realtek/rtw88/mac.c | 11 +++-- drivers/net/wireless/realtek/rtw88/mac.h | 2 + drivers/net/wireless/realtek/rtw88/pci.c | 2 + drivers/net/wireless/realtek/rtw88/sdio.c | 2 + drivers/net/wireless/realtek/rtw88/usb.c | 55 +++++++++++++++++++++++ 6 files changed, 76 insertions(+), 4 deletions(-)
drivers/net/wireless/realtek/rtw88/hci.h +8 -0
@@ -19,6 +19,8 @@ struct rtw_hci_ops {void (*link_ps)(struct rtw_dev *rtwdev,bool enter);void (*interface_cfg)(struct rtw_dev *rtwdev);void (*dynamic_rx_agg)(struct rtw_dev *rtwdev,bool enable); +void (*write_firmware_page)(struct rtw_dev *rtwdev,u32 page, +const u8 *data,u32 size);int (*write_data_rsvd_page)(struct rtw_dev *rtwdev,u8 *buf,u32 size);int (*write_data_h2c)(struct rtw_dev *rtwdev,u8 *buf,u32 size);
@@ -79,6 +81,12 @@ static inline void rtw_hci_dynamic_rx_agg(struct rtw_dev *rtwdev, bool enable) rtwdev->hci.ops->dynamic_rx_agg (rtwdev, enable); } +static inline void rtw_hci_write_firmware_page (struct rtw_dev *rtwdev,u32 page, +const u8 *data,u32 size) +{ + rtwdev->hci.ops->write_firmware_page (rtwdev, page, data, size); +} +static inline int rtw_hci_write_data_rsvd_page (struct rtw_dev *rtwdev,u8 *buf,u32 size) {
drivers/net/wireless/realtek/rtw88/mac.c +7 -4
@@ -856,8 +856,8 @@ static void en_download_firmware_legacy(struct rtw_dev *rtwdev, bool en) } } -static void -write_firmware_page (struct rtw_dev *rtwdev,u32 page,const u8 *data,u32 size) +void rtw_write_firmware_page (struct rtw_dev *rtwdev,u32 page, +const u8 *data,u32 size) {u32 val32;u32 block_nr;
@@ -887,6 +887,7 @@ write_firmware_page(struct rtw_dev *rtwdev, u32 page, const u8 *data, u32 size)rtw_write32 (rtwdev, write_addr,le32_to_cpu (remain_data)); } } +EXPORT_SYMBOL (rtw_write_firmware_page);static int download_firmware_legacy (struct rtw_dev *rtwdev,const u8 *data,u32 size)
@@ -904,11 +905,13 @@ download_firmware_legacy(struct rtw_dev *rtwdev, const u8 *data, u32 size)rtw_write8_set (rtwdev,REG_MCUFW_CTRL ,BIT_FWDL_CHK_RPT );for (page =0 ; page < total_page; page++) { -write_firmware_page (rtwdev, page, data,DLFW_PAGE_SIZE_LEGACY ); +rtw_hci_write_firmware_page (rtwdev, page, data, +DLFW_PAGE_SIZE_LEGACY ); data +=DLFW_PAGE_SIZE_LEGACY ; }if (last_page_size) -write_firmware_page (rtwdev, page, data, last_page_size); +rtw_hci_write_firmware_page (rtwdev, page, data, + last_page_size);if (!check_hw_ready (rtwdev,REG_MCUFW_CTRL ,BIT_FWDL_CHK_RPT ,1 )) {rtw_err (rtwdev,"failed to check download firmware report\n" );
drivers/net/wireless/realtek/rtw88/mac.h +2 -0
@@ -34,6 +34,8 @@ int rtw_pwr_seq_parser(struct rtw_dev *rtwdev, const struct rtw_pwr_seq_cmd * const *cmd_seq);int rtw_mac_power_on (struct rtw_dev *rtwdev);void rtw_mac_power_off (struct rtw_dev *rtwdev); +void rtw_write_firmware_page (struct rtw_dev *rtwdev,u32 page, +const u8 *data,u32 size);int rtw_download_firmware (struct rtw_dev *rtwdev,struct rtw_fw_state *fw);int rtw_mac_init (struct rtw_dev *rtwdev);void rtw_mac_flush_queues (struct rtw_dev *rtwdev,u32 queues,bool drop);
drivers/net/wireless/realtek/rtw88/pci.c +2 -0
@@ -12,6 +12,7 @@#include "fw.h" #include "ps.h" #include "debug.h" +#include "mac.h" static bool rtw_disable_msi;static bool rtw_pci_disable_aspm;
@@ -1602,6 +1603,7 @@ static const struct rtw_hci_ops rtw_pci_ops = { .link_ps = rtw_pci_link_ps, .interface_cfg = rtw_pci_interface_cfg, .dynamic_rx_agg = NULL, + .write_firmware_page = rtw_write_firmware_page, .read8 = rtw_pci_read8, .read16 = rtw_pci_read16,
drivers/net/wireless/realtek/rtw88/sdio.c +2 -0
@@ -10,6 +10,7 @@#include <linux/mmc/host.h> #include <linux/mmc/sdio_func.h> #include "main.h" +#include "mac.h" #include "debug.h" #include "fw.h" #include "ps.h"
@@ -1164,6 +1165,7 @@ static const struct rtw_hci_ops rtw_sdio_ops = { .link_ps = rtw_sdio_link_ps, .interface_cfg = rtw_sdio_interface_cfg, .dynamic_rx_agg = NULL, + .write_firmware_page = rtw_write_firmware_page, .read8 = rtw_sdio_read8, .read16 = rtw_sdio_read16,
drivers/net/wireless/realtek/rtw88/usb.c +55 -0
67 lines not on this page · raw message
Signature · 1 line
2.49.0
Ping-Ke Shih
maintainerQuoted 22 lines · Bitterblue Smith
RTL8811AU stops responding during the firmware download on some systems:
[ 809.256440] rtw_8821au 5-2.1:1.0: Firmware version 42.4.0, H2C version 0 [ 812.759142] rtw_8821au 5-2.1:1.0 wlp48s0f4u2u1: renamed from wlan0 [ 837.315388] rtw_8821au 1-4:1.0: write register 0x1ef4 failed with -110 [ 867.524259] rtw_8821au 1-4:1.0: write register 0x1ef8 failed with -110 [ 868.930976] rtw_8821au 5-2.1:1.0 wlp48s0f4u2u1: entered promiscuous mode [ 897.730952] rtw_8821au 1-4:1.0: write register 0x1efc failed with -110Each write takes 30 seconds to fail because that's the timeout currently used for control messages in
rtw_usb_write().In this scenario the firmware download takes at least 2000 seconds. Because this is done from the USB probe function, the long delay makes other things in the system hang.
Reduce the timeout to 500 ms. This is the value used by the official USB wifi drivers from Realtek.
Of course this only makes things hang for ~30 seconds instead of ~30 minutes. It doesn't fix the firmware download.
Quoted 8 lines
Tested with RTL8822CU, RTL8812BU, RTL8811CU, RTL8814AU, RTL8811AU, RTL8812AU, RTL8821AU, RTL8723DU.
Fixes a82dfd33d123 ("wifi: rtw88: Add common USB chip support")Signed-off-by Bitterblue Smith <[email protected]>Acked-by Ping-Ke Shih <[email protected]>
2 patch(es) applied to rtw-next branch of rtw.git, thanks.
490340faddea wifi: rtw88: usb: Reduce control message timeout to 500 ms 80fe0bc1659c wifi: rtw88: usb: Upload the firmware in bigger chunks