Skip to content

Commit 445ea4e

Browse files
committed
mac80211: stop queues temporarily for flushing
Sometimes queues are flushed in the middle of operation, which can lead to driver issues. Stop queues temporarily, while flushing, to avoid transmitting new packets while they are being flushed. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 39ecc01 commit 445ea4e

8 files changed

Lines changed: 33 additions & 12 deletions

File tree

‎include/net/mac80211.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ struct device;
9393
* enum ieee80211_max_queues - maximum number of queues
9494
*
9595
* @IEEE80211_MAX_QUEUES: Maximum number of regular device queues.
96+
* @IEEE80211_MAX_QUEUE_MAP: bitmap with maximum queues set
9697
*/
9798
enum ieee80211_max_queues {
9899
IEEE80211_MAX_QUEUES = 16,
100+
IEEE80211_MAX_QUEUE_MAP = BIT(IEEE80211_MAX_QUEUES) - 1,
99101
};
100102

101103
#define IEEE80211_INVAL_HW_QUEUE 0xff

‎net/mac80211/ieee80211_i.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ enum queue_stop_reason {
809809
IEEE80211_QUEUE_STOP_REASON_SUSPEND,
810810
IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
811811
IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL,
812+
IEEE80211_QUEUE_STOP_REASON_FLUSH,
812813
};
813814

814815
#ifdef CONFIG_MAC80211_LEDS
@@ -1522,8 +1523,10 @@ void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
15221523
struct ieee80211_hdr *hdr, bool ack);
15231524

15241525
void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
1526+
unsigned long queues,
15251527
enum queue_stop_reason reason);
15261528
void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
1529+
unsigned long queues,
15271530
enum queue_stop_reason reason);
15281531
void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
15291532
enum queue_stop_reason reason);

‎net/mac80211/main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ void ieee80211_restart_hw(struct ieee80211_hw *hw)
277277
"Hardware restart was requested\n");
278278

279279
/* use this reason, ieee80211_reconfig will unblock it */
280-
ieee80211_stop_queues_by_reason(hw,
281-
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
280+
ieee80211_stop_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP,
281+
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
282282

283283
/*
284284
* Stop all Rx during the reconfig. We don't want state changes

‎net/mac80211/mlme.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ static void ieee80211_chswitch_work(struct work_struct *work)
10091009

10101010
/* XXX: wait for a beacon first? */
10111011
ieee80211_wake_queues_by_reason(&sdata->local->hw,
1012+
IEEE80211_MAX_QUEUE_MAP,
10121013
IEEE80211_QUEUE_STOP_REASON_CSA);
10131014
out:
10141015
ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED;
@@ -1108,6 +1109,7 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
11081109

11091110
if (sw_elem->mode)
11101111
ieee80211_stop_queues_by_reason(&sdata->local->hw,
1112+
IEEE80211_MAX_QUEUE_MAP,
11111113
IEEE80211_QUEUE_STOP_REASON_CSA);
11121114

11131115
if (sdata->local->ops->channel_switch) {
@@ -1375,6 +1377,7 @@ void ieee80211_dynamic_ps_disable_work(struct work_struct *work)
13751377
}
13761378

13771379
ieee80211_wake_queues_by_reason(&local->hw,
1380+
IEEE80211_MAX_QUEUE_MAP,
13781381
IEEE80211_QUEUE_STOP_REASON_PS);
13791382
}
13801383

@@ -2071,6 +2074,7 @@ static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata)
20712074
true, frame_buf);
20722075
ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED;
20732076
ieee80211_wake_queues_by_reason(&sdata->local->hw,
2077+
IEEE80211_MAX_QUEUE_MAP,
20742078
IEEE80211_QUEUE_STOP_REASON_CSA);
20752079
mutex_unlock(&ifmgd->mtx);
20762080

‎net/mac80211/offchannel.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local)
118118
* Stop queues and transmit all frames queued by the driver
119119
* before sending nullfunc to enable powersave at the AP.
120120
*/
121-
ieee80211_stop_queues_by_reason(&local->hw,
121+
ieee80211_stop_queues_by_reason(&local->hw, IEEE80211_MAX_QUEUE_MAP,
122122
IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL);
123123
ieee80211_flush_queues(local, NULL);
124124

@@ -181,7 +181,7 @@ void ieee80211_offchannel_return(struct ieee80211_local *local)
181181
}
182182
mutex_unlock(&local->iflist_mtx);
183183

184-
ieee80211_wake_queues_by_reason(&local->hw,
184+
ieee80211_wake_queues_by_reason(&local->hw, IEEE80211_MAX_QUEUE_MAP,
185185
IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL);
186186
}
187187

‎net/mac80211/pm.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
3030
}
3131

3232
ieee80211_stop_queues_by_reason(hw,
33-
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
33+
IEEE80211_MAX_QUEUE_MAP,
34+
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
3435

3536
/* flush out all packets */
3637
synchronize_net();
@@ -68,6 +69,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
6869
mutex_unlock(&local->sta_mtx);
6970
}
7071
ieee80211_wake_queues_by_reason(hw,
72+
IEEE80211_MAX_QUEUE_MAP,
7173
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
7274
return err;
7375
} else if (err > 0) {

‎net/mac80211/tx.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ ieee80211_tx_h_dynamic_ps(struct ieee80211_tx_data *tx)
233233

234234
if (local->hw.conf.flags & IEEE80211_CONF_PS) {
235235
ieee80211_stop_queues_by_reason(&local->hw,
236+
IEEE80211_MAX_QUEUE_MAP,
236237
IEEE80211_QUEUE_STOP_REASON_PS);
237238
ifmgd->flags &= ~IEEE80211_STA_NULLFUNC_ACKED;
238239
ieee80211_queue_work(&local->hw,

‎net/mac80211/util.c‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -453,23 +453,24 @@ void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local,
453453
}
454454

455455
void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw,
456-
enum queue_stop_reason reason)
456+
unsigned long queues,
457+
enum queue_stop_reason reason)
457458
{
458459
struct ieee80211_local *local = hw_to_local(hw);
459460
unsigned long flags;
460461
int i;
461462

462463
spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
463464

464-
for (i = 0; i < hw->queues; i++)
465+
for_each_set_bit(i, &queues, hw->queues)
465466
__ieee80211_stop_queue(hw, i, reason);
466467

467468
spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
468469
}
469470

470471
void ieee80211_stop_queues(struct ieee80211_hw *hw)
471472
{
472-
ieee80211_stop_queues_by_reason(hw,
473+
ieee80211_stop_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP,
473474
IEEE80211_QUEUE_STOP_REASON_DRIVER);
474475
}
475476
EXPORT_SYMBOL(ieee80211_stop_queues);
@@ -491,6 +492,7 @@ int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue)
491492
EXPORT_SYMBOL(ieee80211_queue_stopped);
492493

493494
void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
495+
unsigned long queues,
494496
enum queue_stop_reason reason)
495497
{
496498
struct ieee80211_local *local = hw_to_local(hw);
@@ -499,15 +501,16 @@ void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
499501

500502
spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
501503

502-
for (i = 0; i < hw->queues; i++)
504+
for_each_set_bit(i, &queues, hw->queues)
503505
__ieee80211_wake_queue(hw, i, reason);
504506

505507
spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
506508
}
507509

508510
void ieee80211_wake_queues(struct ieee80211_hw *hw)
509511
{
510-
ieee80211_wake_queues_by_reason(hw, IEEE80211_QUEUE_STOP_REASON_DRIVER);
512+
ieee80211_wake_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP,
513+
IEEE80211_QUEUE_STOP_REASON_DRIVER);
511514
}
512515
EXPORT_SYMBOL(ieee80211_wake_queues);
513516

@@ -533,7 +536,13 @@ void ieee80211_flush_queues(struct ieee80211_local *local,
533536
queues = BIT(local->hw.queues) - 1;
534537
}
535538

539+
ieee80211_stop_queues_by_reason(&local->hw, IEEE80211_MAX_QUEUE_MAP,
540+
IEEE80211_QUEUE_STOP_REASON_FLUSH);
541+
536542
drv_flush(local, queues, false);
543+
544+
ieee80211_wake_queues_by_reason(&local->hw, IEEE80211_MAX_QUEUE_MAP,
545+
IEEE80211_QUEUE_STOP_REASON_FLUSH);
537546
}
538547

539548
void ieee80211_iterate_active_interfaces(
@@ -1676,8 +1685,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
16761685
mutex_unlock(&local->sta_mtx);
16771686
}
16781687

1679-
ieee80211_wake_queues_by_reason(hw,
1680-
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
1688+
ieee80211_wake_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP,
1689+
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
16811690

16821691
/*
16831692
* If this is for hw restart things are still running.

0 commit comments

Comments
 (0)