From: Kang Yang <kang.yang@oss.qualcomm.com>
To: Loic Poulain <loic.poulain@oss.qualcomm.com>
Cc: Jeff Johnson <jjohnson@kernel.org>,
Baochen Qiang <baochen.qiang@oss.qualcomm.com>,
Jeff Johnson <jeff.johnson@oss.qualcomm.com>,
linux-wireless@vger.kernel.org, ath10k@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH ath-next v3 01/10] wifi: ath10k: fix SDIO aux workqueue starvation in recovery detection
Date: Fri, 20 Nov 2026 14:42:04 +0800 [thread overview]
Message-ID: <fd5cf760-b750-4c97-bc32-93bd4451664e@oss.qualcomm.com> (raw)
In-Reply-To: <CAFEp6-12bAc5YoP7BaP-GENQsNAifXVxehpdPUu2pi-X8hfC=Q@mail.gmail.com>
On 11/13/2026 5:24 PM, Loic Poulain wrote:
> On Thu, Nov 12, 2026 at 12:26 PM Kang Yang<kang.yang@oss.qualcomm.com> wrote:
>> Recovery monitoring runs on workqueue_aux, which is also
>> used by SDIO RX dispatch and WMI SERVICE_READY handling.
>>
>> A single firmware crash may generate multiple recovery
>> triggers. Recovery detection currently handles each one by
>> waiting for recovery completion on workqueue_aux. On SDIO,
>> this blocks the same workqueue needed to deliver recovery
>> traffic, preventing recovery from completing.
>>
>> As a result, otherwise recoverable firmware crashes fail
>> with:
>> ctl_resp never came in (-110)
>>
>> Treat duplicate triggers as part of the same recovery attempt. Use an
>> atomic compare-and-exchange on pending_recovery so only the first
>> trigger starts restart_work.
>>
>> Convert the recovery monitor to self-rearming delayed work. While
>> recovery remains pending, the monitor periodically checks its state
>> without blocking workqueue_aux. Cancel the monitor when recovery
>> succeeds or the device is stopped.
>>
>> 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
>>
>> Fixes: f35a07a4842a ("wifi: ath10k: move recovery check logic into a new work")
>> Signed-off-by: Kang Yang<kang.yang@oss.qualcomm.com>
>> ---
>> drivers/net/wireless/ath/ath10k/core.c | 71 +++++++++++++++++++---------------
>> drivers/net/wireless/ath/ath10k/core.h | 2 +-
>> drivers/net/wireless/ath/ath10k/mac.c | 13 ++++++-
>> 3 files changed, 53 insertions(+), 33 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
>> index 7c2939cbde5f..82bb0bb72dc7 100644
>> --- a/drivers/net/wireless/ath/ath10k/core.c
>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>> @@ -2493,48 +2493,54 @@ static int ath10k_init_hw_params(struct ath10k *ar)
>>
>> static void ath10k_core_recovery_check_work(struct work_struct *work)
>> {
>> - struct ath10k *ar = container_of(work, struct ath10k, recovery_check_work);
>> - long time_left;
>> + struct ath10k *ar = container_of(work, struct ath10k,
>> + recovery_check_work.work);
>> + int fail_count;
>>
>> - /* Sometimes the recovery will fail and then the next all recovery fail,
>> - * so avoid infinite recovery.
>> - */
>> - if (atomic_read(&ar->fail_cont_count) >= ATH10K_RECOVERY_MAX_FAIL_COUNT) {
>> - ath10k_err(ar, "consecutive fail %d times, will shutdown driver!",
>> - atomic_read(&ar->fail_cont_count));
>> - ar->state = ATH10K_STATE_WEDGED;
>> + if (ar->state == ATH10K_STATE_WEDGED)
>> return;
>> - }
>> -
>> - ath10k_dbg(ar, ATH10K_DBG_BOOT, "total recovery count: %d", ++ar->recovery_count);
>>
>> - if (atomic_read(&ar->pending_recovery)) {
>> - /* Sometimes it happened another recovery work before the previous one
>> - * completed, then the second recovery work will destroy the previous
>> - * one, thus below is to avoid that.
>> - */
>> - time_left = wait_for_completion_timeout(&ar->driver_recovery,
>> - ATH10K_RECOVERY_TIMEOUT_HZ);
>> - if (time_left) {
>> - ath10k_warn(ar, "previous recovery succeeded, skip this!\n");
>> - return;
>> - }
>> + /*
>> + * Pure monitor: only ath10k_core_start_recovery() starts a fresh
>> + * cycle. Bail if there is nothing in flight.
>> + */
>> + if (!atomic_read(&ar->pending_recovery))
>> + return;
>>
>> - /* Record the continuous recovery fail count when recovery failed. */
>> - atomic_inc(&ar->fail_cont_count);
>> + /* Record the continuous recovery fail count when recovery is late. */
>> + fail_count = atomic_inc_return(&ar->fail_cont_count);
> I don't understand why we need so much complication and the need to
> count and restart this work again, why not simply scheduling the work
> or a timer at the final expected timeout instead, then if we reach the
> timeout the device is simply marked as wedged.
Yeah, you are right. Early this patch-set will re-queue restart work so
we have the fail_cont_count. Now only one restart work will be executed
at one time, so we can delete the fail_cont_count and related code.
>
>
>> - /* Avoid having multiple recoveries at the same time. */
>> + 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;
>> }
>>
>> - atomic_inc(&ar->pending_recovery);
>> - queue_work(ar->workqueue, &ar->restart_work);
>> + /* Recovery still in flight; check again later. */
>> + queue_delayed_work(ar->workqueue_aux, &ar->recovery_check_work,
>> + ATH10K_RECOVERY_TIMEOUT_HZ);
>> }
>>
>> void ath10k_core_start_recovery(struct ath10k *ar)
>> {
>> - /* Use workqueue_aux to avoid blocking recovery tracking */
>> - queue_work(ar->workqueue_aux, &ar->recovery_check_work);
>> + if (ar->state == ATH10K_STATE_WEDGED)
>> + return;
>> +
>> + /*
>> + * SDIO raises several triggers within microseconds of one crash;
>> + * only the first winner starts a fresh cycle. Losers do nothing
>> + * while the owner runs recovery.
>> + */
>> + if (atomic_cmpxchg(&ar->pending_recovery, 0, 1) != 0)
>> + 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);
>> + queue_work(ar->workqueue, &ar->restart_work);
>> + queue_delayed_work(ar->workqueue_aux, &ar->recovery_check_work,
>> + ATH10K_RECOVERY_TIMEOUT_HZ);
>> }
>> EXPORT_SYMBOL(ath10k_core_start_recovery);
>>
>> @@ -3727,7 +3733,7 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
>>
>> INIT_WORK(&ar->register_work, ath10k_core_register_work);
>> INIT_WORK(&ar->restart_work, ath10k_core_restart);
>> - INIT_WORK(&ar->recovery_check_work, ath10k_core_recovery_check_work);
>> + INIT_DELAYED_WORK(&ar->recovery_check_work, ath10k_core_recovery_check_work);
>> INIT_WORK(&ar->set_coverage_class_work,
>> ath10k_core_set_coverage_class_work);
>>
>> @@ -3764,6 +3770,9 @@ EXPORT_SYMBOL(ath10k_core_create);
>>
>> void ath10k_core_destroy(struct ath10k *ar)
>> {
>> + cancel_work_sync(&ar->restart_work);
>> + cancel_delayed_work_sync(&ar->recovery_check_work);
>> +
>> destroy_workqueue(ar->workqueue);
>>
>> destroy_workqueue(ar->workqueue_aux);
>> diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
>> index dfee432615eb..e8fcbef38ca6 100644
>> --- a/drivers/net/wireless/ath/ath10k/core.h
>> +++ b/drivers/net/wireless/ath/ath10k/core.h
>> @@ -1207,7 +1207,7 @@ struct ath10k {
>>
>> struct work_struct register_work;
>> struct work_struct restart_work;
>> - struct work_struct recovery_check_work;
>> + struct delayed_work recovery_check_work;
>> struct work_struct bundle_tx_work;
>> struct work_struct tx_complete_work;
>>
>> diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
>> index 8e604697d6c2..3c45e5483b60 100644
>> --- a/drivers/net/wireless/ath/ath10k/mac.c
>> +++ b/drivers/net/wireless/ath/ath10k/mac.c
>> @@ -5427,7 +5427,15 @@ static void ath10k_stop(struct ieee80211_hw *hw, bool suspend)
>> cancel_work_sync(&ar->set_coverage_class_work);
>> cancel_delayed_work_sync(&ar->scan.timeout);
>> cancel_work_sync(&ar->restart_work);
>> - cancel_work_sync(&ar->recovery_check_work);
>> + cancel_delayed_work_sync(&ar->recovery_check_work);
>> +
>> + /* ath10k_stop() can race with an in-flight recovery. Clear the
>> + * recovery state after the works are cancelled so a later
>> + * ath10k_start() can start a fresh cycle instead of being blocked
>> + * by a stale pending_recovery that nothing will clear.
>> + */
>> + atomic_set(&ar->fail_cont_count, 0);
>> + atomic_set(&ar->pending_recovery, 0);
>> }
>>
>> static int ath10k_config_ps(struct ath10k *ar)
>> @@ -8170,6 +8178,9 @@ static void ath10k_reconfig_complete(struct ieee80211_hw *hw,
>> 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);
>>
>> --
>> 2.34.1
>>
next prev parent reply other threads:[~2026-11-20 6:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 11:25 [PATCH ath-next v3 00/10] wifi: ath10k: fix recovery and WEDGED failure handling Kang Yang
2026-11-12 11:26 ` [PATCH ath-next v3 01/10] wifi: ath10k: fix SDIO aux workqueue starvation in recovery detection Kang Yang
2026-11-13 9:24 ` Loic Poulain
2026-11-20 6:42 ` Kang Yang [this message]
2026-11-12 11:26 ` [PATCH ath-next v3 02/10] wifi: ath10k: wake blocked waiters when entering WEDGED state Kang Yang
2026-11-12 11:26 ` [PATCH ath-next v3 03/10] wifi: ath10k: also wake remaining blocked waiters Kang Yang
2026-11-12 11:26 ` [PATCH ath-next v3 04/10] wifi: ath10k: bound recovery time before entering WEDGED Kang Yang
2026-11-12 11:26 ` [PATCH ath-next v3 05/10] wifi: ath10k: hard-block the radio when entering WEDGED state Kang Yang
2026-11-12 11:26 ` [PATCH ath-next v3 06/10] wifi: ath10k: remove now-unused driver_recovery completion Kang Yang
2026-11-12 11:26 ` [PATCH ath-next v3 07/10] wifi: ath10k: trigger recovery on PCIe MMIO wake-up failures Kang Yang
2026-11-12 11:26 ` [PATCH ath-next v3 08/10] wifi: ath10k: trigger recovery on corrupted HTC bundle lookahead Kang Yang
2026-11-12 11:26 ` [PATCH ath-next v3 09/10] wifi: ath10k: reject scan requests while the device is not running Kang Yang
2026-11-12 11:26 ` [PATCH ath-next v3 10/10] wifi: ath10k: drop async writes and sleep timer across power cycles Kang Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fd5cf760-b750-4c97-bc32-93bd4451664e@oss.qualcomm.com \
--to=kang.yang@oss.qualcomm.com \
--cc=ath10k@lists.infradead.org \
--cc=baochen.qiang@oss.qualcomm.com \
--cc=jeff.johnson@oss.qualcomm.com \
--cc=jjohnson@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®