diff mbox

[2/2] cfg80211: fix processing world regdomain when non modular

Message ID 1398137975-14275-3-git-send-email-mcgrof@do-not-panic.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Luis R. Rodriguez April 22, 2014, 3:39 a.m. UTC
From: "Luis R. Rodriguez" <mcgrof@suse.com>

This allows processing of the last regulatory request when
we determine its still pending. Without this if a regulatory
request failed to get processed by userspace we wouldn't
be able to re-process it later. An example situation that can
lead to an unprocessed last_request is enabling cfg80211 to
be built-in to the kernel, not enabling CFG80211_INTERNAL_REGDB
and the CRDA binary not being available at the time the udev
rule that kicks of CRDA triggers.

In such a situation we want to let some cfg80211 triggers
eventually kick CRDA for us again. Without this if the first
cycle attempt to kick off CRDA failed we'd be stuck without
the ability to change process any further regulatory domains.

cfg80211 will trigger re-processing of the regulatory queue
whenever schedule_work(&reg_work) is called, currently this
happens when:

  * suspend / resume
  * disconnect
  * a beacon hint gets triggered (non DFS 5 GHz AP found)
  * a regulatory request gets added to the queue

We don't have any specific opportunistic late boot triggers
to address a late mount of where CRDA resides though, adding
that should be done separately through another patch.
Without an opportunistic fix then this fix relies at least
one of the triggeres above to happen.

Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 net/wireless/reg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Johannes Berg April 22, 2014, 3:18 p.m. UTC | #1
Applied, I hope it won't blow up again :)

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sander Eikelenboom April 22, 2014, 3:37 p.m. UTC | #2
Tuesday, April 22, 2014, 5:18:19 PM, you wrote:

> Applied, I hope it won't blow up again :)

> johannes

At least there is some time left this time around ;-)
Will retest tomorrow to at least verify that it indeed also fixes something !

Thanks!

--
Sander

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luis R. Rodriguez April 22, 2014, 4:44 p.m. UTC | #3
On Tue, Apr 22, 2014 at 8:37 AM, Sander Eikelenboom
<linux@eikelenboom.it> wrote:
>
> Tuesday, April 22, 2014, 5:18:19 PM, you wrote:
>
>> Applied, I hope it won't blow up again :)
>
>> johannes
>
> At least there is some time left this time around ;-)
> Will retest tomorrow to at least verify that it indeed also fixes something !

FWIW you had already tested the second patch which had solved your
issue, the first patch is an enhancement fix that addresses two
regressions introduced by enabling reprocessing of the last request
which as Arik found was caused by treating free'ing a new request (or
reprocessing after my patch) being processed as a last request. One
aspect of the full series I had originally sent out is still not
merged and that is the last patch which added opportunistic triggers
to check the regulatory queue after bootup. That was rejected based on
an architectural design to compartmentalize regulatory and while I
could argue with it, over time I think Johannes is right and will send
out a follow up patch with a timer for it eventually. The other
triggers for hitting the queue can be manual (userspace iw reg set) or
beacon hints on 5 GHz channels (most folks will have this) my goal was
to automate something to kick it after boot up.

  Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Helmut Schaa Sept. 2, 2014, noon UTC | #4
Hi Luis,

On Tue, Apr 22, 2014 at 5:39 AM, Luis R. Rodriguez
<mcgrof@do-not-panic.com> wrote:
> From: "Luis R. Rodriguez" <mcgrof@suse.com>
>
> This allows processing of the last regulatory request when
> we determine its still pending. Without this if a regulatory
> request failed to get processed by userspace we wouldn't
> be able to re-process it later. An example situation that can
> lead to an unprocessed last_request is enabling cfg80211 to
> be built-in to the kernel, not enabling CFG80211_INTERNAL_REGDB
> and the CRDA binary not being available at the time the udev
> rule that kicks of CRDA triggers.
>
> In such a situation we want to let some cfg80211 triggers
> eventually kick CRDA for us again. Without this if the first
> cycle attempt to kick off CRDA failed we'd be stuck without
> the ability to change process any further regulatory domains.
>
> cfg80211 will trigger re-processing of the regulatory queue
> whenever schedule_work(&reg_work) is called, currently this
> happens when:
>
>   * suspend / resume
>   * disconnect
>   * a beacon hint gets triggered (non DFS 5 GHz AP found)
>   * a regulatory request gets added to the queue
>
> We don't have any specific opportunistic late boot triggers
> to address a late mount of where CRDA resides though, adding
> that should be done separately through another patch.
> Without an opportunistic fix then this fix relies at least
> one of the triggeres above to happen.
>
> Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
> Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
> ---
>  net/wireless/reg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/wireless/reg.c b/net/wireless/reg.c
> index 081c571..625c41e 100644
> --- a/net/wireless/reg.c
> +++ b/net/wireless/reg.c
> @@ -1912,7 +1912,7 @@ static void reg_process_pending_hints(void)
>
>         /* When last_request->processed becomes true this will be rescheduled */
>         if (lr && !lr->processed) {
> -               REG_DBG_PRINT("Pending regulatory request, waiting for it to be processed...\n");
> +               reg_process_hint(lr);
>                 return;
>         }
>

This change created a race in my setup (ar9344 based AP with two ath9k devices):
Sometimes during boot the following happens:

...
[    6.190000] ath: Country alpha2 being used: US
...
[    6.210000] ath: Country alpha2 being used: US
...
[    6.240000] cfg80211: Calling CRDA for country: US
[    6.240000] cfg80211: Calling CRDA for country: US
[    6.240000] cfg80211: Current regulatory domain intersected:
[    6.240000] cfg80211:  DFS Master region: unset
[    6.240000] cfg80211:   (start_freq - end_freq @ bandwidth),
(max_antenna_gain, max_eirp), (dfs_cac_time)
[    6.240000] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz),
(N/A, 2000 mBm), (N/A)
[    6.240000] cfg80211:   (2457000 KHz - 2472000 KHz @ 15000 KHz),
(N/A, 2000 mBm), (N/A)
[    6.240000] cfg80211:   (5170000 KHz - 5250000 KHz @ 80000 KHz),
(N/A, 1700 mBm), (N/A)
[    6.240000] cfg80211:   (5250000 KHz - 5330000 KHz @ 80000 KHz),
(N/A, 2000 mBm), (0 s)
[    6.240000] cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz),
(N/A, 2000 mBm), (N/A)
[    6.240000] cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000
KHz), (N/A, 0 mBm), (N/A)
...

CRDA (or in my case the internal regdb) is called twice for country
code US by two different devices.
In this case the second request came in before the first one was
completely processed and the first
request will be re-processed (due to this patch) leading to an
intersected regdomain (US with US :) ).

Reverting this patch fixes this race for me but I think you had some
good reasons to do this patch.

Any ideas?

Thanks,
Helmut
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 081c571..625c41e 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1912,7 +1912,7 @@  static void reg_process_pending_hints(void)
 
 	/* When last_request->processed becomes true this will be rescheduled */
 	if (lr && !lr->processed) {
-		REG_DBG_PRINT("Pending regulatory request, waiting for it to be processed...\n");
+		reg_process_hint(lr);
 		return;
 	}