From: Yunseong Kim <yunseong.kim@est.tech>
To: Jeff Johnson <jjohnson@kernel.org>,
Muhammad Usama Anjum <usama.anjum@arm.com>,
Baochen Qiang <baochen.qiang@oss.qualcomm.com>,
Maharaja Kennadyrajan <quic_mkenna@quicinc.com>,
Karthikeyan Periyasamy <quic_periyasa@quicinc.com>,
Vasanthakumar Thiagarajan
<vasanthakumar.thiagarajan@oss.qualcomm.com>,
Shashidhar Lakkavalli <slakkavalli@datto.com>,
Kalle Valo <kvalo@kernel.org>
Cc: Jeroen Trappers <jeroen.trappers@gmail.com>,
mike Seo <mikeseohyungjin@gmail.com>,
1152007@bugs.debian.org, stable@vger.kernel.org,
Jeff Johnson <jeff.johnson@oss.qualcomm.com>,
Sathishkumar Muruganandam <quic_murugana@quicinc.com>,
John Crispin <john@phrozen.org>,
Venkateswara Naralasetty <quic_vnaralas@quicinc.com>,
Sriram R <sriram.ramachandran@oss.qualcomm.com>,
linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
linux-kernel@vger.kernel.org,
Yunseong Kim <yunseong.kim@est.tech>
Subject: [PATCH 2/3] wifi: ath11k: use kvmalloc() for the TX completion status buffer
Date: Mon, 02 Nov 2026 12:59:52 +0100 [thread overview]
Message-ID: <20261102-ath11k-oom-v1-2-f3c391bd63f3@est.tech> (raw)
In-Reply-To: <20261102-ath11k-oom-v1-0-f3c391bd63f3@est.tech>
On devices where resume from suspend (e.g. s2idle) goes through the
firmware crash recovery path (ath11k_core_restart() ->
ath11k_core_reconfigure_on_crash()), the driver reinitializes the data
path by calling ath11k_dp_alloc().
ath11k_dp_alloc() allocates a host-side copy of the TX completion ring:
size = sizeof(struct hal_wbm_release_ring) * DP_TX_COMP_RING_SIZE;
dp->tx_ring[i].tx_status = kmalloc(size, GFP_KERNEL);
With 32768 entries of 32 bytes each, this requires a 1 MiB allocation,
corresponding to an order-8 page request from the buddy allocator.
During suspend/resume, the PM core restricts the allocation flags by
clearing __GFP_IO and __GFP_FS from gfp_allowed_mask (via
pm_restrict_gfp_mask()). Under GFP_NOIO, page reclaim cannot perform
I/O to write out dirty pages or swap, and direct memory compaction is
inhibited (gfp_compaction_allowed() returns false without __GFP_IO).
When memory has become fragmented over time, reclaim fails to assemble
a 1 MiB contiguous block, and the order-8 allocation fails with -ENOMEM
even when hundreds of megabytes of total system memory remain free.
The tx_status buffer is accessed purely by host CPU software (memcpy from
the hardware WBM release ring descriptors) and is never mapped to DMA or
device physical addresses. It therefore does not require physically
contiguous pages.
Switch the allocation from kmalloc() to kvmalloc() and kvfree() so that
the allocation can fall back to virtually contiguous memory under
fragmentation, avoiding the reclaim failure.
Additionally, fix the error unwind path in ath11k_dp_alloc(): if an
allocation fails on a multi-ring device or on ring 0, previously allocated
tx_status buffers and initialized txbuf_idr radix trees were never freed
because the caller (ath11k_core_qmi_firmware_ready()) does not invoke
ath11k_dp_free() on failure. Unwind all initialized rings cleanly by
destroying their IDRs and freeing tx_status.
Reported-by: Jeroen Trappers <jeroen.trappers@gmail.com>
Closes: https://bugs.debian.org/1152007
Fixes: d0998eb84ed3 ("ath11k: optimise ath11k_dp_tx_completion_handler")
Cc: Jeroen Trappers <jeroen.trappers@gmail.com>
Cc: 1152007@bugs.debian.org
Cc: stable@vger.kernel.org
Signed-off-by: Yunseong Kim <yunseong.kim@est.tech>
---
drivers/net/wireless/ath/ath11k/dp.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/dp.c b/drivers/net/wireless/ath/ath11k/dp.c
index be65d73b904b6..45602ec2dce63 100644
--- a/drivers/net/wireless/ath/ath11k/dp.c
+++ b/drivers/net/wireless/ath/ath11k/dp.c
@@ -1040,7 +1040,7 @@ void ath11k_dp_free(struct ath11k_base *ab)
ath11k_dp_tx_pending_cleanup, ab);
idr_destroy(&dp->tx_ring[i].txbuf_idr);
spin_unlock_bh(&dp->tx_ring[i].tx_idr_lock);
- kfree(dp->tx_ring[i].tx_status);
+ kvfree(dp->tx_ring[i].tx_status);
dp->tx_ring[i].tx_status = NULL;
}
@@ -1093,10 +1093,10 @@ int ath11k_dp_alloc(struct ath11k_base *ab)
dp->tx_ring[i].tx_status_head = 0;
dp->tx_ring[i].tx_status_tail = DP_TX_COMP_RING_SIZE - 1;
- dp->tx_ring[i].tx_status = kmalloc(size, GFP_KERNEL);
+ dp->tx_ring[i].tx_status = kvmalloc(size, GFP_KERNEL);
if (!dp->tx_ring[i].tx_status) {
ret = -ENOMEM;
- goto fail_cmn_srng_cleanup;
+ goto fail_tx_status;
}
}
@@ -1107,7 +1107,14 @@ int ath11k_dp_alloc(struct ath11k_base *ab)
return 0;
-fail_cmn_srng_cleanup:
+fail_tx_status:
+ while (i >= 0) {
+ idr_destroy(&dp->tx_ring[i].txbuf_idr);
+ kvfree(dp->tx_ring[i].tx_status);
+ dp->tx_ring[i].tx_status = NULL;
+ i--;
+ }
+
ath11k_dp_srng_common_cleanup(ab);
fail_link_desc_cleanup:
--
2.47.3
next prev parent reply other threads:[~2026-11-02 12:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 11:59 [PATCH 0/3] wifi: ath11k: fix crash recovery panic and order-8 allocation failure Yunseong Kim
2026-11-02 11:59 ` [PATCH 1/3] wifi: ath11k: don't free HAL SRNG memory when crash recovery fails Yunseong Kim
2026-11-02 11:59 ` Yunseong Kim [this message]
2026-11-02 11:59 ` [PATCH 3/3] wifi: ath11k: add KUnit tests for crash recovery and TX status allocation Yunseong Kim
2026-12-02 13:22 ` [PATCH 0/3] wifi: ath11k: fix crash recovery panic and order-8 allocation failure Yunseong Kim
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=20261102-ath11k-oom-v1-2-f3c391bd63f3@est.tech \
--to=yunseong.kim@est.tech \
--cc=1152007@bugs.debian.org \
--cc=ath11k@lists.infradead.org \
--cc=baochen.qiang@oss.qualcomm.com \
--cc=jeff.johnson@oss.qualcomm.com \
--cc=jeroen.trappers@gmail.com \
--cc=jjohnson@kernel.org \
--cc=john@phrozen.org \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=mikeseohyungjin@gmail.com \
--cc=quic_mkenna@quicinc.com \
--cc=quic_murugana@quicinc.com \
--cc=quic_periyasa@quicinc.com \
--cc=quic_vnaralas@quicinc.com \
--cc=slakkavalli@datto.com \
--cc=sriram.ramachandran@oss.qualcomm.com \
--cc=stable@vger.kernel.org \
--cc=usama.anjum@arm.com \
--cc=vasanthakumar.thiagarajan@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®