[PATCH ath-next v3 05/13] wifi: ath11k: hold back WMI commands while the firmware restarts
From: Julius Bairaktaris
Date: Sat Nov 21 2026 - 18:08:24 EST
ath11k_core_restart() brings the firmware up outside mac80211's restart,
so cfg80211 operations keep sending WMI commands while the HTC services
reconnect and before the firmware reports ready. These commands crash
the restarting firmware again, and recovery then fails on the unified
ready timeout:
ath11k c000000.wifi: failed to receive wmi unified ready event: -110
ath11k c000000.wifi: failed to reconfigure driver on crash recovery
With iw setting the RTS threshold in a loop from the moment the firmware
stops, the firmware crashed 15, 15 and 11 times on three triggers
before recovery succeeded. With this patch it crashed once per trigger
(5 of 5).
Return -ESHUTDOWN for commands from outside the restart worker while
ATH11K_FLAG_RECOVERY is set. mac80211 replays the configuration when the
driver restarts the hardware. Test the flag on every try of the send
loop, not only on entry: a command that already waits for a WMI credit
or a CE descriptor when the firmware crashes would otherwise be sent once
the restart worker's own commands free one. Wake the waiters for CE
descriptors in ath11k_core_pre_reconfigure_recovery(), as it already
does for credits, so they return when the recovery starts.
On targets that do not restart the firmware after the cold boot
calibration, the QMI FW_READY handler clears the flag also during a
recovery, while the restart worker is still bringing the firmware up.
Clear it there only on the first boot.
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: test RECOVERY on every try of the send loops, wake the CE descriptor
waiters in ath11k_core_pre_reconfigure_recovery(), clear RECOVERY in the
FW_READY handler only on the first boot. Florian's Tested-by dropped, as the
code changed.
drivers/net/wireless/ath/ath11k/core.c | 2 ++
drivers/net/wireless/ath/ath11k/qmi.c | 2 +-
drivers/net/wireless/ath/ath11k/wmi.c | 21 +++++++++++++++++++--
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c
index 7456a8422654..e8d245f1023a 100644
--- a/drivers/net/wireless/ath/ath11k/core.c
+++ b/drivers/net/wireless/ath/ath11k/core.c
@@ -2463,6 +2463,8 @@ void ath11k_core_pre_reconfigure_recovery(struct ath11k_base *ab)
}
wake_up(&ab->wmi_ab.tx_credits_wq);
+ for (i = 0; i < ARRAY_SIZE(ab->wmi_ab.wmi); i++)
+ wake_up(&ab->wmi_ab.wmi[i].tx_ce_desc_wq);
wake_up(&ab->peer_mapping_wq);
reinit_completion(&ab->driver_recovery);
diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c
index a176e6498ec9..aee32aec8732 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_RECOVERY, &ab->dev_flags);
if (!test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) {
clear_bit(ATH11K_FLAG_CRASH_FLUSH,
&ab->dev_flags);
+ clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags);
ret = ath11k_core_qmi_firmware_ready(ab);
if (ret) {
set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags);
diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
index 5f2412982229..82b8481ba818 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -303,6 +303,17 @@ static int ath11k_wmi_cmd_send_nowait(struct ath11k_pdev_wmi *wmi, struct sk_buf
return ret;
}
+/*
+ * While the firmware restarts, only the restart work talks to it.
+ * Tested on every try, so that a sender which already waits for a
+ * credit or a CE descriptor when the firmware crashes is held back too.
+ */
+static bool ath11k_wmi_cmd_held_back(struct ath11k_base *ab)
+{
+ return test_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags) &&
+ current_work() != &ab->restart_work;
+}
+
int ath11k_wmi_cmd_send(struct ath11k_pdev_wmi *wmi, struct sk_buff *skb,
u32 cmd_id)
{
@@ -314,7 +325,10 @@ int ath11k_wmi_cmd_send(struct ath11k_pdev_wmi *wmi, struct sk_buff *skb,
if (ab->hw_params.credit_flow) {
wait_event_timeout(wmi_ab->tx_credits_wq, ({
- ret = ath11k_wmi_cmd_send_nowait(wmi, skb, cmd_id);
+ if (ath11k_wmi_cmd_held_back(ab))
+ ret = -ESHUTDOWN;
+ else
+ ret = ath11k_wmi_cmd_send_nowait(wmi, skb, cmd_id);
if (ret && test_bit(ATH11K_FLAG_CRASH_FLUSH,
&wmi_ab->ab->dev_flags))
@@ -324,7 +338,10 @@ int ath11k_wmi_cmd_send(struct ath11k_pdev_wmi *wmi, struct sk_buff *skb,
}), WMI_SEND_TIMEOUT_HZ);
} else {
wait_event_timeout(wmi->tx_ce_desc_wq, ({
- ret = ath11k_wmi_cmd_send_nowait(wmi, skb, cmd_id);
+ if (ath11k_wmi_cmd_held_back(ab))
+ ret = -ESHUTDOWN;
+ else
+ ret = ath11k_wmi_cmd_send_nowait(wmi, skb, cmd_id);
if (ret && test_bit(ATH11K_FLAG_CRASH_FLUSH,
&wmi_ab->ab->dev_flags))
--
2.53.0