IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
        IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
        IEEE80211_QUEUE_STOP_REASON_FLUSH,
+
+       IEEE80211_QUEUE_STOP_REASONS,
 };
 
 #ifdef CONFIG_MAC80211_LEDS
        struct workqueue_struct *workqueue;
 
        unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES];
+       int q_stop_reasons[IEEE80211_MAX_QUEUES][IEEE80211_QUEUE_STOP_REASONS];
        /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
        spinlock_t queue_stop_reason_lock;
 
 
 void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
                                     unsigned long queues,
-                                    enum queue_stop_reason reason);
+                                    enum queue_stop_reason reason,
+                                    bool refcounted);
 void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
                                     unsigned long queues,
-                                    enum queue_stop_reason reason);
+                                    enum queue_stop_reason reason,
+                                    bool refcounted);
 void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
-                                   enum queue_stop_reason reason);
+                                   enum queue_stop_reason reason,
+                                   bool refcounted);
 void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
-                                   enum queue_stop_reason reason);
+                                   enum queue_stop_reason reason,
+                                   bool refcounted);
 void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
 void ieee80211_add_pending_skb(struct ieee80211_local *local,
                               struct sk_buff *skb);
 
        if (!ieee80211_csa_needs_block_tx(local))
                ieee80211_wake_queues_by_reason(&local->hw,
                                        IEEE80211_MAX_QUEUE_MAP,
-                                       IEEE80211_QUEUE_STOP_REASON_CSA);
+                                       IEEE80211_QUEUE_STOP_REASON_CSA,
+                                       false);
        mutex_unlock(&local->mtx);
 
        ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED;
        if (sdata->csa_block_tx)
                ieee80211_stop_queues_by_reason(&local->hw,
                                        IEEE80211_MAX_QUEUE_MAP,
-                                       IEEE80211_QUEUE_STOP_REASON_CSA);
+                                       IEEE80211_QUEUE_STOP_REASON_CSA,
+                                       false);
        mutex_unlock(&local->mtx);
 
        if (local->ops->channel_switch) {
 
        ieee80211_wake_queues_by_reason(&local->hw,
                                        IEEE80211_MAX_QUEUE_MAP,
-                                       IEEE80211_QUEUE_STOP_REASON_PS);
+                                       IEEE80211_QUEUE_STOP_REASON_PS,
+                                       false);
 }
 
 void ieee80211_dynamic_ps_enable_work(struct work_struct *work)
        if (!ieee80211_csa_needs_block_tx(local))
                ieee80211_wake_queues_by_reason(&local->hw,
                                        IEEE80211_MAX_QUEUE_MAP,
-                                       IEEE80211_QUEUE_STOP_REASON_CSA);
+                                       IEEE80211_QUEUE_STOP_REASON_CSA,
+                                       false);
        mutex_unlock(&local->mtx);
 
        sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM;
        if (!ieee80211_csa_needs_block_tx(local))
                ieee80211_wake_queues_by_reason(&local->hw,
                                        IEEE80211_MAX_QUEUE_MAP,
-                                       IEEE80211_QUEUE_STOP_REASON_CSA);
+                                       IEEE80211_QUEUE_STOP_REASON_CSA,
+                                       false);
        mutex_unlock(&local->mtx);
 
        cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
 
 }
 
 static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue,
-                                  enum queue_stop_reason reason)
+                                  enum queue_stop_reason reason,
+                                  bool refcounted)
 {
        struct ieee80211_local *local = hw_to_local(hw);
 
        if (!test_bit(reason, &local->queue_stop_reasons[queue]))
                return;
 
-       __clear_bit(reason, &local->queue_stop_reasons[queue]);
+       if (!refcounted)
+               local->q_stop_reasons[queue][reason] = 0;
+       else
+               local->q_stop_reasons[queue][reason]--;
+
+       if (local->q_stop_reasons[queue][reason] == 0)
+               __clear_bit(reason, &local->queue_stop_reasons[queue]);
 
        if (local->queue_stop_reasons[queue] != 0)
                /* someone still has this queue stopped */
 }
 
 void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
-                                   enum queue_stop_reason reason)
+                                   enum queue_stop_reason reason,
+                                   bool refcounted)
 {
        struct ieee80211_local *local = hw_to_local(hw);
        unsigned long flags;
 
        spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
-       __ieee80211_wake_queue(hw, queue, reason);
+       __ieee80211_wake_queue(hw, queue, reason, refcounted);
        spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
 }
 
 void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue)
 {
        ieee80211_wake_queue_by_reason(hw, queue,
-                                      IEEE80211_QUEUE_STOP_REASON_DRIVER);
+                                      IEEE80211_QUEUE_STOP_REASON_DRIVER,
+                                      false);
 }
 EXPORT_SYMBOL(ieee80211_wake_queue);
 
 static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue,
-                                  enum queue_stop_reason reason)
+                                  enum queue_stop_reason reason,
+                                  bool refcounted)
 {
        struct ieee80211_local *local = hw_to_local(hw);
        struct ieee80211_sub_if_data *sdata;
        if (WARN_ON(queue >= hw->queues))
                return;
 
-       if (test_bit(reason, &local->queue_stop_reasons[queue]))
-               return;
+       if (!refcounted)
+               local->q_stop_reasons[queue][reason] = 1;
+       else
+               local->q_stop_reasons[queue][reason]++;
 
-       __set_bit(reason, &local->queue_stop_reasons[queue]);
+       if (__test_and_set_bit(reason, &local->queue_stop_reasons[queue]))
+               return;
 
        if (local->hw.queues < IEEE80211_NUM_ACS)
                n_acs = 1;
 }
 
 void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
-                                   enum queue_stop_reason reason)
+                                   enum queue_stop_reason reason,
+                                   bool refcounted)
 {
        struct ieee80211_local *local = hw_to_local(hw);
        unsigned long flags;
 
        spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
-       __ieee80211_stop_queue(hw, queue, reason);
+       __ieee80211_stop_queue(hw, queue, reason, refcounted);
        spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
 }
 
 void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue)
 {
        ieee80211_stop_queue_by_reason(hw, queue,
-                                      IEEE80211_QUEUE_STOP_REASON_DRIVER);
+                                      IEEE80211_QUEUE_STOP_REASON_DRIVER,
+                                      false);
 }
 EXPORT_SYMBOL(ieee80211_stop_queue);
 
        }
 
        spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
-       __ieee80211_stop_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD);
+       __ieee80211_stop_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
+                              false);
        __skb_queue_tail(&local->pending[queue], skb);
-       __ieee80211_wake_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD);
+       __ieee80211_wake_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
+                              false);
        spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
 }
 
                queue = info->hw_queue;
 
                __ieee80211_stop_queue(hw, queue,
-                               IEEE80211_QUEUE_STOP_REASON_SKB_ADD);
+                               IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
+                               false);
 
                __skb_queue_tail(&local->pending[queue], skb);
        }
 
        for (i = 0; i < hw->queues; i++)
                __ieee80211_wake_queue(hw, i,
-                       IEEE80211_QUEUE_STOP_REASON_SKB_ADD);
+                       IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
+                       false);
        spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
 }
 
 void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
                                     unsigned long queues,
-                                    enum queue_stop_reason reason)
+                                    enum queue_stop_reason reason,
+                                    bool refcounted)
 {
        struct ieee80211_local *local = hw_to_local(hw);
        unsigned long flags;
        spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
 
        for_each_set_bit(i, &queues, hw->queues)
-               __ieee80211_stop_queue(hw, i, reason);
+               __ieee80211_stop_queue(hw, i, reason, refcounted);
 
        spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
 }
 void ieee80211_stop_queues(struct ieee80211_hw *hw)
 {
        ieee80211_stop_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP,
-                                       IEEE80211_QUEUE_STOP_REASON_DRIVER);
+                                       IEEE80211_QUEUE_STOP_REASON_DRIVER,
+                                       false);
 }
 EXPORT_SYMBOL(ieee80211_stop_queues);
 
 
 void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
                                     unsigned long queues,
-                                    enum queue_stop_reason reason)
+                                    enum queue_stop_reason reason,
+                                    bool refcounted)
 {
        struct ieee80211_local *local = hw_to_local(hw);
        unsigned long flags;
        spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
 
        for_each_set_bit(i, &queues, hw->queues)
-               __ieee80211_wake_queue(hw, i, reason);
+               __ieee80211_wake_queue(hw, i, reason, refcounted);
 
        spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
 }
 void ieee80211_wake_queues(struct ieee80211_hw *hw)
 {
        ieee80211_wake_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP,
-                                       IEEE80211_QUEUE_STOP_REASON_DRIVER);
+                                       IEEE80211_QUEUE_STOP_REASON_DRIVER,
+                                       false);
 }
 EXPORT_SYMBOL(ieee80211_wake_queues);
 
        }
 
        ieee80211_stop_queues_by_reason(&local->hw, queues,
-                                       IEEE80211_QUEUE_STOP_REASON_FLUSH);
+                                       IEEE80211_QUEUE_STOP_REASON_FLUSH,
+                                       false);
 
        drv_flush(local, sdata, queues, false);
 
        ieee80211_wake_queues_by_reason(&local->hw, queues,
-                                       IEEE80211_QUEUE_STOP_REASON_FLUSH);
+                                       IEEE80211_QUEUE_STOP_REASON_FLUSH,
+                                       false);
 }
 
 static void __iterate_active_interfaces(struct ieee80211_local *local,
        }
 
        ieee80211_wake_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP,
-                                       IEEE80211_QUEUE_STOP_REASON_SUSPEND);
+                                       IEEE80211_QUEUE_STOP_REASON_SUSPEND,
+                                       false);
 
        /*
         * Reconfigure sched scan if it was interrupted by FW restart or