diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-03-11 15:38:19 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-03-14 14:46:58 -0400 |
commit | 86271e460a66003dc1f4cbfd845adafb790b7587 (patch) | |
tree | aac8bd62df92a0a8975d0d1604cd9bb62a7c5f5a /drivers/net/wireless/ath/ath9k/main.c | |
parent | 0d51cccc2436fa4d978efc3764552779e163d840 (diff) |
ath9k: fix the .flush driver op implementation
This patch simplifies the flush op and reuses ath_drain_all_txq for
flushing out pending frames if necessary. It also uses a global timeout
of 200ms instead of the per-queue 60ms timeout.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/main.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/main.c | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 2e228aada1a9..115f162c617a 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c | |||
@@ -2128,56 +2128,42 @@ static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class) | |||
2128 | 2128 | ||
2129 | static void ath9k_flush(struct ieee80211_hw *hw, bool drop) | 2129 | static void ath9k_flush(struct ieee80211_hw *hw, bool drop) |
2130 | { | 2130 | { |
2131 | #define ATH_FLUSH_TIMEOUT 60 /* ms */ | ||
2132 | struct ath_softc *sc = hw->priv; | 2131 | struct ath_softc *sc = hw->priv; |
2133 | struct ath_txq *txq = NULL; | 2132 | int timeout = 200; /* ms */ |
2134 | struct ath_hw *ah = sc->sc_ah; | 2133 | int i, j; |
2135 | struct ath_common *common = ath9k_hw_common(ah); | ||
2136 | int i, j, npend = 0; | ||
2137 | 2134 | ||
2135 | ath9k_ps_wakeup(sc); | ||
2138 | mutex_lock(&sc->mutex); | 2136 | mutex_lock(&sc->mutex); |
2139 | 2137 | ||
2140 | cancel_delayed_work_sync(&sc->tx_complete_work); | 2138 | cancel_delayed_work_sync(&sc->tx_complete_work); |
2141 | 2139 | ||
2142 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) { | 2140 | if (drop) |
2143 | if (!ATH_TXQ_SETUP(sc, i)) | 2141 | timeout = 1; |
2144 | continue; | ||
2145 | txq = &sc->tx.txq[i]; | ||
2146 | 2142 | ||
2147 | if (!drop) { | 2143 | for (j = 0; j < timeout; j++) { |
2148 | for (j = 0; j < ATH_FLUSH_TIMEOUT; j++) { | 2144 | int npend = 0; |
2149 | if (!ath9k_has_pending_frames(sc, txq)) | 2145 | |
2150 | break; | 2146 | if (j) |
2151 | usleep_range(1000, 2000); | 2147 | usleep_range(1000, 2000); |
2152 | } | ||
2153 | } | ||
2154 | 2148 | ||
2155 | if (drop || ath9k_has_pending_frames(sc, txq)) { | 2149 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) { |
2156 | ath_dbg(common, ATH_DBG_QUEUE, "Drop frames from hw queue:%d\n", | 2150 | if (!ATH_TXQ_SETUP(sc, i)) |
2157 | txq->axq_qnum); | 2151 | continue; |
2158 | spin_lock_bh(&txq->axq_lock); | 2152 | |
2159 | txq->txq_flush_inprogress = true; | 2153 | npend += ath9k_has_pending_frames(sc, &sc->tx.txq[i]); |
2160 | spin_unlock_bh(&txq->axq_lock); | ||
2161 | |||
2162 | ath9k_ps_wakeup(sc); | ||
2163 | ath9k_hw_stoptxdma(ah, txq->axq_qnum); | ||
2164 | npend = ath9k_hw_numtxpending(ah, txq->axq_qnum); | ||
2165 | ath9k_ps_restore(sc); | ||
2166 | if (npend) | ||
2167 | break; | ||
2168 | |||
2169 | ath_draintxq(sc, txq, false); | ||
2170 | txq->txq_flush_inprogress = false; | ||
2171 | } | 2154 | } |
2155 | |||
2156 | if (!npend) | ||
2157 | goto out; | ||
2172 | } | 2158 | } |
2173 | 2159 | ||
2174 | if (npend) { | 2160 | if (!ath_drain_all_txq(sc, false)) |
2175 | ath_reset(sc, false); | 2161 | ath_reset(sc, false); |
2176 | txq->txq_flush_inprogress = false; | ||
2177 | } | ||
2178 | 2162 | ||
2163 | out: | ||
2179 | ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0); | 2164 | ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0); |
2180 | mutex_unlock(&sc->mutex); | 2165 | mutex_unlock(&sc->mutex); |
2166 | ath9k_ps_restore(sc); | ||
2181 | } | 2167 | } |
2182 | 2168 | ||
2183 | struct ieee80211_ops ath9k_ops = { | 2169 | struct ieee80211_ops ath9k_ops = { |