Merge tag 'char-misc-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[firefly-linux-kernel-4.4.55.git] / net / mac80211 / pm.c
index ca405b6b686da37a0e966f09e64b972a2d8ec7e2..06b60980c62c62cf8c8f95e10052060be5d36ed8 100644 (file)
@@ -23,7 +23,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
 
        ieee80211_del_virtual_monitor(local);
 
-       if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) {
+       if (ieee80211_hw_check(hw, AMPDU_AGGREGATION)) {
                mutex_lock(&local->sta_mtx);
                list_for_each_entry(sta, &local->sta_list, list) {
                        set_sta_flag(sta, WLAN_STA_BLOCK_BA);
@@ -59,13 +59,30 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
        cancel_work_sync(&local->dynamic_ps_enable_work);
        del_timer_sync(&local->dynamic_ps_timer);
 
-       local->wowlan = wowlan && local->open_count;
+       local->wowlan = wowlan;
        if (local->wowlan) {
-               int err = drv_suspend(local, wowlan);
+               int err;
+
+               /* Drivers don't expect to suspend while some operations like
+                * authenticating or associating are in progress. It doesn't
+                * make sense anyway to accept that, since the authentication
+                * or association would never finish since the driver can't do
+                * that on its own.
+                * Thus, clean up in-progress auth/assoc first.
+                */
+               list_for_each_entry(sdata, &local->interfaces, list) {
+                       if (!ieee80211_sdata_running(sdata))
+                               continue;
+                       if (sdata->vif.type != NL80211_IFTYPE_STATION)
+                               continue;
+                       ieee80211_mgd_quiesce(sdata);
+               }
+
+               err = drv_suspend(local, wowlan);
                if (err < 0) {
                        local->quiescing = false;
                        local->wowlan = false;
-                       if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) {
+                       if (ieee80211_hw_check(hw, AMPDU_AGGREGATION)) {
                                mutex_lock(&local->sta_mtx);
                                list_for_each_entry(sta,
                                                    &local->sta_list, list) {
@@ -80,6 +97,13 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
                        return err;
                } else if (err > 0) {
                        WARN_ON(err != 1);
+                       /* cfg80211 will call back into mac80211 to disconnect
+                        * all interfaces, allow that to proceed properly
+                        */
+                       ieee80211_wake_queues_by_reason(hw,
+                                       IEEE80211_MAX_QUEUE_MAP,
+                                       IEEE80211_QUEUE_STOP_REASON_SUSPEND,
+                                       false);
                        return err;
                } else {
                        goto suspend;