Re: [PATCH ath-next v5 02/12] wifi: ath10k: replace the recovery failure count with a single deadline
From: Loic Poulain
Date: Wed Dec 02 2026 - 04:53:20 EST
On Wed, Dec 2, 2026 at 7:09 AM Kang Yang <kang.yang@xxxxxxxxxxxxxxxx> wrote:
>
> The recovery monitor re-arms itself every ATH10K_RECOVERY_TIMEOUT_HZ
> (5 s) and counts the expirations in fail_cont_count, declaring the
> device WEDGED once the count reaches ATH10K_RECOVERY_MAX_FAIL_COUNT (4).
> Nothing restarts restart_work between those expirations, so the count
> only measures how long the single pending recovery has been running:
> 4 x 5 s = 20 s.
>
> Replace it with a one-shot delayed work armed by
> ath10k_core_start_recovery() for the full 20 s. If pending_recovery is
> still set when it fires, recovery did not complete and the device is
> marked WEDGED. The monitor is still cancelled when recovery completes
> or the device is stopped.
>
> In ath10k_reconfig_complete(), move cancel_delayed_work_sync() and
> the pending_recovery reset in front of the RESTARTED check. The monitor
> runs on its own timeline, so after an unsuccessful recovery the state
> has already been set to WEDGED and the monitor may still be scheduled.
> Cancelling it up front also pairs the monitor cancellation with the
> pending_recovery reset so neither can race with a late expiration.
>
> This drops fail_cont_count, its resets in ath10k_core_start_recovery(),
> ath10k_stop() and ath10k_reconfig_complete(), and the self re-arming.
> The time allowed for recovery to complete is unchanged.
>
> Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00288-QCARMSWPZ-1
> Tested-on: QCA6174 hw3.2 SDIO WLAN.RMH.4.4.1-00189
>
> Signed-off-by: Kang Yang <kang.yang@xxxxxxxxxxxxxxxx>
Reviewed-by: Loic Poulain <loic.poulain@xxxxxxxxxxxxxxxx>
> ---
> drivers/net/wireless/ath/ath10k/core.c | 24 ++++--------------------
> drivers/net/wireless/ath/ath10k/core.h | 5 +----
> drivers/net/wireless/ath/ath10k/mac.c | 15 ++++++---------
> 3 files changed, 11 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
> index ab461aaf5c01..b617066df652 100644
> --- a/drivers/net/wireless/ath/ath10k/core.c
> +++ b/drivers/net/wireless/ath/ath10k/core.c
> @@ -2537,31 +2537,17 @@ static void ath10k_core_recovery_check_work(struct work_struct *work)
> {
> struct ath10k *ar = container_of(work, struct ath10k,
> recovery_check_work.work);
> - int fail_count;
>
> if (ar->state == ATH10K_STATE_WEDGED)
> return;
>
> - /*
> - * Pure monitor: only ath10k_core_start_recovery() starts a fresh
> - * cycle. Bail if there is nothing in flight.
> - */
> + /* Deadline monitor: bail if no recovery is in flight. */
> if (!atomic_read(&ar->pending_recovery))
> return;
>
> - /* Record the continuous recovery fail count when recovery is late. */
> - fail_count = atomic_inc_return(&ar->fail_cont_count);
> -
> - if (fail_count >= ATH10K_RECOVERY_MAX_FAIL_COUNT) {
> - ath10k_err(ar, "consecutive fail %d times, will shutdown driver!",
> - fail_count);
> - ar->state = ATH10K_STATE_WEDGED;
> - return;
> - }
> -
> - /* Recovery still in flight; check again later. */
> - queue_delayed_work(ar->workqueue_aux, &ar->recovery_check_work,
> - ATH10K_RECOVERY_TIMEOUT_HZ);
> + ath10k_err(ar, "recovery did not complete in %u ms, will shutdown driver!\n",
> + jiffies_to_msecs(ATH10K_RECOVERY_TIMEOUT_HZ));
> + ar->state = ATH10K_STATE_WEDGED;
> }
>
> void ath10k_core_start_recovery(struct ath10k *ar)
> @@ -2574,8 +2560,6 @@ void ath10k_core_start_recovery(struct ath10k *ar)
> return;
> ath10k_dbg(ar, ATH10K_DBG_BOOT, "total recovery count: %d",
> ++ar->recovery_count);
> - /* Start a fresh failure budget; the last cycle may not have completed. */
> - atomic_set(&ar->fail_cont_count, 0);
> /* Arm the monitor first; restart_work may cancel it. */
> queue_delayed_work(ar->workqueue_aux, &ar->recovery_check_work,
> ATH10K_RECOVERY_TIMEOUT_HZ);
> diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
> index e8fcbef38ca6..2e100dd246e2 100644
> --- a/drivers/net/wireless/ath/ath10k/core.h
> +++ b/drivers/net/wireless/ath/ath10k/core.h
> @@ -87,8 +87,7 @@
> IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER)
> #define ATH10K_ITER_RESUME_FLAGS (IEEE80211_IFACE_ITER_RESUME_ALL |\
> IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER)
> -#define ATH10K_RECOVERY_TIMEOUT_HZ (5 * HZ)
> -#define ATH10K_RECOVERY_MAX_FAIL_COUNT 4
> +#define ATH10K_RECOVERY_TIMEOUT_HZ (20 * HZ)
>
> struct ath10k;
>
> @@ -1213,8 +1212,6 @@ struct ath10k {
>
> atomic_t pending_recovery;
> unsigned int recovery_count;
> - /* continuous recovery fail count */
> - atomic_t fail_cont_count;
>
> /* cycle count is reported twice for each visited channel during scan.
> * access protected by data_lock
> diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
> index c224d3db10f6..a51eb070d987 100644
> --- a/drivers/net/wireless/ath/ath10k/mac.c
> +++ b/drivers/net/wireless/ath/ath10k/mac.c
> @@ -5430,7 +5430,6 @@ static void ath10k_stop(struct ieee80211_hw *hw, bool suspend)
> cancel_delayed_work_sync(&ar->recovery_check_work);
>
> /* Works are cancelled; clear stale recovery state for next start. */
> - atomic_set(&ar->fail_cont_count, 0);
> atomic_set(&ar->pending_recovery, 0);
> }
>
> @@ -8166,21 +8165,19 @@ static void ath10k_reconfig_complete(struct ieee80211_hw *hw,
>
> mutex_lock(&ar->conf_mutex);
>
> - /* If device failed to restart it will be in a different state, e.g.
> + /* Cancel the monitor first so it cannot wedge a recovered device. */
> + cancel_delayed_work_sync(&ar->recovery_check_work);
> + atomic_set(&ar->pending_recovery, 0);
> +
> + /*
> + * If device failed to restart it will be in a different state, e.g.
> * ATH10K_STATE_WEDGED
> */
> if (ar->state == ATH10K_STATE_RESTARTED) {
> ath10k_info(ar, "device successfully recovered\n");
> ar->state = ATH10K_STATE_ON;
> ieee80211_wake_queues(ar->hw);
> -
> - /* Cancel the monitor first so it cannot bump the count after reset. */
> - cancel_delayed_work_sync(&ar->recovery_check_work);
> -
> - /* Clear recovery state. */
> complete(&ar->driver_recovery);
> - atomic_set(&ar->fail_cont_count, 0);
> - atomic_set(&ar->pending_recovery, 0);
>
> if (ar->hw_params.hw_restart_disconnect) {
> list_for_each_entry(arvif, &ar->arvifs, list) {
>
> --
> 2.34.1
>