2010-04-07 06:00:48

by Teemu Paasikivi

[permalink] [raw]
Subject: [PATCH v2] mac80211: check whether scan is in progress before queueing scan_work

As scan_work is queued from work_work it needs to be checked if scan
has been started during execution of work_work. Otherwise, when hw
scan is used, the stack gets error about hw being busy with ongoing
scan. This causes the stack to abort scan without notifying the driver
about it. This leads to a situation where the hw is scanning and the stack
thinks it's not. Then when the scan finishes, the stack will complain by
warnings.

Signed-off-by: Teemu Paasikivi <[email protected]>
---
net/mac80211/work.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/work.c b/net/mac80211/work.c
index 1e1ea30..5df48a9 100644
--- a/net/mac80211/work.c
+++ b/net/mac80211/work.c
@@ -919,12 +919,17 @@ static void ieee80211_work_work(struct work_struct *work)
run_again(local, jiffies + HZ/2);
}

- if (list_empty(&local->work_list) && local->scan_req)
+ mutex_unlock(&local->work_mtx);
+
+ mutex_lock(&local->scan_mtx);
+
+ if (list_empty(&local->work_list) && local->scan_req &&
+ !local->scanning)
ieee80211_queue_delayed_work(&local->hw,
&local->scan_work,
round_jiffies_relative(0));

- mutex_unlock(&local->work_mtx);
+ mutex_unlock(&local->scan_mtx);

ieee80211_recalc_idle(local);

--
1.5.6.3



2010-04-07 06:30:04

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH v2] mac80211: check whether scan is in progress before queueing scan_work

On Wed, 2010-04-07 at 08:56 +0300, Teemu Paasikivi wrote:
> As scan_work is queued from work_work it needs to be checked if scan
> has been started during execution of work_work. Otherwise, when hw
> scan is used, the stack gets error about hw being busy with ongoing
> scan. This causes the stack to abort scan without notifying the driver
> about it. This leads to a situation where the hw is scanning and the stack
> thinks it's not. Then when the scan finishes, the stack will complain by
> warnings.
>
> Signed-off-by: Teemu Paasikivi <[email protected]>
> ---
> net/mac80211/work.c | 9 +++++++--
> 1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/net/mac80211/work.c b/net/mac80211/work.c
> index 1e1ea30..5df48a9 100644
> --- a/net/mac80211/work.c
> +++ b/net/mac80211/work.c
> @@ -919,12 +919,17 @@ static void ieee80211_work_work(struct work_struct *work)
> run_again(local, jiffies + HZ/2);
> }
>
> - if (list_empty(&local->work_list) && local->scan_req)
> + mutex_unlock(&local->work_mtx);
> +
> + mutex_lock(&local->scan_mtx);
> +
> + if (list_empty(&local->work_list) && local->scan_req &&
> + !local->scanning)
> ieee80211_queue_delayed_work(&local->hw,
> &local->scan_work,
> round_jiffies_relative(0));
>
> - mutex_unlock(&local->work_mtx);
> + mutex_unlock(&local->scan_mtx);

But should we touch work_list w/o holding work_mtx?

johannes