sta->last_qual = rx->status->qual;
        sta->last_noise = rx->status->noise;
 
+       /*
+        * Change STA power saving mode only at the end of a frame
+        * exchange sequence.
+        */
        if (!ieee80211_has_morefrags(hdr->frame_control) &&
            (rx->sdata->vif.type == NL80211_IFTYPE_AP ||
             rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) {
-               /* Change STA power saving mode only in the end of a frame
-                * exchange sequence */
-               if (test_sta_flags(sta, WLAN_STA_PS) &&
-                   !ieee80211_has_pm(hdr->frame_control))
-                       rx->sent_ps_buffered += ap_sta_ps_end(sta);
-               else if (!test_sta_flags(sta, WLAN_STA_PS) &&
-                        ieee80211_has_pm(hdr->frame_control))
-                       ap_sta_ps_start(sta);
+               if (test_sta_flags(sta, WLAN_STA_PS)) {
+                       /*
+                        * Ignore doze->wake transitions that are
+                        * indicated by non-data frames, the standard
+                        * is unclear here, but for example going to
+                        * PS mode and then scanning would cause a
+                        * doze->wake transition for the probe request,
+                        * and that is clearly undesirable.
+                        */
+                       if (ieee80211_is_data(hdr->frame_control) &&
+                           !ieee80211_has_pm(hdr->frame_control))
+                               rx->sent_ps_buffered += ap_sta_ps_end(sta);
+               } else {
+                       if (ieee80211_has_pm(hdr->frame_control))
+                               ap_sta_ps_start(sta);
+               }
        }
 
        /* Drop data::nullfunc frames silently, since they are used only to