]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
mac80211: fix resume
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 19 Nov 2009 13:29:39 +0000 (14:29 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 19 Nov 2009 16:08:39 +0000 (11:08 -0500)
When mac80211 resumes, it currently first sets suspended
to false so the driver can start doing things and we can
receive frames.

However, if we actually receive frames then it can end
up starting some work which adds timers and then later
runs into a BUG_ON in the timer code because it tries
add_timer() on a pending timer.

Fix this by keeping track of the resuming process by
introducing a new variable 'resuming' which gets set to
true early on instead of setting 'suspended' to false,
and allow queueing work but not receiving frames while
resuming.

Reported-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/mac80211/ieee80211_i.h
net/mac80211/util.c

index 588005c84a6d2b34eb1ef9900ee9a6ef99fcbcd8..a910bf1f092f301e973f9b9e8be6899f93f6655f 100644 (file)
@@ -661,6 +661,14 @@ struct ieee80211_local {
         */
        bool suspended;
 
+       /*
+        * Resuming is true while suspended, but when we're reprogramming the
+        * hardware -- at that time it's allowed to use ieee80211_queue_work()
+        * again even though some other parts of the stack are still suspended
+        * and we still drop received frames to avoid waking the stack.
+        */
+       bool resuming;
+
        /*
         * quiescing is true during the suspend process _only_ to
         * ease timer cancelling etc.
index aeb65b3d2295a7a3c99c279a3e669e583c282e5e..e6c08da8da26de707ece65fb11bb8d45d7a309de 100644 (file)
@@ -520,9 +520,9 @@ EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_atomic);
  */
 static bool ieee80211_can_queue_work(struct ieee80211_local *local)
 {
-        if (WARN(local->suspended, "queueing ieee80211 work while "
-                "going to suspend\n"))
-                return false;
+       if (WARN(local->suspended && !local->resuming,
+                "queueing ieee80211 work while going to suspend\n"))
+               return false;
 
        return true;
 }
@@ -1025,13 +1025,9 @@ int ieee80211_reconfig(struct ieee80211_local *local)
        struct sta_info *sta;
        unsigned long flags;
        int res;
-       bool from_suspend = local->suspended;
 
-       /*
-        * We're going to start the hardware, at that point
-        * we are no longer suspended and can RX frames.
-        */
-       local->suspended = false;
+       if (local->suspended)
+               local->resuming = true;
 
        /* restart hardware */
        if (local->open_count) {
@@ -1129,11 +1125,14 @@ int ieee80211_reconfig(struct ieee80211_local *local)
         * If this is for hw restart things are still running.
         * We may want to change that later, however.
         */
-       if (!from_suspend)
+       if (!local->suspended)
                return 0;
 
 #ifdef CONFIG_PM
+       /* first set suspended false, then resuming */
        local->suspended = false;
+       mb();
+       local->resuming = false;
 
        list_for_each_entry(sdata, &local->interfaces, list) {
                switch(sdata->vif.type) {