1: 180d97702d52 < -: ------------ wifi: rtw88: free the reserved pages of an interface on firmware recovery -: ------------ > 1: 307c0d99f800 wifi: rtw88: free the reserved pages of an interface on firmware recovery 2: be48aed2959c ! 2: 978f3eb5c076 wifi: rtw88: report the frames purged from the TX report queue @@ Metadata ## Commit message ## wifi: rtw88: report the frames purged from the TX report queue  - A frame whose sender asked for its TX status waits in the TX report - queue for the report of the firmware. When no report comes, the purge - timer frees the frames with skb_queue_purge(), and rtw_core_deinit() - does the same. mac80211 is not told: the sender gets no status, and the - copy mac80211 keeps for the status of a frame from user space stays in - its list until ieee80211_free_hw() warns about it. On an RTL8822CE with - hostapd, after a firmware crash and an unbind of the driver: + Frames waiting for a TX report of the firmware are freed with + skb_queue_purge() when the report times out and in rtw_core_deinit(). + mac80211 gets no TX status for them, and the frames it keeps for the + TX status of user space stay pending until ieee80211_free_hw() warns. + On an RTL8822CE, after a firmware crash and an unbind:  rtw88_8822ce 0000:01:00.0: failed to get tx report from firmware [...] @@ Commit message idr_for_each+0x6c/0xf4 ieee80211_free_hw+0x30/0x8c [mac80211] rtw_pci_remove+0xd8/0xf0 [rtw88_pci] - pci_device_remove+0x44/0xd4  - Take the frames off the queue under its lock and hand them to - ieee80211_purge_tx_queue(), which reports each one as not sent. + Free them with ieee80211_purge_tx_queue() instead, which reports them + as dropped. Clear the TX status of a frame when it is queued, as + rtw_tx_report_handle() does, so that a purged frame does not report + its leftover TX control data as status flags and link ID.  Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver") Signed-off-by: Mehmet Fide  - Reviewed-by: Luka Gejak   ## drivers/net/wireless/realtek/rtw88/main.c ##  @@ drivers/net/wireless/realtek/rtw88/main.c: void rtw_core_deinit(struct rtw_dev *rtwdev) @@ drivers/net/wireless/realtek/rtw88/tx.c: static void rtw_tx_report_enable(struct }  void rtw_tx_report_enqueue(struct rtw_dev *rtwdev, struct sk_buff *skb, u8 sn) + { ++ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct rtw_tx_report *tx_report = &rtwdev->tx_report; + unsigned long timeout; + unsigned long flags; + u8 *drv_data; +  ++ ieee80211_tx_info_clear_status(info); ++ + /* pass sn to tx report handler through driver data */ +- drv_data = (u8 *)IEEE80211_SKB_CB(skb)->status.status_driver_data; ++ drv_data = (u8 *)info->status.status_driver_data; + *drv_data = sn; +  + spin_lock_irqsave(&tx_report->q_lock, flags);  ## drivers/net/wireless/realtek/rtw88/tx.h ##  @@ drivers/net/wireless/realtek/rtw88/tx.h: void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev, 3: a209a28d2034 ! 3: cd4f303f33e9 wifi: rtw88: do not drop stations when collecting them for an iteration @@ Metadata ## Commit message ## wifi: rtw88: do not drop stations when collecting them for an iteration  - rtw_iterate_stas() collects the stations with an atomic iterator and - calls the iterator for them afterwards. It allocates an entry for each - station with GFP_ATOMIC and silently skips the station when that fails. + rtw_iterate_stas() allocates an entry with GFP_ATOMIC for each station + it collects, and skips the station when that fails. Once the firmware + recovery resets the stations through it (next patch), a skipped station + keeps its TX queues on rtwdev->txqs, and rtw_txq_init() later + reinitializes a list node that is still linked.  - The firmware recovery resets the stations through it with the next - patch. A skipped station keeps its TX queues on rtwdev->txqs, and when - mac80211 adds it again, rtw_txq_init() reinitializes the list node of a - queue that is still linked there. + Link the stations through a list node in struct rtw_sta_info instead. + All callers hold rtwdev->mutex and no iterator collects again, so one + node per station is enough.  - Link the stations through a list node in struct rtw_sta_info instead, - so the collection cannot fail. All callers hold rtwdev->mutex, which - keeps two collections apart, and no station iterator collects again. + Skip stations without si->vif. A station moved back from ASSOC to AUTH + has gone through rtw_sta_remove() but is still found by the atomic + iterator, and mac80211 can free it without calling the driver before + the iterator runs.  Reported-by: Luka Gejak  Closes: https://lore.kernel.org/linux-wireless/4EE3D95E-988D-4514-9849-9546CD49D8E9@linux.dev/ @@ drivers/net/wireless/realtek/rtw88/util.c: void rtw_desc_to_mcsrate(u16 rate, u8 struct rtw_dev *rtwdev; struct list_head list;  @@ drivers/net/wireless/realtek/rtw88/util.c: struct rtw_iter_stas_data { +  static void rtw_collect_sta_iter(void *data, struct ieee80211_sta *sta) { ++ struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv; struct rtw_iter_stas_data *iter_stas = data;  - struct rtw_stas_entry *stas_entry; -+ struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv;   - stas_entry = kmalloc_obj(*stas_entry, GFP_ATOMIC);  - if (!stas_entry) -- return; -- ++ if (!si->vif) + return; +   - stas_entry->sta = sta;  - list_add_tail(&stas_entry->list, &iter_stas->list);  + list_add_tail(&si->iter_list, &iter_stas->list); 4: 7c1418e5db85 = 4: 65bca59b0312 wifi: rtw88: reset the stations outside of RCU on firmware recovery 5: 9049903f3dac < -: ------------ wifi: rtw88: clear the restart flag when the device is stopped