Skip to contentSkip to conversation

wifi: ath9k_htc: start ANI for an AP interface at the right time

PATCH Applied Mehmet Fide 3 participants 6 messages Oct 5 – Oct 26 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

cover wifi: ath9k_htc: start ANI for an AP interface at the right time

From: Mehmet Fide <[email protected]>

ath9k_htc starts ANI for an AP interface in add_interface, before a channel and the calibration data exist. When the bring-up stalls between add_interface and the first channel configuration, the first ANI tick dereferences a NULL ah->caldata and the device does not recover. Patch 1 removes that start. Patch 2 starts ANI once the interface beacons, which is where ath9k_htc_vif_reconfig() already re-arms it after a channel change; without it ANI and the periodic calibration never ran during a normal AP start.

Tested with AR9271 on 6.18.48 and on a 6.12 product kernel: the oops reproduces on every start with a 500 ms delay after add_interface and is gone with the series; an hour as an AP, station mode, a channel switch, hostapd disable/enable and a restart are clean.

Mehmet Fide (2):
wifi: ath9k_htc: do not start ANI before the first channel is set
wifi: ath9k_htc: start ANI when an AP interface begins to beacon

 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/2 wifi: ath9k_htc: do not start ANI before the first channel is set

From: Mehmet Fide <[email protected]>

ath9k_htc_add_interface() starts ANI for the first AP interface, before any channel is configured. The per-channel calibration data only gets attached by the first ath9k_htc_set_channel() that is not a fast channel change, and that same call cancels the ANI work a few milliseconds after add_interface, so normally the work never runs.

When the bring-up stalls for more than the 100 ms ANI poll interval in between, it does run, and ar9002_hw_per_calibration() records the IQ calibration result in the calibration data that does not exist yet:

  Unable to handle kernel NULL pointer dereference at virtual address
  00000008
  PC is at ar9002_hw_calibrate+0x1f8/0x570 [ath9k_hw]
  Workqueue: phy0 ath9k_htc_ani_work [ath9k_htc]

Seen about once per thousand AP starts with an AR9271 on a Cortex-A5 board that starts hostapd while still booting; a 500 ms delay after add_interface reproduces it on every start. The crashed work never completes, so the next cancel_delayed_work_sync() blocks for good.

Drop the start; it has nothing to calibrate against and is cancelled anyway. The TSF adjust bit that shared its condition is now set for every AP interface, which is harmless: the next reset applies it. The next patch starts ANI once the interface beacons.

Fixes a236254c35f0 ("ath9k_htc: Add ANI for AP mode")
---
 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_main.c +1 -4
index 0d6272ac0dac..a86dd28b0ab7 100644
@@ -1098,11 +1098,8 @@ static int ath9k_htc_add_interface(struct ieee80211_hw *hw,
 
 	ath9k_htc_set_opmode(priv);
 
-	if ((priv->ah->opmode == NL80211_IFTYPE_AP) &&
-	    !test_bit(ATH_OP_ANI_RUN, &common->op_flags)) {
+	if (priv->ah->opmode == NL80211_IFTYPE_AP)
 		ath9k_hw_set_tsfadjust(priv->ah, true);
-		ath9k_htc_start_ani(priv);
-	}
 
 	ath_dbg(common, CONFIG, "Attach a VIF of type: %d at idx: %d\n",
 		vif->type, avp->index);
Signature · 1 line
2.55.0
maintainer Acked-by on v1 1/2
#2 lore raw

Re: [PATCH ath-current 1/2] wifi: ath9k_htc: do not start ANI before the first channel is set

Quoted 22 lines · Mehmet Fide

From: Mehmet Fide <[email protected]>

ath9k_htc_add_interface() starts ANI for the first AP interface, before any channel is configured. The per-channel calibration data only gets attached by the first ath9k_htc_set_channel() that is not a fast channel change, and that same call cancels the ANI work a few milliseconds after add_interface, so normally the work never runs.

When the bring-up stalls for more than the 100 ms ANI poll interval in between, it does run, and ar9002_hw_per_calibration() records the IQ calibration result in the calibration data that does not exist yet:

  Unable to handle kernel NULL pointer dereference at virtual address
  00000008
  PC is at ar9002_hw_calibrate+0x1f8/0x570 [ath9k_hw]
  Workqueue: phy0 ath9k_htc_ani_work [ath9k_htc]

Seen about once per thousand AP starts with an AR9271 on a Cortex-A5 board that starts hostapd while still booting; a 500 ms delay after add_interface reproduces it on every start. The crashed work never completes, so the next cancel_delayed_work_sync() blocks for good.

Quoted 8 lines

Drop the start; it has nothing to calibrate against and is cancelled anyway. The TSF adjust bit that shared its condition is now set for every AP interface, which is harmless: the next reset applies it. The next patch starts ANI once the interface beacons.

Fixes a236254c35f0 ("ath9k_htc: Add ANI for AP mode")
#3 lore raw

PATCH 2/2 wifi: ath9k_htc: start ANI when an AP interface begins to beacon

In reply to Mehmet Fide

From: Mehmet Fide <[email protected]>

ath9k_htc_vif_reconfig() re-arms ANI after a channel change when an AP interface beacons. mac80211 configures the channel before it enables the beacon, so during a normal AP start that never triggers, and the start from add_interface that the previous patch removed was cancelled by the same channel configuration: with hostapd, ANI and the periodic calibration it drives did not run in AP mode until a later channel change.

Start ANI when the beacon is enabled. The channel and its calibration data are in place by then, which is the state vif_reconfig() re-arms it in, and remove_interface() already stops it with the last AP interface.

Fixes a236254c35f0 ("ath9k_htc: Add ANI for AP mode")
---
 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath9k/htc_drv_main.c +3 -0
index a86dd28b0ab7..6578114a4019 100644
@@ -1551,6 +1551,9 @@ static void ath9k_htc_bss_info_changed(struct ieee80211_hw *hw,
 		ath9k_htc_set_tsfadjust(priv, vif);
 		priv->cur_beacon_conf.enable_beacon = 1;
 		ath9k_htc_beacon_config(priv, vif);
+		if (priv->ah->opmode == NL80211_IFTYPE_AP &&
+		    !test_bit(ATH_OP_ANI_RUN, &common->op_flags))
+			ath9k_htc_start_ani(priv);
 	}
 
 	if ((changed & BSS_CHANGED_BEACON_ENABLED) && !bss_conf->enable_beacon) {
Signature · 1 line
2.55.0
maintainer Acked-by on v1 2/2
#4 lore raw

Re: [PATCH ath-current 2/2] wifi: ath9k_htc: start ANI when an AP interface begins to beacon

Quoted 10 lines · Mehmet Fide

From: Mehmet Fide <[email protected]>

ath9k_htc_vif_reconfig() re-arms ANI after a channel change when an AP interface beacons. mac80211 configures the channel before it enables the beacon, so during a normal AP start that never triggers, and the start from add_interface that the previous patch removed was cancelled by the same channel configuration: with hostapd, ANI and the periodic calibration it drives did not run in AP mode until a later channel change.

Quoted 7 lines

Start ANI when the beacon is enabled. The channel and its calibration data are in place by then, which is the state vif_reconfig() re-arms it in, and remove_interface() already stops it with the last AP interface.

Fixes a236254c35f0 ("ath9k_htc: Add ANI for AP mode")
Applied
#5 lore raw
In reply to Mehmet Fide
Quoted 11 lines · Mehmet Fide

From: Mehmet Fide <[email protected]>

ath9k_htc starts ANI for an AP interface in add_interface, before a channel and the calibration data exist. When the bring-up stalls between add_interface and the first channel configuration, the first ANI tick dereferences a NULL ah->caldata and the device does not recover. Patch 1 removes that start. Patch 2 starts ANI once the interface beacons, which is where ath9k_htc_vif_reconfig() already re-arms it after a channel change; without it ANI and the periodic calibration never ran during a normal AP start.

Quoted 1 line

[...]

Applied, thanks!

[1/2] wifi: ath9k_htc: do not start ANI before the first channel is set

      commit: 86210ad4ddf1aedcaa45bde16d829fc27aa7c5c9
[2/2] wifi: ath9k_htc: start ANI when an AP interface begins to beacon
      commit: 9f0fe5ad0c9af369400bb87143bc936ebb741391

Best regards,

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