From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796141255; b=R3Jd2vuatO8X1F6FWvJY8lV+MWu4YzL4VYlRSGqJaGaQYvN2PCxYWBo4BeYktbRoQ9RA IfUcppHvS+UgXhzDIaSHk81GV1Zt/kKbWKU/d317ZaOhg8QaT3cB4a4TcL79m7ol97cof ggyM9NxTQJertyRBtfSc8rDhBGQFwUqVly8ywID+GXVU3fWHHc7hunzI4FPEskplKW67c 3DhTKXUs2xKFoYOme4HSKPpjK4PGYthS6K/M+mSW+BMF+BTvKqzT/b2YkWZDRFFMkYWiY /hCuSzsxGYf60LbfHhHIQnMB0pVUuzrFuru2MdTxdBXbucI/khv1BCwfUL1Ay2nEjag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796141255; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=c2UH3xiPd/jh39EbmkLXzoJlresP/rbWQ2wm6jGlfO4=; b=20/Bjl6T45D6HBR7Uaw82043YHjf22w7UUwBp+rPq16oHlhQjsU23DcUIuacExR3UT45 X83Q32Ji8X01qTNoxPfy0dSZTGPQZ9MextwhKE2xUtPy/ImBBbr+gqU2nwp3rUIeUKZvA 9mQTk8Z8PE02Fy+bxC5D1sLlrW9j//UJ4ho8mSmkFH1x2Si6qQWt691x5p+4pwDOQcmYm +YhpLWjsp0gspffKFCMOsn4J7s3ZcgUH3GPemfatitkXv3NxJDzsKJBWyG9mAHq9oBWma u3k6OjcVwvf8o8R6J9oszITqb9JydVpPATAIXol3oFK34YzEF9zgeZbfBvk1eTfZCxg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="VnhJ24R/"; arc=none smtp.remote-ip=209.85.221.44 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9147A606A31A for ; Tue, 1 Dec 2026 16:07:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9147A606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=VnhJ24R/ Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-492f0a1b685so8649173f8f.0 for ; Tue, 01 Dec 2026 08:07:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796141253; x=1796746053; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=c2UH3xiPd/jh39EbmkLXzoJlresP/rbWQ2wm6jGlfO4=; b=VnhJ24R/DZVnpwftz42FWY8ySDWkg+5C+JgYyimEKQY8jfz0scIffTiyvn2dJdbFnU KW9JwFN6nJNiri9lgPUNiHtD3tNMv/veAPIedntBA7acdKQvNXzjfj/M6BWYuuLB9q7E 7RjZdTVUowjSe2IltkM+64U8VJD1gFxJevvO16B1JhqqWuuOKwKPeGJSQNXTVLg+REmW VycviyW1Lm+T3qi7y+5s7+TBZFMlxYi6SaTRnjd+SDcqkXGX1fA82VrMY+JMqZRogtL4 DKf9+ew+jPJmFabf+fSkBjLP6Bv5RB9OsFe9bndMzwtoAIS4R4OTBj3sMpQ5TG5udZWu jeWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796141253; x=1796746053; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=c2UH3xiPd/jh39EbmkLXzoJlresP/rbWQ2wm6jGlfO4=; b=BGErItdAfy5A76cvJ4MOrCINjkIJZHpiy8dDlWfJ/67MfvxK+QqxMRX1zL7QyKhyyO YiEcwyFywyqB1C6ltMzXe+Q7W6LYzSXGA+z5b2FGV56yI2K3kGFwvYIRFykUC7ih/6vY m2hd5r9BKHxXmTCriSiRSU+9LOUuwhnai3nt2nHmrGVNDkYLjbi1Cqhul2hi5EmWa+qN A2fAGIovvD0w5aGCU4uilb2FoL5gn+BMEmO/l8sUu+pRiJkSD5woj27jQIRBogjDoc8x qdnrZOBIkOpCV1Uu7yHHMI0VhP/aRMC9CHnTuSnMbpqg8hGeb0w0chBDXdwlpSofWpmj AzPQ== X-Gm-Message-State: APuU4Z/Dr8wUz/UobRY1qk0kUjklEa6uB9JkgHB+e9jJnG9J2yb65yKC 1mp8MJHuaH04Ng3C5PrVqJ5iwd9NhIyamO6UCuCij1poMLLtxU3kmC3J5dAjAg== X-Gm-Gg: AZFdTZchJAlef87zKUL85caJj73eR4NyqS57GrCkk8u9CPu3JWwPqAur0PkJv4c0Hla jdVAuzoHvqZXG03SeJuo+Jgd/HX8OuO97+lwMEW8Zx3h0amhoZ0xEXu6g5HWL6qu3RTAyDOA/IH t1zLLUmf/L+mDHhAjZH5RFXBM4mu1yTOyqIWyMFSQ93WrFkTqqpzb0ZlPwQRW3iNCNxbNXMNtXa 9o0voRfg4rf5BNWMLt5oAxNX4vfE/48K1EsFm7bUT9VkhLG64XvwsZjvlefSysWraF6N1YaKy/D ZvN5znp93WIo2ZLTiVl8Kl1eAwjahx0xdiw91MZc6neDKh9DV/91KLtnzv9y7CtnXoPcwdWXrws DYk4CybS5NhjfQkCneO3KbvX+wTVlN6GBLfVBvS0EsHzpOsZMO3RPcFVYYeEfWAPazA9MDVprL7 QqRzUt6q3hprm9zP+kTrHgGP3zjQ1+iCooba75sbqZwfjbpb7IrHEjnrEQoZusLe4hHod/G+ZlB 0Hlum8LyP11ABm6h3Xw04U1//obQqNU56GHeQE4MeBDA/sVsb/ltMHDqi4SVfhdGDngqSspF3Fa PI0xtBoGqIBSg1NO5G/BbY1iGZNglIGrmqHm2uJQ19hULaByKIkWwTg2oVrHZH+W945vggOZwBT lc4t56wVa+8T9asgI X-Received: by 2002:a05:6000:4812:b0:4a7:9630:7b32 with SMTP id ffacd0b85a97d-4abb5518569mr69608097f8f.46.1796141252478; Tue, 01 Dec 2026 08:07:32 -0800 (PST) Received: from VivoBook-ASUS-X712UA-M712UA.lan (user-31-175-178-153.play-internet.pl. [31.175.178.153]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6b8b7888sm71917342f8f.42.2026.12.01.08.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 08:07:31 -0800 (PST) From: Stanislaw Pal To: Johannes Berg Cc: linux-wireless@vger.kernel.org, Louis Komiwes Subject: [PATCH wireless-next] wifi: cfg80211: keep the DFS state when a self-managed wiphy applies its domain again Date: Tue, 1 Dec 2026 17:07:29 +0100 Message-ID: <20261201160729.44058-1-kuncy7@gmail.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit A self-managed wiphy applies its regulatory domain again whenever the driver asks for it, and handle_channel_custom() then starts every channel at NL80211_DFS_USABLE. A channel that had completed its CAC is no longer available, and one in its non-occupancy period is usable again. Nothing acts on that at once. reg_check_chans_work() does, 60 s later (REG_ENFORCE_GRACE_MS): an AP or a mesh on a chandef that needs DFS is now on channels that are only usable, so it is stopped. hostapd logs the NL80211_CMD_STOP_AP only at debug level and keeps reporting the AP as enabled. ath11k asks after every restart of its firmware: the firmware sends its channel list again and the driver passes it on. Seen on an IPQ5018 with a QCN6122 (TP-Link Archer AX55 v1) and reported with a QCN9074 (Xiaomi AX6000): AP and mesh on channel 36 at 160 MHz, which takes in channels 52-64, a simulated firmware crash, recovery within 5 s, "DFS state: usable" 7 s after the crash, and carrier and channel gone 61 s after that. At 80 MHz, without a radar channel, nothing happens. ath12k does the same, and there one wiphy can carry several radios. Reported with a QCN9224 on an IPQ53xx (5 GHz and 6 GHz on one wiphy): a 5 GHz AP on channel 100 at 80 MHz after a completed CAC, then a restart of the 6 GHz radio only. Channel 100 drops to usable, and the 5 GHz AP stops 61 s after the restart although its own radio was never touched. Setting the country again (iw reg set) takes the same path through the driver and ends a non-occupancy period after a radar early. Save the DFS state of every channel before the domain is applied and put it back on the channels whose place in the DFS scheme did not change: radar before and after, not disabled, and the DFS region of the domain the same. These are the conditions under which reg_copy_dfs_chan_state() already carries a state from one wiphy to another. A domain with another DFS region, or a channel that gained or lost its radar flag, starts from usable as before. Tested as a backport to the cfg80211 of OpenWrt on 6.18, on an Archer AX55 v1 and a GL.iNet GL-B3000 (both IPQ5018 with a QCN6122): three firmware crashes on each, channel 52 stays available throughout and the AP and the mesh stay up. Tested the same way by Louis Komiwes on the QCN9224: channel 100 stays available, both APs stay up, and a radar channel keeps its non-occupancy period across iw reg set. On this tree it is build-tested only (arm64, W=1). I used an LLM (Claude) to help find the cause and write this patch; I reviewed and tested the result. Tested-by: Louis Komiwes Signed-off-by: Stanislaw Pal --- net/wireless/reg.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 090d21739d..0a2af9c3d5 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -3230,11 +3230,100 @@ static void reg_process_pending_beacon_hints(void) } } +/* + * The DFS state of a channel before a regulatory domain is applied to the + * wiphy, see reg_dfs_state_save(). + */ +struct reg_dfs_chan_state { + u32 flags; + enum nl80211_dfs_state dfs_state; + unsigned long dfs_state_entered; +}; + +/* + * handle_channel_custom() starts every channel at NL80211_DFS_USABLE, so a + * self-managed wiphy that applies a regulatory domain again loses the CAC + * results and the non-occupancy periods it had. Nothing acts on that right + * away, but reg_check_chans_work() does REG_ENFORCE_GRACE_MS later: an AP or + * a mesh on a channel that needs DFS is then stopped. + * + * Save the states before the domain is applied and put them back on the + * channels whose place in the DFS scheme did not change: radar before and + * after, not disabled, and the DFS region of the domain the same. These are + * the conditions under which reg_copy_dfs_chan_state() carries a state from + * one wiphy to another. + */ +static struct reg_dfs_chan_state *reg_dfs_state_save(struct wiphy *wiphy) +{ + struct reg_dfs_chan_state *saved, *s; + struct ieee80211_supported_band *sband; + enum nl80211_band band; + unsigned int n = 0, i; + + for (band = 0; band < NUM_NL80211_BANDS; band++) { + sband = wiphy->bands[band]; + if (sband) + n += sband->n_channels; + } + + saved = kzalloc_objs(*saved, n); + if (!saved) + return NULL; + + s = saved; + for (band = 0; band < NUM_NL80211_BANDS; band++) { + sband = wiphy->bands[band]; + if (!sband) + continue; + for (i = 0; i < sband->n_channels; i++, s++) { + const struct ieee80211_channel *chan = &sband->channels[i]; + + s->flags = chan->flags; + s->dfs_state = chan->dfs_state; + s->dfs_state_entered = chan->dfs_state_entered; + } + } + + return saved; +} + +static void reg_dfs_state_restore(struct wiphy *wiphy, + const struct reg_dfs_chan_state *saved) +{ + struct ieee80211_supported_band *sband; + const struct reg_dfs_chan_state *s = saved; + enum nl80211_band band; + unsigned int i; + + for (band = 0; band < NUM_NL80211_BANDS; band++) { + sband = wiphy->bands[band]; + if (!sband) + continue; + for (i = 0; i < sband->n_channels; i++, s++) { + struct ieee80211_channel *chan = &sband->channels[i]; + + if (!(s->flags & IEEE80211_CHAN_RADAR) || + s->flags & IEEE80211_CHAN_DISABLED) + continue; + if (!(chan->flags & IEEE80211_CHAN_RADAR) || + chan->flags & IEEE80211_CHAN_DISABLED) + continue; + if (chan->dfs_state != NL80211_DFS_USABLE || + s->dfs_state == NL80211_DFS_USABLE) + continue; + + chan->dfs_state = s->dfs_state; + chan->dfs_state_entered = s->dfs_state_entered; + } + } +} + static void reg_process_self_managed_hint(struct wiphy *wiphy) { struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); const struct ieee80211_regdomain *tmp; const struct ieee80211_regdomain *regd; + struct reg_dfs_chan_state *dfs_saved = NULL; enum nl80211_band band; struct regulatory_request request = {}; @@ -3253,12 +3342,19 @@ static void reg_process_self_managed_hint(struct wiphy *wiphy) return; tmp = get_wiphy_regdom(wiphy); + if (tmp && tmp->dfs_region == regd->dfs_region) + dfs_saved = reg_dfs_state_save(wiphy); rcu_assign_pointer(wiphy->regd, regd); rcu_free_regdom(tmp); for (band = 0; band < NUM_NL80211_BANDS; band++) handle_band_custom(wiphy, wiphy->bands[band], regd); + if (dfs_saved) { + reg_dfs_state_restore(wiphy, dfs_saved); + kfree(dfs_saved); + } + reg_process_ht_flags(wiphy); request.wiphy_idx = get_wiphy_idx(wiphy); -- 2.43.0