Re: [PATCH ath-next v4 10/10] wifi: ath10k: drop async writes and sleep timer across power cycles

From: Kang Yang

Date: Thu Nov 26 2026 - 05:02:07 EST




On 11/26/2026 4:37 PM, Baochen Qiang wrote:


On 11/20/2026 4:41 PM, Kang Yang wrote:
ath10k_sdio_hif_tx_sg() queues writes on ar_sdio->wr_asyncq and
schedules wr_async_work. The SDIO sleep timer also schedules this
work, and the work may re-arm the timer.

The current shutdown sequence does not prevent this activity from
surviving an SDIO power cycle:

- ath10k_sdio_hif_stop() drains wr_asyncq once, but new writes may
still be queued before the card is marked disabled.

- ath10k_sdio_hif_power_down() deletes the sleep timer but does not
cancel wr_async_work.

- ath10k_sdio_hif_power_up() does not clear work or requests left
from the previous power cycle.

As a result, stale work may access the SDIO bus while the device is
being reinitialized in BMI mode, causing errors such as:

failed to read from address 0x868: -110
failed to read fifo/chip control register: -110
bmi communication timeout
could not write board data (-110)

Mark the card disabled before power-down begins so new asynchronous
transfers are rejected. Make wr_async_work drop requests that raced
with the state change instead of accessing the bus.

Synchronize the sleep timer and wr_async_work, then drain wr_asyncq
during both power-down and power-up so no request from an earlier
power cycle can run during BMI initialization. Factor the queue
cleanup into a helper shared with ath10k_sdio_hif_stop().

A dropped request is completed the same way as a written one, only
without the bus access. HTC messages go through
ath10k_htc_notify_tx_completion(), which lets the endpoint release the
skb. The IRQ disable request signals its completion and leaves the skb
to the waiter, which frees it. Every bus request is returned to the
free pool, so nothing is leaked.

As a result, ath10k_sdio_hif_stop() no longer frees the skb of a
non-HTC request itself. The IRQ disable request is the only such
request, and its skb is owned by its waiter.

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>
---
drivers/net/wireless/ath/ath10k/sdio.c | 78 ++++++++++++++++++++++++----------
1 file changed, 56 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c
index fdf19ce4b55b..f0e1feacb629 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.c
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -1461,6 +1461,33 @@ static void ath10k_sdio_sleep_timer_handler(struct timer_list *t)
queue_work(ar_sdio->workqueue, &ar_sdio->wr_async_work);
}
+/* Drop any requests still queued on wr_asyncq without touching the bus.
+ * Caller must ensure wr_async_work is not running concurrently.
+ */
+static void ath10k_sdio_drop_wr_async_reqs(struct ath10k *ar)
+{
+ struct ath10k_sdio *ar_sdio = ath10k_sdio_priv(ar);
+ struct ath10k_sdio_bus_request *req, *tmp_req;
+
+ spin_lock_bh(&ar_sdio->wr_async_lock);
+
+ list_for_each_entry_safe(req, tmp_req, &ar_sdio->wr_asyncq, list) {
+ struct ath10k_htc_ep *ep;
+
+ list_del(&req->list);
+
+ if (req->htc_msg) {
+ ep = &ar->htc.endpoint[req->eid];
+ ath10k_htc_notify_tx_completion(ep, req->skb);
+ } else if (req->comp) {
+ complete(req->comp);

In ath10k_sdio_irq_disable(), irqs_disabled_comp is on the stack. If
wait_for_completion_timeout() expires, the function frees the skb and returns while the
request may still be on wr_asyncq. ath10k_sdio_hif_stop() then reaches this branch and
calls complete() on a dead stack frame.

This seems to be a pre-exist issue.
Got it, will add a check/clean for this case.