1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -429,6 +429,7 @@ void ath9k_set_beaconing_status(struct a
5 #define ATH_PAPRD_TIMEOUT 100 /* msecs */
7 +void ath_reset_work(struct work_struct *work);
8 void ath_hw_check(struct work_struct *work);
9 void ath_hw_pll_work(struct work_struct *work);
10 void ath_paprd_calibrate(struct work_struct *work);
11 @@ -609,6 +610,7 @@ struct ath_softc {
13 struct work_struct paprd_work;
14 struct work_struct hw_check_work;
15 + struct work_struct hw_reset_work;
16 struct completion paprd_complete;
18 unsigned int hw_busy_count;
19 @@ -655,7 +657,6 @@ struct ath_softc {
22 void ath9k_tasklet(unsigned long data);
23 -int ath_reset(struct ath_softc *sc, bool retry_tx);
24 int ath_cabq_update(struct ath_softc *);
26 static inline void ath_read_cachesize(struct ath_common *common, int *csz)
27 --- a/drivers/net/wireless/ath/ath9k/beacon.c
28 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
29 @@ -386,9 +386,7 @@ void ath_beacon_tasklet(unsigned long da
30 ath_dbg(common, ATH_DBG_BSTUCK,
31 "beacon is officially stuck\n");
32 sc->sc_flags |= SC_OP_TSF_RESET;
33 - spin_lock(&sc->sc_pcu_lock);
34 - ath_reset(sc, true);
35 - spin_unlock(&sc->sc_pcu_lock);
36 + ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
40 --- a/drivers/net/wireless/ath/ath9k/init.c
41 +++ b/drivers/net/wireless/ath/ath9k/init.c
42 @@ -776,6 +776,7 @@ int ath9k_init_device(u16 devid, struct
46 + INIT_WORK(&sc->hw_reset_work, ath_reset_work);
47 INIT_WORK(&sc->hw_check_work, ath_hw_check);
48 INIT_WORK(&sc->paprd_work, ath_paprd_calibrate);
49 INIT_DELAYED_WORK(&sc->hw_pll_work, ath_hw_pll_work);
50 --- a/drivers/net/wireless/ath/ath9k/main.c
51 +++ b/drivers/net/wireless/ath/ath9k/main.c
52 @@ -236,6 +236,7 @@ static int ath_set_channel(struct ath_so
53 del_timer_sync(&common->ani.timer);
54 cancel_work_sync(&sc->paprd_work);
55 cancel_work_sync(&sc->hw_check_work);
56 + cancel_work_sync(&sc->hw_reset_work);
57 cancel_delayed_work_sync(&sc->tx_complete_work);
58 cancel_delayed_work_sync(&sc->hw_pll_work);
60 @@ -595,74 +596,6 @@ static void ath_node_detach(struct ath_s
61 ath_tx_node_cleanup(sc, an);
64 -void ath_hw_check(struct work_struct *work)
66 - struct ath_softc *sc = container_of(work, struct ath_softc, hw_check_work);
67 - struct ath_common *common = ath9k_hw_common(sc->sc_ah);
68 - unsigned long flags;
71 - ath9k_ps_wakeup(sc);
72 - if (ath9k_hw_check_alive(sc->sc_ah))
75 - spin_lock_irqsave(&common->cc_lock, flags);
76 - busy = ath_update_survey_stats(sc);
77 - spin_unlock_irqrestore(&common->cc_lock, flags);
79 - ath_dbg(common, ATH_DBG_RESET, "Possible baseband hang, "
80 - "busy=%d (try %d)\n", busy, sc->hw_busy_count + 1);
82 - if (++sc->hw_busy_count >= 3) {
83 - spin_lock_bh(&sc->sc_pcu_lock);
84 - ath_reset(sc, true);
85 - spin_unlock_bh(&sc->sc_pcu_lock);
87 - } else if (busy >= 0)
88 - sc->hw_busy_count = 0;
91 - ath9k_ps_restore(sc);
94 -static void ath_hw_pll_rx_hang_check(struct ath_softc *sc, u32 pll_sqsum)
97 - struct ath_common *common = ath9k_hw_common(sc->sc_ah);
99 - if (pll_sqsum >= 0x40000) {
102 - /* Rx is hung for more than 500ms. Reset it */
103 - ath_dbg(common, ATH_DBG_RESET,
104 - "Possible RX hang, resetting");
105 - spin_lock_bh(&sc->sc_pcu_lock);
106 - ath_reset(sc, true);
107 - spin_unlock_bh(&sc->sc_pcu_lock);
114 -void ath_hw_pll_work(struct work_struct *work)
116 - struct ath_softc *sc = container_of(work, struct ath_softc,
120 - if (AR_SREV_9485(sc->sc_ah)) {
122 - ath9k_ps_wakeup(sc);
123 - pll_sqsum = ar9003_get_pll_sqsum_dvc(sc->sc_ah);
124 - ath9k_ps_restore(sc);
126 - ath_hw_pll_rx_hang_check(sc, pll_sqsum);
128 - ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, HZ/5);
133 void ath9k_tasklet(unsigned long data)
135 @@ -675,9 +608,7 @@ void ath9k_tasklet(unsigned long data)
137 if ((status & ATH9K_INT_FATAL) ||
138 (status & ATH9K_INT_BB_WATCHDOG)) {
139 - spin_lock(&sc->sc_pcu_lock);
140 - ath_reset(sc, true);
141 - spin_unlock(&sc->sc_pcu_lock);
142 + ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
146 @@ -968,7 +899,7 @@ void ath_radio_disable(struct ath_softc
147 ath9k_ps_restore(sc);
150 -int ath_reset(struct ath_softc *sc, bool retry_tx)
151 +static int ath_reset(struct ath_softc *sc, bool retry_tx)
153 struct ath_hw *ah = sc->sc_ah;
154 struct ath_common *common = ath9k_hw_common(ah);
155 @@ -1035,6 +966,84 @@ int ath_reset(struct ath_softc *sc, bool
159 +void ath_reset_work(struct work_struct *work)
161 + struct ath_softc *sc = container_of(work, struct ath_softc, hw_reset_work);
163 + spin_lock_bh(&sc->sc_pcu_lock);
164 + ath_reset(sc, true);
165 + spin_unlock_bh(&sc->sc_pcu_lock);
168 +void ath_hw_check(struct work_struct *work)
170 + struct ath_softc *sc = container_of(work, struct ath_softc, hw_check_work);
171 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
172 + unsigned long flags;
175 + ath9k_ps_wakeup(sc);
176 + if (ath9k_hw_check_alive(sc->sc_ah))
179 + spin_lock_irqsave(&common->cc_lock, flags);
180 + busy = ath_update_survey_stats(sc);
181 + spin_unlock_irqrestore(&common->cc_lock, flags);
183 + ath_dbg(common, ATH_DBG_RESET, "Possible baseband hang, "
184 + "busy=%d (try %d)\n", busy, sc->hw_busy_count + 1);
186 + if (++sc->hw_busy_count >= 3) {
187 + spin_lock_bh(&sc->sc_pcu_lock);
188 + ath_reset(sc, true);
189 + spin_unlock_bh(&sc->sc_pcu_lock);
192 + } else if (busy >= 0)
193 + sc->hw_busy_count = 0;
196 + ath9k_ps_restore(sc);
199 +static void ath_hw_pll_rx_hang_check(struct ath_softc *sc, u32 pll_sqsum)
202 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
204 + if (pll_sqsum >= 0x40000) {
207 + /* Rx is hung for more than 500ms. Reset it */
208 + ath_dbg(common, ATH_DBG_RESET,
209 + "Possible RX hang, resetting");
210 + spin_lock_bh(&sc->sc_pcu_lock);
211 + ath_reset(sc, true);
212 + spin_unlock_bh(&sc->sc_pcu_lock);
219 +void ath_hw_pll_work(struct work_struct *work)
221 + struct ath_softc *sc = container_of(work, struct ath_softc,
225 + if (AR_SREV_9485(sc->sc_ah)) {
227 + ath9k_ps_wakeup(sc);
228 + pll_sqsum = ar9003_get_pll_sqsum_dvc(sc->sc_ah);
229 + ath9k_ps_restore(sc);
231 + ath_hw_pll_rx_hang_check(sc, pll_sqsum);
233 + ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, HZ/5);
237 /**********************/
238 /* mac80211 callbacks */
239 /**********************/
240 @@ -1227,6 +1236,7 @@ static void ath9k_stop(struct ieee80211_
241 cancel_delayed_work_sync(&sc->hw_pll_work);
242 cancel_work_sync(&sc->paprd_work);
243 cancel_work_sync(&sc->hw_check_work);
244 + cancel_work_sync(&sc->hw_reset_work);
246 if (sc->sc_flags & SC_OP_INVALID) {
247 ath_dbg(common, ATH_DBG_ANY, "Device not present\n");
248 --- a/drivers/net/wireless/ath/ath9k/xmit.c
249 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
250 @@ -604,7 +604,7 @@ static void ath_tx_complete_aggr(struct
254 - ath_reset(sc, false);
255 + ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
258 static bool ath_lookup_legacy(struct ath_buf *bf)
259 @@ -1357,7 +1357,7 @@ void ath_txq_schedule(struct ath_softc *
260 struct ath_atx_ac *ac, *ac_tmp, *last_ac;
261 struct ath_atx_tid *tid, *last_tid;
263 - if (list_empty(&txq->axq_acq) ||
264 + if (work_pending(&sc->hw_reset_work) || list_empty(&txq->axq_acq) ||
265 txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
268 @@ -2184,6 +2184,9 @@ static void ath_tx_processq(struct ath_s
270 spin_lock_bh(&txq->axq_lock);
272 + if (work_pending(&sc->hw_reset_work))
275 if (list_empty(&txq->axq_q)) {
276 txq->axq_link = NULL;
277 if (sc->sc_flags & SC_OP_TXAGGR)
278 @@ -2271,9 +2274,7 @@ static void ath_tx_complete_poll_work(st
280 ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET,
281 "tx hung, resetting the chip\n");
282 - spin_lock_bh(&sc->sc_pcu_lock);
283 - ath_reset(sc, true);
284 - spin_unlock_bh(&sc->sc_pcu_lock);
285 + ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
288 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work,
289 @@ -2306,6 +2307,9 @@ void ath_tx_edma_tasklet(struct ath_soft
293 + if (work_pending(&sc->hw_reset_work))
296 status = ath9k_hw_txprocdesc(ah, NULL, (void *)&ts);
297 if (status == -EINPROGRESS)