Skip to content

Commit debd133

Browse files
jmberg-intelnbd168
authored andcommitted
wifi: mt76: use atomic iface iteration for pre-TBTT work
In addition to the previous series I posted, over time I'd also like to get rid of the iflist_mtx in mac80211. That isn't easy now since lots of places use iteration and would have to be audited, but even a cursory look suggests that mt76 might be more problematic than most since holding the wiphy lock for the latency-sensitive pre-TBTT work could be an issue. Convert the pre-TBTT work to use atomic iteration and then sending the device commands outside of it. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
1 parent c2fcc83 commit debd133

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ EXPORT_SYMBOL_GPL(mt76x02_resync_beacon_timer);
136136
void
137137
mt76x02_update_beacon_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
138138
{
139-
struct mt76x02_dev *dev = (struct mt76x02_dev *)priv;
139+
struct beacon_bc_data *data = priv;
140+
struct mt76x02_dev *dev = data->dev;
140141
struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
141142
struct sk_buff *skb = NULL;
142143

@@ -147,7 +148,7 @@ mt76x02_update_beacon_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
147148
if (!skb)
148149
return;
149150

150-
mt76x02_mac_set_beacon(dev, skb);
151+
__skb_queue_tail(&data->q, skb);
151152
}
152153
EXPORT_SYMBOL_GPL(mt76x02_update_beacon_iter);
153154

@@ -182,9 +183,6 @@ mt76x02_enqueue_buffered_bc(struct mt76x02_dev *dev,
182183
{
183184
int i, nframes;
184185

185-
data->dev = dev;
186-
__skb_queue_head_init(&data->q);
187-
188186
do {
189187
nframes = skb_queue_len(&data->q);
190188
ieee80211_iterate_active_interfaces_atomic(mt76_hw(dev),

drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ static void mt76x02_pre_tbtt_tasklet(struct tasklet_struct *t)
1616
struct mt76x02_dev *dev = from_tasklet(dev, t, mt76.pre_tbtt_tasklet);
1717
struct mt76_dev *mdev = &dev->mt76;
1818
struct mt76_queue *q = dev->mphy.q_tx[MT_TXQ_PSD];
19-
struct beacon_bc_data data = {};
19+
struct beacon_bc_data data = {
20+
.dev = dev,
21+
};
2022
struct sk_buff *skb;
2123
int i;
2224

2325
if (mt76_hw(dev)->conf.flags & IEEE80211_CONF_OFFCHANNEL)
2426
return;
2527

28+
__skb_queue_head_init(&data.q);
29+
2630
mt76x02_resync_beacon_timer(dev);
2731

2832
/* Prevent corrupt transmissions during update */
@@ -31,7 +35,10 @@ static void mt76x02_pre_tbtt_tasklet(struct tasklet_struct *t)
3135

3236
ieee80211_iterate_active_interfaces_atomic(mt76_hw(dev),
3337
IEEE80211_IFACE_ITER_RESUME_ALL,
34-
mt76x02_update_beacon_iter, dev);
38+
mt76x02_update_beacon_iter, &data);
39+
40+
while ((skb = __skb_dequeue(&data.q)) != NULL)
41+
mt76x02_mac_set_beacon(dev, skb);
3542

3643
mt76_wr(dev, MT_BCN_BYPASS_MASK,
3744
0xff00 | ~(0xff00 >> dev->beacon_data_count));

drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ static void mt76x02u_pre_tbtt_work(struct work_struct *work)
182182
{
183183
struct mt76x02_dev *dev =
184184
container_of(work, struct mt76x02_dev, pre_tbtt_work);
185-
struct beacon_bc_data data = {};
185+
struct beacon_bc_data data = {
186+
.dev = dev,
187+
};
186188
struct sk_buff *skb;
187189
int nbeacons;
188190

@@ -192,15 +194,20 @@ static void mt76x02u_pre_tbtt_work(struct work_struct *work)
192194
if (mt76_hw(dev)->conf.flags & IEEE80211_CONF_OFFCHANNEL)
193195
return;
194196

197+
__skb_queue_head_init(&data.q);
198+
195199
mt76x02_resync_beacon_timer(dev);
196200

197201
/* Prevent corrupt transmissions during update */
198202
mt76_set(dev, MT_BCN_BYPASS_MASK, 0xffff);
199203
dev->beacon_data_count = 0;
200204

201-
ieee80211_iterate_active_interfaces(mt76_hw(dev),
205+
ieee80211_iterate_active_interfaces_atomic(mt76_hw(dev),
202206
IEEE80211_IFACE_ITER_RESUME_ALL,
203-
mt76x02_update_beacon_iter, dev);
207+
mt76x02_update_beacon_iter, &data);
208+
209+
while ((skb = __skb_dequeue(&data.q)) != NULL)
210+
mt76x02_mac_set_beacon(dev, skb);
204211

205212
mt76_csa_check(&dev->mt76);
206213

0 commit comments

Comments
 (0)