/* Aggregation logic */
 /*********************/
 
+static void ath_txq_lock(struct ath_softc *sc, struct ath_txq *txq)
+{
+       spin_lock_bh(&txq->axq_lock);
+}
+
+static void ath_txq_unlock(struct ath_softc *sc, struct ath_txq *txq)
+{
+       spin_unlock_bh(&txq->axq_lock);
+}
+
+static void ath_txq_unlock_complete(struct ath_softc *sc, struct ath_txq *txq)
+{
+       struct sk_buff_head q;
+       struct sk_buff *skb;
+
+       __skb_queue_head_init(&q);
+       skb_queue_splice_init(&txq->complete_q, &q);
+       spin_unlock_bh(&txq->axq_lock);
+
+       while ((skb = __skb_dequeue(&q)))
+               ieee80211_tx_status(sc->hw, skb);
+}
+
 static void ath_tx_queue_tid(struct ath_txq *txq, struct ath_atx_tid *tid)
 {
        struct ath_atx_ac *ac = tid->ac;
 
        WARN_ON(!tid->paused);
 
-       spin_lock_bh(&txq->axq_lock);
+       ath_txq_lock(sc, txq);
        tid->paused = false;
 
        if (skb_queue_empty(&tid->buf_q))
        ath_tx_queue_tid(txq, tid);
        ath_txq_schedule(sc, txq);
 unlock:
-       spin_unlock_bh(&txq->axq_lock);
+       ath_txq_unlock_complete(sc, txq);
 }
 
 static struct ath_frame_info *get_frame_info(struct sk_buff *skb)
                tid->state &= ~AGGR_CLEANUP;
        }
 
-       if (sendbar)
+       if (sendbar) {
+               ath_txq_unlock(sc, txq);
                ath_send_bar(tid, tid->seq_start);
+               ath_txq_lock(sc, txq);
+       }
 }
 
 static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
                bf = bf_next;
        }
 
-       if (bar_index >= 0) {
-               u16 bar_seq = ATH_BA_INDEX2SEQ(seq_first, bar_index);
-               ath_send_bar(tid, ATH_BA_INDEX2SEQ(seq_first, bar_index + 1));
-               if (BAW_WITHIN(tid->seq_start, tid->baw_size, bar_seq))
-                       tid->bar_index = ATH_BA_INDEX(tid->seq_start, bar_seq);
-       }
-
        /* prepend un-acked frames to the beginning of the pending frame queue */
        if (!skb_queue_empty(&bf_pending)) {
                if (an->sleeping)
                }
        }
 
+       if (bar_index >= 0) {
+               u16 bar_seq = ATH_BA_INDEX2SEQ(seq_first, bar_index);
+
+               if (BAW_WITHIN(tid->seq_start, tid->baw_size, bar_seq))
+                       tid->bar_index = ATH_BA_INDEX(tid->seq_start, bar_seq);
+
+               ath_txq_unlock(sc, txq);
+               ath_send_bar(tid, ATH_BA_INDEX2SEQ(seq_first, bar_index + 1));
+               ath_txq_lock(sc, txq);
+       }
+
        if (tid->state & AGGR_CLEANUP)
                ath_tx_flush_tid(sc, tid);
 
                return;
        }
 
-       spin_lock_bh(&txq->axq_lock);
+       ath_txq_lock(sc, txq);
        txtid->paused = true;
 
        /*
                txtid->state &= ~AGGR_ADDBA_COMPLETE;
 
        ath_tx_flush_tid(sc, txtid);
-       spin_unlock_bh(&txq->axq_lock);
+       ath_txq_unlock_complete(sc, txq);
 }
 
 void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc,
                ac = tid->ac;
                txq = ac->txq;
 
-               spin_lock_bh(&txq->axq_lock);
+               ath_txq_lock(sc, txq);
 
                buffered = !skb_queue_empty(&tid->buf_q);
 
                        list_del(&ac->list);
                }
 
-               spin_unlock_bh(&txq->axq_lock);
+               ath_txq_unlock(sc, txq);
 
                ieee80211_sta_set_buffered(sta, tidno, buffered);
        }
                ac = tid->ac;
                txq = ac->txq;
 
-               spin_lock_bh(&txq->axq_lock);
+               ath_txq_lock(sc, txq);
                ac->clear_ps_filter = true;
 
                if (!skb_queue_empty(&tid->buf_q) && !tid->paused) {
                        ath_txq_schedule(sc, txq);
                }
 
-               spin_unlock_bh(&txq->axq_lock);
+               ath_txq_unlock_complete(sc, txq);
        }
 }
 
                txq->axq_qnum = axq_qnum;
                txq->mac80211_qnum = -1;
                txq->axq_link = NULL;
+               __skb_queue_head_init(&txq->complete_q);
                INIT_LIST_HEAD(&txq->axq_q);
                INIT_LIST_HEAD(&txq->axq_acq);
                spin_lock_init(&txq->axq_lock);
  */
 void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq, bool retry_tx)
 {
-       spin_lock_bh(&txq->axq_lock);
+       ath_txq_lock(sc, txq);
+
        if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
                int idx = txq->txq_tailidx;
 
        if ((sc->sc_flags & SC_OP_TXAGGR) && !retry_tx)
                ath_txq_drain_pending_buffers(sc, txq);
 
-       spin_unlock_bh(&txq->axq_lock);
+       ath_txq_unlock_complete(sc, txq);
 }
 
 bool ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
         */
 
        q = skb_get_queue_mapping(skb);
-       spin_lock_bh(&txq->axq_lock);
+
+       ath_txq_lock(sc, txq);
        if (txq == sc->tx.txq_map[q] &&
            ++txq->pending_frames > ATH_MAX_QDEPTH && !txq->stopped) {
                ieee80211_stop_queue(sc->hw, q);
 
        ath_tx_start_dma(sc, skb, txctl);
 
-       spin_unlock_bh(&txq->axq_lock);
+       ath_txq_unlock(sc, txq);
 
        return 0;
 }
 static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
                            int tx_flags, struct ath_txq *txq)
 {
-       struct ieee80211_hw *hw = sc->hw;
        struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
        struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
                }
        }
 
-       ieee80211_tx_status(hw, skb);
+       __skb_queue_tail(&txq->complete_q, skb);
 }
 
 static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
                txq->axq_qnum, ath9k_hw_gettxbuf(sc->sc_ah, txq->axq_qnum),
                txq->axq_link);
 
-       spin_lock_bh(&txq->axq_lock);
+       ath_txq_lock(sc, txq);
        for (;;) {
                if (work_pending(&sc->hw_reset_work))
                        break;
 
                ath_tx_process_buffer(sc, txq, &ts, bf, &bf_head);
        }
-       spin_unlock_bh(&txq->axq_lock);
+       ath_txq_unlock_complete(sc, txq);
 }
 
 static void ath_tx_complete_poll_work(struct work_struct *work)
        for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
                if (ATH_TXQ_SETUP(sc, i)) {
                        txq = &sc->tx.txq[i];
-                       spin_lock_bh(&txq->axq_lock);
+                       ath_txq_lock(sc, txq);
                        if (txq->axq_depth) {
                                if (txq->axq_tx_inprogress) {
                                        needreset = true;
-                                       spin_unlock_bh(&txq->axq_lock);
+                                       ath_txq_unlock(sc, txq);
                                        break;
                                } else {
                                        txq->axq_tx_inprogress = true;
                                }
                        }
-                       spin_unlock_bh(&txq->axq_lock);
+                       ath_txq_unlock_complete(sc, txq);
                }
 
        if (needreset) {
 
                txq = &sc->tx.txq[ts.qid];
 
-               spin_lock_bh(&txq->axq_lock);
+               ath_txq_lock(sc, txq);
 
                if (list_empty(&txq->txq_fifo[txq->txq_tailidx])) {
-                       spin_unlock_bh(&txq->axq_lock);
+                       ath_txq_unlock(sc, txq);
                        return;
                }
 
                }
 
                ath_tx_process_buffer(sc, txq, &ts, bf, &bf_head);
-               spin_unlock_bh(&txq->axq_lock);
+               ath_txq_unlock_complete(sc, txq);
        }
 }
 
                ac = tid->ac;
                txq = ac->txq;
 
-               spin_lock_bh(&txq->axq_lock);
+               ath_txq_lock(sc, txq);
 
                if (tid->sched) {
                        list_del(&tid->list);
                tid->state &= ~AGGR_ADDBA_COMPLETE;
                tid->state &= ~AGGR_CLEANUP;
 
-               spin_unlock_bh(&txq->axq_lock);
+               ath_txq_unlock(sc, txq);
        }
 }