* [PATCH 2/6] mac80211: merge ieee80211_scan_work() common code
2010-10-01 12:05 [PATCH 1/6] mac80211: perform scan cancel in hw reset work Stanislaw Gruszka
@ 2010-10-01 12:05 ` Stanislaw Gruszka
2010-10-04 13:02 ` Johannes Berg
2010-10-04 13:07 ` Johannes Berg
2010-10-01 12:05 ` [PATCH 3/6] mac80211: keep lock when calling __ieee80211_scan_completed() Stanislaw Gruszka
` (4 subsequent siblings)
5 siblings, 2 replies; 15+ messages in thread
From: Stanislaw Gruszka @ 2010-10-01 12:05 UTC (permalink / raw)
To: Johannes Berg, Wey-Yi Guy
Cc: John W. Linville, linux-wireless, Stanislaw Gruszka
Merge common code using goto instruction. Except less LOC, one of
the benefit is decrease number of places where function
ieee80211_scan_completed() is called.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
net/mac80211/scan.c | 40 ++++++++++++++++++----------------------
1 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 57b5e66..e9ab896 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -652,53 +652,43 @@ void ieee80211_scan_work(struct work_struct *work)
container_of(work, struct ieee80211_local, scan_work.work);
struct ieee80211_sub_if_data *sdata = local->scan_sdata;
unsigned long next_delay = 0;
+ int rc = 1;
+ bool aborted = true;
- if (test_and_clear_bit(SCAN_COMPLETED, &local->scanning)) {
- bool aborted;
+ mutex_lock(&local->mtx);
+ if (test_and_clear_bit(SCAN_COMPLETED, &local->scanning)) {
aborted = test_and_clear_bit(SCAN_ABORTED, &local->scanning);
- __ieee80211_scan_completed(&local->hw, aborted);
- return;
+ goto out_complete;
}
- mutex_lock(&local->mtx);
if (!sdata || !local->scan_req) {
mutex_unlock(&local->mtx);
return;
}
if (local->hw_scan_req) {
- int rc = drv_hw_scan(local, sdata, local->hw_scan_req);
- mutex_unlock(&local->mtx);
- if (rc)
- __ieee80211_scan_completed(&local->hw, true);
- return;
+ rc = drv_hw_scan(local, sdata, local->hw_scan_req);
+ goto out_complete;
}
if (local->scan_req && !local->scanning) {
struct cfg80211_scan_request *req = local->scan_req;
- int rc;
local->scan_req = NULL;
local->scan_sdata = NULL;
rc = __ieee80211_start_scan(sdata, req);
- mutex_unlock(&local->mtx);
-
- if (rc)
- __ieee80211_scan_completed(&local->hw, true);
- return;
+ goto out_complete;
}
- mutex_unlock(&local->mtx);
-
/*
* Avoid re-scheduling when the sdata is going away.
*/
- if (!ieee80211_sdata_running(sdata)) {
- __ieee80211_scan_completed(&local->hw, true);
- return;
- }
+ if (!ieee80211_sdata_running(sdata))
+ goto out_complete;
+
+ mutex_unlock(&local->mtx);
/*
* as long as no delay is required advance immediately
@@ -726,6 +716,12 @@ void ieee80211_scan_work(struct work_struct *work)
} while (next_delay == 0);
ieee80211_queue_delayed_work(&local->hw, &local->scan_work, next_delay);
+ return;
+
+out_complete:
+ mutex_unlock(&local->mtx);
+ if (rc)
+ __ieee80211_scan_completed(&local->hw, true);
}
int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
--
1.7.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 2/6] mac80211: merge ieee80211_scan_work() common code
2010-10-01 12:05 ` [PATCH 2/6] mac80211: merge ieee80211_scan_work() common code Stanislaw Gruszka
@ 2010-10-04 13:02 ` Johannes Berg
2010-10-04 13:07 ` Johannes Berg
1 sibling, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2010-10-04 13:02 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Wey-Yi Guy, John W. Linville, linux-wireless
On Fri, 2010-10-01 at 14:05 +0200, Stanislaw Gruszka wrote:
> Merge common code using goto instruction. Except less LOC, one of
> the benefit is decrease number of places where function
> ieee80211_scan_completed() is called.
> + int rc = 1;
This shouldn't be necessary, and will only serve to hide warnings if
somebody rearranges this code in the future.
> + bool aborted = true;
I'd prefer also not initialising this here and putting the = true into
all the few places that need it so that we get warnings for new places
that jump to the completed w/o properly setting aborted.
johannes
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/6] mac80211: merge ieee80211_scan_work() common code
2010-10-01 12:05 ` [PATCH 2/6] mac80211: merge ieee80211_scan_work() common code Stanislaw Gruszka
2010-10-04 13:02 ` Johannes Berg
@ 2010-10-04 13:07 ` Johannes Berg
1 sibling, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2010-10-04 13:07 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Wey-Yi Guy, John W. Linville, linux-wireless
On Fri, 2010-10-01 at 14:05 +0200, Stanislaw Gruszka wrote:
> +out_complete:
> + mutex_unlock(&local->mtx);
> + if (rc)
> + __ieee80211_scan_completed(&local->hw, true);
That must be aborted, not "true".
Also, I just noticed that together with the other patch this gets quite
confusing with the "if (rc)" logic. I think
out_complete:
mutex_unlock
completed()
return;
out:
mutex_unlock()
}
would ultimately be easier to understand.
johannes
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/6] mac80211: keep lock when calling __ieee80211_scan_completed()
2010-10-01 12:05 [PATCH 1/6] mac80211: perform scan cancel in hw reset work Stanislaw Gruszka
2010-10-01 12:05 ` [PATCH 2/6] mac80211: merge ieee80211_scan_work() common code Stanislaw Gruszka
@ 2010-10-01 12:05 ` Stanislaw Gruszka
2010-10-04 13:09 ` Johannes Berg
2010-10-01 12:05 ` [PATCH 4/6] mac80211: assure we also cancel deferred scan request Stanislaw Gruszka
` (3 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Stanislaw Gruszka @ 2010-10-01 12:05 UTC (permalink / raw)
To: Johannes Berg, Wey-Yi Guy
Cc: John W. Linville, linux-wireless, Stanislaw Gruszka
We are taking local->mtx inside __ieee80211_scan_completed(), but just
before call to that function we drop the lock. Dropping/taking lock is not
good, because can lead to hard to understand race conditions.
Patch split scan_completed() code into two functions, first must be called
with local->mtx taken and second without it.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
net/mac80211/scan.c | 85 +++++++++++++++++++++++++++------------------------
1 files changed, 45 insertions(+), 40 deletions(-)
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index e9ab896..44deb05 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -250,12 +250,12 @@ static bool ieee80211_prep_hw_scan(struct ieee80211_local *local)
return true;
}
-static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
+static bool __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted,
+ bool was_hw_scan)
{
struct ieee80211_local *local = hw_to_local(hw);
- bool was_hw_scan;
- mutex_lock(&local->mtx);
+ lockdep_assert_held(&local->mtx);
/*
* It's ok to abort a not-yet-running scan (that
@@ -266,17 +266,13 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
if (WARN_ON(!local->scanning && !aborted))
aborted = true;
- if (WARN_ON(!local->scan_req)) {
- mutex_unlock(&local->mtx);
- return;
- }
+ if (WARN_ON(!local->scan_req))
+ return false;
- was_hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
if (was_hw_scan && !aborted && ieee80211_prep_hw_scan(local)) {
ieee80211_queue_delayed_work(&local->hw,
&local->scan_work, 0);
- mutex_unlock(&local->mtx);
- return;
+ return false;
}
kfree(local->hw_scan_req);
@@ -290,23 +286,25 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
local->scanning = 0;
local->scan_channel = NULL;
- /* we only have to protect scan_req and hw/sw scan */
- mutex_unlock(&local->mtx);
-
- ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
- if (was_hw_scan)
- goto done;
-
- ieee80211_configure_filter(local);
+ return true;
+}
- drv_sw_scan_complete(local);
+static void __ieee80211_scan_completed_finish(struct ieee80211_hw *hw,
+ bool was_hw_scan)
+{
+ struct ieee80211_local *local = hw_to_local(hw);
- ieee80211_offchannel_return(local, true);
+ ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
+ if (!was_hw_scan) {
+ ieee80211_configure_filter(local);
+ drv_sw_scan_complete(local);
+ ieee80211_offchannel_return(local, true);
+ }
- done:
mutex_lock(&local->mtx);
ieee80211_recalc_idle(local);
mutex_unlock(&local->mtx);
+
ieee80211_mlme_notify_scan_completed(local);
ieee80211_ibss_notify_scan_completed(local);
ieee80211_mesh_notify_scan_completed(local);
@@ -367,6 +365,8 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
struct ieee80211_local *local = sdata->local;
int rc;
+ lockdep_assert_held(&local->mtx);
+
if (local->scan_req)
return -EBUSY;
@@ -432,7 +432,6 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
local->scan_req = NULL;
local->scan_sdata = NULL;
}
-
return rc;
}
@@ -448,8 +447,8 @@ ieee80211_scan_get_channel_time(struct ieee80211_channel *chan)
return IEEE80211_PROBE_DELAY + IEEE80211_CHANNEL_TIME;
}
-static int ieee80211_scan_state_decision(struct ieee80211_local *local,
- unsigned long *next_delay)
+static void ieee80211_scan_state_decision(struct ieee80211_local *local,
+ unsigned long *next_delay)
{
bool associated = false;
bool tx_empty = true;
@@ -459,12 +458,6 @@ static int ieee80211_scan_state_decision(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata;
struct ieee80211_channel *next_chan;
- /* if no more bands/channels left, complete scan and advance to the idle state */
- if (local->scan_channel_idx >= local->scan_req->n_channels) {
- __ieee80211_scan_completed(&local->hw, false);
- return 1;
- }
-
/*
* check if at least one STA interface is associated,
* check if at least one STA interface has pending tx frames
@@ -536,7 +529,6 @@ static int ieee80211_scan_state_decision(struct ieee80211_local *local,
}
*next_delay = 0;
- return 0;
}
static void ieee80211_scan_state_leave_oper_channel(struct ieee80211_local *local,
@@ -654,6 +646,7 @@ void ieee80211_scan_work(struct work_struct *work)
unsigned long next_delay = 0;
int rc = 1;
bool aborted = true;
+ bool finish, hw_scan;
mutex_lock(&local->mtx);
@@ -697,8 +690,12 @@ void ieee80211_scan_work(struct work_struct *work)
do {
switch (local->next_scan_state) {
case SCAN_DECISION:
- if (ieee80211_scan_state_decision(local, &next_delay))
- return;
+ /* if no more bands/channels left, complete scan */
+ if (local->scan_channel_idx >= local->scan_req->n_channels) {
+ aborted = false;
+ goto out_complete;
+ }
+ ieee80211_scan_state_decision(local, &next_delay);
break;
case SCAN_SET_CHANNEL:
ieee80211_scan_state_set_channel(local, &next_delay);
@@ -719,9 +716,16 @@ void ieee80211_scan_work(struct work_struct *work)
return;
out_complete:
+ finish = false;
+ if (rc) {
+ hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
+ finish = __ieee80211_scan_completed(&local->hw, aborted, hw_scan);
+ }
+
mutex_unlock(&local->mtx);
- if (rc)
- __ieee80211_scan_completed(&local->hw, true);
+
+ if (finish)
+ __ieee80211_scan_completed_finish(&local->hw, hw_scan);
}
int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
@@ -785,7 +789,7 @@ int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata,
void ieee80211_scan_cancel(struct ieee80211_local *local)
{
- bool abortscan;
+ bool finish = false;
cancel_delayed_work_sync(&local->scan_work);
@@ -794,10 +798,11 @@ void ieee80211_scan_cancel(struct ieee80211_local *local)
* queued -- mostly at suspend under RTNL.
*/
mutex_lock(&local->mtx);
- abortscan = test_bit(SCAN_SW_SCANNING, &local->scanning) ||
- (!local->scanning && local->scan_req);
+ if (test_bit(SCAN_SW_SCANNING, &local->scanning) ||
+ (!local->scanning && local->scan_req))
+ finish = __ieee80211_scan_completed(&local->hw, true, false);
mutex_unlock(&local->mtx);
- if (abortscan)
- __ieee80211_scan_completed(&local->hw, true);
+ if (finish)
+ __ieee80211_scan_completed_finish(&local->hw, false);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 3/6] mac80211: keep lock when calling __ieee80211_scan_completed()
2010-10-01 12:05 ` [PATCH 3/6] mac80211: keep lock when calling __ieee80211_scan_completed() Stanislaw Gruszka
@ 2010-10-04 13:09 ` Johannes Berg
2010-10-04 14:52 ` Stanislaw Gruszka
0 siblings, 1 reply; 15+ messages in thread
From: Johannes Berg @ 2010-10-04 13:09 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Wey-Yi Guy, John W. Linville, linux-wireless
On Fri, 2010-10-01 at 14:05 +0200, Stanislaw Gruszka wrote:
> out_complete:
> + finish = false;
> + if (rc) {
> + hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
> + finish = __ieee80211_scan_completed(&local->hw, aborted, hw_scan);
> + }
> +
> mutex_unlock(&local->mtx);
> - if (rc)
> - __ieee80211_scan_completed(&local->hw, true);
> +
> + if (finish)
> + __ieee80211_scan_completed_finish(&local->hw, hw_scan);
> }
And this makes the logic here even more confusing :-)
johannes
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 3/6] mac80211: keep lock when calling __ieee80211_scan_completed()
2010-10-04 13:09 ` Johannes Berg
@ 2010-10-04 14:52 ` Stanislaw Gruszka
0 siblings, 0 replies; 15+ messages in thread
From: Stanislaw Gruszka @ 2010-10-04 14:52 UTC (permalink / raw)
To: Johannes Berg; +Cc: Wey-Yi Guy, John W. Linville, linux-wireless
On Mon, Oct 04, 2010 at 03:09:06PM +0200, Johannes Berg wrote:
> On Fri, 2010-10-01 at 14:05 +0200, Stanislaw Gruszka wrote:
>
> > out_complete:
> > + finish = false;
> > + if (rc) {
> > + hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
> > + finish = __ieee80211_scan_completed(&local->hw, aborted, hw_scan);
> > + }
> > +
> > mutex_unlock(&local->mtx);
> > - if (rc)
> > - __ieee80211_scan_completed(&local->hw, true);
> > +
> > + if (finish)
> > + __ieee80211_scan_completed_finish(&local->hw, hw_scan);
> > }
>
> And this makes the logic here even more confusing :-)
I'll try to rewrite that more clean.
Stanislaw
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 4/6] mac80211: assure we also cancel deferred scan request
2010-10-01 12:05 [PATCH 1/6] mac80211: perform scan cancel in hw reset work Stanislaw Gruszka
2010-10-01 12:05 ` [PATCH 2/6] mac80211: merge ieee80211_scan_work() common code Stanislaw Gruszka
2010-10-01 12:05 ` [PATCH 3/6] mac80211: keep lock when calling __ieee80211_scan_completed() Stanislaw Gruszka
@ 2010-10-01 12:05 ` Stanislaw Gruszka
2010-10-04 13:11 ` Johannes Berg
2010-10-01 12:05 ` [PATCH 5/6] mac80211: do not requeue scan work when not needed Stanislaw Gruszka
` (2 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Stanislaw Gruszka @ 2010-10-01 12:05 UTC (permalink / raw)
To: Johannes Berg, Wey-Yi Guy
Cc: John W. Linville, linux-wireless, Stanislaw Gruszka
When cfg80211 request the scan and mac80211 perform some management work,
we defer the scan request. We do not canceling such requests when calling
ieee80211_scan_cancel(), because of SCAN_SW_SCANNING bit check just
before the call. So fix that problem. Keeping local->mtx lock assures
that the deferred scan will not become "working" HW scan.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
net/mac80211/main.c | 3 +--
net/mac80211/pm.c | 3 +--
net/mac80211/scan.c | 2 +-
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 494dba1..8ba09ff 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -304,8 +304,7 @@ static void ieee80211_restart_work(struct work_struct *work)
mutex_unlock(&local->mtx);
rtnl_lock();
- if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)))
- ieee80211_scan_cancel(local);
+ ieee80211_scan_cancel(local);
ieee80211_reconfig(local);
rtnl_unlock();
}
diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
index ce671df..d287fde 100644
--- a/net/mac80211/pm.c
+++ b/net/mac80211/pm.c
@@ -12,8 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
struct ieee80211_sub_if_data *sdata;
struct sta_info *sta;
- if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)))
- ieee80211_scan_cancel(local);
+ ieee80211_scan_cancel(local);
ieee80211_stop_queues_by_reason(hw,
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 44deb05..2e9a70c 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -799,7 +799,7 @@ void ieee80211_scan_cancel(struct ieee80211_local *local)
*/
mutex_lock(&local->mtx);
if (test_bit(SCAN_SW_SCANNING, &local->scanning) ||
- (!local->scanning && local->scan_req))
+ (!test_bit(SCAN_HW_SCANNING, &local->scanning) && local->scan_req))
finish = __ieee80211_scan_completed(&local->hw, true, false);
mutex_unlock(&local->mtx);
--
1.7.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 4/6] mac80211: assure we also cancel deferred scan request
2010-10-01 12:05 ` [PATCH 4/6] mac80211: assure we also cancel deferred scan request Stanislaw Gruszka
@ 2010-10-04 13:11 ` Johannes Berg
2010-10-04 15:17 ` Stanislaw Gruszka
0 siblings, 1 reply; 15+ messages in thread
From: Johannes Berg @ 2010-10-04 13:11 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Wey-Yi Guy, John W. Linville, linux-wireless
On Fri, 2010-10-01 at 14:05 +0200, Stanislaw Gruszka wrote:
> When cfg80211 request the scan and mac80211 perform some management work,
> we defer the scan request. We do not canceling such requests when calling
> ieee80211_scan_cancel(), because of SCAN_SW_SCANNING bit check just
> before the call. So fix that problem. Keeping local->mtx lock assures
> that the deferred scan will not become "working" HW scan.
But don't we also delay it becoming a working scan while we have work
pending? Which seems OK?
Also what's with all the other changes here, they don't seem related to
this?
johannes
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 4/6] mac80211: assure we also cancel deferred scan request
2010-10-04 13:11 ` Johannes Berg
@ 2010-10-04 15:17 ` Stanislaw Gruszka
0 siblings, 0 replies; 15+ messages in thread
From: Stanislaw Gruszka @ 2010-10-04 15:17 UTC (permalink / raw)
To: Johannes Berg; +Cc: Wey-Yi Guy, John W. Linville, linux-wireless
On Mon, Oct 04, 2010 at 03:11:01PM +0200, Johannes Berg wrote:
> On Fri, 2010-10-01 at 14:05 +0200, Stanislaw Gruszka wrote:
> > When cfg80211 request the scan and mac80211 perform some management work,
> > we defer the scan request. We do not canceling such requests when calling
> > ieee80211_scan_cancel(), because of SCAN_SW_SCANNING bit check just
> > before the call. So fix that problem. Keeping local->mtx lock assures
> > that the deferred scan will not become "working" HW scan.
>
> But don't we also delay it becoming a working scan while we have work
> pending? Which seems OK?
Yes, you have right, we cancel the scan_work before that, so transition
will not happen.
> Also what's with all the other changes here, they don't seem related to
> this?
This change
mutex_lock(&local->mtx);
if (test_bit(SCAN_SW_SCANNING, &local->scanning) ||
- (!local->scanning && local->scan_req))
+ (!test_bit(SCAN_HW_SCANNING, &local->scanning) && local->scan_req))
finish = __ieee80211_scan_completed(&local->hw, true, false);
mutex_unlock(&local->mtx);
is for ignore local->scanning bits, in case we have some bits set up but no
hw scanning is pending. Not sure If this fix some real problem, but
make things safer IMHO.
We have to think here about hw, sw and deferred scan. Canceling scan_work
seems to wrong for hw_scan, but we still have to remember about sw scan and
deferred scan ... I will try to rewrite patch to cope with all cases.
Stanislaw
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 5/6] mac80211: do not requeue scan work when not needed
2010-10-01 12:05 [PATCH 1/6] mac80211: perform scan cancel in hw reset work Stanislaw Gruszka
` (2 preceding siblings ...)
2010-10-01 12:05 ` [PATCH 4/6] mac80211: assure we also cancel deferred scan request Stanislaw Gruszka
@ 2010-10-01 12:05 ` Stanislaw Gruszka
2010-10-01 12:05 ` [PATCH 6/6] Revert "iwlwifi: do not perferm force reset while doing scan" Stanislaw Gruszka
2010-10-01 16:11 ` [PATCH 1/6] mac80211: perform scan cancel in hw reset work Johannes Berg
5 siblings, 0 replies; 15+ messages in thread
From: Stanislaw Gruszka @ 2010-10-01 12:05 UTC (permalink / raw)
To: Johannes Berg, Wey-Yi Guy
Cc: John W. Linville, linux-wireless, Stanislaw Gruszka
In case of performing hw scan and not abort it
__ieee80211_scan_completed() is currently called from scan work, so does
not need to reschedule work to call drv_hw_scan().
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
net/mac80211/scan.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 2e9a70c..cf60f20 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -270,9 +270,9 @@ static bool __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted,
return false;
if (was_hw_scan && !aborted && ieee80211_prep_hw_scan(local)) {
- ieee80211_queue_delayed_work(&local->hw,
- &local->scan_work, 0);
- return false;
+ int rc = drv_hw_scan(local, local->scan_sdata, local->hw_scan_req);
+ if (rc == 0)
+ return false;
}
kfree(local->hw_scan_req);
@@ -660,11 +660,6 @@ void ieee80211_scan_work(struct work_struct *work)
return;
}
- if (local->hw_scan_req) {
- rc = drv_hw_scan(local, sdata, local->hw_scan_req);
- goto out_complete;
- }
-
if (local->scan_req && !local->scanning) {
struct cfg80211_scan_request *req = local->scan_req;
--
1.7.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 6/6] Revert "iwlwifi: do not perferm force reset while doing scan"
2010-10-01 12:05 [PATCH 1/6] mac80211: perform scan cancel in hw reset work Stanislaw Gruszka
` (3 preceding siblings ...)
2010-10-01 12:05 ` [PATCH 5/6] mac80211: do not requeue scan work when not needed Stanislaw Gruszka
@ 2010-10-01 12:05 ` Stanislaw Gruszka
2010-10-01 16:11 ` [PATCH 1/6] mac80211: perform scan cancel in hw reset work Johannes Berg
5 siblings, 0 replies; 15+ messages in thread
From: Stanislaw Gruszka @ 2010-10-01 12:05 UTC (permalink / raw)
To: Johannes Berg, Wey-Yi Guy
Cc: John W. Linville, linux-wireless, Stanislaw Gruszka
This reverts commit 7acc7c683a747689aaaaad4fce1683fc3f85e552. It was
applied to avoid possible warning in ieee80211_restart_hw, however
reason of the warning were races in mac80211, currently hopefully fixed.
Not reseting device when performing scan is bad for two reasons.
When forcing reset from iwl_check_stuck_queue(), in case of fail,
reset will be repeated until scan finish. But since firmware is in bad
shape, scan only finish after scan_check work (about 7s). So we will
delay the reset, what is not good behaviour.
When forcing reset from iwl_recover_from_statistics(), we will not
repeat the reset, so we will not perform reset at all when needed.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/iwlwifi/iwl-core.c | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 5c56893..393f02d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -2736,11 +2736,6 @@ int iwl_force_reset(struct iwl_priv *priv, int mode, bool external)
if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return -EINVAL;
- if (test_bit(STATUS_SCANNING, &priv->status)) {
- IWL_DEBUG_INFO(priv, "scan in progress.\n");
- return -EINVAL;
- }
-
if (mode >= IWL_MAX_FORCE_RESET) {
IWL_DEBUG_INFO(priv, "invalid reset request.\n");
return -EINVAL;
--
1.7.1
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 1/6] mac80211: perform scan cancel in hw reset work
2010-10-01 12:05 [PATCH 1/6] mac80211: perform scan cancel in hw reset work Stanislaw Gruszka
` (4 preceding siblings ...)
2010-10-01 12:05 ` [PATCH 6/6] Revert "iwlwifi: do not perferm force reset while doing scan" Stanislaw Gruszka
@ 2010-10-01 16:11 ` Johannes Berg
2010-10-01 17:20 ` Luis R. Rodriguez
5 siblings, 1 reply; 15+ messages in thread
From: Johannes Berg @ 2010-10-01 16:11 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Wey-Yi Guy, John W. Linville, linux-wireless
On Fri, 2010-10-01 at 14:05 +0200, Stanislaw Gruszka wrote:
> Move ieee80211_scan_cancel() and all other related code to
> ieee80211_restart_work() as ieee80211_restart_hw() is intended to be
> callable from any context.
>
> Fix a bug that RTNL lock is not taken during ieee80211_cancel_scan().
>
> Take local->mtx before WARN(test_bit(SCAN_HW_SCANNING, &local->scanning)
> to prevent the race condition with __ieee80211_start_scan() described
> here: http://marc.info/?l=linux-wireless&m=128516716810537&w=2
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
This one's obvious -- the other ones I need a bit of time to review, and
it's practically weekend here now. I'll try to get to it ASAP.
johannes
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 1/6] mac80211: perform scan cancel in hw reset work
2010-10-01 16:11 ` [PATCH 1/6] mac80211: perform scan cancel in hw reset work Johannes Berg
@ 2010-10-01 17:20 ` Luis R. Rodriguez
2010-10-05 9:25 ` Stanislaw Gruszka
0 siblings, 1 reply; 15+ messages in thread
From: Luis R. Rodriguez @ 2010-10-01 17:20 UTC (permalink / raw)
To: Johannes Berg
Cc: Stanislaw Gruszka, Wey-Yi Guy, John W. Linville, linux-wireless
On Fri, Oct 1, 2010 at 9:11 AM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Fri, 2010-10-01 at 14:05 +0200, Stanislaw Gruszka wrote:
>> Move ieee80211_scan_cancel() and all other related code to
>> ieee80211_restart_work() as ieee80211_restart_hw() is intended to be
>> callable from any context.
>>
>> Fix a bug that RTNL lock is not taken during ieee80211_cancel_scan().
>>
>> Take local->mtx before WARN(test_bit(SCAN_HW_SCANNING, &local->scanning)
>> to prevent the race condition with __ieee80211_start_scan() described
>> here: http://marc.info/?l=linux-wireless&m=128516716810537&w=2
>>
>> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
>
> This one's obvious -- the other ones I need a bit of time to review, and
> it's practically weekend here now. I'll try to get to it ASAP.
I'm going to suck this into linux-next-pending/ on compat-wireless for
today's release as it may fix a deadlock with carl9170.
Luis
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/6] mac80211: perform scan cancel in hw reset work
2010-10-01 17:20 ` Luis R. Rodriguez
@ 2010-10-05 9:25 ` Stanislaw Gruszka
0 siblings, 0 replies; 15+ messages in thread
From: Stanislaw Gruszka @ 2010-10-05 9:25 UTC (permalink / raw)
To: John W. Linville
Cc: Johannes Berg, Wey-Yi Guy, linux-wireless, Luis R. Rodriguez
On Fri, Oct 01, 2010 at 10:20:08AM -0700, Luis R. Rodriguez wrote:
> > This one's obvious -- the other ones I need a bit of time to review, and
> > it's practically weekend here now. I'll try to get to it ASAP.
>
> I'm going to suck this into linux-next-pending/ on compat-wireless for
> today's release as it may fix a deadlock with carl9170.
John,
Since this patch is obvious and fix real bugs please apply it. Other
patches in the series need more work, I will repost them without this
one.
Stanislaw
^ permalink raw reply [flat|nested] 15+ messages in thread