Skip to contentSkip to conversation

wifi: ath11k: more firmware crash recovery fixes for AHB

PATCH New Florian Maurer 1 participant 4 messages Nov 1 Qualcomm Atheros ATH11K wireless driver

lore
Share & tools
lore
#0 lore raw

cover wifi: ath11k: more firmware crash recovery fixes for AHB

Three patches on top of Julius Bairaktaris' "wifi: ath11k: firmware crash recovery fixes" v2 [1], for firmware crash recovery on IPQ8074 (AHB).

Patch 1 keeps the ext IRQs from being disabled twice when a recovery follows a failed one. With 2/5 and 3/5 of [1] a failed recovery is recoverable, but without this patch TX completions stop afterwards.

Patch 2 turns the "select RPMSG" of ATH11K_AHB into a dependency, which patch 3 needs to depend on QCOM_RPROC_COMMON without a recursive Kconfig dependency.

Patch 3 stops TX before remoteproc resets WCSS on a firmware crash. Today a TX in that window ends in an asynchronous SError and a kernel panic. It depends on 4/5 of [1].

Patches 1 and 3 were tested on a Xiaomi AX3600 (IPQ8074, WLAN.HK.2.9.0.1-02146) together with [1], backported to backports-6.18.55 (OpenWrt 25.12), with real firmware asserts under AP and mesh load, with simulated crashes, and with a forced failed recovery followed by another crash.

Not covered yet, both to be addressed separately:
- A second firmware crash 10-20 ms after the firmware is up again can make the QMI firmware start fail before the CE pipes are set up again; the next recovery then dereferences the cleared srngs in ath11k_ce_cleanup_pipes(). This is not caused by these patches; I'm reporting it in the thread of [1].
- A crash within the few milliseconds before the restart work clears ATH11K_FLAG_CRASH_FLUSH (see patch 3).

[1] https://lore.kernel.org/linux-wireless/[email protected]/

Florian Maurer (3):
wifi: ath11k: don't disable ext IRQs twice
wifi: ath11k: depend on RPMSG instead of selecting it
wifi: ath11k: ahb: stop TX before WCSS is reset on a firmware crash

 drivers/net/wireless/ath/ath11k/Kconfig |  3 +-
 drivers/net/wireless/ath/ath11k/ahb.c   | 63 ++++++++++++++++++++++++-
 drivers/net/wireless/ath/ath11k/ahb.h   |  2 +
 drivers/net/wireless/ath/ath11k/ce.c    |  7 +++
 drivers/net/wireless/ath/ath11k/core.c  |  1 +
 drivers/net/wireless/ath/ath11k/hw.h    |  1 +
 drivers/net/wireless/ath/ath11k/pcic.c  |  4 +-
 7 files changed, 76 insertions(+), 5 deletions(-)

base-commit: 7b14c8f4a9615579b09cbcdc4515b65ae6124753
prerequisite-patch-id: cd9f2849ade92e165f15fe3f887edabd1d06b6e8
prerequisite-patch-id: 3c9ba2aec0d93942448aba1dc5d26b632d519e5a
prerequisite-patch-id: 9a833c602db147b490fba6df590eeea3847f4877
prerequisite-patch-id: 6fd3e11242fb3ead65751e3cd9972c4d7c63f989
prerequisite-patch-id: 01e149ed860e5e40e79725580548ce4034f344b2

Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/3 wifi: ath11k: don't disable ext IRQs twice

ath11k_core_reconfigure_on_crash() disables the IRQs at the start of every firmware recovery and ath11k_core_qmi_firmware_ready() enables them again at its end. If a recovery fails, they stay disabled. The next recovery disables them again, so the disable depth of the ext IRQs goes to two and the single enable_irq() leaves them masked. The DP rings would then not be serviced after an otherwise successful recovery.

This is the same kind of imbalance as the one fixed for suspend/resume by commit e56c9d429ba0 ("wifi: ath11k: fix unbalanced IRQ enable/disable during suspend/resume"), but caused by a failed recovery.

NAPI already handles this: it is only disabled if it is enabled. The ext IRQs are only enabled together with NAPI, so only disable them if NAPI is enabled as well. The pcic ext IRQ code has the same pattern, so change it there too. The PCI CE IRQs (ath11k_pcic_ce_irqs_disable()) can have the same imbalance after a failed recovery; they are not changed here. The AHB CE IRQs are not affected, as they are enabled and disabled through register bits without a disable depth.

On IPQ8074 (AHB) this shows up when a failed recovery (forced with a test patch) is followed by another firmware crash: the recovery reports success, but TX completions stop, TX fails with "failed to transmit frame -12" and the firmware asserts again repeatedly. With this change the same sequence recovered 3 out of 3 times. The pcic change is compile-tested only.

Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1

Fixes f7a74e131d3f ("wifi: ath11k: disable interrupts during firmware crash recovery")

---
Hardware-tested on IPQ8074 with [1] backported to backports-6.18.55 (OpenWrt 25.12), build-tested on ath-next with [1].

[1] https://lore.kernel.org/linux-wireless/[email protected]/

 drivers/net/wireless/ath/ath11k/ahb.c  | 4 ++--
 drivers/net/wireless/ath/ath11k/pcic.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath11k/ahb.c +2 -2
index 27d01411b6e9..3ff7d5f27f5e 100644
@@ -235,9 +235,9 @@ static void __ath11k_ahb_ext_irq_disable(struct ath11k_base *ab)
 	for (i = 0; i < ATH11K_EXT_IRQ_GRP_NUM_MAX; i++) {
 		struct ath11k_ext_irq_grp *irq_grp = &ab->ext_irq_grp[i];
 
-		ath11k_ahb_ext_grp_disable(irq_grp);
-
+		/* The IRQs are only enabled together with NAPI */
 		if (irq_grp->napi_enabled) {
+			ath11k_ahb_ext_grp_disable(irq_grp);
 			napi_synchronize(&irq_grp->napi);
 			napi_disable(&irq_grp->napi);
 			irq_grp->napi_enabled = false;
drivers/net/wireless/ath/ath11k/pcic.c +2 -2
index 2259adc3bbdc..2e7dfa8388b0 100644
@@ -455,9 +455,9 @@ static void __ath11k_pcic_ext_irq_disable(struct ath11k_base *ab)
 	for (i = 0; i < ATH11K_EXT_IRQ_GRP_NUM_MAX; i++) {
 		struct ath11k_ext_irq_grp *irq_grp = &ab->ext_irq_grp[i];
 
-		ath11k_pcic_ext_grp_disable(irq_grp);
-
+		/* The IRQs are only enabled together with NAPI */
 		if (irq_grp->napi_enabled) {
+			ath11k_pcic_ext_grp_disable(irq_grp);
 			napi_synchronize(&irq_grp->napi);
 			napi_disable(&irq_grp->napi);
 			irq_grp->napi_enabled = false;
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/3 wifi: ath11k: depend on RPMSG instead of selecting it

In reply to Florian Maurer

Commit 32ec8488d75d ("wifi: ath11k: fix sporadic WLAN initialization failures") made ATH11K_AHB select RPMSG, QRTR and QRTR_SMD. Selecting RPMSG makes it impossible for ATH11K_AHB to depend on QCOM_RPROC_COMMON, which is needed to use the remoteproc SSR notifier when ath11k_ahb is built in. Adding that dependency gives a recursive dependency error:

symbol RPMSG is selected by ATH11K_AHB
symbol ATH11K_AHB depends on QCOM_RPROC_COMMON symbol QCOM_RPROC_COMMON is selected by QCOM_Q6V5_ADSP symbol QCOM_Q6V5_ADSP depends on QCOM_SYSMON symbol QCOM_SYSMON depends on RPMSG

RPMSG has no prompt and is selected by the rpmsg bus drivers (GLINK, SMD, virtio). ath11k_ahb needs one of these transports anyway, so it can depend on RPMSG like QRTR_SMD and QCOM_SYSMON do. QRTR and QRTR_SMD are still selected.

---
Build-tested on ath-next with [1] for arm64 and x86_64. No functional change for configs that already have an RPMSG transport enabled, as IPQ8074 and WCN6750 do (GLINK).

[1] https://lore.kernel.org/linux-wireless/[email protected]/

 drivers/net/wireless/ath/ath11k/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/Kconfig +1 -1
index 44b520d2e66e..84b7eb5df253 100644
@@ -14,7 +14,7 @@ config ATH11K_AHB
 	tristate "Atheros ath11k AHB support"
 	depends on ATH11K
 	depends on REMOTEPROC
-	select RPMSG
+	depends on RPMSG
 	select QRTR
 	select QRTR_SMD
 	help
Signature · 1 line
2.47.3
#3 lore raw

PATCH 3/3 wifi: ath11k: ahb: stop TX before WCSS is reset on a firmware crash

In reply to Florian Maurer

On IPQ8074 a firmware crash is handled by remoteproc, which stops the remote processor and thereby resets WCSS. ath11k sets ATH11K_FLAG_CRASH_FLUSH, which stops the TX paths, only when it handles the QMI server exit event. That event results from the glink teardown in rproc_stop() and is handled asynchronously, so it can be processed after WCSS is already in reset. A TX in that window writes a ring head pointer to the reset block, which ends in an asynchronous SError:

remoteproc remoteproc0: stopped remote processor cd00000.q6v5_wcss SError Interrupt on CPU3, code 0x00000000bf000002 -- SError

  pc : ath11k_dp_tx+0x45c/0x878 [ath11k]
  Kernel panic - not syncing: Asynchronous SError Interrupt

remoteproc sends a QCOM_SSR_BEFORE_SHUTDOWN notification with crashed set before it stops the processor. Register for it, like ath10k does on SNOC, set ATH11K_FLAG_CRASH_FLUSH there and wait with synchronize_rcu() for TX paths which have not seen the flag yet. ath11k_dp_tx() is called by mac80211 within RCU read-side critical sections or with BHs disabled. Check the flag in ath11k_ce_send() again under ce_lock, so that this also covers WMI and HTC.

This stops new TX descriptors, for data and for everything sent through CE. Ring pointer updates from the RX and TX completion paths (NAPI, CE tasklets) are not stopped by this.

A crash during the restart work of an earlier crash, after the QMI firmware start and before ath11k_core_qmi_firmware_ready() clears ATH11K_FLAG_CRASH_FLUSH after ath11k_dp_alloc(), is not covered yet:
the flag set by the notifier is cleared again, and CE/HTC sends from the restart work can still reach the reset WCSS. mac80211 data queues are still stopped at that point. That window is a few milliseconds and will be addressed separately.

The SSR subsystem name depends on the remoteproc driver, so add it to hw_params. Only IPQ8074 sets it for now. qcom_register_ssr_notifier() must be reachable from ath11k_ahb, so add the same Kconfig dependency on QCOM_RPROC_COMMON as ath10k SNOC has.

Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1

---
Depends on 4/5 of [1], which moved clearing ATH11K_FLAG_CRASH_FLUSH into ath11k_core_qmi_firmware_ready(), and on patch 2 of this series for the Kconfig dependency. For that reason there is no Fixes tag: without patch 2 the Kconfig dependency added here is a recursive dependency error, so this must not be backported on its own.

Hardware-tested on IPQ8074 with [1] backported to backports-6.18.55 (OpenWrt 25.12). The tested version also had a give-up path for a crash during the restart work, which was never triggered in the tests and is left out here; the remaining code is the same apart from a shorter comment. Build-tested on ath-next with [1], including ATH11K_AHB=y with QCOM_RPROC_COMMON=y.

[1] https://lore.kernel.org/linux-wireless/[email protected]/

 drivers/net/wireless/ath/ath11k/Kconfig |  1 +
 drivers/net/wireless/ath/ath11k/ahb.c   | 59 +++++++++++++++++++++++++
 drivers/net/wireless/ath/ath11k/ahb.h   |  2 +
 drivers/net/wireless/ath/ath11k/ce.c    |  7 +++
 drivers/net/wireless/ath/ath11k/core.c  |  1 +
 drivers/net/wireless/ath/ath11k/hw.h    |  1 +
 6 files changed, 71 insertions(+)
drivers/net/wireless/ath/ath11k/Kconfig +1 -0
index 84b7eb5df253..a425da76934b 100644
@@ -14,6 +14,7 @@ config ATH11K_AHB
 	tristate "Atheros ath11k AHB support"
 	depends on ATH11K
 	depends on REMOTEPROC
+	depends on QCOM_RPROC_COMMON || QCOM_RPROC_COMMON=n
 	depends on RPMSG
 	select QRTR
 	select QRTR_SMD
drivers/net/wireless/ath/ath11k/ahb.c +59 -0

89 lines not on this page · raw message

drivers/net/wireless/ath/ath11k/ahb.h +2 -0
index 8c1eb1e8e6b1..d7ea47f42edf 100644
@@ -23,6 +23,8 @@ struct ath11k_base;
 
 struct ath11k_ahb {
 	struct rproc *tgt_rproc;
+	struct notifier_block ssr_nb;
+	void *ssr_handle;
 	struct {
 		struct device *dev;
 		struct iommu_domain *iommu_domain;
drivers/net/wireless/ath/ath11k/ce.c +7 -0
index 1e08b0970b14..895648687d99 100644
@@ -745,6 +745,12 @@ int ath11k_ce_send(struct ath11k_base *ab, struct sk_buff *skb, u8 pipe_id,
 
 	spin_lock_bh(&ab->ce.ce_lock);
 
+	/* Check again with BHs disabled, see ath11k_ahb_ssr_notifier() */
+	if (test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags)) {
+		ret = -ESHUTDOWN;
+		goto err_ce_unlock;
+	}
+
 	write_index = pipe->src_ring->write_index;
 	nentries_mask = pipe->src_ring->nentries_mask;
 
@@ -791,6 +797,7 @@ int ath11k_ce_send(struct ath11k_base *ab, struct sk_buff *skb, u8 pipe_id,
 err_unlock:
 	spin_unlock_bh(&srng->lock);
 
+err_ce_unlock:
 	spin_unlock_bh(&ab->ce.ce_lock);
 
 	return ret;
drivers/net/wireless/ath/ath11k/core.c +1 -0
index 4666245aee36..7ba05c63ede6 100644
@@ -91,6 +91,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
 		.coldboot_cal_mm = true,
 		.coldboot_cal_ftm = true,
 		.cbcal_restart_fw = true,
+		.ssr_name = "q6wcss",
 		.fw_mem_mode = 0,
 		.num_vdevs = 16 + 1,
 		.num_peers = 512,
drivers/net/wireless/ath/ath11k/hw.h +1 -0
index 4996536fbd14..ce52c61d661d 100644
@@ -191,6 +191,7 @@ struct ath11k_hw_params {
 	bool coldboot_cal_mm;
 	bool coldboot_cal_ftm;
 	bool cbcal_restart_fw;
+	const char *ssr_name;
 	int fw_mem_mode;
 	u32 num_vdevs;
 	u32 num_peers;
Signature · 1 line
2.47.3