]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: rtw89: Lower the timeout in rtw89_fwdl_check_path_ready_ax() for USB
authorBitterblue Smith <rtl8821cerfe2@gmail.com>
Tue, 15 Jul 2025 19:46:20 +0000 (22:46 +0300)
committerPing-Ke Shih <pkshih@realtek.com>
Fri, 18 Jul 2025 06:22:35 +0000 (14:22 +0800)
When the chip is not powered on correctly (like during driver
development) rtw89_fwdl_check_path_ready_ax() can fail.
read_poll_timeout_atomic() with a delay of 1 µs and a timeout of
400000 µs can take 50 seconds with USB because of the time it takes to
send a USB control message. The firmware upload is tried 5 times, so
in total it takes 250 seconds.

Lower the timeout to 3200 for USB in order to reduce the time
rtw89_fwdl_check_path_ready_ax() takes from 50 seconds to less than 1
second.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/af0b25d0-ea67-455e-91f2-8e4c18ae4328@gmail.com
drivers/net/wireless/realtek/rtw89/fw.h
drivers/net/wireless/realtek/rtw89/mac.c

index 7865930299c87516ecfeca3e6d0e7b2ed8d9b609..3de29137b11300b85f9126fd28e221a868128312 100644 (file)
@@ -4699,6 +4699,7 @@ struct rtw89_c2h_rf_tas_info {
 #define RTW89_FW_BACKTRACE_KEY 0xBACEBACE
 
 #define FWDL_WAIT_CNT 400000
+#define FWDL_WAIT_CNT_USB 3200
 
 int rtw89_fw_check_rdy(struct rtw89_dev *rtwdev, enum rtw89_fwdl_check_type type);
 int rtw89_fw_recognize(struct rtw89_dev *rtwdev);
index 65d36fcad8b2ec1ea5b8f14e39787a2ced4c2ecf..5a5da9d9c0c5b75bb25fa47da804d8c4757bee7c 100644 (file)
@@ -6940,10 +6940,16 @@ int rtw89_fwdl_check_path_ready_ax(struct rtw89_dev *rtwdev,
                                   bool h2c_or_fwdl)
 {
        u8 check = h2c_or_fwdl ? B_AX_H2C_PATH_RDY : B_AX_FWDL_PATH_RDY;
+       u32 timeout;
        u8 val;
 
+       if (rtwdev->hci.type == RTW89_HCI_TYPE_USB)
+               timeout = FWDL_WAIT_CNT_USB;
+       else
+               timeout = FWDL_WAIT_CNT;
+
        return read_poll_timeout_atomic(rtw89_read8, val, val & check,
-                                       1, FWDL_WAIT_CNT, false,
+                                       1, timeout, false,
                                        rtwdev, R_AX_WCPU_FW_CTRL);
 }