From: Mehmet Fide rtw_fw_download_rsvd_page() downloads the beacon twice: as part of the reserved page, and again on its own so that the firmware gets a TX descriptor for the beacon instead of the whole page. The second download fetches a new beacon from mac80211 instead of the one in the page. Each fetch advances the DTIM count and, during a channel switch, the CSA countdown. Two fetches per update step a countdown of 2 past 1, and mac80211 warns "beacon TX faster than countdown". Keep the beacon from the page build and download that one. The hw scan, which downloads the beacon without a page build, still fetches its own. The hardware writes the DTIM count of an AP beacon itself (BIT_TCR_UPDATE_TIMIE), so nothing on the air changes without a channel switch, and this is not marked as a fix. Signed-off-by: Mehmet Fide Reviewed-by: Luka Gejak Acked-by: Ping-Ke Shih --- Notes: Changes in v14: - dropped two comments that repeated the commit message, reworded the commit message; rebased on the rtw88 firmware recovery fixes v4 Changes in v13: - none, rebased on rtw-next Changes in v12: - the commit message says why this is not marked as a fix and what mac80211 reports for the double fetch (Sashiko); no code change, the tags are kept - rebased on patches 1-4 of the rtw88 firmware recovery fixes v3 Changes in v11: - none, rebased on rtw-next Changes in v10: - none, rebased on rtw-next Changes in v9: - none Changes in v8: - none Changes in v7: - none, rebased on rtw-next Changes in v6: - none Changes in v5: - none Changes in v4: - none, rebased on rtw-next Changes in v3: - the beacon out-pointer is initialised in the caller drivers/net/wireless/realtek/rtw88/fw.c | 32 +++++++++++++++---------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c index 09b5836540c4..4575073d0149 100644 --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c @@ -1622,7 +1622,8 @@ static int __rtw_build_rsvd_page_from_vifs(struct rtw_dev *rtwdev) return 0; } -static u8 *rtw_build_rsvd_page(struct rtw_dev *rtwdev, u32 *size) +static u8 *rtw_build_rsvd_page(struct rtw_dev *rtwdev, u32 *size, + struct sk_buff **beacon) { const struct rtw_chip_info *chip = rtwdev->chip; struct ieee80211_hw *hw = rtwdev->hw; @@ -1702,13 +1703,14 @@ static u8 *rtw_build_rsvd_page(struct rtw_dev *rtwdev, u32 *size) list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, build_list) { rtw_rsvd_page_list_to_buf(rtwdev, page_size, page_margin, page, buf, rsvd_pkt); - if (page == 0) + if (page == 0) { page += rtw_len_to_page(rsvd_pkt->skb->len + tx_desc_sz, page_size); - else + *beacon = rsvd_pkt->skb; + } else { page += rtw_len_to_page(rsvd_pkt->skb->len, page_size); - - kfree_skb(rsvd_pkt->skb); + kfree_skb(rsvd_pkt->skb); + } rsvd_pkt->skb = NULL; } @@ -1723,11 +1725,11 @@ static u8 *rtw_build_rsvd_page(struct rtw_dev *rtwdev, u32 *size) return NULL; } -static int rtw_download_beacon(struct rtw_dev *rtwdev) +static int rtw_download_beacon(struct rtw_dev *rtwdev, struct sk_buff *beacon) { struct ieee80211_hw *hw = rtwdev->hw; struct rtw_rsvd_page *rsvd_pkt; - struct sk_buff *skb; + struct sk_buff *skb = beacon; int ret = 0; rsvd_pkt = list_first_entry_or_null(&rtwdev->rsvd_page_list, @@ -1744,7 +1746,8 @@ static int rtw_download_beacon(struct rtw_dev *rtwdev) return -EINVAL; } - skb = rtw_get_rsvd_page_skb(hw, rsvd_pkt); + if (!skb) + skb = rtw_get_rsvd_page_skb(hw, rsvd_pkt); if (!skb) { rtw_err(rtwdev, "failed to get beacon skb\n"); return -ENOMEM; @@ -1754,18 +1757,20 @@ static int rtw_download_beacon(struct rtw_dev *rtwdev) if (ret) rtw_err(rtwdev, "failed to download drv rsvd page\n"); - dev_kfree_skb(skb); + if (!beacon) + dev_kfree_skb(skb); return ret; } int rtw_fw_download_rsvd_page(struct rtw_dev *rtwdev) { - u8 *buf; + struct sk_buff *beacon = NULL; u32 size; + u8 *buf; int ret; - buf = rtw_build_rsvd_page(rtwdev, &size); + buf = rtw_build_rsvd_page(rtwdev, &size, &beacon); if (!buf) { rtw_err(rtwdev, "failed to build rsvd page pkt\n"); return -ENOMEM; @@ -1782,13 +1787,14 @@ int rtw_fw_download_rsvd_page(struct rtw_dev *rtwdev) * the beacon again to replace the TX desc header, and we will get * a correct tx_desc for the beacon in the rsvd page. */ - ret = rtw_download_beacon(rtwdev); + ret = rtw_download_beacon(rtwdev, beacon); if (ret) { rtw_err(rtwdev, "failed to download beacon\n"); goto free; } free: + dev_kfree_skb(beacon); kfree(buf); return ret; @@ -2346,7 +2352,7 @@ int rtw_hw_scan_offload(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, rtw_fw_set_scan_offload(rtwdev, &cs_option, rtwvif, &chan_list); out: if (rtwdev->ap_active) { - ret = rtw_download_beacon(rtwdev); + ret = rtw_download_beacon(rtwdev, NULL); if (ret) rtw_err(rtwdev, "HW scan download beacon failed\n"); } -- 2.56.0