* [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling
@ 2026-11-08 14:27 Kalpesh Solanki
2026-11-08 14:27 ` [PATCH v4 1/3] wifi: rtw88: clear RTW_FLAG_RESTARTING on stop and start failure Kalpesh Solanki
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Kalpesh Solanki @ 2026-11-08 14:27 UTC (permalink / raw)
To: pkshih, luka.gejak; +Cc: kvalo, linux-wireless, linux-kernel, Kalpesh Solanki
This series addresses firmware recovery robustness and LPS hang handling
in rtw88 based on review feedback from Luka Gejak and Ping-Ke Shih.
Patch 1/2 from the v2 series (DMI quirk for HP Laptop 15s-fr5xxx) was
already applied to rtw-next. The previous LPS leave recovery patch was
dropped from rtw-next by Ping-Ke Shih for respin.
This v4 series splits the recovery fixes into three focused patches:
1. Patch 1/3: Clear RTW_FLAG_RESTARTING on stop and start failure.
mac80211's drv_stop() skips local->ops->stop() when local->started
is false (such as after a failed drv_start()). If rtw_core_start()
fails during restart, clearing the flag only in rtw_ops_stop() left
it permanently set. We now clear RTW_FLAG_RESTARTING in both
rtw_ops_stop() and in rtw_ops_start() upon rtw_core_start() failure.
2. Patch 2/3: Skip already reset station in rtw_sta_remove().
During station disconnect (e.g., ieee80211_set_disassoc()), mac80211
leaves LPS before removing the AP station. If recovery is triggered by
LPS leave failure, __fw_recovery_work() removes all stations via
rtw_reset_sta_iter(). When mac80211 subsequently calls
rtw_ops_sta_remove(), rtw_sta_remove() ran a second time, resulting in
a double free of si->mask and underflow of rtwdev->sta_cnt. We check
si->vif at entry and clear si->vif and si->mask upon removal.
3. Patch 3/3: Trigger firmware recovery only after consecutive LPS leave
failures on PCI.
Restricts recovery to PCI devices (rtw_hci_type == RTW_HCI_TYPE_PCIE)
because USB (usb_control_msg()) and SDIO (sdio_claim_host()) sleep,
which triggers a "scheduling while atomic" panic under
local->key_lock during key clearing in __fw_recovery_work(). Retains
rtw_fw_dump_dbg_info() on the first failure (guarded by RTW_DBG_FW),
and requires 3 consecutive timeouts (RTW_PS_HANG_MAX_CNT) before
triggering hardware recovery. ps_hang_cnt is reset on success and in
rtw_core_start().
Changes in v4:
- In patch 1/3: Also clear RTW_FLAG_RESTARTING in rtw_ops_start() if
rtw_core_start() fails.
- Add patch 2/3: Prevent double free and sta_cnt underflow in
rtw_sta_remove() when recovery races with station disconnect.
- In patch 3/3:
- Keep rtw_fw_dump_dbg_info() in place on first failure.
- Restrict firmware recovery invocation to PCIe devices to prevent
scheduling while atomic panic on USB and SDIO.
- Explicitly check rtw_hci_type() in rtw_fw_recovery().
Changes in v3:
- Note: v2 patch 1/2 (DMI quirk) is already applied in rtw-next.
- Add patch 1/2 to clear RTW_FLAG_RESTARTING in rtw_ops_stop()
with Fixes tag.
- In patch 2/2:
- Count consecutive failures before triggering recovery
(RTW_PS_HANG_MAX_CNT = 3).
- Reset ps_hang_cnt on successful LPS leave and in rtw_core_start().
- Suppress raw register dump on transient failures to avoid log spam.
Changes in v2:
- Rebase on top of rtw-next.
Kalpesh Solanki (3):
wifi: rtw88: clear RTW_FLAG_RESTARTING on stop and start failure
wifi: rtw88: skip already reset station in rtw_sta_remove()
wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS
leave failures on PCI
drivers/net/wireless/realtek/rtw88/mac80211.c | 3 +++
drivers/net/wireless/realtek/rtw88/main.c | 10 ++++++++++
drivers/net/wireless/realtek/rtw88/main.h | 1 +
drivers/net/wireless/realtek/rtw88/ps.c | 7 +++++++
drivers/net/wireless/realtek/rtw88/ps.h | 1 +
5 files changed, 22 insertions(+)
--
2.53.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v4 1/3] wifi: rtw88: clear RTW_FLAG_RESTARTING on stop and start failure
2026-11-08 14:27 [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling Kalpesh Solanki
@ 2026-11-08 14:27 ` Kalpesh Solanki
2026-11-09 7:05 ` Luka Gejak
2026-11-08 14:27 ` [PATCH v4 2/3] wifi: rtw88: skip already reset station in rtw_sta_remove() Kalpesh Solanki
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: Kalpesh Solanki @ 2026-11-08 14:27 UTC (permalink / raw)
To: pkshih, luka.gejak
Cc: kvalo, linux-wireless, linux-kernel, Kalpesh Solanki, stable
When mac80211 stops or suspends the device without WoWLAN,
drv_reconfig_complete() is never invoked with
IEEE80211_RECONFIG_TYPE_RESTART. If firmware recovery was in flight
during this transition, RTW_FLAG_RESTARTING remains set permanently,
blocking all subsequent firmware recoveries until the module is reloaded.
Similarly, if rtw_core_start() fails during drv_start() in a recovery
restart, local->started remains false. When mac80211 cleans up via
cfg80211_shutdown_all_interfaces(), drv_stop() returns early without
calling rtw_ops_stop(), leaving RTW_FLAG_RESTARTING set permanently on
hardware that failed to recover.
Clear RTW_FLAG_RESTARTING in rtw_ops_stop(), as well as in
rtw_ops_start() when rtw_core_start() returns an error, ensuring the
driver always exits the restarting state on error or teardown.
Fixes: 5c831644e1f4 ("rtw88: handle and recover when firmware crash")
Cc: stable@vger.kernel.org
Signed-off-by: Kalpesh Solanki <skalpesh942@gmail.com>
---
drivers/net/wireless/realtek/rtw88/mac80211.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c
index 5e40cf06a9e..ffd86f08185 100644
--- a/drivers/net/wireless/realtek/rtw88/mac80211.c
+++ b/drivers/net/wireless/realtek/rtw88/mac80211.c
@@ -57,6 +57,8 @@ static int rtw_ops_start(struct ieee80211_hw *hw)
mutex_lock(&rtwdev->mutex);
ret = rtw_core_start(rtwdev);
+ if (ret)
+ clear_bit(RTW_FLAG_RESTARTING, rtwdev->flags);
mutex_unlock(&rtwdev->mutex);
return ret;
@@ -67,6 +69,7 @@ static void rtw_ops_stop(struct ieee80211_hw *hw, bool suspend)
struct rtw_dev *rtwdev = hw->priv;
mutex_lock(&rtwdev->mutex);
+ clear_bit(RTW_FLAG_RESTARTING, rtwdev->flags);
rtw_core_stop(rtwdev);
mutex_unlock(&rtwdev->mutex);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v4 2/3] wifi: rtw88: skip already reset station in rtw_sta_remove()
2026-11-08 14:27 [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling Kalpesh Solanki
2026-11-08 14:27 ` [PATCH v4 1/3] wifi: rtw88: clear RTW_FLAG_RESTARTING on stop and start failure Kalpesh Solanki
@ 2026-11-08 14:27 ` Kalpesh Solanki
2026-11-09 7:11 ` Luka Gejak
2026-11-08 14:27 ` [PATCH v4 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI Kalpesh Solanki
2026-11-11 3:37 ` [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling Ping-Ke Shih
3 siblings, 1 reply; 13+ messages in thread
From: Kalpesh Solanki @ 2026-11-08 14:27 UTC (permalink / raw)
To: pkshih, luka.gejak
Cc: kvalo, linux-wireless, linux-kernel, Kalpesh Solanki, stable
During firmware recovery, __fw_recovery_work() iterates over all
stations and invokes rtw_sta_remove() via rtw_reset_sta_iter().
If recovery is triggered concurrently with station teardown (such as
during ieee80211_set_disassoc() where mac80211 leaves LPS before
removing the AP station), rtw_ops_sta_remove() is subsequently called
for the same station. This causes rtw_sta_remove() to execute twice,
leading to a double free of si->mask and an underflow of rtwdev->sta_cnt.
Check si->vif in rtw_sta_remove() and return early if the station was
already reset, setting si->vif and si->mask to NULL upon removal.
Fixes: 5c831644e1f4 ("rtw88: handle and recover when firmware crash")
Cc: stable@vger.kernel.org
Signed-off-by: Kalpesh Solanki <skalpesh942@gmail.com>
---
drivers/net/wireless/realtek/rtw88/main.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index f7708ad17b6..a74f199a93a 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -384,6 +384,9 @@ void rtw_sta_remove(struct rtw_dev *rtwdev, struct ieee80211_sta *sta,
struct ieee80211_vif *vif = si->vif;
int i;
+ if (!vif)
+ return;
+
cancel_work_sync(&si->rc_work);
if (vif->type != NL80211_IFTYPE_STATION || sta->tdls)
@@ -395,8 +398,10 @@ void rtw_sta_remove(struct rtw_dev *rtwdev, struct ieee80211_sta *sta,
rtw_txq_cleanup(rtwdev, sta->txq[i]);
kfree(si->mask);
+ si->mask = NULL;
rtwdev->sta_cnt--;
+ si->vif = NULL;
rtw_dbg(rtwdev, RTW_DBG_STATE, "sta %pM with macid %d left\n",
sta->addr, si->mac_id);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v4 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI
2026-11-08 14:27 [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling Kalpesh Solanki
2026-11-08 14:27 ` [PATCH v4 1/3] wifi: rtw88: clear RTW_FLAG_RESTARTING on stop and start failure Kalpesh Solanki
2026-11-08 14:27 ` [PATCH v4 2/3] wifi: rtw88: skip already reset station in rtw_sta_remove() Kalpesh Solanki
@ 2026-11-08 14:27 ` Kalpesh Solanki
2026-11-09 7:13 ` Luka Gejak
2026-11-11 3:37 ` [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling Ping-Ke Shih
3 siblings, 1 reply; 13+ messages in thread
From: Kalpesh Solanki @ 2026-11-08 14:27 UTC (permalink / raw)
To: pkshih, luka.gejak; +Cc: kvalo, linux-wireless, linux-kernel, Kalpesh Solanki
A single timeout in rtw_fw_leave_lps_check() does not always indicate a
frozen firmware; in noisy RF environments or during beacon loss, the
802.11 null data frame ACK can be delayed or dropped. Immediately
triggering firmware recovery and a full hardware restart on a single
timeout causes unnecessary disconnections and kernel warning traces on
idle links.
Follow rtw89 by introducing a consecutive failure counter (ps_hang_cnt)
and only triggering rtw_fw_recovery() after RTW_PS_HANG_MAX_CNT (3)
consecutive failures. Reset the counter to 0 on every successful LPS
leave and in rtw_core_start() so that cold starts and hardware restarts
always begin with a clean slate.
Additionally, rtw_fw_recovery() clears keys via rtw_iterate_keys_atomic()
under a spinlock. On USB and SDIO, register writes in key clearing sleep
(via usb_control_msg() and sdio_claim_host()), which would trigger a
BUG: scheduling while atomic if executed. Because USB and SDIO do not
support firmware recovery, restrict rtw_fw_recovery() to PCI devices
via rtw_hci_type().
Signed-off-by: Kalpesh Solanki <skalpesh942@gmail.com>
---
drivers/net/wireless/realtek/rtw88/main.c | 5 +++++
drivers/net/wireless/realtek/rtw88/main.h | 1 +
drivers/net/wireless/realtek/rtw88/ps.c | 7 +++++++
drivers/net/wireless/realtek/rtw88/ps.h | 1 +
4 files changed, 14 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index a74f199a93a..7009f8ae3e5 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -638,6 +638,9 @@ static void rtw_reset_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
void rtw_fw_recovery(struct rtw_dev *rtwdev)
{
+ if (rtw_hci_type(rtwdev) != RTW_HCI_TYPE_PCIE)
+ return;
+
if (!test_bit(RTW_FLAG_RESTARTING, rtwdev->flags))
ieee80211_queue_work(rtwdev->hw, &rtwdev->fw_recovery_work);
}
@@ -1536,6 +1539,8 @@ int rtw_core_start(struct rtw_dev *rtwdev)
set_bit(RTW_FLAG_RUNNING, rtwdev->flags);
+ rtwdev->ps_hang_cnt = 0;
+
return 0;
}
diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index 6ecbeb4ffe4..525f17590ad 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -2113,6 +2113,7 @@ struct rtw_dev {
/* lps power state & handler work */
struct rtw_lps_conf lps_conf;
bool ps_enabled;
+ u8 ps_hang_cnt;
bool beacon_loss;
struct completion lps_leave_check;
diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c
index add5a20b843..fa3a4e476cf 100644
--- a/drivers/net/wireless/realtek/rtw88/ps.c
+++ b/drivers/net/wireless/realtek/rtw88/ps.c
@@ -166,6 +166,13 @@ static void rtw_fw_leave_lps_check(struct rtw_dev *rtwdev)
rtw_write32_clr(rtwdev, REG_TCR, BIT_PWRMGT_HWDATA_EN);
rtw_warn(rtwdev, "firmware failed to leave lps state\n");
rtw_fw_dump_dbg_info(rtwdev);
+
+ rtwdev->ps_hang_cnt++;
+ if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_PCIE &&
+ rtwdev->ps_hang_cnt >= RTW_PS_HANG_MAX_CNT)
+ rtw_fw_recovery(rtwdev);
+ } else {
+ rtwdev->ps_hang_cnt = 0;
}
}
diff --git a/drivers/net/wireless/realtek/rtw88/ps.h b/drivers/net/wireless/realtek/rtw88/ps.h
index 5ae83d2526c..b088fad7cd8 100644
--- a/drivers/net/wireless/realtek/rtw88/ps.h
+++ b/drivers/net/wireless/realtek/rtw88/ps.h
@@ -14,6 +14,7 @@
#define LEAVE_LPS_TRY_CNT 5
#define LEAVE_LPS_TIMEOUT msecs_to_jiffies(100)
+#define RTW_PS_HANG_MAX_CNT 3
int rtw_enter_ips(struct rtw_dev *rtwdev);
int rtw_leave_ips(struct rtw_dev *rtwdev);
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v4 1/3] wifi: rtw88: clear RTW_FLAG_RESTARTING on stop and start failure
2026-11-08 14:27 ` [PATCH v4 1/3] wifi: rtw88: clear RTW_FLAG_RESTARTING on stop and start failure Kalpesh Solanki
@ 2026-11-09 7:05 ` Luka Gejak
0 siblings, 0 replies; 13+ messages in thread
From: Luka Gejak @ 2026-11-09 7:05 UTC (permalink / raw)
To: Kalpesh Solanki, pkshih; +Cc: kvalo, linux-wireless, linux-kernel, stable
On November 8, 2026 3:27:05 PM GMT+01:00, Kalpesh Solanki
<skalpesh942@gmail.com> wrote:
>When mac80211 stops or suspends the device without WoWLAN,
>drv_reconfig_complete() is never invoked with
>IEEE80211_RECONFIG_TYPE_RESTART. If firmware recovery was in flight
>during this transition, RTW_FLAG_RESTARTING remains set permanently,
>blocking all subsequent firmware recoveries until the module is reloaded.
>
>Similarly, if rtw_core_start() fails during drv_start() in a recovery
>restart, local->started remains false. When mac80211 cleans up via
>cfg80211_shutdown_all_interfaces(), drv_stop() returns early without
>calling rtw_ops_stop(), leaving RTW_FLAG_RESTARTING set permanently on
>hardware that failed to recover.
>
>Clear RTW_FLAG_RESTARTING in rtw_ops_stop(), as well as in
>rtw_ops_start() when rtw_core_start() returns an error, ensuring the
>driver always exits the restarting state on error or teardown.
>
>Fixes: 5c831644e1f4 ("rtw88: handle and recover when firmware crash")
>Cc: stable@vger.kernel.org
>Signed-off-by: Kalpesh Solanki <skalpesh942@gmail.com>
>---
Looks good to me,
Reviewed-by: Luka Gejak <luka.gejak@linux.dev>
Best regards,
Luka Gejak
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v4 2/3] wifi: rtw88: skip already reset station in rtw_sta_remove()
2026-11-08 14:27 ` [PATCH v4 2/3] wifi: rtw88: skip already reset station in rtw_sta_remove() Kalpesh Solanki
@ 2026-11-09 7:11 ` Luka Gejak
0 siblings, 0 replies; 13+ messages in thread
From: Luka Gejak @ 2026-11-09 7:11 UTC (permalink / raw)
To: Kalpesh Solanki, pkshih; +Cc: kvalo, linux-wireless, linux-kernel, stable
Hi Kalpesh,
Thanks for adding this. One comment below.
On November 8, 2026 3:27:06 PM GMT+01:00, Kalpesh Solanki
<skalpesh942@gmail.com> wrote:
> diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
> index f7708ad17b6f..a74f199a93ab 100644
> --- a/drivers/net/wireless/realtek/rtw88/main.c
> +++ b/drivers/net/wireless/realtek/rtw88/main.c
> @@ -384,6 +384,9 @@ void rtw_sta_remove(struct rtw_dev *rtwdev, struct ieee80211_sta *sta,
> struct ieee80211_vif *vif = si->vif;
> int i;
>
> + if (!vif)
> + return;
> +
> cancel_work_sync(&si->rc_work);
As far as I can see rtw_ops_sta_rc_update() can queue rc_work again after
the recovery has reset the station. If the station is then removed before
the restart adds it back, this return skips the only cancel_work_sync()
and rtw_sta_rc_work() could run on a freed station.
The window is small, but maybe the check could just go below
cancel_work_sync()?
Best regards,
Luka Gejak
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v4 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI
2026-11-08 14:27 ` [PATCH v4 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI Kalpesh Solanki
@ 2026-11-09 7:13 ` Luka Gejak
[not found] ` <CADYuhkqCNQxevZih3D+Zu-HcuyOao99iF31+Y6kDP0iM_Rr1kQ@mail.gmail.com>
0 siblings, 1 reply; 13+ messages in thread
From: Luka Gejak @ 2026-11-09 7:13 UTC (permalink / raw)
To: Kalpesh Solanki, pkshih; +Cc: kvalo, linux-wireless, linux-kernel
Hi Kalpesh,
Thanks for the new version. Two comments below.
On November 8, 2026 3:27:07 PM GMT+01:00, Kalpesh Solanki
<skalpesh942@gmail.com> wrote:
> diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
> index a74f199a93ab..7009f8ae3e57 100644 > --- a/drivers/net/wireless/realtek/rtw88/main.c > +++ b/drivers/net/wireless/realtek/rtw88/main.c > @@ -638,6 +638,9 @@ static void rtw_reset_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
>
> void rtw_fw_recovery(struct rtw_dev *rtwdev)
> {
> + if (rtw_hci_type(rtwdev) != RTW_HCI_TYPE_PCIE)
> + return;
> +
The same check is also in rtw_fw_leave_lps_check() below, and the other
callers of rtw_fw_recovery() are PCI only, so I think this one can go.
[ ... ]
> diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c
> index add5a20b8432..fa3a4e476cf6 100644
> --- a/drivers/net/wireless/realtek/rtw88/ps.c
> +++ b/drivers/net/wireless/realtek/rtw88/ps.c
> @@ -166,6 +166,13 @@ static void rtw_fw_leave_lps_check(struct rtw_dev *rtwdev)
> rtw_write32_clr(rtwdev, REG_TCR, BIT_PWRMGT_HWDATA_EN);
> rtw_warn(rtwdev, "firmware failed to leave lps state\n");
> rtw_fw_dump_dbg_info(rtwdev);
> +
> + rtwdev->ps_hang_cnt++;
> + if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_PCIE &&
> + rtwdev->ps_hang_cnt >= RTW_PS_HANG_MAX_CNT)
> + rtw_fw_recovery(rtwdev);
> + } else {
> + rtwdev->ps_hang_cnt = 0;
> }
As far as I can see this can't reach the limit on stuck firmware without
FW_FEATURE_LPS_C2H, which seems to include rtw8822b and rtw8723d. The
register check passes once the bit is clear, the failure path above
clears it, and I can only see the firmware setting it again when it
enters LPS.
So if I read it right, stuck firmware gives one failure, then the next
check passes and resets the counter, as long as the registers still read
fine. Three in a row would need firmware that is still running.
Would it make sense to only count failures when FW_FEATURE_LPS_C2H is set?
Ping-Ke, do you know if only the firmware sets this bit?
Best regards,
Luka Gejak
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v4 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI
[not found] ` <CADYuhkqCNQxevZih3D+Zu-HcuyOao99iF31+Y6kDP0iM_Rr1kQ@mail.gmail.com>
@ 2026-11-09 8:32 ` KALPESH SOLANKI
2026-11-09 8:42 ` Luka Gejak
0 siblings, 1 reply; 13+ messages in thread
From: KALPESH SOLANKI @ 2026-11-09 8:32 UTC (permalink / raw)
To: Luka Gejak; +Cc: pkshih, kvalo, linux-wireless, linux-kernel
Hi Luka, Ping-Ke,
Thank you for the reviews and feedback. I have had a bereavement in
the family yesterday and will be away for a few days.
I have noted the comments and will follow up with v5 once I am back
and after lore/patchwork is operational.
Best regards,
Kalpesh
On Mon, 9 Nov 2026 at 13:53, KALPESH SOLANKI <skalpesh942@gmail.com> wrote:
>
> Hi Luka, Ping-Ke,
>
> Thank you for the reviews and feedback. I have had a bereavement in the family yesterday and will be away for a few days.
>
> I have noted the comments and will follow up with v5 once I am back and after lore/patchwork is operational.
>
> Best regards,
> Kalpesh
>
> On Mon, 9 Nov 2026 at 12:43, Luka Gejak <luka.gejak@linux.dev> wrote:
>>
>> Hi Kalpesh,
>>
>> Thanks for the new version. Two comments below.
>>
>> On November 8, 2026 3:27:07 PM GMT+01:00, Kalpesh Solanki
>> <skalpesh942@gmail.com> wrote:
>> > diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
>> > index a74f199a93ab..7009f8ae3e57 100644 > --- a/drivers/net/wireless/realtek/rtw88/main.c > +++ b/drivers/net/wireless/realtek/rtw88/main.c > @@ -638,6 +638,9 @@ static void rtw_reset_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
>> >
>> > void rtw_fw_recovery(struct rtw_dev *rtwdev)
>> > {
>> > + if (rtw_hci_type(rtwdev) != RTW_HCI_TYPE_PCIE)
>> > + return;
>> > +
>>
>> The same check is also in rtw_fw_leave_lps_check() below, and the other
>> callers of rtw_fw_recovery() are PCI only, so I think this one can go.
>>
>> [ ... ]
>>
>> > diff --git a/drivers/net/wireless/realtek/rtw88/ps.c b/drivers/net/wireless/realtek/rtw88/ps.c
>> > index add5a20b8432..fa3a4e476cf6 100644
>> > --- a/drivers/net/wireless/realtek/rtw88/ps.c
>> > +++ b/drivers/net/wireless/realtek/rtw88/ps.c
>> > @@ -166,6 +166,13 @@ static void rtw_fw_leave_lps_check(struct rtw_dev *rtwdev)
>> > rtw_write32_clr(rtwdev, REG_TCR, BIT_PWRMGT_HWDATA_EN);
>> > rtw_warn(rtwdev, "firmware failed to leave lps state\n");
>> > rtw_fw_dump_dbg_info(rtwdev);
>> > +
>> > + rtwdev->ps_hang_cnt++;
>> > + if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_PCIE &&
>> > + rtwdev->ps_hang_cnt >= RTW_PS_HANG_MAX_CNT)
>> > + rtw_fw_recovery(rtwdev);
>> > + } else {
>> > + rtwdev->ps_hang_cnt = 0;
>> > }
>>
>> As far as I can see this can't reach the limit on stuck firmware without
>> FW_FEATURE_LPS_C2H, which seems to include rtw8822b and rtw8723d. The
>> register check passes once the bit is clear, the failure path above
>> clears it, and I can only see the firmware setting it again when it
>> enters LPS.
>>
>> So if I read it right, stuck firmware gives one failure, then the next
>> check passes and resets the counter, as long as the registers still read
>> fine. Three in a row would need firmware that is still running.
>>
>> Would it make sense to only count failures when FW_FEATURE_LPS_C2H is set?
>> Ping-Ke, do you know if only the firmware sets this bit?
>>
>>
>> Best regards,
>> Luka Gejak
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v4 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI
2026-11-09 8:32 ` KALPESH SOLANKI
@ 2026-11-09 8:42 ` Luka Gejak
0 siblings, 0 replies; 13+ messages in thread
From: Luka Gejak @ 2026-11-09 8:42 UTC (permalink / raw)
To: KALPESH SOLANKI; +Cc: pkshih, kvalo, linux-wireless, linux-kernel
On November 9, 2026 9:32:09 AM GMT+01:00, KALPESH SOLANKI
<skalpesh942@gmail.com> wrote:
>Hi Luka, Ping-Ke,
>
>Thank you for the reviews and feedback. I have had a bereavement in
>the family yesterday and will be away for a few days.
>
>I have noted the comments and will follow up with v5 once I am back
>and after lore/patchwork is operational.
>
>Best regards,
>Kalpesh
>
>
Of course, take your time, no rush.
Best regards,
Luka Gejak
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling
2026-11-08 14:27 [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling Kalpesh Solanki
` (2 preceding siblings ...)
2026-11-08 14:27 ` [PATCH v4 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI Kalpesh Solanki
@ 2026-11-11 3:37 ` Ping-Ke Shih
2026-11-11 6:28 ` Luka Gejak
3 siblings, 1 reply; 13+ messages in thread
From: Ping-Ke Shih @ 2026-11-11 3:37 UTC (permalink / raw)
To: Kalpesh Solanki, luka.gejak@linux.dev
Cc: kvalo@kernel.org, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org
Kalpesh Solanki <skalpesh942@gmail.com> wrote:
> Changes in v4:
> - In patch 1/3: Also clear RTW_FLAG_RESTARTING in rtw_ops_start() if
> rtw_core_start() fails.
> - Add patch 2/3: Prevent double free and sta_cnt underflow in
> rtw_sta_remove() when recovery races with station disconnect.
> - In patch 3/3:
> - Keep rtw_fw_dump_dbg_info() in place on first failure.
> - Restrict firmware recovery invocation to PCIe devices to prevent
> scheduling while atomic panic on USB and SDIO.
> - Explicitly check rtw_hci_type() in rtw_fw_recovery().
I can't see v4 in lore nor patchwork. Please send v5 (identical to v4).
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling
2026-11-11 3:37 ` [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling Ping-Ke Shih
@ 2026-11-11 6:28 ` Luka Gejak
2026-11-11 6:44 ` Ping-Ke Shih
0 siblings, 1 reply; 13+ messages in thread
From: Luka Gejak @ 2026-11-11 6:28 UTC (permalink / raw)
To: Ping-Ke Shih, Kalpesh Solanki
Cc: kvalo@kernel.org, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org
On November 11, 2026 4:37:18 AM GMT+01:00, Ping-Ke Shih
<pkshih@realtek.com> wrote:
>Kalpesh Solanki <skalpesh942@gmail.com> wrote:
>> Changes in v4:
>> - In patch 1/3: Also clear RTW_FLAG_RESTARTING in rtw_ops_start() if
>> rtw_core_start() fails.
>> - Add patch 2/3: Prevent double free and sta_cnt underflow in
>> rtw_sta_remove() when recovery races with station disconnect.
>> - In patch 3/3:
>> - Keep rtw_fw_dump_dbg_info() in place on first failure.
>> - Restrict firmware recovery invocation to PCIe devices to prevent
>> scheduling while atomic panic on USB and SDIO.
>> - Explicitly check rtw_hci_type() in rtw_fw_recovery().
>
>I can't see v4 in lore nor patchwork. Please send v5 (identical to v4).
>
>
Shouldn't Kalpesh address the review comments before pushing v5 so we don't
waste a version cycle? He mentioned he'd follow up in a few days with v5 to
address the v4 feedback.
Best regards,
Luka Gejak
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling
2026-11-11 6:28 ` Luka Gejak
@ 2026-11-11 6:44 ` Ping-Ke Shih
0 siblings, 0 replies; 13+ messages in thread
From: Ping-Ke Shih @ 2026-11-11 6:44 UTC (permalink / raw)
To: Luka Gejak, Kalpesh Solanki
Cc: kvalo@kernel.org, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org
Luka Gejak <luka.gejak@linux.dev> wrote:
> On November 11, 2026 4:37:18 AM GMT+01:00, Ping-Ke Shih
> <pkshih@realtek.com> wrote:
> >Kalpesh Solanki <skalpesh942@gmail.com> wrote:
> >> Changes in v4:
> >> - In patch 1/3: Also clear RTW_FLAG_RESTARTING in rtw_ops_start() if
> >> rtw_core_start() fails.
> >> - Add patch 2/3: Prevent double free and sta_cnt underflow in
> >> rtw_sta_remove() when recovery races with station disconnect.
> >> - In patch 3/3:
> >> - Keep rtw_fw_dump_dbg_info() in place on first failure.
> >> - Restrict firmware recovery invocation to PCIe devices to prevent
> >> scheduling while atomic panic on USB and SDIO.
> >> - Explicitly check rtw_hci_type() in rtw_fw_recovery().
> >
> >I can't see v4 in lore nor patchwork. Please send v5 (identical to v4).
> >
> >
>
> Shouldn't Kalpesh address the review comments before pushing v5 so we don't
> waste a version cycle? He mentioned he'd follow up in a few days with v5 to
> address the v4 feedback.
Ok. I just noted that v4 was missing.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v4 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI
@ 2026-11-12 13:13 Kalpesh Solanki
0 siblings, 0 replies; 13+ messages in thread
From: Kalpesh Solanki @ 2026-11-12 13:13 UTC (permalink / raw)
To: luka.gejak, pkshih; +Cc: kvalo, linux-wireless, linux-kernel, Kalpesh Solanki
Hi Luka, Ping-Ke,
Thank you both for your patience while I was away, and thank you Luka for
advocating to address the review feedback before pushing v5.
Regarding Luka's two comments on v4:
1. Redundant rtw_hci_type check in rtw_fw_recovery():
You are completely right. Since rtw_fw_leave_lps_check() already guards the
call with rtw_hci_type(rtwdev) == RTW_HCI_TYPE_PCIE, and the other callers in
pci.c are PCI-only, having an HCI check in rtw_fw_recovery() in main.c is
redundant. I have dropped it in v5.
2. ps_hang_cnt on non-FW_FEATURE_LPS_C2H chipsets:
Excellent catch! On chipsets without FW_FEATURE_LPS_C2H (such as RTL8822B
and RTL8723D), the check falls back to polling REG_TCR for
BIT_PWRMGT_HWDATA_EN. On timeout, the driver forcefully clears this bit via
rtw_write32_clr(rtwdev, REG_TCR, BIT_PWRMGT_HWDATA_EN) so packets can continue
to be transmitted. If the firmware is frozen, it will never re-assert this
bit. On the next check, the register read sees the bit cleared, falsely reports
success, and resets ps_hang_cnt back to 0. Thus, a stuck firmware on these
chips could never reach RTW_PS_HANG_MAX_CNT.
In v5, I have updated patch 3/3 so that ps_hang_cnt is only incremented and
evaluated when FW_FEATURE_LPS_C2H is supported:
if (rtw_fw_feature_check(fw, FW_FEATURE_LPS_C2H) &&
rtw_hci_type(rtwdev) == RTW_HCI_TYPE_PCIE) {
rtwdev->ps_hang_cnt++;
if (rtwdev->ps_hang_cnt >= RTW_PS_HANG_MAX_CNT)
rtw_fw_recovery(rtwdev);
}
For C2H-capable devices (such as RTL8822C and RTL8821C), completion signaling
reliably accumulates consecutive timeouts when the firmware hangs, while
legacy chipsets without C2H retain the upstream behavior (clear TCR and warn)
without getting trapped in a broken counter reset loop.
Regarding lore / patchwork:
It appears v4 was either dropped by list filters or delayed during list delivery.
I have sent out the full v5 series [PATCH v5 0/3] incorporating all the above
changes to the mailing list.
Thanks,
Kalpesh
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-11-12 13:13 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-08 14:27 [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling Kalpesh Solanki
2026-11-08 14:27 ` [PATCH v4 1/3] wifi: rtw88: clear RTW_FLAG_RESTARTING on stop and start failure Kalpesh Solanki
2026-11-09 7:05 ` Luka Gejak
2026-11-08 14:27 ` [PATCH v4 2/3] wifi: rtw88: skip already reset station in rtw_sta_remove() Kalpesh Solanki
2026-11-09 7:11 ` Luka Gejak
2026-11-08 14:27 ` [PATCH v4 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI Kalpesh Solanki
2026-11-09 7:13 ` Luka Gejak
[not found] ` <CADYuhkqCNQxevZih3D+Zu-HcuyOao99iF31+Y6kDP0iM_Rr1kQ@mail.gmail.com>
2026-11-09 8:32 ` KALPESH SOLANKI
2026-11-09 8:42 ` Luka Gejak
2026-11-11 3:37 ` [PATCH v4 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling Ping-Ke Shih
2026-11-11 6:28 ` Luka Gejak
2026-11-11 6:44 ` Ping-Ke Shih
-- strict thread matches above, loose matches on Subject: below --
2026-11-12 13:13 [PATCH v4 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI Kalpesh Solanki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox