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 v2 1/8] wifi: ath10k: fix SDIO aux workqueue starvation in recovery detection
Date: Thu, 22 Oct 2026 10:06:07 +0800 [thread overview]
Message-ID: <c49d0198-7207-4439-9be4-22d35e741ac9@oss.qualcomm.com> (raw)
In-Reply-To: <CAFEp6-3UB=U16NkQNM_H4gUA71XWvYLcmcO_mJhFpX=9yC=HiQ@mail.gmail.com>
On 10/21/2026 9:33 PM, Loic Poulain wrote:
> On Wed, Oct 21, 2026 at 11:09 AM 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 recovery triggers as part of a single
>> recovery attempt by gating recovery startup in
>> ath10k_core_start_recovery() with an atomic_cmpxchg() on
>> pending_recovery, and by making the monitor path check the
>> elapsed time since the attempt started instead of blocking
>> on a completion.
>>
>> 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 | 64 +++++++++++++++++++---------------
>> drivers/net/wireless/ath/ath10k/core.h | 2 ++
>> 2 files changed, 37 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
>> index 7c2939cbde5f..07beefa06c4c 100644
>> --- a/drivers/net/wireless/ath/ath10k/core.c
>> +++ b/drivers/net/wireless/ath/ath10k/core.c
>> @@ -2494,46 +2494,52 @@ 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;
>> + unsigned long recovery_start = READ_ONCE(ar->recovery_start_jiffies);
>> + 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);
>> + /*
>> + * 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;
>>
>> - 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;
>> - }
>> + if (!time_after(jiffies, recovery_start + ATH10K_RECOVERY_TIMEOUT_HZ))
>
> You can use time_is_after_jiffies() for this.
>
>> + 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);
>>
>> - /* Avoid having multiple recoveries at the same time. */
>> - return;
>> + 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;
>> }
>> -
>> - atomic_inc(&ar->pending_recovery);
>> - queue_work(ar->workqueue, &ar->restart_work);
>
> So we are not re-arming anymore for additional tries? or I miss something.
>
>> }
>>
>> void ath10k_core_start_recovery(struct ath10k *ar)
>> {
>> - /* Use workqueue_aux to avoid blocking recovery tracking */
>> + if (ar->state == ATH10K_STATE_WEDGED)
>> + return;
>> +
>> + /*
>> + * SDIO raises several triggers within microseconds of one crash;
>> + * only the first winner starts a fresh cycle and stamps the
>> + * deadline. 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);
>> + WRITE_ONCE(ar->recovery_start_jiffies, jiffies);
>> + queue_work(ar->workqueue, &ar->restart_work);
>> +
>> + /* Start monitoring after publishing the recovery timestamp. */
>> queue_work(ar->workqueue_aux, &ar->recovery_check_work);
>
> So now that the recovery check is no longer blocking, it seems to me
> that this could be implemented as a simple timer (alternatively, a
> delayed work) as it would avoid having to perform the timeout
> calculation...
>
Patch 5 will change it into delayed work, let me think if i need to
merge patch 5 into patch 1.
>> }
>> EXPORT_SYMBOL(ath10k_core_start_recovery);
>> diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
>> index dfee432615eb..c739fbadc8bb 100644
>> --- a/drivers/net/wireless/ath/ath10k/core.h
>> +++ b/drivers/net/wireless/ath/ath10k/core.h
>> @@ -1215,6 +1215,8 @@ struct ath10k {
>> unsigned int recovery_count;
>> /* continuous recovery fail count */
>> atomic_t fail_cont_count;
>> + /* jiffies when the current recovery attempt started */
>> + unsigned long recovery_start_jiffies;
>>
>> /* cycle count is reported twice for each visited channel during scan.
>> * access protected by data_lock
>>
>> --
>> 2.34.1
>>
next prev parent reply other threads:[~2026-10-22 2:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 9:09 [PATCH ath-next v2 0/8] wifi: ath10k: fix recovery and WEDGED failure handling Kang Yang
2026-10-21 9:09 ` [PATCH ath-next v2 1/8] wifi: ath10k: fix SDIO aux workqueue starvation in recovery detection Kang Yang
2026-10-21 13:33 ` Loic Poulain
2026-10-22 2:06 ` Kang Yang [this message]
2026-10-21 9:09 ` [PATCH ath-next v2 2/8] wifi: ath10k: wake blocked waiters when entering WEDGED state Kang Yang
2026-10-21 9:09 ` [PATCH ath-next v2 3/8] wifi: ath10k: also wake remaining blocked waiters Kang Yang
2026-10-21 13:43 ` Loic Poulain
2026-10-21 9:09 ` [PATCH ath-next v2 4/8] wifi: ath10k: bound recovery time before entering WEDGED Kang Yang
2026-10-21 9:09 ` [PATCH ath-next v2 5/8] wifi: ath10k: check the recovery deadline on its own timeline Kang Yang
2026-10-21 9:09 ` [PATCH ath-next v2 6/8] wifi: ath10k: hard-block the radio when entering WEDGED state Kang Yang
2026-10-21 13:54 ` Loic Poulain
2026-10-22 1:55 ` Kang Yang
2026-10-21 9:09 ` [PATCH ath-next v2 7/8] wifi: ath10k: remove now-unused driver_recovery completion Kang Yang
2026-10-21 9:09 ` [PATCH ath-next v2 8/8] wifi: ath10k: trigger recovery on PCIe MMIO wake-up failures 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=c49d0198-7207-4439-9be4-22d35e741ac9@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®