* [PATCH] wifi: ath12k: set the regdomain before registering the wiphy
@ 2026-10-11 7:44 François Roux
0 siblings, 0 replies; only message in thread
From: François Roux @ 2026-10-11 7:44 UTC (permalink / raw)
To: Jeff Johnson
Cc: Jeff Johnson, Johannes Berg, ath12k, linux-wireless, linux-kernel
ath12k marks its wiphy as REGULATORY_WIPHY_SELF_MANAGED, but it applies
the regdomain received from the firmware only after
ieee80211_register_hw(). cfg80211 announces the new wiphy to userspace
during registration, so a GET_REG request sent in that window finds a
self-managed wiphy without a regdomain:
WARNING: net/wireless/nl80211.c:10828 at nl80211_get_reg_do+0x1d0/0x1fc [cfg80211], CPU#5: iwd/721
iwd queries the regdomain of each new wiphy right away, so this shows up
at boot. On a Microsoft Surface Pro 11 (WCN7850) it happened in 3 of 4
boots.
Apply the boot-time regdomain before ieee80211_register_hw().
regulatory_set_wiphy_regd() only queues it. cfg80211 then applies it in
wiphy_regulatory_register(), which runs under the RTNL before
wiphy_register() returns. nl80211_get_reg_do() also takes the
RTNL, so userspace can no longer see the wiphy without a regdomain.
The regdomain update no longer needs to unregister the hw on failure,
so drop that error path.
Tested on a Surface Pro 11 (WCN7850 hw2.0, WLAN.HMT.1.1.c7-00108) with
next-20260929:
- without this patch, every driver unbind/bind triggers the warning
(12 warnings over 6 cycles);
- with it, there is no warning over two boots, two module reloads and
17 unbind/bind cycles, and Wi-Fi connects each time;
- with CONFIG_ATH_REG_DYNAMIC_USER_REG_HINTS and the user regdomain set
to CH, the wiphy ends up with CH after each of 4 unbind/bind cycles,
with or without this patch. The user hint handling added by commit
906619a00967 ("wifi: ath12k: handle regulatory hints during mac
registration") still works.
Link: https://lore.kernel.org/all/20261006161744.3804-1-franzelfranzel@gmail.com/
Assisted-by: LLM
Signed-off-by: François Roux <franzelfranzel@gmail.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 196b80721..1208c1698 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -15041,6 +15041,18 @@ static int ath12k_mac_hw_register(struct ath12k_hw *ah)
for_each_ar(ah, ar, i)
complete_all(&ar->regd_update_completed);
+ /* Apply the regd received during initialization before registering
+ * the wiphy. It is self-managed, so userspace may ask for its regd as
+ * soon as it shows up, and cfg80211 expects one to be there.
+ */
+ for_each_ar(ah, ar, i) {
+ ret = ath12k_regd_update(ar, true);
+ if (ret) {
+ ath12k_err(ar->ab, "ath12k regd update failed: %d\n", ret);
+ goto err_cleanup_if_combs;
+ }
+ }
+
ret = ieee80211_register_hw(hw);
if (ret) {
ath12k_err(ab, "ieee80211 registration failed: %d\n", ret);
@@ -15058,13 +15070,6 @@ static int ath12k_mac_hw_register(struct ath12k_hw *ah)
for_each_ar(ah, ar, i) {
struct ath12k_base *this_ab = ar->ab;
- /* Apply the regd received during initialization */
- ret = ath12k_regd_update(ar, true);
- if (ret) {
- ath12k_err(this_ab, "ath12k regd update failed: %d\n", ret);
- goto err_unregister_hw;
- }
-
if (this_ab->hw_params->current_cc_support) {
struct wmi_set_current_country_arg current_cc = {};
struct ieee80211_regdomain *default_regd;
@@ -15105,12 +15110,6 @@ static int ath12k_mac_hw_register(struct ath12k_hw *ah)
return 0;
-err_unregister_hw:
- for_each_ar(ah, ar, i)
- ath12k_debugfs_unregister(ar);
-
- ieee80211_unregister_hw(hw);
-
err_cleanup_if_combs:
ath12k_mac_cleanup_iface_combinations(ah);
base-commit: 6474fa070f2b8013b4b87350b775b8c3be6e8aac
--
2.56.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-11 7:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-11 7:44 [PATCH] wifi: ath12k: set the regdomain before registering the wiphy François Roux
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®