Linux wireless drivers development
 help / color / mirror / Atom feed
* [BUG] 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)
@ 2026-11-22 21:30 Gaston Guevara
  2026-11-23 15:40 ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 2+ messages in thread
From: Gaston Guevara @ 2026-11-22 21:30 UTC (permalink / raw)
  To: linux-wireless; +Cc: toke, johannes

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):

--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ 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

-- 
Gaston Guevara

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-23 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 21:30 [BUG] 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) Gaston Guevara
2026-11-23 15:40 ` Toke Høiland-Jørgensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox