mac80211/ath9k: improve pending patches based on review feedback
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 573-ath9k_beacon_stop.patch
1 --- a/drivers/net/wireless/ath/ath9k/mac.c
2 +++ b/drivers/net/wireless/ath/ath9k/mac.c
3 @@ -171,84 +171,31 @@ void ath9k_hw_abort_tx_dma(struct ath_hw
4 }
5 EXPORT_SYMBOL(ath9k_hw_abort_tx_dma);
6
7 -bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q)
8 +bool ath9k_hw_stop_dma_queue(struct ath_hw *ah, u32 q)
9 {
10 -#define ATH9K_TX_STOP_DMA_TIMEOUT 4000 /* usec */
11 +#define ATH9K_TX_STOP_DMA_TIMEOUT 1000 /* usec */
12 #define ATH9K_TIME_QUANTUM 100 /* usec */
13 - struct ath_common *common = ath9k_hw_common(ah);
14 - struct ath9k_hw_capabilities *pCap = &ah->caps;
15 - struct ath9k_tx_queue_info *qi;
16 - u32 tsfLow, j, wait;
17 - u32 wait_time = ATH9K_TX_STOP_DMA_TIMEOUT / ATH9K_TIME_QUANTUM;
18 -
19 - if (q >= pCap->total_queues) {
20 - ath_dbg(common, ATH_DBG_QUEUE,
21 - "Stopping TX DMA, invalid queue: %u\n", q);
22 - return false;
23 - }
24 -
25 - qi = &ah->txq[q];
26 - if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
27 - ath_dbg(common, ATH_DBG_QUEUE,
28 - "Stopping TX DMA, inactive queue: %u\n", q);
29 - return false;
30 - }
31 + int wait_time = ATH9K_TX_STOP_DMA_TIMEOUT / ATH9K_TIME_QUANTUM;
32 + int wait;
33
34 REG_WRITE(ah, AR_Q_TXD, 1 << q);
35
36 for (wait = wait_time; wait != 0; wait--) {
37 - if (ath9k_hw_numtxpending(ah, q) == 0)
38 - break;
39 - udelay(ATH9K_TIME_QUANTUM);
40 - }
41 -
42 - if (ath9k_hw_numtxpending(ah, q)) {
43 - ath_dbg(common, ATH_DBG_QUEUE,
44 - "%s: Num of pending TX Frames %d on Q %d\n",
45 - __func__, ath9k_hw_numtxpending(ah, q), q);
46 -
47 - for (j = 0; j < 2; j++) {
48 - tsfLow = REG_READ(ah, AR_TSF_L32);
49 - REG_WRITE(ah, AR_QUIET2,
50 - SM(10, AR_QUIET2_QUIET_DUR));
51 - REG_WRITE(ah, AR_QUIET_PERIOD, 100);
52 - REG_WRITE(ah, AR_NEXT_QUIET_TIMER, tsfLow >> 10);
53 - REG_SET_BIT(ah, AR_TIMER_MODE,
54 - AR_QUIET_TIMER_EN);
55 -
56 - if ((REG_READ(ah, AR_TSF_L32) >> 10) == (tsfLow >> 10))
57 - break;
58 -
59 - ath_dbg(common, ATH_DBG_QUEUE,
60 - "TSF has moved while trying to set quiet time TSF: 0x%08x\n",
61 - tsfLow);
62 - }
63 -
64 - REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
65 -
66 - udelay(200);
67 - REG_CLR_BIT(ah, AR_TIMER_MODE, AR_QUIET_TIMER_EN);
68 -
69 - wait = wait_time;
70 - while (ath9k_hw_numtxpending(ah, q)) {
71 - if ((--wait) == 0) {
72 - ath_err(common,
73 - "Failed to stop TX DMA in 100 msec after killing last frame\n");
74 - break;
75 - }
76 + if (wait != wait_time)
77 udelay(ATH9K_TIME_QUANTUM);
78 - }
79
80 - REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
81 + if (ath9k_hw_numtxpending(ah, q) == 0)
82 + break;
83 }
84
85 REG_WRITE(ah, AR_Q_TXD, 0);
86 +
87 return wait != 0;
88
89 #undef ATH9K_TX_STOP_DMA_TIMEOUT
90 #undef ATH9K_TIME_QUANTUM
91 }
92 -EXPORT_SYMBOL(ath9k_hw_stoptxdma);
93 +EXPORT_SYMBOL(ath9k_hw_stop_dma_queue);
94
95 void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs)
96 {
97 --- a/drivers/net/wireless/ath/ath9k/mac.h
98 +++ b/drivers/net/wireless/ath/ath9k/mac.h
99 @@ -675,7 +675,7 @@ void ath9k_hw_txstart(struct ath_hw *ah,
100 void ath9k_hw_cleartxdesc(struct ath_hw *ah, void *ds);
101 u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q);
102 bool ath9k_hw_updatetxtriglevel(struct ath_hw *ah, bool bIncTrigLevel);
103 -bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q);
104 +bool ath9k_hw_stop_dma_queue(struct ath_hw *ah, u32 q);
105 void ath9k_hw_abort_tx_dma(struct ath_hw *ah);
106 void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs);
107 bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q,
108 --- a/drivers/net/wireless/ath/ath9k/beacon.c
109 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
110 @@ -373,6 +373,7 @@ void ath_beacon_tasklet(unsigned long da
111 ath_dbg(common, ATH_DBG_BSTUCK,
112 "missed %u consecutive beacons\n",
113 sc->beacon.bmisscnt);
114 + ath9k_hw_stop_dma_queue(ah, sc->beacon.beaconq);
115 ath9k_hw_bstuck_nfcal(ah);
116 } else if (sc->beacon.bmisscnt >= BSTUCK_THRESH) {
117 ath_dbg(common, ATH_DBG_BSTUCK,
118 @@ -450,16 +451,6 @@ void ath_beacon_tasklet(unsigned long da
119 sc->beacon.updateslot = OK;
120 }
121 if (bfaddr != 0) {
122 - /*
123 - * Stop any current dma and put the new frame(s) on the queue.
124 - * This should never fail since we check above that no frames
125 - * are still pending on the queue.
126 - */
127 - if (!ath9k_hw_stoptxdma(ah, sc->beacon.beaconq)) {
128 - ath_err(common, "beacon queue %u did not stop?\n",
129 - sc->beacon.beaconq);
130 - }
131 -
132 /* NB: cabq traffic should already be queued and primed */
133 ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bfaddr);
134 ath9k_hw_txstart(ah, sc->beacon.beaconq);
135 @@ -780,7 +771,7 @@ void ath9k_set_beaconing_status(struct a
136 ah->imask &= ~ATH9K_INT_SWBA;
137 ath9k_hw_set_interrupts(ah, ah->imask);
138 tasklet_kill(&sc->bcon_tasklet);
139 - ath9k_hw_stoptxdma(ah, sc->beacon.beaconq);
140 + ath9k_hw_stop_dma_queue(ah, sc->beacon.beaconq);
141 }
142 ath9k_ps_restore(sc);
143 }