ath9k: fix a DMA related race condition at hw reset time
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 520-ath9k_reset_fix.patch
1 --- a/drivers/net/wireless/ath/ath9k/xmit.c
2 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
3 @@ -1172,7 +1172,7 @@ void ath_draintxq(struct ath_softc *sc,
4 }
5 }
6
7 -void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
8 +bool ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
9 {
10 struct ath_hw *ah = sc->sc_ah;
11 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
12 @@ -1180,7 +1180,7 @@ void ath_drain_all_txq(struct ath_softc
13 int i, npend = 0;
14
15 if (sc->sc_flags & SC_OP_INVALID)
16 - return;
17 + return true;
18
19 /* Stop beacon queue */
20 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
21 @@ -1194,23 +1194,15 @@ void ath_drain_all_txq(struct ath_softc
22 }
23 }
24
25 - if (npend) {
26 - int r;
27 -
28 - ath_print(common, ATH_DBG_FATAL,
29 - "Failed to stop TX DMA. Resetting hardware!\n");
30 -
31 - r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false);
32 - if (r)
33 - ath_print(common, ATH_DBG_FATAL,
34 - "Unable to reset hardware; reset status %d\n",
35 - r);
36 - }
37 + if (npend)
38 + ath_print(common, ATH_DBG_FATAL, "Failed to stop TX DMA!\n");
39
40 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
41 if (ATH_TXQ_SETUP(sc, i))
42 ath_draintxq(sc, &sc->tx.txq[i], retry_tx);
43 }
44 +
45 + return !npend;
46 }
47
48 void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq)
49 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
50 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
51 @@ -311,7 +311,7 @@ void ath_rx_cleanup(struct ath_softc *sc
52 int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp);
53 struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype);
54 void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq);
55 -void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx);
56 +bool ath_drain_all_txq(struct ath_softc *sc, bool retry_tx);
57 void ath_draintxq(struct ath_softc *sc,
58 struct ath_txq *txq, bool retry_tx);
59 void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
60 --- a/drivers/net/wireless/ath/ath9k/main.c
61 +++ b/drivers/net/wireless/ath/ath9k/main.c
62 @@ -246,9 +246,10 @@ int ath_set_channel(struct ath_softc *sc
63 * the relevant bits of the h/w.
64 */
65 ath9k_hw_disable_interrupts(ah);
66 - ath_drain_all_txq(sc, false);
67 + stopped = ath_drain_all_txq(sc, false);
68
69 - stopped = ath_stoprecv(sc);
70 + if (!ath_stoprecv(sc))
71 + stopped = false;
72
73 /* XXX: do not flush receive queue here. We don't want
74 * to flush data frames already in queue because of