[PATCH ath-next v3 04/13] wifi: ath11k: clear CRASH_FLUSH only after recovery rebuilds the rings
From: Julius Bairaktaris
Date: Sat Nov 21 2026 - 18:07:57 EST
ath11k_core_reconfigure_on_crash() clears ATH11K_FLAG_CRASH_FLUSH right
after ath11k_hal_srng_clear() zeroes the rings, but
ath11k_ce_init_pipes() and ath11k_dp_alloc() rebuild them only later. A
WMI command sent in between passes the CRASH_FLUSH check in
ath11k_ce_send() and dereferences the NULL tail pointer of the cleared
ring:
Unable to handle kernel read from unreadable memory at virtual address 0
pc : ath11k_hal_srng_access_begin+0xc/0x60 [ath11k]
lr : ath11k_ce_send+0x114/0x350 [ath11k]
Call trace:
ath11k_hal_srng_access_begin+0xc/0x60 [ath11k] (P)
ath11k_htc_send+0x188/0x3c8 [ath11k]
ath11k_wmi_cmd_send+0xc8/0x2f4 [ath11k]
ath11k_wmi_send_peer_create_cmd+0x78/0xe0 [ath11k]
ath11k_peer_create+0x138/0x500 [ath11k]
Clear the flag once the rings are rebuilt, before ath11k_core_start()
sends the first HTC message.
If ath11k_core_start() or ath11k_core_pdev_create() then fails, the error
path frees the data path rings with the flag clear. The stations stay in
ab->peers, so removing one later, or removing the driver, makes
ath11k_dp_tx_send_reo_cmd() write a REO command into the freed REO
command ring. Set the flag again before ath11k_dp_free().
On targets that do not restart the firmware after the cold boot
calibration, the QMI FW_READY handler clears the flag as well, also
during a recovery. FW_READY follows the firmware start, so it arrives
while the restart work is still rebuilding the rings. Clear the flag
there only on the first boot, before that handler starts the firmware
itself.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1
Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
Signed-off-by: Julius Bairaktaris <julius@xxxxxxxxxxxxxx>
---
v3: set CRASH_FLUSH again before ath11k_dp_free() in the error path; clear it
in the FW_READY handler only on the first boot.
drivers/net/wireless/ath/ath11k/core.c | 5 +++--
drivers/net/wireless/ath/ath11k/qmi.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c
index d6346e0ee047..7456a8422654 100644
--- a/drivers/net/wireless/ath/ath11k/core.c
+++ b/drivers/net/wireless/ath/ath11k/core.c
@@ -2298,6 +2298,8 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)
goto err_firmware_stop;
}
+ clear_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags);
+
if (ath11k_frame_mode == ATH11K_HW_TXRX_RAW)
set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
@@ -2323,6 +2325,7 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)
if (!test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags))
ath11k_mac_destroy(ab);
err_dp_free:
+ set_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags);
ath11k_dp_free(ab);
mutex_unlock(&ab->core_lock);
err_firmware_stop:
@@ -2354,8 +2357,6 @@ static int ath11k_core_reconfigure_on_crash(struct ath11k_base *ab)
ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS(ab))) - 1;
- clear_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags);
-
ret = ath11k_core_qmi_firmware_ready(ab);
if (ret)
return ret;
diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c
index 7dc07339b957..a176e6498ec9 100644
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -3291,10 +3291,10 @@ static void ath11k_qmi_driver_event_work(struct work_struct *work)
if (ab->hw_params.cbcal_restart_fw)
break;
- clear_bit(ATH11K_FLAG_CRASH_FLUSH,
- &ab->dev_flags);
clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags);
if (!test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) {
+ clear_bit(ATH11K_FLAG_CRASH_FLUSH,
+ &ab->dev_flags);
ret = ath11k_core_qmi_firmware_ready(ab);
if (ret) {
set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags);
--
2.53.0