Since the link teardown moved to mt7996_remove_interface(), a station link stays in the firmware after its chanctx is unassigned. When the links of the vif go to 0, mt7996_change_vif_links() frees the MLD group and remap index in the driver, while the firmware BSS of each link still names them. The firmware has no MLD link removal for a station link, so the next vif that takes the same index shares it with a stale BSS until the station vif is removed. That removal then uses &vif->bss_conf instead of the link conf. Destroy the station links when the vif leaves MLO, with the link confs that mac80211 passes, and before the indexes are freed. mac80211 releases the chanctx of each removed link before it calls the driver, so all links of the vif are unassigned at this point. AP links are not affected: they leave their group at unassign through the MLD link operation. First abort a remain-on-channel that holds one of the destroyed links, since mt76_unassign_vif_chanctx() aborts only a scan and mac80211 ends a remain-on-channel only when the interface stops. Fixes: 08813703ac41 ("wifi: mt76: mt7996: Destroy vif active links in mt7996_remove_interface()") Co-developed-by: Shayne Chen Signed-off-by: Shayne Chen Signed-off-by: Felix Fietkau --- .../net/wireless/mediatek/mt76/mt7996/main.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c index cc8ce83f8b2d..1ca4d9e099fe 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c @@ -2995,6 +2995,26 @@ mt7996_net_setup_tc(struct ieee80211_hw *hw, struct ieee80211_vif *vif, } #endif +static void +mt7996_vif_link_roc_abort(struct mt7996_dev *dev, struct ieee80211_vif *vif) +{ + struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; + struct mt76_phy *phy = mvif->mt76.roc_phy; + struct mt76_vif_link *mlink; + bool abort; + + if (!phy) + return; + + mutex_lock(&dev->mt76.mutex); + mlink = phy->roc_link; + abort = phy->roc_vif == vif && mlink && !mlink->offchannel; + mutex_unlock(&dev->mt76.mutex); + + if (abort) + mt76_abort_roc(phy); +} + static int mt7996_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 old_links, u16 new_links, @@ -3002,8 +3022,15 @@ mt7996_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, { struct mt7996_dev *dev = mt7996_hw_dev(hw); struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; + bool sta_links_destroy; int ret = 0; + sta_links_destroy = !vif->valid_links && + vif->type == NL80211_IFTYPE_STATION; + /* a ROC can hold a station link that is destroyed below */ + if (sta_links_destroy) + mt7996_vif_link_roc_abort(dev, vif); + mutex_lock(&dev->mt76.mutex); if (!old_links) { @@ -3030,6 +3057,13 @@ mt7996_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, if (new_links) goto out; + /* the firmware supports no MLD link removal for a station link, so + * remove its BSS before the group and remap index can be reused + */ + if (sta_links_destroy) + mt7996_vif_links_destroy(dev, vif, mvif->mt76.valid_links, + old); + dev->mld_idx_mask &= ~BIT_ULL(mvif->mld_group_idx); dev->mld_remap_idx_mask &= ~BIT_ULL(mvif->mld_remap_idx); -- 2.47.3