mt76: avoid extra RCU synchronization on station removal
authorFelix Fietkau <nbd@nbd.name>
Thu, 6 Feb 2020 17:30:08 +0000 (18:30 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 14 Feb 2020 09:06:09 +0000 (10:06 +0100)
Use sta_pre_rcu_remove callback to clear wcid pointer earlier

Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mac80211.c
drivers/net/wireless/mediatek/mt76/mt76.h
drivers/net/wireless/mediatek/mt76/mt7603/main.c
drivers/net/wireless/mediatek/mt76/mt7615/main.c
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c
drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c
drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c

index a9909debf9de79168a07d62bb02f31da52e6461c..4b19ac91ab720391a67e67c1fb0d024f7839d3f6 100644 (file)
@@ -984,9 +984,6 @@ void __mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif,
        struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
        int i, idx = wcid->idx;
 
-       rcu_assign_pointer(dev->wcid[idx], NULL);
-       synchronize_rcu();
-
        for (i = 0; i < ARRAY_SIZE(wcid->aggr); i++)
                mt76_rx_aggr_stop(dev, wcid, i);
 
@@ -1036,6 +1033,19 @@ int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 }
 EXPORT_SYMBOL_GPL(mt76_sta_state);
 
+void mt76_sta_pre_rcu_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+                            struct ieee80211_sta *sta)
+{
+       struct mt76_phy *phy = hw->priv;
+       struct mt76_dev *dev = phy->dev;
+       struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
+
+       mutex_lock(&dev->mutex);
+       rcu_assign_pointer(dev->wcid[wcid->idx], NULL);
+       mutex_unlock(&dev->mutex);
+}
+EXPORT_SYMBOL_GPL(mt76_sta_pre_rcu_remove);
+
 int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                     int *dbm)
 {
index 81f7df01307393132cdba64d34d6f602e92fba09..ca9d8ae43fecef016e711c7ba36eb41312dfa31a 100644 (file)
@@ -806,6 +806,8 @@ int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                   enum ieee80211_sta_state new_state);
 void __mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif,
                       struct ieee80211_sta *sta);
+void mt76_sta_pre_rcu_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+                            struct ieee80211_sta *sta);
 
 int mt76_get_min_avg_rssi(struct mt76_dev *dev, bool ext_phy);
 
index e5776d936c0a36479cf3aa2e2cdc161790924859..26cb711b465f38b6f078b52202ba40fca8a55017 100644 (file)
@@ -680,6 +680,7 @@ const struct ieee80211_ops mt7603_ops = {
        .configure_filter = mt7603_configure_filter,
        .bss_info_changed = mt7603_bss_info_changed,
        .sta_state = mt76_sta_state,
+       .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
        .set_key = mt7603_set_key,
        .conf_tx = mt7603_conf_tx,
        .sw_scan_start = mt76_sw_scan,
index 8a62d7d0c10416e53c2052a968a9572b7d9df5de..00176070937942108ce1b27548ff22ccbb39eabf 100644 (file)
@@ -712,6 +712,7 @@ const struct ieee80211_ops mt7615_ops = {
        .bss_info_changed = mt7615_bss_info_changed,
        .sta_add = mt7615_sta_add,
        .sta_remove = mt7615_sta_remove,
+       .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
        .set_key = mt7615_set_key,
        .ampdu_action = mt7615_ampdu_action,
        .set_rts_threshold = mt7615_set_rts_threshold,
index 88ff51400f8f2cb05a8f0042991d340161af228d..0b520ae08d018a65610b36bd2411ab7296e52373 100644 (file)
@@ -67,6 +67,7 @@ static const struct ieee80211_ops mt76x0e_ops = {
        .configure_filter = mt76x02_configure_filter,
        .bss_info_changed = mt76x02_bss_info_changed,
        .sta_state = mt76_sta_state,
+       .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
        .set_key = mt76x02_set_key,
        .conf_tx = mt76x02_conf_tx,
        .sw_scan_start = mt76_sw_scan,
index 747d21b3ee57c731466ed8dc2c20ee7c53ee9f55..5535b9c0632f427ab7cfb109fa46d99d8f9e8d33 100644 (file)
@@ -126,6 +126,7 @@ static const struct ieee80211_ops mt76x0u_ops = {
        .configure_filter = mt76x02_configure_filter,
        .bss_info_changed = mt76x02_bss_info_changed,
        .sta_state = mt76_sta_state,
+       .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
        .set_key = mt76x02_set_key,
        .conf_tx = mt76x02_conf_tx,
        .sw_scan_start = mt76_sw_scan,
index 93d56d7ce5db48304679914af493ff247f72194f..3d8bd61c5b4365da2cbba3bfbfbcc6d4c28160a0 100644 (file)
@@ -427,6 +427,8 @@ static void mt76x02_reset_state(struct mt76x02_dev *dev)
                if (!wcid)
                        continue;
 
+               rcu_assign_pointer(dev->mt76.wcid[i], NULL);
+
                priv = msta = container_of(wcid, struct mt76x02_sta, wcid);
                sta = container_of(priv, struct ieee80211_sta, drv_priv);
 
index dd336f54b8eea4817d11221567ae384b4c36306f..105e5b99b3f9b56ad1035d39bf980f7d0b0fd571 100644 (file)
@@ -145,6 +145,7 @@ const struct ieee80211_ops mt76x2_ops = {
        .configure_filter = mt76x02_configure_filter,
        .bss_info_changed = mt76x02_bss_info_changed,
        .sta_state = mt76_sta_state,
+       .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
        .set_key = mt76x02_set_key,
        .conf_tx = mt76x02_conf_tx,
        .sw_scan_start = mt76_sw_scan,
index 746f1a8304a6bde05fe25169dd3886b9913b23ba..bab4e6e1904ea2f4eadcdf13ae70ed224fea9c09 100644 (file)
@@ -105,6 +105,7 @@ const struct ieee80211_ops mt76x2u_ops = {
        .add_interface = mt76x02_add_interface,
        .remove_interface = mt76x02_remove_interface,
        .sta_state = mt76_sta_state,
+       .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
        .set_key = mt76x02_set_key,
        .ampdu_action = mt76x02_ampdu_action,
        .config = mt76x2u_config,