wireless: address REGULATORY_CUSTOM_REG usage with regulatory_hint()
cover wireless: address REGULATORY_CUSTOM_REG usage with regulatory_hint()
Sujith spotted a warning on the ath module when it doesn't set the REGULATORY_CUSTOM_REG flag but still uses the wiphy_apply_custom_regulatory(). The issue is that the cards that it is warning on are not world roaming but the ath module preference is to be conservative and to apply a custom world roaming regulatory domain *prior* to applying the one seen mandated by the alpha2 on the card with regulatory_hint().
Fix this first in the shared ath module for the Atheros drivers and then later merge a generic solution so that others drivers don't have to do this, and remove the temporary flag removal within the ath module then.
The split of the patches should let John take in the ath module fix while Johannes can take in the generic solution for cfg80211 separately. Once Johannes sends a pull request to Linville I suspect there will be no conflicts.
Sujith please test each one separately if you can.
Luis R. Rodriguez (2):
ath: fix warning on usage of REGULATORY_CUSTOM_REG
cfg80211: make regulatory_hint() remove REGULATORY_CUSTOM_REG
drivers/net/wireless/ath/regd.c | 7 ++++--- include/net/regulatory.h | 4 ++++ net/wireless/reg.c | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.4.3
PATCH 1/2 ath: fix warning on usage of REGULATORY_CUSTOM_REG
ath wants to first apply the custom regd and only later will it revert to not using it if an alpha2 regulatory domain is found. Since the wireless core now enforces usage of the REGULATORY_CUSTOM_REG strictly when wiphy_apply_custom_regulatory() is used this makes ath adhere to the expected behaviour but also updates the wiphy after its done with the custom usage.
This fixes this warning:
[ 5.488733] ath: phy0: ASPM enabled: 0x43 [ 5.488735] ath: EEPROM regdomain: 0x0 [ 5.488736] ath: EEPROM indicates default country code should be used [ 5.488736] ath: doing EEPROM country->regdmn map search [ 5.488737] ath: country maps to regdmn code: 0x3a [ 5.488737] ath: Country alpha2 being used: US [ 5.488738] ath: Regpair used: 0x3a [ 5.488738] ------------[ cut here ]------------ [ 5.488745] WARNING: CPU: 0 PID: 161 at /home/sujith/dev/wireless-testing/net/wireless/reg.c:1361 wiphy_apply_custom_regulatory+0x17a/0x1b0 [cfg80211]() [ 5.488746] wiphy should have REGULATORY_CUSTOM_REG
The wireless core can *later* lift this flag for us for when using the regulatory_hint() to make this fix more generic.
--- drivers/net/wireless/ath/regd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/regd.c +6 -3
@@ -602,7 +602,8 @@ ath_regd_init_wiphy(struct ath_regulatory *reg,const struct ieee80211_regdomain *regd; wiphy->reg_notifier = reg_notifier; - wiphy->regulatory_flags |=REGULATORY_STRICT_REG ; + wiphy->regulatory_flags |=REGULATORY_STRICT_REG | +REGULATORY_CUSTOM_REG ;if (ath_is_world_regd (reg)) {/*
@@ -610,8 +611,7 @@ ath_regd_init_wiphy(struct ath_regulatory *reg,* saved on the wiphy orig_* parameters */ regd =ath_world_regdomain (reg); - wiphy->regulatory_flags |=REGULATORY_CUSTOM_REG | -REGULATORY_COUNTRY_IE_FOLLOW_POWER ; + wiphy->regulatory_flags |=REGULATORY_COUNTRY_IE_FOLLOW_POWER ; }else {/* * This gets applied in the case of the absence of CRDA,
@@ -620,7 +620,10 @@ ath_regd_init_wiphy(struct ath_regulatory *reg,*/ regd =ath_default_world_regdomain (); } +wiphy_apply_custom_regulatory (wiphy, regd); +if (!ath_is_world_regd (reg)) + wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG ;ath_reg_apply_radar_flags (wiphy);ath_reg_apply_world_flags (wiphy,NL80211_REGDOM_SET_BY_DRIVER , reg);return 0 ;
Signature · 1 line
1.8.4.3
Re: [RFT 1/2] ath: fix warning on usage of REGULATORY_CUSTOM_REG
drivers/net/wireless/ath/regd.c ath_regd_init_wiphy(struct ath_regulatory *reg, · line 626
Quoted 3 lines · Luis R. Rodriguez
drivers/net/wireless/ath/regd.c +2
-0wiphy_apply_custom_regulatory (wiphy, regd); +if (!ath_is_world_regd (reg)) + wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG ;
The warning is gone, but why is this cleared here ?
Sujith
Re: [RFT 1/2] ath: fix warning on usage of REGULATORY_CUSTOM_REG
Quoted 6 lines · Sujith Manoharan
drivers/net/wireless/ath/regd.c ath_regd_init_wiphy(struct ath_regulatory *reg, · line 626
Quoted 3 lines · Luis R. Rodriguez
wiphy_apply_custom_regulatory(wiphy, regd);drivers/net/wireless/ath/regd.c +2
-0+if (!ath_is_world_regd (reg)) + wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG ;The warning is gone, but why is this cleared here ?
It should be CUSTOM that gets cleared, sorry.
Luis
PATCH 2/2 cfg80211: make regulatory_hint() remove REGULATORY_CUSTOM_REG
In reply to Luis R. RodriguezThe REGULATORY_CUSTOM_REG can be used during early init with the goal of overriding the wiphy's default regulatory settings in case the alpha2 of the device is not known. In the case that the alpha2 becomes known lets avoid having drivers having to clear the REGULATORY_CUSTOM_REG flag by doing it for them when regulatory_hint() is used.
--- drivers/net/wireless/ath/regd.c | 2 -- include/net/regulatory.h | 4 ++++ net/wireless/reg.c | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/regd.c +0 -2
@@ -622,8 +622,6 @@ ath_regd_init_wiphy(struct ath_regulatory *reg, }wiphy_apply_custom_regulatory (wiphy, regd); -if (!ath_is_world_regd (reg)) - wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG ;ath_reg_apply_radar_flags (wiphy);ath_reg_apply_world_flags (wiphy,NL80211_REGDOM_SET_BY_DRIVER , reg);return 0 ;
include/net/regulatory.h +4 -0
@@ -96,6 +96,10 @@ struct regulatory_request {* initiator is %REGDOM_SET_BY_CORE). Drivers that use * wiphy_apply_custom_regulatory() should have this flag set * or the regulatory core will set it for the wiphy. +* If you use regulatory_hint() *after* using +* wiphy_apply_custom_regulatory() the wireless core will +* clear the REGULATORY_CUSTOM_REG for your wiphy as it would be +* implied that the device somehow gained knowledge of its region. * @REGULATORY_STRICT_REG: tells us that the wiphy for this device * has regulatory domain that it wishes to be considered as the * superset for regulatory rules. After this device gets its regulatory
net/wireless/reg.c +2 -0
@@ -1826,6 +1826,8 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2)if (WARN_ON (!alpha2 || !wiphy))return -EINVAL ; + wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG ; + request =kzalloc (sizeof (struct regulatory_request ),GFP_KERNEL );if (!request)return -ENOMEM ;
Signature · 1 line
1.8.4.3
Re: [RFT 2/2] cfg80211: make regulatory_hint() remove REGULATORY_CUSTOM_REG
net/wireless/reg.c int regulatory_hint(struct wiphy *wiphy, const char *alpha2) · line 1830
Quoted 6 lines
net/wireless/reg.c +2
-0@@ -1826,6 +1826,8 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2)if (WARN_ON (!alpha2 || !wiphy))return -EINVAL ; + wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG ; +
Clear REGULATORY_CUSTOM_REG
Signature · 1 line
~Mihir~
Re: [RFT 2/2] cfg80211: make regulatory_hint() remove REGULATORY_CUSTOM_REG
Quoted 7 lines · Mihir Shete
net/wireless/reg.c int regulatory_hint(struct wiphy *wiphy, const char *alpha2) · line 1830
Quoted 6 lines
net/wireless/reg.c +2
-0@@ -1826,6 +1826,8 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2)if (WARN_ON (!alpha2 || !wiphy))return -EINVAL ; + wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG ; +Clear
REGULATORY_CUSTOM_REG
Thanks, yes, did you test it?
Luis