From: Lorenzo Bianconi Date: Sun, 15 Mar 2026 10:26:24 +0000 (+0100) Subject: wifi: mt76: mt7996: Rely on msta_link link_id in mt7996_vif_link_remove() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=76ceccd60bdd1e496e0e70700f3e045d7bc339bf;p=thirdparty%2Fkernel%2Flinux.git wifi: mt76: mt7996: Rely on msta_link link_id in mt7996_vif_link_remove() Rely on msta_link link_id value in mt7996_vif_link_remove routine instead of using link_conf pointer. This assumption is correct since msta_link link_id is set to link_conf link_id value in mt7996_vif_link_add routine. Moreover, fallback to default ieee80211_bss_conf struct if the link_conf pointer in mt7996_vif_link_remove() is NULL. MT7996 hw requires to remove AP MLD links from MCU configuration during AP tear-down process (e.g. running mt7996_remove_interface()). Doing so, we can't assume link_conf pointer is always non-NULL running mt7996_vif_link_remove routine. Signed-off-by: Lorenzo Bianconi Link: https://patch.msgid.link/20260315-mt7996-mlo-link-reconf-v1-1-a8a634fbc927@kernel.org Signed-off-by: Felix Fietkau --- diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c index 834edd31458d5..21a240f0c8c27 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c @@ -396,17 +396,21 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif, struct mt7996_vif_link *link = container_of(mlink, struct mt7996_vif_link, mt76); struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; struct mt7996_sta_link *msta_link = &link->msta_link; + unsigned int link_id = msta_link->wcid.link_id; struct mt7996_phy *phy = mphy->priv; struct mt7996_dev *dev = phy->dev; struct mt7996_key_iter_data it = { .cmd = SET_KEY, - .link_id = link_conf->link_id, + .link_id = link_id, }; int idx = msta_link->wcid.idx; if (!mlink->wcid->offchannel) ieee80211_iter_keys(mphy->hw, vif, mt7996_key_iter, &it); + if (!link_conf) + link_conf = &vif->bss_conf; + mt7996_mcu_add_sta(dev, link_conf, NULL, link, NULL, CONN_STATE_DISCONNECT, false); mt7996_mcu_add_bss_info(phy, vif, link_conf, mlink, msta_link, false); @@ -416,10 +420,9 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif, rcu_assign_pointer(dev->mt76.wcid[idx], NULL); if (vif->txq && !mlink->wcid->offchannel && - mvif->mt76.deflink_id == link_conf->link_id) { + mvif->mt76.deflink_id == link_id) { struct ieee80211_bss_conf *iter; struct mt76_txq *mtxq; - unsigned int link_id; mvif->mt76.deflink_id = IEEE80211_LINK_UNSPECIFIED; mtxq = (struct mt76_txq *)vif->txq->drv_priv; @@ -427,7 +430,7 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif, for_each_vif_active_link(vif, iter, link_id) { struct mt7996_vif_link *link; - if (link_id == link_conf->link_id) + if (link_id == msta_link->wcid.link_id) continue; link = mt7996_vif_link(dev, vif, link_id);