]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: add polling for LPS H2C to ensure FW received
authorChih-Kang Chang <gary.chang@realtek.com>
Thu, 20 Jun 2024 05:58:25 +0000 (13:58 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Thu, 27 Jun 2024 01:25:41 +0000 (09:25 +0800)
We add polling after sending LPS H2C to ensure that the Firmware is
received and executes RPWM thereafter. Otherwise, if the Firmware
executes RPWM without receiving LPS H2C, it will cause beacon loss in
WoWLAN mode due to the inability to obtain channel and bandwidth
information from H2C.

Signed-off-by: Chih-Kang Chang <gary.chang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20240620055825.17592-8-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/reg.h

index e3fc9f168ae582d787bb45b53109f8ae00ba62ad..fbe08c162b93de5123456749aedb6343cf507c43 100644 (file)
@@ -2496,6 +2496,7 @@ int rtw89_fw_h2c_lps_ch_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
        struct rtw89_h2c_lps_ch_info *h2c;
        u32 len = sizeof(*h2c);
        struct sk_buff *skb;
+       u32 done;
        int ret;
 
        if (chip->chip_gen != RTW89_CHIP_BE)
@@ -2519,12 +2520,18 @@ int rtw89_fw_h2c_lps_ch_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
                              H2C_CAT_OUTSRC, H2C_CL_OUTSRC_DM,
                              H2C_FUNC_FW_LPS_CH_INFO, 0, 0, len);
 
+       rtw89_phy_write32_mask(rtwdev, R_CHK_LPS_STAT, B_CHK_LPS_STAT, 0);
        ret = rtw89_h2c_tx(rtwdev, skb, false);
        if (ret) {
                rtw89_err(rtwdev, "failed to send h2c\n");
                goto fail;
        }
 
+       ret = read_poll_timeout(rtw89_phy_read32_mask, done, done, 50, 5000,
+                               true, rtwdev, R_CHK_LPS_STAT, B_CHK_LPS_STAT);
+       if (ret)
+               rtw89_warn(rtwdev, "h2c_lps_ch_info done polling timeout\n");
+
        return 0;
 fail:
        dev_kfree_skb_any(skb);
index c9f6bdc84d0307492fdedfee46efe829f6376c84..897884e9667fc9dadd2f2ce36e6728e7347f3fb9 100644 (file)
 #define B_UPD_P0_EN BIT(31)
 #define R_EMLSR 0x0044
 #define B_EMLSR_PARM GENMASK(27, 12)
+#define R_CHK_LPS_STAT 0x0058
+#define B_CHK_LPS_STAT BIT(0)
 #define R_SPOOF_CG 0x00B4
 #define B_SPOOF_CG_EN BIT(17)
 #define R_CHINFO_SEG 0x00B4