ath9k: get rid of most of those annoying dma tx stop issues
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 571-ath9k_fix_dma_stop.patch
1 --- a/drivers/net/wireless/ath/ath9k/xmit.c
2 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
3 @@ -1271,16 +1271,14 @@ bool ath_drain_all_txq(struct ath_softc
4 if (sc->sc_flags & SC_OP_INVALID)
5 return true;
6
7 - /* Stop beacon queue */
8 - ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
9 + ath9k_hw_abort_tx_dma(ah);
10
11 - /* Stop data queues */
12 + /* Check if any queue remains active */
13 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
14 - if (ATH_TXQ_SETUP(sc, i)) {
15 - txq = &sc->tx.txq[i];
16 - ath9k_hw_stoptxdma(ah, txq->axq_qnum);
17 - npend += ath9k_hw_numtxpending(ah, txq->axq_qnum);
18 - }
19 + if (!ATH_TXQ_SETUP(sc, i))
20 + continue;
21 +
22 + npend += ath9k_hw_numtxpending(ah, sc->tx.txq[i].axq_qnum);
23 }
24
25 if (npend)
26 --- a/drivers/net/wireless/ath/ath9k/mac.c
27 +++ b/drivers/net/wireless/ath/ath9k/mac.c
28 @@ -143,6 +143,37 @@ bool ath9k_hw_updatetxtriglevel(struct a
29 }
30 EXPORT_SYMBOL(ath9k_hw_updatetxtriglevel);
31
32 +bool ath9k_hw_abort_tx_dma(struct ath_hw *ah)
33 +{
34 + int i, q;
35 +
36 + REG_WRITE(ah, AR_Q_TXD, AR_Q_TXD_M);
37 +
38 + REG_SET_BIT(ah, AR_PCU_MISC, AR_PCU_FORCE_QUIET_COLL | AR_PCU_CLEAR_VMF);
39 + REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
40 + REG_SET_BIT(ah, AR_D_GBL_IFS_MISC, AR_D_GBL_IFS_MISC_IGNORE_BACKOFF);
41 +
42 + for (q = 0; q < AR_NUM_QCU; q++) {
43 + for (i = 1000; i > 0; i--) {
44 + if (!ath9k_hw_numtxpending(ah, q))
45 + break;
46 +
47 + udelay(5);
48 + }
49 + }
50 + if (!i)
51 + return false;
52 +
53 + REG_CLR_BIT(ah, AR_PCU_MISC, AR_PCU_FORCE_QUIET_COLL | AR_PCU_CLEAR_VMF);
54 + REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
55 + REG_CLR_BIT(ah, AR_D_GBL_IFS_MISC, AR_D_GBL_IFS_MISC_IGNORE_BACKOFF);
56 +
57 + REG_WRITE(ah, AR_Q_TXD, 0);
58 +
59 + return true;
60 +}
61 +EXPORT_SYMBOL(ath9k_hw_abort_tx_dma);
62 +
63 bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q)
64 {
65 #define ATH9K_TX_STOP_DMA_TIMEOUT 4000 /* usec */
66 --- a/drivers/net/wireless/ath/ath9k/mac.h
67 +++ b/drivers/net/wireless/ath/ath9k/mac.h
68 @@ -676,6 +676,7 @@ void ath9k_hw_cleartxdesc(struct ath_hw
69 u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q);
70 bool ath9k_hw_updatetxtriglevel(struct ath_hw *ah, bool bIncTrigLevel);
71 bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q);
72 +bool ath9k_hw_abort_tx_dma(struct ath_hw *ah);
73 void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs);
74 bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q,
75 const struct ath9k_tx_queue_info *qinfo);