]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: rtw89: Lower the timeout in rtw89_fw_read_c2h_reg() for USB
authorBitterblue Smith <rtl8821cerfe2@gmail.com>
Tue, 15 Jul 2025 19:44:47 +0000 (22:44 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Aug 2025 16:41:07 +0000 (18:41 +0200)
[ Upstream commit 671be46afd1f03de9dc6e4679c88e1a7a81cdff6 ]

This read_poll_timeout_atomic() with a delay of 1 µs and a timeout of
1000000 µs can take ~250 seconds in the worst case because sending a
USB control message takes ~250 µs.

Lower the timeout to 4000 for USB in order to reduce the maximum polling
time to ~1 second.

This problem was observed with RTL8851BU while suspending to RAM with
WOWLAN enabled. The computer sat for 4 minutes with a black screen
before suspending.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/09313da6-c865-4e91-b758-4cb38a878796@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/fw.h

index 00b65b2995cffc62ed404ddbac1d38e8be991118..f270d5e2140d2e896c8fd89d98e8ef70c2e6c5ee 100644 (file)
@@ -6506,13 +6506,18 @@ static int rtw89_fw_read_c2h_reg(struct rtw89_dev *rtwdev,
        const struct rtw89_chip_info *chip = rtwdev->chip;
        struct rtw89_fw_info *fw_info = &rtwdev->fw;
        const u32 *c2h_reg = chip->c2h_regs;
-       u32 ret;
+       u32 ret, timeout;
        u8 i, val;
 
        info->id = RTW89_FWCMD_C2HREG_FUNC_NULL;
 
+       if (rtwdev->hci.type == RTW89_HCI_TYPE_USB)
+               timeout = RTW89_C2H_TIMEOUT_USB;
+       else
+               timeout = RTW89_C2H_TIMEOUT;
+
        ret = read_poll_timeout_atomic(rtw89_read8, val, val, 1,
-                                      RTW89_C2H_TIMEOUT, false, rtwdev,
+                                      timeout, false, rtwdev,
                                       chip->c2h_ctrl_reg);
        if (ret) {
                rtw89_warn(rtwdev, "c2h reg timeout\n");
index 0fcc824e41be6dc9da9d6698befcc7580d523ab2..a6b5dc6851f11cc0a66e848b850997c9c41d4422 100644 (file)
@@ -112,6 +112,8 @@ struct rtw89_h2creg_sch_tx_en {
 #define RTW89_C2HREG_HDR_LEN 2
 #define RTW89_H2CREG_HDR_LEN 2
 #define RTW89_C2H_TIMEOUT 1000000
+#define RTW89_C2H_TIMEOUT_USB 4000
+
 struct rtw89_mac_c2h_info {
        u8 id;
        u8 content_len;