ath9k: get rid of most of those annoying dma tx stop issues
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 572-ath9k_fix_tx_flush.patch
1 --- a/drivers/net/wireless/ath/ath9k/main.c
2 +++ b/drivers/net/wireless/ath/ath9k/main.c
3 @@ -2149,54 +2149,37 @@ static void ath9k_set_coverage_class(str
4
5 static void ath9k_flush(struct ieee80211_hw *hw, bool drop)
6 {
7 -#define ATH_FLUSH_TIMEOUT 60 /* ms */
8 struct ath_softc *sc = hw->priv;
9 - struct ath_txq *txq = NULL;
10 - struct ath_hw *ah = sc->sc_ah;
11 - struct ath_common *common = ath9k_hw_common(ah);
12 - int i, j, npend = 0;
13 + int timeout = 60; /* ms */
14 + int i, j;
15
16 mutex_lock(&sc->mutex);
17
18 cancel_delayed_work_sync(&sc->tx_complete_work);
19
20 - for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
21 - if (!ATH_TXQ_SETUP(sc, i))
22 - continue;
23 - txq = &sc->tx.txq[i];
24 -
25 - if (!drop) {
26 - for (j = 0; j < ATH_FLUSH_TIMEOUT; j++) {
27 - if (!ath9k_has_pending_frames(sc, txq))
28 - break;
29 - usleep_range(1000, 2000);
30 - }
31 - }
32 + if (drop)
33 + timeout = 1;
34
35 - if (drop || ath9k_has_pending_frames(sc, txq)) {
36 - ath_dbg(common, ATH_DBG_QUEUE, "Drop frames from hw queue:%d\n",
37 - txq->axq_qnum);
38 - spin_lock_bh(&txq->axq_lock);
39 - txq->txq_flush_inprogress = true;
40 - spin_unlock_bh(&txq->axq_lock);
41 -
42 - ath9k_ps_wakeup(sc);
43 - ath9k_hw_stoptxdma(ah, txq->axq_qnum);
44 - npend = ath9k_hw_numtxpending(ah, txq->axq_qnum);
45 - ath9k_ps_restore(sc);
46 - if (npend)
47 - break;
48 + for (j = 0; j < timeout; j++) {
49 + int npend = 0;
50 + for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
51 + if (!ATH_TXQ_SETUP(sc, i))
52 + continue;
53
54 - ath_draintxq(sc, txq, false);
55 - txq->txq_flush_inprogress = false;
56 + npend += ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
57 }
58 - }
59
60 - if (npend) {
61 - ath_reset(sc, false);
62 - txq->txq_flush_inprogress = false;
63 + if (!npend)
64 + goto out;
65 +
66 + usleep_range(1000, 2000);
67 }
68
69 + ath9k_ps_wakeup(sc);
70 + ath_drain_all_txq(sc, false);
71 + ath9k_ps_restore(sc);
72 +
73 +out:
74 ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0);
75 mutex_unlock(&sc->mutex);
76 }