linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac80211: fix configure_filter invocation after stop
@ 2009-08-20 17:46 Johannes Berg
  2009-08-20 18:02 ` [PATCH v2] " Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2009-08-20 17:46 UTC (permalink / raw)
  To: John Linville; +Cc: Lennert Buytenhek, linux-wireless

Since configure_filter can sleep now, any multicast
configuration needed to be postponed to a work struct.
This, however, lead to a problem that we could queue
the work, stop the device and then afterwards invoke
configure_filter which may lead to driver hangs and is
a bug. To fix this, we can just cancel the filter work
since it's unnecessary to do after stopping the hw.

Since there are various places that call drv_stop, and
two of them do very similar things, the code for them
can be put into a shared function at the same time.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reported-by: Lennert Buytenhek <buytenh@wantstofly.org>
---
 net/mac80211/ieee80211_i.h |    1 +
 net/mac80211/iface.c       |    6 +-----
 net/mac80211/pm.c          |   11 +----------
 net/mac80211/util.c        |   10 ++++++++++
 4 files changed, 13 insertions(+), 15 deletions(-)

--- wireless-testing.orig/net/mac80211/iface.c	2009-08-20 13:30:41.000000000 +0200
+++ wireless-testing/net/mac80211/iface.c	2009-08-20 14:55:48.000000000 +0200
@@ -552,11 +552,7 @@ static int ieee80211_stop(struct net_dev
 	ieee80211_recalc_ps(local, -1);
 
 	if (local->open_count == 0) {
-		drv_stop(local);
-
-		ieee80211_led_radio(local, false);
-
-		flush_workqueue(local->workqueue);
+		ieee80211_stop_device(local);
 
 		tasklet_disable(&local->tx_pending_tasklet);
 		tasklet_disable(&local->tasklet);
--- wireless-testing.orig/net/mac80211/ieee80211_i.h	2009-08-20 14:53:42.000000000 +0200
+++ wireless-testing/net/mac80211/ieee80211_i.h	2009-08-20 14:53:58.000000000 +0200
@@ -1078,6 +1078,7 @@ void ieee80211_process_measurement_req(s
 
 /* Suspend/resume and hw reconfiguration */
 int ieee80211_reconfig(struct ieee80211_local *local);
+void ieee80211_stop_device(struct ieee80211_local *local);
 
 #ifdef CONFIG_PM
 int __ieee80211_suspend(struct ieee80211_hw *hw);
--- wireless-testing.orig/net/mac80211/util.c	2009-08-20 14:52:09.000000000 +0200
+++ wireless-testing/net/mac80211/util.c	2009-08-20 14:55:43.000000000 +0200
@@ -1007,6 +1007,16 @@ u32 ieee80211_sta_get_rates(struct ieee8
 	return supp_rates;
 }
 
+void ieee80211_stop_device(struct ieee80211_local *local)
+{
+	ieee80211_led_radio(local, false);
+
+	cancel_work_sync(&local->reconfig_filter);
+	drv_stop(local);
+
+	flush_workqueue(local->workqueue);
+}
+
 int ieee80211_reconfig(struct ieee80211_local *local)
 {
 	struct ieee80211_hw *hw = &local->hw;
--- wireless-testing.orig/net/mac80211/pm.c	2009-08-20 14:55:52.000000000 +0200
+++ wireless-testing/net/mac80211/pm.c	2009-08-20 14:56:28.000000000 +0200
@@ -107,17 +107,8 @@ int __ieee80211_suspend(struct ieee80211
 	}
 
 	/* stop hardware - this must stop RX */
-	if (local->open_count) {
-		ieee80211_led_radio(local, false);
+	if (local->open_count)
 		ieee80211_stop_device(local);
-	}
-
-	/*
-	 * flush again, in case driver queued work -- it
-	 * shouldn't be doing (or cancel everything in the
-	 * stop callback) that but better safe than sorry.
-	 */
-	flush_workqueue(local->workqueue);
 
 	local->suspended = true;
 	/* need suspended to be visible before quiescing is false */



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] mac80211: fix configure_filter invocation after stop
  2009-08-20 17:46 [PATCH] mac80211: fix configure_filter invocation after stop Johannes Berg
@ 2009-08-20 18:02 ` Johannes Berg
  2009-08-20 19:56   ` Lennert Buytenhek
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2009-08-20 18:02 UTC (permalink / raw)
  To: John Linville; +Cc: Lennert Buytenhek, linux-wireless

Since configure_filter can sleep now, any multicast
configuration needed to be postponed to a work struct.
This, however, lead to a problem that we could queue
the work, stop the device and then afterwards invoke
configure_filter which may lead to driver hangs and is
a bug. To fix this, we can just cancel the filter work
since it's unnecessary to do after stopping the hw.

Since there are various places that call drv_stop, and
two of them do very similar things, the code for them
can be put into a shared function at the same time.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reported-by: Lennert Buytenhek <buytenh@wantstofly.org>
---
messed up with quilt in v1

 net/mac80211/ieee80211_i.h |    1 +
 net/mac80211/iface.c       |    6 +-----
 net/mac80211/pm.c          |   13 ++-----------
 net/mac80211/util.c        |   10 ++++++++++
 4 files changed, 14 insertions(+), 16 deletions(-)

--- wireless-testing.orig/net/mac80211/pm.c	2009-08-20 20:01:01.000000000 +0200
+++ wireless-testing/net/mac80211/pm.c	2009-08-20 20:01:14.000000000 +0200
@@ -107,17 +107,8 @@ int __ieee80211_suspend(struct ieee80211
 	}
 
 	/* stop hardware - this must stop RX */
-	if (local->open_count) {
-		ieee80211_led_radio(local, false);
-		drv_stop(local);
-	}
-
-	/*
-	 * flush again, in case driver queued work -- it
-	 * shouldn't be doing (or cancel everything in the
-	 * stop callback) that but better safe than sorry.
-	 */
-	flush_workqueue(local->workqueue);
+	if (local->open_count)
+		ieee80211_stop_device(local);
 
 	local->suspended = true;
 	/* need suspended to be visible before quiescing is false */
--- wireless-testing.orig/net/mac80211/iface.c	2009-08-20 20:00:35.000000000 +0200
+++ wireless-testing/net/mac80211/iface.c	2009-08-20 20:01:14.000000000 +0200
@@ -552,11 +552,7 @@ static int ieee80211_stop(struct net_dev
 	ieee80211_recalc_ps(local, -1);
 
 	if (local->open_count == 0) {
-		drv_stop(local);
-
-		ieee80211_led_radio(local, false);
-
-		flush_workqueue(local->workqueue);
+		ieee80211_stop_device(local);
 
 		tasklet_disable(&local->tx_pending_tasklet);
 		tasklet_disable(&local->tasklet);
--- wireless-testing.orig/net/mac80211/ieee80211_i.h	2009-08-20 20:00:35.000000000 +0200
+++ wireless-testing/net/mac80211/ieee80211_i.h	2009-08-20 20:01:14.000000000 +0200
@@ -1078,6 +1078,7 @@ void ieee80211_process_measurement_req(s
 
 /* Suspend/resume and hw reconfiguration */
 int ieee80211_reconfig(struct ieee80211_local *local);
+void ieee80211_stop_device(struct ieee80211_local *local);
 
 #ifdef CONFIG_PM
 int __ieee80211_suspend(struct ieee80211_hw *hw);
--- wireless-testing.orig/net/mac80211/util.c	2009-08-20 20:00:35.000000000 +0200
+++ wireless-testing/net/mac80211/util.c	2009-08-20 20:01:14.000000000 +0200
@@ -1007,6 +1007,16 @@ u32 ieee80211_sta_get_rates(struct ieee8
 	return supp_rates;
 }
 
+void ieee80211_stop_device(struct ieee80211_local *local)
+{
+	ieee80211_led_radio(local, false);
+
+	cancel_work_sync(&local->reconfig_filter);
+	drv_stop(local);
+
+	flush_workqueue(local->workqueue);
+}
+
 int ieee80211_reconfig(struct ieee80211_local *local)
 {
 	struct ieee80211_hw *hw = &local->hw;



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mac80211: fix configure_filter invocation after stop
  2009-08-20 18:02 ` [PATCH v2] " Johannes Berg
@ 2009-08-20 19:56   ` Lennert Buytenhek
  0 siblings, 0 replies; 3+ messages in thread
From: Lennert Buytenhek @ 2009-08-20 19:56 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John Linville, linux-wireless

On Thu, Aug 20, 2009 at 08:02:20PM +0200, Johannes Berg wrote:

> Since configure_filter can sleep now, any multicast
> configuration needed to be postponed to a work struct.
> This, however, lead to a problem that we could queue
> the work, stop the device and then afterwards invoke
> configure_filter which may lead to driver hangs and is
> a bug. To fix this, we can just cancel the filter work
> since it's unnecessary to do after stopping the hw.
> 
> Since there are various places that call drv_stop, and
> two of them do very similar things, the code for them
> can be put into a shared function at the same time.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> Reported-by: Lennert Buytenhek <buytenh@wantstofly.org>

Seems to work for me, I now no longer see firmware commands being
posted after ->stop() is called.

Tested-by: Lennert Buytenhek <buytenh@marvell.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-20 19:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-20 17:46 [PATCH] mac80211: fix configure_filter invocation after stop Johannes Berg
2009-08-20 18:02 ` [PATCH v2] " Johannes Berg
2009-08-20 19:56   ` Lennert Buytenhek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).