+@@ -640,6 +667,8 @@ static void __sta_info_recalc_tim(struct
+
+ indicate_tim |=
+ sta->driver_buffered_tids & tids;
++ indicate_tim |=
++ sta->txq_buffered_tids & tids;
+ }
+
+ done:
+@@ -1071,7 +1100,7 @@ void ieee80211_sta_ps_deliver_wakeup(str
+ struct ieee80211_sub_if_data *sdata = sta->sdata;
+ struct ieee80211_local *local = sdata->local;
+ struct sk_buff_head pending;
+- int filtered = 0, buffered = 0, ac;
++ int filtered = 0, buffered = 0, ac, i;
+ unsigned long flags;
+ struct ps_data *ps;
+
+@@ -1090,10 +1119,25 @@ void ieee80211_sta_ps_deliver_wakeup(str
+
+ BUILD_BUG_ON(BITS_TO_LONGS(IEEE80211_NUM_TIDS) > 1);
+ sta->driver_buffered_tids = 0;
++ sta->txq_buffered_tids = 0;
+
+ if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS))
+ drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta);
+
++ if (sta->txqi) {
++ for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
++ struct txq_info *txqi;
++
++ txqi = container_of(sta->sta.txq[i], struct txq_info,
++ txq);
++
++ if (!skb_queue_len(&txqi->queue))
++ continue;
++
++ drv_wake_tx_queue(local, txqi);
++ }
++ }
++
+ skb_queue_head_init(&pending);
+
+ /* sync with ieee80211_tx_h_unicast_ps_buf */
+@@ -1254,7 +1298,7 @@ ieee80211_sta_ps_deliver_response(struct
+ struct ieee80211_sub_if_data *sdata = sta->sdata;
+ struct ieee80211_local *local = sdata->local;
+ bool more_data = false;
+- int ac;
++ int ac, tid;
+ unsigned long driver_release_tids = 0;
+ struct sk_buff_head frames;
+
+@@ -1275,8 +1319,10 @@ ieee80211_sta_ps_deliver_response(struct
+ /* if we already have frames from software, then we can't also
+ * release from hardware queues
+ */
+- if (skb_queue_empty(&frames))
++ if (skb_queue_empty(&frames)) {
+ driver_release_tids |= sta->driver_buffered_tids & tids;
++ driver_release_tids |= sta->txq_buffered_tids & tids;
++ }
+
+ if (driver_release_tids) {
+ /* If the driver has data on more than one TID then
+@@ -1447,6 +1493,8 @@ ieee80211_sta_ps_deliver_response(struct
+
+ sta_info_recalc_tim(sta);
+ } else {
++ unsigned long tids = sta->txq_buffered_tids & driver_release_tids;
++
+ /*
+ * We need to release a frame that is buffered somewhere in the
+ * driver ... it'll have to handle that.
+@@ -1466,8 +1514,25 @@ ieee80211_sta_ps_deliver_response(struct
+ * that the TID(s) became empty before returning here from the
+ * release function.
+ * Either way, however, when the driver tells us that the TID(s)
+- * became empty we'll do the TIM recalculation.
++ * became empty or we find that a txq became empty, we'll do the
++ * TIM recalculation.
+ */
++
++ if (!sta->txqi)
++ return;
++
++ for (tid = 0; tid < IEEE80211_NUM_TIDS; tid++) {
++ struct txq_info *txqi;
++
++ txqi = container_of(sta->sta.txq[tid], struct txq_info,
++ txq);
++
++ if (!(tids & BIT(tid)) || skb_queue_len(&txqi->queue))
++ continue;
++
++ sta_info_recalc_tim(sta);
++ break;
++ }
+ }
+ }
+