Skip to contentSkip to conversation

wifi: ath11k: fix QRTR readiness related WLAN initialization failures

PATCH Applied Miaoqing Pan 4 participants 7 messages Aug 6 – Sep 3 Qualcomm Atheros ATH11K wireless driver

lore
Share & tools
lore
#0 lore raw

v2 cover wifi: ath11k: fix QRTR readiness related WLAN initialization failures

On WCN6750 platforms, QRTR SMD may not be available when ath11k starts during boot. If QMI messages never arrive, WLAN initialization can stall, leaving firmware running but no wireless interface created.

It also hardens the cleanup path to avoid crashes when deinitializing partially initialized devices after QMI setup failures.

---
v2: Replace the ATH11K_FLAG_QMI_FAIL guard with !ATH11K_FLAG_REGISTERED.
---
Miaoqing Pan (3):
wifi: ath11k: fix sporadic WLAN initialization failures
wifi: ath11k: fix NULL dereference in ahb remove when QMI init
incomplete
wifi: ath11k: unregister PM notifier on QMI init failure path

 drivers/net/wireless/ath/ath11k/Kconfig | 3 +++
 drivers/net/wireless/ath/ath11k/ahb.c   | 7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

base-commit: 0ece44d394570806e97c8471a50dc9f584516ef6

Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/3 wifi: ath11k: fix sporadic WLAN initialization failures

On WCN6750 platforms, reboot stress testing occasionally results in WLAN initialization failures after boot. The WPSS firmware reaches the running state successfully, but no WLAN interface is created.

Analysis shows that ath11k_ahb depends on the QRTR SMD transport for QMI communication with WPSS firmware. However, this dependency is not currently expressed in Kconfig, allowing qrtr_smd and ath11k_ahb to load in either order when built as modules.

If ath11k_ahb is loaded before qrtr_smd becomes available, WLAN initialization may not complete successfully.

Make the QRTR and QRTR_SMD dependencies explicit and add a soft dependency to ensure qrtr_smd is loaded before ath11k_ahb.

Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.2.0.c2-00204-QCAMSLSWPLZ-1

Fixes 00402f49d26f ("ath11k: Add support for WCN6750 device")
---
 drivers/net/wireless/ath/ath11k/Kconfig | 3 +++
 drivers/net/wireless/ath/ath11k/ahb.c   | 1 +
 2 files changed, 4 insertions(+)
drivers/net/wireless/ath/ath11k/Kconfig +3 -0
index 122726f84492..44b520d2e66e 100644
@@ -14,6 +14,9 @@ config ATH11K_AHB
 	tristate "Atheros ath11k AHB support"
 	depends on ATH11K
 	depends on REMOTEPROC
+	select RPMSG
+	select QRTR
+	select QRTR_SMD
 	help
 	  This module adds support for AHB bus
 
drivers/net/wireless/ath/ath11k/ahb.c +1 -0
index ec5bf5c9fd79..e417b0a0f2d7 100644
@@ -1343,5 +1343,6 @@ static struct platform_driver ath11k_ahb_driver = {
 
 module_platform_driver(ath11k_ahb_driver);
 
+MODULE_SOFTDEP("pre: qrtr_smd");
 MODULE_DESCRIPTION("Driver support for Qualcomm Technologies 802.11ax WLAN AHB devices");
 MODULE_LICENSE("Dual BSD/GPL");
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/3 wifi: ath11k: fix NULL dereference in ahb remove when QMI init incomplete

In reply to Miaoqing Pan

On WCN6750, if QMI messages never arrive (for example when qrtr_smd is not ready), WLAN initialization stops before the device is fully registered. In this case ATH11K_FLAG_QMI_FAIL is not set because no QMI event handler is executed.

When the driver is removed, ath11k_ahb_remove() still calls ath11k_core_deinit(), which eventually triggers ath11k_ce_cleanup_pipes() on uninitialized CE pipes and results in a NULL pointer dereference in ath11k_hal_srng_access_begin():

  ath11k_hal_srng_access_begin+0x14/0x68 [ath11k]
  ath11k_ce_cleanup_pipes+0x184/0x190 [ath11k]
  ath11k_pcic_stop+0x24/0x38 [ath11k]
  ath11k_core_deinit+0xfc/0x1c0 [ath11k]
  ath11k_ahb_remove+0x38/0xa0 [ath11k_ahb]

Fix this by invoking ath11k_ahb_remove_prepare() before the state check and skipping ath11k_core_deinit() if ATH11K_FLAG_REGISTERED is not set, core initialization did not complete and CE pipes may remain uninitialized, making ath11k_core_deinit() unsafe.

Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.2.0.c2-00204-QCAMSLSWPLZ-1

Fixes 00402f49d26f ("ath11k: Add support for WCN6750 device")
---
 drivers/net/wireless/ath/ath11k/ahb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/ahb.c +3 -2
index e417b0a0f2d7..c3ce5ea36e3c 100644
@@ -1296,14 +1296,15 @@ static void ath11k_ahb_remove(struct platform_device *pdev)
 {
 	struct ath11k_base *ab = platform_get_drvdata(pdev);
 
-	if (test_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags)) {
+	ath11k_ahb_remove_prepare(ab);
+
+	if (!test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) {
 		ath11k_ahb_power_down(ab, false);
 		ath11k_debugfs_soc_destroy(ab);
 		ath11k_qmi_deinit_service(ab);
 		goto qmi_fail;
 	}
 
-	ath11k_ahb_remove_prepare(ab);
 	ath11k_core_deinit(ab);
 
 qmi_fail:
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 3/3 wifi: ath11k: unregister PM notifier on QMI init failure path

In reply to Miaoqing Pan

ath11k_core_init() registers a PM notifier before the QMI server becomes available. If the QMI server never arrives, the device remove() path can take the early-exit path introduced for QMI initialization failures, skipping ath11k_core_deinit().

As a result, the PM notifier remains registered after the ath11k base object has been freed. A subsequent suspend or resume event may invoke the stale notifier and trigger a use-after-free.

Fix this by explicitly unregistering the PM notifier in the QMI failure cleanup path before releasing ath11k resources.

Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.2.0.c2-00204-QCAMSLSWPLZ-1

Fixes 32d93b51bc7e ("wifi: ath11k: choose default PM policy for hibernation")
---
 drivers/net/wireless/ath/ath11k/ahb.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath11k/ahb.c +1 -0
index c3ce5ea36e3c..ee3f493d2e44 100644
@@ -1302,6 +1302,7 @@ static void ath11k_ahb_remove(struct platform_device *pdev)
 		ath11k_ahb_power_down(ab, false);
 		ath11k_debugfs_soc_destroy(ab);
 		ath11k_qmi_deinit_service(ab);
+		ath11k_core_pm_notifier_unregister(ab);
 		goto qmi_fail;
 	}
 
Signature · 1 line
2.34.1
Reviewed-by on the v2 series
#4 lore raw
In reply to Miaoqing Pan
Quoted 16 lines · Miaoqing Pan

On WCN6750 platforms, QRTR SMD may not be available when ath11k starts during boot. If QMI messages never arrive, WLAN initialization can stall, leaving firmware running but no wireless interface created.

It also hardens the cleanup path to avoid crashes when deinitializing partially initialized devices after QMI setup failures.

---
v2: Replace the ATH11K_FLAG_QMI_FAIL guard with !ATH11K_FLAG_REGISTERED.
---
Miaoqing Pan (3):
wifi: ath11k: fix sporadic WLAN initialization failures
wifi: ath11k: fix NULL dereference in ahb remove when QMI init
incomplete
wifi: ath11k: unregister PM notifier on QMI init failure path

Quoted 6 lines
  drivers/net/wireless/ath/ath11k/Kconfig | 3 +++
  drivers/net/wireless/ath/ath11k/ahb.c   | 7 +++++--
  2 files changed, 8 insertions(+), 2 deletions(-)

base-commit: 0ece44d394570806e97c8471a50dc9f584516ef6

Reviewed-by on the v2 series
#5 lore raw
In reply to Miaoqing Pan
Quoted 16 lines · Miaoqing Pan

On WCN6750 platforms, QRTR SMD may not be available when ath11k starts during boot. If QMI messages never arrive, WLAN initialization can stall, leaving firmware running but no wireless interface created.

It also hardens the cleanup path to avoid crashes when deinitializing partially initialized devices after QMI setup failures.

---
v2: Replace the ATH11K_FLAG_QMI_FAIL guard with !ATH11K_FLAG_REGISTERED.
---
Miaoqing Pan (3):
wifi: ath11k: fix sporadic WLAN initialization failures
wifi: ath11k: fix NULL dereference in ahb remove when QMI init
incomplete
wifi: ath11k: unregister PM notifier on QMI init failure path

Quoted 6 lines
 drivers/net/wireless/ath/ath11k/Kconfig | 3 +++
 drivers/net/wireless/ath/ath11k/ahb.c   | 7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

base-commit: 0ece44d394570806e97c8471a50dc9f584516ef6

Applied
#6 lore raw
In reply to Miaoqing Pan
Quoted 8 lines · Miaoqing Pan

On WCN6750 platforms, QRTR SMD may not be available when ath11k starts during boot. If QMI messages never arrive, WLAN initialization can stall, leaving firmware running but no wireless interface created.

It also hardens the cleanup path to avoid crashes when deinitializing partially initialized devices after QMI setup failures.

[...]

Applied, thanks!

[1/3] wifi: ath11k: fix sporadic WLAN initialization failures

      commit: 32ec8488d75d122768b1977501bcb5ec799230c4
[2/3] wifi: ath11k: fix NULL dereference in ahb remove when QMI init incomplete
      commit: 1a7bcf5324c8e2de6512eca5b028b6b283181d3f
[3/3] wifi: ath11k: unregister PM notifier on QMI init failure path
      commit: 1d8e73163ef933624341075f576e2f36ef9133f7

Best regards,

Signature · 1 line
Jeff Johnson <[email protected]>