diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-05-18 15:28:15 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2013-05-22 14:28:44 -0400 |
commit | 08c96abd611beadf2af414a306fe0fb02ba706ff (patch) | |
tree | 2ee91910a79083004eacad4a05fe0699d4a7e534 /drivers/net/wireless/ath | |
parent | 323a98db4d51e4fefc74290adfb5493047cbbe22 (diff) |
ath9k: prevent aggregation session deadlocks
Waiting for all subframes of an existing aggregation session to drain
before allowing mac80211 to start a new one is fragile and deadlocks
caused by this behavior have been observed.
Since mac80211 has proper synchronization for aggregation session
start/stop handling, a better approach to session handling is to simply
allow mac80211 to start a new session at any time. This requires
changing the code to discard any packets outside of the BlockAck window
in the A-MPDU software retry code.
This patch implements the above and also simplifies the code.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/ath9k.h | 14 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/main.c | 3 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/rc.c | 5 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/xmit.c | 138 |
4 files changed, 46 insertions, 114 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 366002f266f8..42b03dc39d14 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h | |||
@@ -251,10 +251,9 @@ struct ath_atx_tid { | |||
251 | int tidno; | 251 | int tidno; |
252 | int baw_head; /* first un-acked tx buffer */ | 252 | int baw_head; /* first un-acked tx buffer */ |
253 | int baw_tail; /* next unused tx buffer slot */ | 253 | int baw_tail; /* next unused tx buffer slot */ |
254 | int sched; | 254 | bool sched; |
255 | int paused; | 255 | bool paused; |
256 | u8 state; | 256 | bool active; |
257 | bool stop_cb; | ||
258 | }; | 257 | }; |
259 | 258 | ||
260 | struct ath_node { | 259 | struct ath_node { |
@@ -275,10 +274,6 @@ struct ath_node { | |||
275 | #endif | 274 | #endif |
276 | }; | 275 | }; |
277 | 276 | ||
278 | #define AGGR_CLEANUP BIT(1) | ||
279 | #define AGGR_ADDBA_COMPLETE BIT(2) | ||
280 | #define AGGR_ADDBA_PROGRESS BIT(3) | ||
281 | |||
282 | struct ath_tx_control { | 277 | struct ath_tx_control { |
283 | struct ath_txq *txq; | 278 | struct ath_txq *txq; |
284 | struct ath_node *an; | 279 | struct ath_node *an; |
@@ -352,8 +347,7 @@ void ath_tx_tasklet(struct ath_softc *sc); | |||
352 | void ath_tx_edma_tasklet(struct ath_softc *sc); | 347 | void ath_tx_edma_tasklet(struct ath_softc *sc); |
353 | int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, | 348 | int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, |
354 | u16 tid, u16 *ssn); | 349 | u16 tid, u16 *ssn); |
355 | bool ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid, | 350 | void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid); |
356 | bool flush); | ||
357 | void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid); | 351 | void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid); |
358 | 352 | ||
359 | void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an); | 353 | void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an); |
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 2382d1262e7f..5092ecae7706 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c | |||
@@ -1709,7 +1709,8 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw, | |||
1709 | flush = true; | 1709 | flush = true; |
1710 | case IEEE80211_AMPDU_TX_STOP_CONT: | 1710 | case IEEE80211_AMPDU_TX_STOP_CONT: |
1711 | ath9k_ps_wakeup(sc); | 1711 | ath9k_ps_wakeup(sc); |
1712 | if (ath_tx_aggr_stop(sc, sta, tid, flush)) | 1712 | ath_tx_aggr_stop(sc, sta, tid); |
1713 | if (!flush) | ||
1713 | ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); | 1714 | ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); |
1714 | ath9k_ps_restore(sc); | 1715 | ath9k_ps_restore(sc); |
1715 | break; | 1716 | break; |
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c index aa4d368d8d3d..7eb1f4b458e4 100644 --- a/drivers/net/wireless/ath/ath9k/rc.c +++ b/drivers/net/wireless/ath/ath9k/rc.c | |||
@@ -1227,10 +1227,7 @@ static bool ath_tx_aggr_check(struct ath_softc *sc, struct ieee80211_sta *sta, | |||
1227 | return false; | 1227 | return false; |
1228 | 1228 | ||
1229 | txtid = ATH_AN_2_TID(an, tidno); | 1229 | txtid = ATH_AN_2_TID(an, tidno); |
1230 | 1230 | return !txtid->active; | |
1231 | if (!(txtid->state & (AGGR_ADDBA_COMPLETE | AGGR_ADDBA_PROGRESS))) | ||
1232 | return true; | ||
1233 | return false; | ||
1234 | } | 1231 | } |
1235 | 1232 | ||
1236 | 1233 | ||
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 14bb3354ea64..1c9b1bac8b0d 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c | |||
@@ -125,24 +125,6 @@ static void ath_tx_queue_tid(struct ath_txq *txq, struct ath_atx_tid *tid) | |||
125 | list_add_tail(&ac->list, &txq->axq_acq); | 125 | list_add_tail(&ac->list, &txq->axq_acq); |
126 | } | 126 | } |
127 | 127 | ||
128 | static void ath_tx_resume_tid(struct ath_softc *sc, struct ath_atx_tid *tid) | ||
129 | { | ||
130 | struct ath_txq *txq = tid->ac->txq; | ||
131 | |||
132 | WARN_ON(!tid->paused); | ||
133 | |||
134 | ath_txq_lock(sc, txq); | ||
135 | tid->paused = false; | ||
136 | |||
137 | if (skb_queue_empty(&tid->buf_q)) | ||
138 | goto unlock; | ||
139 | |||
140 | ath_tx_queue_tid(txq, tid); | ||
141 | ath_txq_schedule(sc, txq); | ||
142 | unlock: | ||
143 | ath_txq_unlock_complete(sc, txq); | ||
144 | } | ||
145 | |||
146 | static struct ath_frame_info *get_frame_info(struct sk_buff *skb) | 128 | static struct ath_frame_info *get_frame_info(struct sk_buff *skb) |
147 | { | 129 | { |
148 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); | 130 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
@@ -164,20 +146,7 @@ static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta, | |||
164 | ARRAY_SIZE(bf->rates)); | 146 | ARRAY_SIZE(bf->rates)); |
165 | } | 147 | } |
166 | 148 | ||
167 | static void ath_tx_clear_tid(struct ath_softc *sc, struct ath_atx_tid *tid) | 149 | static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) |
168 | { | ||
169 | tid->state &= ~AGGR_ADDBA_COMPLETE; | ||
170 | tid->state &= ~AGGR_CLEANUP; | ||
171 | if (!tid->stop_cb) | ||
172 | return; | ||
173 | |||
174 | ieee80211_start_tx_ba_cb_irqsafe(tid->an->vif, tid->an->sta->addr, | ||
175 | tid->tidno); | ||
176 | tid->stop_cb = false; | ||
177 | } | ||
178 | |||
179 | static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid, | ||
180 | bool flush_packets) | ||
181 | { | 150 | { |
182 | struct ath_txq *txq = tid->ac->txq; | 151 | struct ath_txq *txq = tid->ac->txq; |
183 | struct sk_buff *skb; | 152 | struct sk_buff *skb; |
@@ -194,15 +163,16 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid, | |||
194 | while ((skb = __skb_dequeue(&tid->buf_q))) { | 163 | while ((skb = __skb_dequeue(&tid->buf_q))) { |
195 | fi = get_frame_info(skb); | 164 | fi = get_frame_info(skb); |
196 | bf = fi->bf; | 165 | bf = fi->bf; |
197 | if (!bf && !flush_packets) | ||
198 | bf = ath_tx_setup_buffer(sc, txq, tid, skb); | ||
199 | 166 | ||
200 | if (!bf) { | 167 | if (!bf) { |
201 | ieee80211_free_txskb(sc->hw, skb); | 168 | bf = ath_tx_setup_buffer(sc, txq, tid, skb); |
202 | continue; | 169 | if (!bf) { |
170 | ieee80211_free_txskb(sc->hw, skb); | ||
171 | continue; | ||
172 | } | ||
203 | } | 173 | } |
204 | 174 | ||
205 | if (fi->retries || flush_packets) { | 175 | if (fi->retries) { |
206 | list_add_tail(&bf->list, &bf_head); | 176 | list_add_tail(&bf->list, &bf_head); |
207 | ath_tx_update_baw(sc, tid, bf->bf_state.seqno); | 177 | ath_tx_update_baw(sc, tid, bf->bf_state.seqno); |
208 | ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); | 178 | ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); |
@@ -213,10 +183,7 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid, | |||
213 | } | 183 | } |
214 | } | 184 | } |
215 | 185 | ||
216 | if (tid->baw_head == tid->baw_tail) | 186 | if (sendbar) { |
217 | ath_tx_clear_tid(sc, tid); | ||
218 | |||
219 | if (sendbar && !flush_packets) { | ||
220 | ath_txq_unlock(sc, txq); | 187 | ath_txq_unlock(sc, txq); |
221 | ath_send_bar(tid, tid->seq_start); | 188 | ath_send_bar(tid, tid->seq_start); |
222 | ath_txq_lock(sc, txq); | 189 | ath_txq_lock(sc, txq); |
@@ -499,19 +466,19 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
499 | tx_info = IEEE80211_SKB_CB(skb); | 466 | tx_info = IEEE80211_SKB_CB(skb); |
500 | fi = get_frame_info(skb); | 467 | fi = get_frame_info(skb); |
501 | 468 | ||
502 | if (ATH_BA_ISSET(ba, ATH_BA_INDEX(seq_st, seqno))) { | 469 | if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) { |
470 | /* | ||
471 | * Outside of the current BlockAck window, | ||
472 | * maybe part of a previous session | ||
473 | */ | ||
474 | txfail = 1; | ||
475 | } else if (ATH_BA_ISSET(ba, ATH_BA_INDEX(seq_st, seqno))) { | ||
503 | /* transmit completion, subframe is | 476 | /* transmit completion, subframe is |
504 | * acked by block ack */ | 477 | * acked by block ack */ |
505 | acked_cnt++; | 478 | acked_cnt++; |
506 | } else if (!isaggr && txok) { | 479 | } else if (!isaggr && txok) { |
507 | /* transmit completion */ | 480 | /* transmit completion */ |
508 | acked_cnt++; | 481 | acked_cnt++; |
509 | } else if (tid->state & AGGR_CLEANUP) { | ||
510 | /* | ||
511 | * cleanup in progress, just fail | ||
512 | * the un-acked sub-frames | ||
513 | */ | ||
514 | txfail = 1; | ||
515 | } else if (flush) { | 482 | } else if (flush) { |
516 | txpending = 1; | 483 | txpending = 1; |
517 | } else if (fi->retries < ATH_MAX_SW_RETRIES) { | 484 | } else if (fi->retries < ATH_MAX_SW_RETRIES) { |
@@ -535,7 +502,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
535 | if (bf_next != NULL || !bf_last->bf_stale) | 502 | if (bf_next != NULL || !bf_last->bf_stale) |
536 | list_move_tail(&bf->list, &bf_head); | 503 | list_move_tail(&bf->list, &bf_head); |
537 | 504 | ||
538 | if (!txpending || (tid->state & AGGR_CLEANUP)) { | 505 | if (!txpending) { |
539 | /* | 506 | /* |
540 | * complete the acked-ones/xretried ones; update | 507 | * complete the acked-ones/xretried ones; update |
541 | * block-ack window | 508 | * block-ack window |
@@ -609,9 +576,6 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
609 | ath_txq_lock(sc, txq); | 576 | ath_txq_lock(sc, txq); |
610 | } | 577 | } |
611 | 578 | ||
612 | if (tid->state & AGGR_CLEANUP) | ||
613 | ath_tx_flush_tid(sc, tid, false); | ||
614 | |||
615 | rcu_read_unlock(); | 579 | rcu_read_unlock(); |
616 | 580 | ||
617 | if (needreset) | 581 | if (needreset) |
@@ -1244,9 +1208,6 @@ int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, | |||
1244 | an = (struct ath_node *)sta->drv_priv; | 1208 | an = (struct ath_node *)sta->drv_priv; |
1245 | txtid = ATH_AN_2_TID(an, tid); | 1209 | txtid = ATH_AN_2_TID(an, tid); |
1246 | 1210 | ||
1247 | if (txtid->state & (AGGR_CLEANUP | AGGR_ADDBA_COMPLETE)) | ||
1248 | return -EAGAIN; | ||
1249 | |||
1250 | /* update ampdu factor/density, they may have changed. This may happen | 1211 | /* update ampdu factor/density, they may have changed. This may happen |
1251 | * in HT IBSS when a beacon with HT-info is received after the station | 1212 | * in HT IBSS when a beacon with HT-info is received after the station |
1252 | * has already been added. | 1213 | * has already been added. |
@@ -1258,7 +1219,7 @@ int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, | |||
1258 | an->mpdudensity = density; | 1219 | an->mpdudensity = density; |
1259 | } | 1220 | } |
1260 | 1221 | ||
1261 | txtid->state |= AGGR_ADDBA_PROGRESS; | 1222 | txtid->active = true; |
1262 | txtid->paused = true; | 1223 | txtid->paused = true; |
1263 | *ssn = txtid->seq_start = txtid->seq_next; | 1224 | *ssn = txtid->seq_start = txtid->seq_next; |
1264 | txtid->bar_index = -1; | 1225 | txtid->bar_index = -1; |
@@ -1269,45 +1230,17 @@ int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, | |||
1269 | return 0; | 1230 | return 0; |
1270 | } | 1231 | } |
1271 | 1232 | ||
1272 | bool ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid, | 1233 | void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid) |
1273 | bool flush) | ||
1274 | { | 1234 | { |
1275 | struct ath_node *an = (struct ath_node *)sta->drv_priv; | 1235 | struct ath_node *an = (struct ath_node *)sta->drv_priv; |
1276 | struct ath_atx_tid *txtid = ATH_AN_2_TID(an, tid); | 1236 | struct ath_atx_tid *txtid = ATH_AN_2_TID(an, tid); |
1277 | struct ath_txq *txq = txtid->ac->txq; | 1237 | struct ath_txq *txq = txtid->ac->txq; |
1278 | bool ret = !flush; | ||
1279 | |||
1280 | if (flush) | ||
1281 | txtid->stop_cb = false; | ||
1282 | |||
1283 | if (txtid->state & AGGR_CLEANUP) | ||
1284 | return false; | ||
1285 | |||
1286 | if (!(txtid->state & AGGR_ADDBA_COMPLETE)) { | ||
1287 | txtid->state &= ~AGGR_ADDBA_PROGRESS; | ||
1288 | return ret; | ||
1289 | } | ||
1290 | 1238 | ||
1291 | ath_txq_lock(sc, txq); | 1239 | ath_txq_lock(sc, txq); |
1240 | txtid->active = false; | ||
1292 | txtid->paused = true; | 1241 | txtid->paused = true; |
1293 | 1242 | ath_tx_flush_tid(sc, txtid); | |
1294 | /* | ||
1295 | * If frames are still being transmitted for this TID, they will be | ||
1296 | * cleaned up during tx completion. To prevent race conditions, this | ||
1297 | * TID can only be reused after all in-progress subframes have been | ||
1298 | * completed. | ||
1299 | */ | ||
1300 | if (txtid->baw_head != txtid->baw_tail) { | ||
1301 | txtid->state |= AGGR_CLEANUP; | ||
1302 | ret = false; | ||
1303 | txtid->stop_cb = !flush; | ||
1304 | } else { | ||
1305 | txtid->state &= ~AGGR_ADDBA_COMPLETE; | ||
1306 | } | ||
1307 | |||
1308 | ath_tx_flush_tid(sc, txtid, flush); | ||
1309 | ath_txq_unlock_complete(sc, txq); | 1243 | ath_txq_unlock_complete(sc, txq); |
1310 | return ret; | ||
1311 | } | 1244 | } |
1312 | 1245 | ||
1313 | void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc, | 1246 | void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc, |
@@ -1371,18 +1304,28 @@ void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an) | |||
1371 | } | 1304 | } |
1372 | } | 1305 | } |
1373 | 1306 | ||
1374 | void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid) | 1307 | void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta, |
1308 | u16 tidno) | ||
1375 | { | 1309 | { |
1376 | struct ath_atx_tid *txtid; | 1310 | struct ath_atx_tid *tid; |
1377 | struct ath_node *an; | 1311 | struct ath_node *an; |
1312 | struct ath_txq *txq; | ||
1378 | 1313 | ||
1379 | an = (struct ath_node *)sta->drv_priv; | 1314 | an = (struct ath_node *)sta->drv_priv; |
1315 | tid = ATH_AN_2_TID(an, tidno); | ||
1316 | txq = tid->ac->txq; | ||
1380 | 1317 | ||
1381 | txtid = ATH_AN_2_TID(an, tid); | 1318 | ath_txq_lock(sc, txq); |
1382 | txtid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor; | 1319 | |
1383 | txtid->state |= AGGR_ADDBA_COMPLETE; | 1320 | tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor; |
1384 | txtid->state &= ~AGGR_ADDBA_PROGRESS; | 1321 | tid->paused = false; |
1385 | ath_tx_resume_tid(sc, txtid); | 1322 | |
1323 | if (!skb_queue_empty(&tid->buf_q)) { | ||
1324 | ath_tx_queue_tid(txq, tid); | ||
1325 | ath_txq_schedule(sc, txq); | ||
1326 | } | ||
1327 | |||
1328 | ath_txq_unlock_complete(sc, txq); | ||
1386 | } | 1329 | } |
1387 | 1330 | ||
1388 | /********************/ | 1331 | /********************/ |
@@ -2431,13 +2374,10 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an) | |||
2431 | tid->baw_head = tid->baw_tail = 0; | 2374 | tid->baw_head = tid->baw_tail = 0; |
2432 | tid->sched = false; | 2375 | tid->sched = false; |
2433 | tid->paused = false; | 2376 | tid->paused = false; |
2434 | tid->state &= ~AGGR_CLEANUP; | 2377 | tid->active = false; |
2435 | __skb_queue_head_init(&tid->buf_q); | 2378 | __skb_queue_head_init(&tid->buf_q); |
2436 | acno = TID_TO_WME_AC(tidno); | 2379 | acno = TID_TO_WME_AC(tidno); |
2437 | tid->ac = &an->ac[acno]; | 2380 | tid->ac = &an->ac[acno]; |
2438 | tid->state &= ~AGGR_ADDBA_COMPLETE; | ||
2439 | tid->state &= ~AGGR_ADDBA_PROGRESS; | ||
2440 | tid->stop_cb = false; | ||
2441 | } | 2381 | } |
2442 | 2382 | ||
2443 | for (acno = 0, ac = &an->ac[acno]; | 2383 | for (acno = 0, ac = &an->ac[acno]; |
@@ -2474,7 +2414,7 @@ void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an) | |||
2474 | } | 2414 | } |
2475 | 2415 | ||
2476 | ath_tid_drain(sc, txq, tid); | 2416 | ath_tid_drain(sc, txq, tid); |
2477 | ath_tx_clear_tid(sc, tid); | 2417 | tid->active = false; |
2478 | 2418 | ||
2479 | ath_txq_unlock(sc, txq); | 2419 | ath_txq_unlock(sc, txq); |
2480 | } | 2420 | } |