Re: [PATCH v5 3/3] wifi: rtw88: ps: trigger firmware recovery only after consecutive LPS leave failures on PCI

From: Luka Gejak

Date: Thu Nov 12 2026 - 18:39:40 EST


On November 12, 2026 2:14:01 PM GMT+01:00, Kalpesh Solanki
<skalpesh942@xxxxxxxxx> wrote:
>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.
>
>On chipsets without FW_FEATURE_LPS_C2H (such as RTL8822B and RTL8723D),
>rtw_fw_leave_lps_check() falls back to polling REG_TCR for
>BIT_PWRMGT_HWDATA_EN. On timeout, the driver forcefully clears this
>bit so subsequent packets can be transmitted. Because stuck firmware
>never re-asserts the bit, subsequent register checks immediately pass,
>clearing ps_hang_cnt back to 0 and preventing the counter from ever
>accumulating. Therefore, only count consecutive failures on devices
>with FW_FEATURE_LPS_C2H, where C2H completion signaling reliably detects
>consecutive timeouts.
>
>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 firmware recovery invocation to
>PCI devices via rtw_hci_type().
>
>Signed-off-by: Kalpesh Solanki <skalpesh942@xxxxxxxxx>
>---

Looks good to me,

Reviewed-by: Luka Gejak <luka.gejak@xxxxxxxxx>

Best regards,
Luka Gejak