ath9k: WARN in ieee80211_beacon_cntdwn_is_complete() on every CSA when AP and STA share a radio (ath9k_csa_update() visits the STA vif)
Hi,
On an ath9k radio running an AP and a station vif on the same channel, every channel switch announced by the upstream AP makes the kernel print about nine WARNINGs from ieee80211_beacon_cntdwn_is_complete(), roughly one every 200 ms for about two seconds. I think ath9k_csa_is_finished() is being called for the station interface, and I'd like to ask whether a vif-type check there is the right fix.
Setup
- Hardware: TP-Link Archer C60 v3, QCA9561 (ath9k) 2.4 GHz radio: one AP (phy1-ap0) plus one STA (phy1-sta0) on the same phy, same channel. The 5 GHz radio (ath10k) is a separate phy and not involved.
- Software: OpenWrt SNAPSHOT r38494, Linux 6.18.64 with the OpenWrt mac80211 backports (kmod-ath9k-6.18.64.7.2-r16). The kernel is therefore tainted O (out-of-tree modules). hostapd and wpa_supplicant are the OpenWrt builds. I have not reproduced this on a vanilla kernel, but the relevant code is identical in v6.12 and v6.18.
- panic_on_warn=0.
How to trigger
The STA is associated to a consumer router that changes channel every 20-60 minutes, announcing it with a CSA plus an ECSA element (operating class 12). mac80211 logs "cannot understand ECSA IE operating class, 12, ignoring" and follows the CSA. The AP on the same phy follows through hostapd. Observed on 2026-11-20 22:33:18, 2026-11-21 11:38:58 and
2026-11-21 16:26:52 (router local time); each time the WARN burst starts
before the switch completes.
What the kernel prints (one of the ~9 per event, trimmed)
WARNING: CPU: 0 PID: 7 at net/mac80211/tx.c:5648 ieee80211_beacon_cntdwn_is_complete+0xac/0x160 [mac80211] CPU: 0 UID: 0 PID: 7 Comm: kworker/0:0H Tainted: G O 6.18.64 #0 NONE Hardware name: TP-Link Archer C60 v3 Call Trace: [<8006cd18>] show_stack+0x28/0xf0 [<800662a4>] dump_stack_lvl+0x4c/0x80 [<8008aa54>] __warn+0x9c/0x118 [<800611d4>] warn_slowpath_fmt+0x5c/0xac [<82241438>] ieee80211_beacon_cntdwn_is_complete+0xac/0x160 [mac80211]
[<82780360>] 0x82780360
The PID and task vary between WARNs (hostapd, logread, kworkers), so this looks like an interrupt/softirq context, not a process doing something wrong. The module base was 0x82780000 in this boot, so the caller is ath9k + 0x360. In an earlier boot the base differed but the offset was the same (0x360).
Resolving the caller
ath9k.ko from the same build has a R_MIPS_26 relocation to ieee80211_beacon_cntdwn_is_complete at .text+0x358 (a jal, so the return address is 0x360). That function, which sits just before ath9k_beacon_assign_slot, also calls ieee80211_csa_finish at .text+0x384. There are only three calls to ieee80211_beacon_cntdwn_is_complete in the module (+0x358, +0x72c inside the out-of-line ath9k_csa_is_finished, and +0xb70 inside ath9k_beacon_tasklet). This matches ath9k_csa_update_vif() with ath9k_csa_is_finished() inlined. I confirmed this by building the same module from the same sources: its .text is byte-identical to the one on the device, and addr2line places .text+0x358 in ath9k_csa_is_finished() (beacon.c:368), inlined into ath9k_csa_update_vif() (beacon.c:378).
Analysis
In v6.18 (and v6.12), ath9k_csa_is_finished() is:
bool ath9k_csa_is_finished(struct ath_softc *sc, struct ieee80211_vif *vif)
{
if (!vif || !vif->bss_conf.csa_active)
return false;
if (!ieee80211_beacon_cntdwn_is_complete(vif, 0))
return false;
ieee80211_csa_finish(vif, 0);
return true;
}and ath9k_csa_update() visits every active interface:
ieee80211_iterate_active_interfaces_atomic(sc->hw, IEEE80211_IFACE_ITER_NORMAL,
ath9k_csa_update_vif, sc);
mac80211's ieee80211_beacon_cntdwn_is_complete() only knows AP, ADHOC and MESH_POINT vifs; for any other type it reaches else { WARN_ON(1); goto out; }. mac80211 sets bss_conf.csa_active on a station vif while it processes a channel switch from its AP (ieee80211_sta_process_chanswitch() does link->conf->csa_active = true). So, while the upstream CSA is in progress, ath9k_csa_update() calls ath9k_csa_is_finished() for the STA vif, csa_active is true, and the WARN fires on each pass, which would explain the periodic burst that starts before the switch completes. I checked the exact sources used for this build: tx.c:5648 is the WARN_ON(1); in that final else branch, not the WARN_ON(!beacon || !beacon->tail) one.
Proposed change (RFC, tested on the device)
Skip station vifs in ath9k_csa_is_finished() (indentation below is spaces because of my mail client; the source uses tabs):
drivers/net/wireless/ath/ath9k/beacon.c +0 -0
@@ bool ath9k_csa_is_finished(struct ath_softc *sc, struct ieee80211_vif *vif) { -if (!vif || !vif->bss_conf.csa_active) +if (!vif || vif->type ==NL80211_IFTYPE_STATION || + !vif->bss_conf.csa_active)return false;
I excluded only NL80211_IFTYPE_STATION rather than requiring NL80211_IFTYPE_AP, so that ad-hoc and mesh keep their current behaviour. If you would rather fix it in mac80211 (e.g. make ieee80211_beacon_cntdwn_is_complete() return false for non-beaconing types without warning), I'm happy to test that instead. I have now tested the ath9k change on the device: with the patched module loaded, twelve consecutive upstream channel switches (2026-11-21 19:38 to 2026-11-22 09:03, router local time) produced no WARNING at all, whereas without the patch all five switches I had logged produced them. This is one router, one upstream AP, and the module is an out-of-tree build of the same sources, so it is not a statistical statement, but the warnings are gone. The patch does not stop the -EBUSY station disconnect that sometimes follows the same CSA (it still happened in four of those twelve switches); that is a separate problem, which I am reporting in its own thread on this list ("mac80211: station is disconnected on an upstream CSA (-EBUSY from ieee80211_vif_use_reserved_switch()) ...").
Background
On OpenWrt 23.05.3 (kernel 5.15) the same kind of WARN was hit (at tx.c:5103 in that tree) and the router rebooted after several CSAs. I have no log of what caused that reboot, so I'm not claiming a link.
I can provide the full dmesg of the three events, the exact ath9k.ko, and test patches on this hardware.
Thanks,
Gastón
Signature · 1 line
Gaston Guevara
Toke Høiland-Jørgensen
maintainerQuoted 8 lines
drivers/net/wireless/ath/ath9k/beacon.c +0
-0@@ bool
ath9k_csa_is_finished(struct ath_softc *sc, struct ieee80211_vif *vif)
{- if (!vif || !vif->bss_conf.csa_active) + if (!vif || vif->type == NL80211_IFTYPE_STATION || + !vif->bss_conf.csa_active) return false;
I think this makes sense, please send a proper patch.
-Toke
PATCH 1/1 wifi: ath9k: don't check CSA completion on station interfaces
ath9k_csa_update() iterates over all active interfaces and calls ath9k_csa_is_finished() for each of them. mac80211 also sets bss_conf.csa_active on a station interface while it follows a channel switch announced by its AP, so when an AP and a station share an ath9k radio, ath9k_csa_is_finished() calls ieee80211_beacon_cntdwn_is_complete() for the station vif. That function only handles AP, ad-hoc and mesh interfaces and hits WARN_ON(1) for any other type, producing a burst of warnings (about one per beacon interval) on every upstream CSA.
Skip station interfaces in ath9k_csa_is_finished(). Ad-hoc and mesh interfaces keep their current behaviour.
Tested on a TP-Link Archer C60 v3 (QCA9561) with an AP and a station on the same radio: twelve consecutive upstream channel switches with no warnings, whereas every logged switch produced them before.
--- drivers/net/wireless/ath/ath9k/beacon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/beacon.c +2 -1
@@ -362,7 +362,8 @@ static void ath9k_set_tsfadjust(struct ath_softc *sc,bool ath9k_csa_is_finished (struct ath_softc *sc,struct ieee80211_vif *vif) { -if (!vif || !vif->bss_conf.csa_active) +if (!vif || vif->type ==NL80211_IFTYPE_STATION || + !vif->bss_conf.csa_active)return false;if (!ieee80211_beacon_cntdwn_is_complete (vif,0 ))
Signature · 1 line
2.39.5
Toke Høiland-Jørgensen
maintainerRe: [PATCH ath-next] wifi: ath9k: don't check CSA completion on station interfaces
Quoted 28 lines · Gaston Guevara
ath9k_csa_update()iterates over all active interfaces and callsath9k_csa_is_finished()for each of them. mac80211 also sets bss_conf.csa_active on a station interface while it follows a channel switch announced by its AP, so when an AP and a station share an ath9k radio,ath9k_csa_is_finished()callsieee80211_beacon_cntdwn_is_complete()for the station vif. That function only handles AP, ad-hoc and mesh interfaces and hitsWARN_ON(1)for any other type, producing a burst of warnings (about one per beacon interval) on every upstream CSA.Skip station interfaces in
ath9k_csa_is_finished(). Ad-hoc and mesh interfaces keep their current behaviour.Tested on a TP-Link Archer C60 v3 (QCA9561) with an AP and a station on the same radio: twelve consecutive upstream channel switches with no warnings, whereas every logged switch produced them before.
Fixes 4effc6fda7ab ("ath9k: prepare for multi-interface CSA support")Link https://lore.kernel.org/linux-wireless/CABMxrRyvsFy7qGXky-OF1KE3c04z0xO_XMGnJC28L0WHE9AF9Q@mail.gmail.com/ open hereSigned-off-by Gaston Guevara <[email protected]>--- drivers/net/wireless/ath/ath9k/beacon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/wireless/ath/ath9k/beacon.c +0
-0
drivers/net/wireless/ath/ath9k/beacon.c static void ath9k_set_tsfadjust(struct ath_softc *sc, · line 366
Quoted 6 lines
drivers/net/wireless/ath/ath9k/beacon.c +2
-1@@ -362,7 +362,8 @@ static void ath9k_set_tsfadjust(struct ath_softc *sc,bool ath9k_csa_is_finished (struct ath_softc *sc,struct ieee80211_vif *vif) { -if (!vif || !vif->bss_conf.csa_active) +if (!vif || vif->type ==NL80211_IFTYPE_STATION || + !vif->bss_conf.csa_active)
Hmm, actually, now that I think about this some more, I think it's better to move this check out to the caller (in ath9k_csa_update_vif()). If we ever do get called through the non-iteration path with a wrong interface type, we want to hear about it through the WARN_ON.
-Toke
pw-bot: cr