[PATCH 2/2] wifi: ath11k: hand freed TX frames back to mac80211

From: Christopher Griffin via B4 Relay

Date: Sun Nov 08 2026 - 17:48:27 EST


From: Christopher Griffin <christophergriffin05@xxxxxxxxx>

Two paths free frames that mac80211 handed to ath11k with
dev_kfree_skb_any(): ath11k_dp_tx_free_txbuf(), for TX completions the
firmware releases with REINJ or INSPECT status, and
ath11k_dp_tx_pending_cleanup(), which frees every frame still in flight
when the datapath is torn down, also during firmware crash recovery,
when mac80211 keeps its stations. mac80211 never learns what became of
those frames: one that asked for a TX status (a control port or
management frame with an ACK cookie) gets no report, and accounting
mac80211 keeps per frame, such as the pending airtime of AQL, is never
returned.

Free them with ieee80211_free_txskb(), which reports each as dropped.
In the pending cleanup do so only while ATH11K_FLAG_CRASH_FLUSH is set;
outside a recovery the hw may already be unregistered, so those frames
are freed as before.

The change, this message and the test were written with Claude, an AI
coding assistant.

Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.r4-00683-QCAHKSWPL_SILICONZ-1
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Signed-off-by: Christopher Griffin <christophergriffin05@xxxxxxxxx>
---
drivers/net/wireless/ath/ath11k/dp.c | 12 +++++++++---
drivers/net/wireless/ath/ath11k/dp_tx.c | 4 ++--
2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/dp.c b/drivers/net/wireless/ath/ath11k/dp.c
index be65d73b904b6..6c2be57f3ae72 100644
--- a/drivers/net/wireless/ath/ath11k/dp.c
+++ b/drivers/net/wireless/ath/ath11k/dp.c
@@ -1013,11 +1013,17 @@ static int ath11k_dp_tx_pending_cleanup(int buf_id, void *skb, void *ctx)
{
struct ath11k_base *ab = ctx;
struct sk_buff *msdu = skb;
+ struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB(msdu);

- dma_unmap_single(ab->dev, ATH11K_SKB_CB(msdu)->paddr, msdu->len,
- DMA_TO_DEVICE);
+ dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);

- dev_kfree_skb_any(msdu);
+ /* In a crash recovery mac80211 keeps its stations: hand the frames
+ * back, so that their TX status and pending airtime are reported.
+ */
+ if (skb_cb->ar && test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags))
+ ieee80211_free_txskb(skb_cb->ar->hw, msdu);
+ else
+ dev_kfree_skb_any(msdu);

return 0;
}
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless/ath/ath11k/dp_tx.c
index cac970c92806a..56f474d67f72d 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.c
@@ -303,11 +303,11 @@ static void ath11k_dp_tx_free_txbuf(struct ath11k_base *ab, u8 mac_id,
}

skb_cb = ATH11K_SKB_CB(msdu);
+ ar = ab->pdevs[mac_id].ar;

dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
- dev_kfree_skb_any(msdu);
+ ieee80211_free_txskb(ar->hw, msdu);

- ar = ab->pdevs[mac_id].ar;
if (atomic_dec_and_test(&ar->dp.num_tx_pending))
wake_up(&ar->dp.tx_empty_waitq);
}

--
2.43.0