From: Nikolay Bryskin <nbryskin@gmail.com>
To: jjohnson@kernel.org
Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org,
johannes@sipsolutions.net, Nikolay Bryskin <nbryskin@gmail.com>
Subject: [PATCH 2/2] wifi: ath11k: apply the initial regdomain before registering the wiphy
Date: Fri, 9 Oct 2026 01:58:53 +0300 [thread overview]
Message-ID: <20261008225853.15399-3-nbryskin@gmail.com> (raw)
In-Reply-To: <20261008225853.15399-1-nbryskin@gmail.com>
ath11k marks its wiphy REGULATORY_WIPHY_SELF_MANAGED in
ath11k_reg_init(), but applies the regdomain received from the firmware
only after ieee80211_register_hw(), and asynchronously:
regulatory_set_wiphy_regd() just stores the request and schedules
reg_work. Userspace is told about the new wiphy from wiphy_register(), so
it can query the regdomain before there is one. iwd does exactly that as
soon as the wiphy appears, which triggers the WARN_ON() in
nl80211_get_reg_do():
!regdom && self_managed
WARNING: net/wireless/nl80211.c:10576 at nl80211_get_reg_do+0x229/0x270 [cfg80211], CPU#4: iwd/716
Call Trace:
genl_family_rcv_msg_doit+0x144/0x1a0
genl_rcv_msg+0x1cc/0x300
netlink_rcv_skb+0xcd/0x150
genl_rcv+0x28/0x40
netlink_unicast+0x2fb/0x4a0
netlink_sendmsg+0x219/0x480
__sys_sendto+0x226/0x230
...
The regdomain is already known at that point (ab->default_regd[], or
ab->new_regd[] if an update arrived meanwhile), so apply it before
ieee80211_register_hw(). wiphy_register() then installs the pending
regdomain itself, via wiphy_regulatory_register() ->
reg_process_self_managed_hints(). That happens under the same RTNL hold
as the NL80211_CMD_NEW_WIPHY notification, and nl80211_get_reg_do() takes
the RTNL as well, so userspace can no longer see the wiphy without its
regdomain.
The window matters beyond the warning. With an msleep(2000) inserted
after ieee80211_register_hw() for testing, iwd associated before the
regdomain was applied; the late regdomain then went through
ath11k_reg_notifier() ("driver initiated regd update") and the channel
list update to the firmware while associated, and from then on TX was
badly degraded while RX stayed fine (QCA6390, 5 GHz DFS channel, signal
-33 dBm, no beacon loss):
tx packets: 2012, tx failed: 1678, tx retries: 0
tx bitrate: 48.0 MBit/s
rx bitrate: 648.5 MBit/s 80MHz HE-MCS 6 HE-NSS 2
ping showed 39% loss. Without the delay, the WARN_ON() shows up at boot
only occasionally. With this patch and the same delay neither the
warning nor the TX degradation occurred.
Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-05266-QCAHSTSWPLZ_V2_TO_X86-1
Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
Link: https://lore.kernel.org/all/16aa99921c4e92e8d4da3c84aacbec2e673666aa.camel@sipsolutions.net/
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Nikolay Bryskin <nbryskin@gmail.com>
---
drivers/net/wireless/ath/ath11k/mac.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 3dfd24d7b5a6..4ebdde872213 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -10648,6 +10648,16 @@ static int __ath11k_mac_register(struct ath11k *ar)
ab->hw_params.bios_sar_capa)
ar->hw->wiphy->sar_capa = ab->hw_params.bios_sar_capa;
+ /* Apply the regd received during initialization. Do it before
+ * registering so that cfg80211 installs it while registering the
+ * wiphy, before userspace can query a self-managed wiphy without one.
+ */
+ ret = ath11k_regd_update(ar);
+ if (ret) {
+ ath11k_err(ar->ab, "ath11k regd update failed: %d\n", ret);
+ goto err_free_if_combs;
+ }
+
ret = ieee80211_register_hw(ar->hw);
if (ret) {
ath11k_err(ar->ab, "ieee80211 registration failed: %d\n", ret);
@@ -10662,13 +10672,6 @@ static int __ath11k_mac_register(struct ath11k *ar)
*/
ar->hw->wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MONITOR);
- /* Apply the regd received during initialization */
- ret = ath11k_regd_update(ar);
- if (ret) {
- ath11k_err(ar->ab, "ath11k regd update failed: %d\n", ret);
- goto err_unregister_hw;
- }
-
if (ab->hw_params.current_cc_support && ab->new_alpha2[0]) {
memcpy(&ar->alpha2, ab->new_alpha2, 2);
ret = ath11k_reg_set_cc(ar);
--
2.56.0
prev parent reply other threads:[~2026-10-08 22:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 22:58 [PATCH ath-next 0/2] wifi: ath11k: fix two races between ieee80211_register_hw() and the rest of mac registration Nikolay Bryskin
2026-10-08 22:58 ` [PATCH 1/2] wifi: ath11k: initialize txmgmt_empty_waitq before registering the hw Nikolay Bryskin
2026-10-08 22:58 ` Nikolay Bryskin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261008225853.15399-3-nbryskin@gmail.com \
--to=nbryskin@gmail.com \
--cc=ath11k@lists.infradead.org \
--cc=jjohnson@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox