* [PATCH rtw-next v4 0/4] wifi: rtw88: fixes around the firmware recovery
@ 2026-11-21 19:15 Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 1/4] wifi: rtw88: free the reserved pages of an interface on " Mehmet Fide
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mehmet Fide @ 2026-11-21 19:15 UTC (permalink / raw)
To: Ping-Ke Shih
Cc: Luka Gejak, Sascha Hauer, Zong-Zhe Yang, Tzu-En Huang,
Yan-Hsuan Chuang, Kalle Valo, Stanislaw Gruszka, Brian Norris,
linux-wireless, linux-kernel, mehmet.fide
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
Fixes for what a firmware crash test showed on an RTL8822CE, and for
what Luka found in v2 and v3. Patch 5 of v3 is dropped, commit
3f2238709f5d ("wifi: rtw88: clear RTW_FLAG_RESTARTING on stop and start
failure") does the same.
Tested on rtw-next 0bdc579dbfc2 on an i.MX8MP board with lockdep and
kmemleak, with firmware crashes triggered from debugfs on the RTL8822CE:
- patch 1: no reserved page leaked after crashes with an AP or a
station interface, where rtw-next leaked pages on each crash. The
beacon update work and a WoWLAN suspend between the crash and the
reconfiguration found the pages
- patch 2: with the firmware TX reports dropped in a test build, hostapd
got a purged client probe as not acknowledged, with no ACK signal or
link ID
- patch 3: with the collection held back in a test build, a client
moved back to AUTH and deleted in that window was skipped
- patch 4: no "sleeping function called from invalid context" on a
crash with an associated station interface
The regression tests on an RTL8822CE, an RTL8822BU, an RTL8822CU and
two RTL8821CU on both bands passed, except the 2.4 GHz beacon test of
the RTL8822CE. A neighbour AP's beacons pass our TBTT on that channel
every 157 s, and the beacon loss over 330 to 400 s is in the same
range with and without the series.
v4:
- patch 1: the pages are kept through the recovery and freed when the
interface is added again; no port checks (Zong-Zhe Yang, Luka Gejak)
- patch 2: the TX status is cleared when a frame is queued (Luka Gejak);
Reviewed-by dropped
- patch 3: stations without si->vif are skipped (Luka Gejak)
- patch 4: no change
- patch 5 of v3 dropped for commit 3f2238709f5d
v3:
- patch 1: no RTW_FLAG_RESTARTING test in the beacon update work; the
page download and the page location H2C do nothing while no port is
in use (Luka Gejak)
- patch 3: new, rtw_iterate_stas() cannot skip a station (Luka Gejak)
- patch 5: new, RTW_FLAG_RESTARTING is cleared when the device stops
(Luka Gejak)
- patches 2 and 4: no change
- rebased on rtw-next
v2:
- patch 1: the beacon update work does nothing while
RTW_FLAG_RESTARTING is set (Luka Gejak)
- patches 2 and 3: Reviewed-by Luka Gejak, no change
- rebased on rtw-next
v3: https://lore.kernel.org/linux-wireless/20261117171003.1840491-1-mehmet.fide@gmail.com/
v2: https://lore.kernel.org/linux-wireless/20261116072014.1142494-1-mehmet.fide@gmail.com/
v1: https://lore.kernel.org/linux-wireless/20261111213239.569224-1-mehmet.fide@gmail.com/
Mehmet Fide (4):
wifi: rtw88: free the reserved pages of an interface on firmware
recovery
wifi: rtw88: report the frames purged from the TX report queue
wifi: rtw88: do not drop stations when collecting them for an
iteration
wifi: rtw88: reset the stations outside of RCU on firmware recovery
drivers/net/wireless/realtek/rtw88/mac80211.c | 8 +++++-
drivers/net/wireless/realtek/rtw88/main.c | 7 ++----
drivers/net/wireless/realtek/rtw88/main.h | 2 ++
drivers/net/wireless/realtek/rtw88/tx.c | 25 +++++++++++++++----
drivers/net/wireless/realtek/rtw88/tx.h | 1 +
drivers/net/wireless/realtek/rtw88/util.c | 23 ++++++-----------
6 files changed, 39 insertions(+), 27 deletions(-)
base-commit: 0bdc579dbfc251a6b6838ee9459b6771b948c617
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH rtw-next v4 1/4] wifi: rtw88: free the reserved pages of an interface on firmware recovery
2026-11-21 19:15 [PATCH rtw-next v4 0/4] wifi: rtw88: fixes around the firmware recovery Mehmet Fide
@ 2026-11-21 19:15 ` Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 2/4] wifi: rtw88: report the frames purged from the TX report queue Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 3/4] wifi: rtw88: do not drop stations when collecting them for an iteration Mehmet Fide
2 siblings, 0 replies; 4+ messages in thread
From: Mehmet Fide @ 2026-11-21 19:15 UTC (permalink / raw)
To: Ping-Ke Shih
Cc: Luka Gejak, Sascha Hauer, Zong-Zhe Yang, Tzu-En Huang,
Yan-Hsuan Chuang, Kalle Valo, Stanislaw Gruszka, Brian Norris,
linux-wireless, linux-kernel, mehmet.fide
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
After a firmware crash, mac80211 adds the interfaces again without
removing them first. rtw_ops_add_interface() then reinitializes the
reserved page list, and the pages allocated before the crash leak:
unreferenced object 0xffff0000cbe22c60 (size 96):
comm "hostapd", pid 25545, jiffies 4296463067
backtrace (crc cbdc21c4):
kmemleak_alloc+0xcc/0xe4
__kmalloc_cache_noprof+0x234/0x3bc
rtw_add_rsvd_page+0x38/0xa8 [rtw88_core]
rtw_add_rsvd_page_bcn+0x30/0x58 [rtw88_core]
rtw_ops_add_interface+0x144/0x2cc [rtw88_core]
mac80211 zeroes the driver data of a new and of a removed interface, so
track in struct rtw_vif whether the list was initialized, and free the
old pages when the interface is added again. Until then the pages stay
on the list, so a download before the reconfiguration, from the beacon
update work or a WoWLAN suspend, still finds them.
Fixes: 5c831644e1f4 ("rtw88: handle and recover when firmware crash")
Suggested-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
Notes:
v4: keep the pages through the recovery and free them in
rtw_ops_add_interface() (Zong-Zhe Yang); no port checks
v3: no RTW_FLAG_RESTARTING test; the page download and the page
location H2C do nothing while no port is in use (Luka Gejak)
v2: the beacon update work does nothing while RTW_FLAG_RESTARTING is
set (Luka Gejak)
drivers/net/wireless/realtek/rtw88/mac80211.c | 8 +++++++-
drivers/net/wireless/realtek/rtw88/main.h | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c
index 3029fbdb288a..b14d7fffb98f 100644
--- a/drivers/net/wireless/realtek/rtw88/mac80211.c
+++ b/drivers/net/wireless/realtek/rtw88/mac80211.c
@@ -166,10 +166,16 @@ static int rtw_ops_add_interface(struct ieee80211_hw *hw,
rtwvif->scan_req = NULL;
memset(&rtwvif->bfee, 0, sizeof(struct rtw_bfee));
rtw_txq_init(rtwdev, vif->txq);
- INIT_LIST_HEAD(&rtwvif->rsvd_page_list);
mutex_lock(&rtwdev->mutex);
+ if (rtwvif->rsvd_page_inited) {
+ rtw_remove_rsvd_page(rtwdev, rtwvif);
+ } else {
+ INIT_LIST_HEAD(&rtwvif->rsvd_page_list);
+ rtwvif->rsvd_page_inited = true;
+ }
+
rtwvif->mac_id = rtw_acquire_macid(rtwdev);
if (rtwvif->mac_id >= RTW_MAX_MAC_ID_NUM) {
mutex_unlock(&rtwdev->mutex);
diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index 525f17590adb..5291de0ea38f 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -830,6 +830,7 @@ struct rtw_vif {
u8 bssid[ETH_ALEN];
u8 port;
u8 bcn_ctrl;
+ bool rsvd_page_inited;
struct list_head rsvd_page_list;
struct ieee80211_tx_queue_params tx_params[IEEE80211_NUM_ACS];
const struct rtw_vif_port *conf;
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH rtw-next v4 2/4] wifi: rtw88: report the frames purged from the TX report queue
2026-11-21 19:15 [PATCH rtw-next v4 0/4] wifi: rtw88: fixes around the firmware recovery Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 1/4] wifi: rtw88: free the reserved pages of an interface on " Mehmet Fide
@ 2026-11-21 19:15 ` Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 3/4] wifi: rtw88: do not drop stations when collecting them for an iteration Mehmet Fide
2 siblings, 0 replies; 4+ messages in thread
From: Mehmet Fide @ 2026-11-21 19:15 UTC (permalink / raw)
To: Ping-Ke Shih
Cc: Luka Gejak, Sascha Hauer, Zong-Zhe Yang, Tzu-En Huang,
Yan-Hsuan Chuang, Kalle Valo, Stanislaw Gruszka, Brian Norris,
linux-wireless, linux-kernel, mehmet.fide
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
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
[...]
Have pending ack frames!
WARNING: net/mac80211/main.c:1761 at ieee80211_free_ack_frame+0x4c/0x70 [mac80211], CPU#1: sh/24725
Call trace:
ieee80211_free_ack_frame+0x4c/0x70 [mac80211] (P)
idr_for_each+0x6c/0xf4
ieee80211_free_hw+0x30/0x8c [mac80211]
rtw_pci_remove+0xd8/0xf0 [rtw88_pci]
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 <mehmet.fide@screeningeagle.com>
---
Notes:
v4: clear the TX status when a frame is queued (Luka Gejak);
Reviewed-by dropped for that change
v3: no change
v2: Reviewed-by Luka Gejak, no change
drivers/net/wireless/realtek/rtw88/main.c | 5 +----
drivers/net/wireless/realtek/rtw88/tx.c | 25 ++++++++++++++++++-----
drivers/net/wireless/realtek/rtw88/tx.h | 1 +
3 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index 2a38a6828e3a..564cddf0bfed 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -2232,7 +2232,6 @@ void rtw_core_deinit(struct rtw_dev *rtwdev)
struct rtw_fw_state *fw = &rtwdev->fw;
struct rtw_fw_state *wow_fw = &rtwdev->wow_fw;
struct rtw_rsvd_page *rsvd_pkt, *tmp;
- unsigned long flags;
rtw_wait_firmware_completion(rtwdev);
@@ -2244,9 +2243,7 @@ void rtw_core_deinit(struct rtw_dev *rtwdev)
destroy_workqueue(rtwdev->tx_wq);
timer_delete_sync(&rtwdev->tx_report.purge_timer);
- spin_lock_irqsave(&rtwdev->tx_report.q_lock, flags);
- skb_queue_purge(&rtwdev->tx_report.queue);
- spin_unlock_irqrestore(&rtwdev->tx_report.q_lock, flags);
+ rtw_tx_report_purge(rtwdev);
skb_queue_purge(&rtwdev->coex.queue);
skb_queue_purge(&rtwdev->c2h_queue);
diff --git a/drivers/net/wireless/realtek/rtw88/tx.c b/drivers/net/wireless/realtek/rtw88/tx.c
index 701ed7c4f3f7..280292a41402 100644
--- a/drivers/net/wireless/realtek/rtw88/tx.c
+++ b/drivers/net/wireless/realtek/rtw88/tx.c
@@ -176,32 +176,47 @@ static void rtw_tx_report_enable(struct rtw_dev *rtwdev,
pkt_info->report = true;
}
+void rtw_tx_report_purge(struct rtw_dev *rtwdev)
+{
+ struct rtw_tx_report *tx_report = &rtwdev->tx_report;
+ struct sk_buff_head purge;
+ unsigned long flags;
+
+ __skb_queue_head_init(&purge);
+
+ spin_lock_irqsave(&tx_report->q_lock, flags);
+ skb_queue_splice_init(&tx_report->queue, &purge);
+ spin_unlock_irqrestore(&tx_report->q_lock, flags);
+
+ ieee80211_purge_tx_queue(rtwdev->hw, &purge);
+}
+
void rtw_tx_report_purge_timer(struct timer_list *t)
{
struct rtw_dev *rtwdev = timer_container_of(rtwdev, t,
tx_report.purge_timer);
struct rtw_tx_report *tx_report = &rtwdev->tx_report;
- unsigned long flags;
if (skb_queue_len(&tx_report->queue) == 0)
return;
rtw_warn(rtwdev, "failed to get tx report from firmware\n");
- spin_lock_irqsave(&tx_report->q_lock, flags);
- skb_queue_purge(&tx_report->queue);
- spin_unlock_irqrestore(&tx_report->q_lock, flags);
+ rtw_tx_report_purge(rtwdev);
}
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);
diff --git a/drivers/net/wireless/realtek/rtw88/tx.h b/drivers/net/wireless/realtek/rtw88/tx.h
index 168f48e87853..363f63525965 100644
--- a/drivers/net/wireless/realtek/rtw88/tx.h
+++ b/drivers/net/wireless/realtek/rtw88/tx.h
@@ -98,6 +98,7 @@ void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev,
struct sk_buff *skb);
void rtw_tx_fill_tx_desc(struct rtw_dev *rtwdev,
struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb);
+void rtw_tx_report_purge(struct rtw_dev *rtwdev);
void rtw_tx_report_enqueue(struct rtw_dev *rtwdev, struct sk_buff *skb, u8 sn);
void rtw_tx_report_handle(struct rtw_dev *rtwdev, struct sk_buff *skb, int src);
void rtw_tx_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH rtw-next v4 3/4] wifi: rtw88: do not drop stations when collecting them for an iteration
2026-11-21 19:15 [PATCH rtw-next v4 0/4] wifi: rtw88: fixes around the firmware recovery Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 1/4] wifi: rtw88: free the reserved pages of an interface on " Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 2/4] wifi: rtw88: report the frames purged from the TX report queue Mehmet Fide
@ 2026-11-21 19:15 ` Mehmet Fide
2 siblings, 0 replies; 4+ messages in thread
From: Mehmet Fide @ 2026-11-21 19:15 UTC (permalink / raw)
To: Ping-Ke Shih
Cc: Luka Gejak, Sascha Hauer, Zong-Zhe Yang, Tzu-En Huang,
Yan-Hsuan Chuang, Kalle Valo, Stanislaw Gruszka, Brian Norris,
linux-wireless, linux-kernel, mehmet.fide
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
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.
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.
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 <luka.gejak@linux.dev>
Closes: https://lore.kernel.org/linux-wireless/4EE3D95E-988D-4514-9849-9546CD49D8E9@linux.dev/
Fixes: 78d5bf925f30 ("wifi: rtw88: iterate over vif/sta list non-atomically")
Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
Notes:
v4: skip stations without si->vif (Luka Gejak)
v3: new (Luka Gejak)
drivers/net/wireless/realtek/rtw88/main.h | 1 +
drivers/net/wireless/realtek/rtw88/util.c | 23 +++++++----------------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index 5291de0ea38f..2830a5a57d61 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -792,6 +792,7 @@ struct rtw_sta_info {
struct cfg80211_bitrate_mask *mask;
struct work_struct rc_work;
+ struct list_head iter_list;
};
enum rtw_bfee_role {
diff --git a/drivers/net/wireless/realtek/rtw88/util.c b/drivers/net/wireless/realtek/rtw88/util.c
index fcd6eb1ab32a..8ade002426b9 100644
--- a/drivers/net/wireless/realtek/rtw88/util.c
+++ b/drivers/net/wireless/realtek/rtw88/util.c
@@ -107,11 +107,6 @@ void rtw_desc_to_mcsrate(u16 rate, u8 *mcs, u8 *nss)
}
}
-struct rtw_stas_entry {
- struct list_head list;
- struct ieee80211_sta *sta;
-};
-
struct rtw_iter_stas_data {
struct rtw_dev *rtwdev;
struct list_head list;
@@ -119,15 +114,13 @@ 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;
- stas_entry = kmalloc_obj(*stas_entry, GFP_ATOMIC);
- if (!stas_entry)
+ 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);
}
void rtw_iterate_stas(struct rtw_dev *rtwdev,
@@ -136,7 +129,7 @@ void rtw_iterate_stas(struct rtw_dev *rtwdev,
void *data)
{
struct rtw_iter_stas_data iter_data;
- struct rtw_stas_entry *sta_entry, *tmp;
+ struct rtw_sta_info *si, *tmp;
/* &rtwdev->mutex makes sure no stations can be removed between
* collecting the stations and iterating over them.
@@ -149,11 +142,9 @@ void rtw_iterate_stas(struct rtw_dev *rtwdev,
ieee80211_iterate_stations_atomic(rtwdev->hw, rtw_collect_sta_iter,
&iter_data);
- list_for_each_entry_safe(sta_entry, tmp, &iter_data.list,
- list) {
- list_del_init(&sta_entry->list);
- iterator(data, sta_entry->sta);
- kfree(sta_entry);
+ list_for_each_entry_safe(si, tmp, &iter_data.list, iter_list) {
+ list_del_init(&si->iter_list);
+ iterator(data, si->sta);
}
}
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-21 19:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-21 19:15 [PATCH rtw-next v4 0/4] wifi: rtw88: fixes around the firmware recovery Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 1/4] wifi: rtw88: free the reserved pages of an interface on " Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 2/4] wifi: rtw88: report the frames purged from the TX report queue Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 3/4] wifi: rtw88: do not drop stations when collecting them for an iteration Mehmet Fide
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®