Skip to content

wifi: rtw88: firmware recovery fixes and LPS hang handling

Kalpesh Solanki linux-wireless lkml stable 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest3 patches 2 repliesIn review
  2. v53 patches 6 repliesSuperseded
  3. v43 patches 8 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v32 patches8 repliesSuperseded

Changes in v6 from the cover letter

- In patch 1/3:
- Pick up Reviewed-by tag from Luka Gejak.
- In patch 2/3:
- Keep cancel_work_sync(&si->rc_work) before checking !vif so that rate control work scheduled by rtw_ops_sta_rc_update() after recovery reset is not skipped if the station is removed before restart adds it back.
- Clear si->use_cfg_mask = false alongside si->mask = NULL to prevent a NULL pointer dereference in rtw_rate_mask_cfg() if mac80211 re-adds the station across recovery restart.
- In patch 3/3:
- Pick up Reviewed-by tag from Luka Gejak.

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3wifi: rtw88: clear RTW_FLAG_RESTARTING on stop and start failuredrivers/net/wireless/realtek/rtw88/mac80211.c+3 -01 reply
2/3wifi: rtw88: skip already reset station in rtw_sta_remove()drivers/net/wireless/realtek/rtw88/main.c+6 -01 reply
3/3wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCIdrivers/net/wireless/realtek/rtw88/main.c drivers/net/wireless/realtek/rtw88/main.h drivers/net/wireless/realtek/rtw88/ps.c +1 more+13 -00 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchLuka Gejak
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH v6 0/3] wifi: rtw88: firmware recovery fixes and LPS hang handling

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 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 after ensuring pending rate control work is cancelled, and clear si->vif, si->mask, and si->use_cfg_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. Gated on FW_FEATURE_LPS_C2H because legacy chips clear REG_TCR on failure which masks stuck firmware from accumulating consecutive timeouts. ps_hang_cnt is reset on success and in rtw_core_start().

Changes in v6:
- In patch 1/3:
- Pick up Reviewed-by tag from Luka Gejak.
- In patch 2/3:
- Keep cancel_work_sync(&si->rc_work) before checking !vif so that rate control work scheduled by rtw_ops_sta_rc_update() after recovery reset is not skipped if the station is removed before restart adds it back.
- Clear si->use_cfg_mask = false alongside si->mask = NULL to prevent a NULL pointer dereference in rtw_rate_mask_cfg() if mac80211 re-adds the station across recovery restart.
- In patch 3/3:
- Pick up Reviewed-by tag from Luka Gejak.

Changes in v5:
- In patch 3/3:
- Drop redundant rtw_hci_type check in rtw_fw_recovery(); the check in rtw_fw_leave_lps_check() and the existing PCI-only callers already guarantee non-PCI devices never invoke recovery.
- Only increment ps_hang_cnt and trigger recovery when the firmware supports FW_FEATURE_LPS_C2H. On legacy chipsets without C2H support, clearing REG_TCR on failure causes subsequent register checks to pass immediately, resetting the counter and preventing stuck firmware from ever reaching the threshold.

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     | 8 ++++++++
 drivers/net/wireless/realtek/rtw88/main.h     | 1 +
 drivers/net/wireless/realtek/rtw88/ps.c       | 9 +++++++++
 drivers/net/wireless/realtek/rtw88/ps.h       | 1 +
 5 files changed, 22 insertions(+)
Signature · 1 line
2.53.0