mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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@ericsson.com>
Subject: Re: [PATCH 0/3] wifi: ath11k: fix crash recovery panic and order-8 allocation failure
Date: Wed, 2 Dec 2026 14:22:57 +0100	[thread overview]
Message-ID: <900acde0-9a99-46fa-b343-1356a054d774@est.tech> (raw)
In-Reply-To: <20261102-ath11k-oom-v1-0-f3c391bd63f3@est.tech>

Hi,

Just a gentle ping on this patch.

Please let me know if any changes are needed, or if you'd like me
to resend it rebased on the latest tree.

On 02/11/2026 12:59 pm, Yunseong Kim wrote:
> Reported in Debian bug #1152007 on a ThinkPad P16v Gen 1 using Qualcomm
> WCN6855 (ath11k_pci), When resuming from suspend, the driver may enter
> the firmware crash recovery path:
> 
>   ath11k_core_restart() -> ath11k_core_reconfigure_on_crash()
> 
> In this path, ath11k_dp_alloc() reallocates data path buffers, including
> the tx_status completion buffer:
> 
>     size = sizeof(struct hal_wbm_release_ring) * DP_TX_COMP_RING_SIZE;
>     dp->tx_ring[i].tx_status = kmalloc(size, GFP_KERNEL);
> 
> With DP_TX_COMP_RING_SIZE = 32768 and 32 bytes per descriptor, this
> requires exactly 1,048,576 bytes (1 MiB), which corresponds to an order-8
> contiguous allocation from the buddy allocator.
> 
> During system suspend and resume, the PM subsystem restricts memory
> allocation flags by removing __GFP_IO and __GFP_FS from gfp_allowed_mask
> via pm_restrict_gfp_mask(). Under GFP_NOIO:
> 
>   1. Direct memory compaction is prohibited because
>      gfp_compaction_allowed() returns false without __GFP_IO.
>   2. Page reclaim cannot perform I/O to swap out anonymous pages or
>      write out dirty pages to backing storage.
> 
> If physical memory has become fragmented over uptime, the buddy
> allocator cannot assemble a 1 MiB contiguous block, and the order-8
> allocation fails with -ENOMEM despite ample total free memory.
> 
> When ath11k_dp_alloc() failed with -ENOMEM,
> ath11k_core_reconfigure_on_crash() branched to its error exit path and
> executed:
> 
>     err_hal_srng_deinit:
>         ath11k_hal_srng_deinit(ab);
>         return ret;
> 
> This was fatal for two reasons:
> 
>   1. HAL SRNG memory is allocated once at driver probe via
>      ath11k_hal_srng_init() and freed at driver remove via
>      ath11k_hal_srng_deinit(). Freeing it during crash recovery left
>      previously initialized CE and DP rings with dangling pointers into
>      unmapped coherent DMA memory (ab->hal.rdp).
>   2. ATH11K_FLAG_CRASH_FLUSH was cleared at the start of
>      ath11k_core_reconfigure_on_crash() and was not restored upon failure.
> 
> When the PM subsystem proceeded to resume subordinate devices, mac80211
> invoked drv_start() (via wiphy_resume() -> ath11k_mac_op_start()),
> queueing a command via ath11k_ce_send(). Because ATH11K_FLAG_CRASH_FLUSH
> was clear, ath11k_ce_send() attempted to access CE ring 3 and called
> ath11k_hal_srng_access_begin(), which dereferenced
> srng->u.src_ring.tp_addr (pointing into the freed rdp buffer). Under an
> IOMMU, this triggered an unhandled page fault in interrupt context,
> panicking the kernel.
> 
> Attached decoded stacktrace with references of debian 7.2.9+deb13-amd64
> vmlinux/source code:
> 
>   https://gist.github.com/yskzalloc/9c3d1980a5ea0fbe0cd119042e09c54f
> 
> Patch 1:
>   wifi: ath11k: don't free HAL SRNG memory when crash recovery fails
>   - Preserves HAL SRNG memory across failed crash recovery (retaining its
>     probe-to-remove lifecycle).
>   - Restores ATH11K_FLAG_CRASH_FLUSH on failure so subsequent CE, WMI,
>     and DP operations immediately bail out with -ESHUTDOWN instead of
>     touching hardware rings or unmapped memory.
> 
> Patch 2:
>   wifi: ath11k: use kvmalloc() for the TX completion status buffer
>   - Confirms that dp->tx_ring[i].tx_status is a purely host CPU software
>     circular buffer used only for memcpy in
>     ath11k_dp_tx_completion_handler(); it is never mapped to DMA or
>     passed to hardware registers.
>   - Replaces kmalloc() with kvmalloc() (and kvfree()) to allow fallback to
>     virtually contiguous allocations when physical memory is fragmented
>     under GFP_NOIO.
>   - Fixes the error unwind path in ath11k_dp_alloc() to destroy IDRs and
>     free tx_status if an allocation failure occurs.
> 
> Patch 3:
>   wifi: ath11k: add KUnit tests for crash recovery and TX status allocation
>   - Adds hardware-independent KUnit tests exercising production recovery
>     and cleanup logic without hardware emulation:
>     * ath11k_test_recovery_success: normal recovery flow.
>     * ath11k_test_recovery_tx_status_alloc_fail: verifies -ENOMEM
>       handling, ATH11K_FLAG_CRASH_FLUSH restoration, and HAL SRNG
>       preservation.
>     * ath11k_test_recovery_subsequent_send_prevented: verifies
>       -ESHUTDOWN rejection on subsequent ath11k_ce_send() and
>       ath11k_dp_tx_send_reo_cmd().
>     * ath11k_test_recovery_resource_cleanup_and_teardown: verifies
>       recovery retry and full teardown without leaks or double-free.
>     * ath11k_test_dp_tx_status_kvmalloc: validates 1 MiB sizing and
>       kvmalloc/kvfree lifecycle.
> 
> Testing
> =======
> - Ran the full KUnit test suite under User Mode Linux (UML):
>   Ran 5 tests: passed: 5, failed: 0.
> - Verified build cleanliness with CONFIG_KUNIT=n and
>   CONFIG_ATH11K_KUNIT_TEST=n.
> 
> Reported-by: Jeroen Trappers <jeroen.trappers@gmail.com>
> Closes: https://bugs.debian.org/1152007
> Link: https://bugs.debian.org/1152007
> Signed-off-by: Yunseong Kim <yunseong.kim@est.tech>
> ---
> Yunseong Kim (3):
>       wifi: ath11k: don't free HAL SRNG memory when crash recovery fails
>       wifi: ath11k: use kvmalloc() for the TX completion status buffer
>       wifi: ath11k: add KUnit tests for crash recovery and TX status allocation
> 
>  drivers/net/wireless/ath/ath11k/.kunitconfig |  14 ++
>  drivers/net/wireless/ath/ath11k/Kconfig      |  11 +
>  drivers/net/wireless/ath/ath11k/Makefile     |   1 +
>  drivers/net/wireless/ath/ath11k/core.c       |  50 +++-
>  drivers/net/wireless/ath/ath11k/core.h       |  17 ++
>  drivers/net/wireless/ath/ath11k/dp.c         |  22 +-
>  drivers/net/wireless/ath/ath11k/test.c       | 330 +++++++++++++++++++++++++++
>  7 files changed, 434 insertions(+), 11 deletions(-)
> ---
> base-commit: d89e1d186ec9271bf78e62771779e9fc03bf0fc3
> change-id: 20261102-ath11k-oom-ed1cb6f5d114
> 
> Best regards,
> --  
> Yunseong Kim <yunseong.kim@est.tech>


Thanks,
Yunseong

      parent reply	other threads:[~2026-12-02 13:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 11:59 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 ` [PATCH 2/3] wifi: ath11k: use kvmalloc() for the TX completion status buffer Yunseong Kim
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 ` Yunseong Kim [this message]

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=900acde0-9a99-46fa-b343-1356a054d774@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 \
    --cc=yunseong.kim@ericsson.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®