[PATCH 4/4] wifi: mt76: mt7925: unwind link restore failures

Jiale Yao yaojiale02 at 163.com
Tue Oct 27 22:03:37 PDT 2026


The reset recovery callback ignores failures while restoring each link in
firmware and continues configuring the link and remaining interface. A
failed two-command device addition can leave partial firmware state, while
links restored earlier in the loop remain active on a partially restored
interface.

Track every attempted link and remove their firmware state if any restore
operation fails. Stop configuring that interface after the failure.

Fixes: 14061994184d ("wifi: mt76: mt7925: add link handling in mt7925_vif_connect_iter")
Cc: stable at vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02 at 163.com>
---
 .../net/wireless/mediatek/mt76/mt7925/mac.c   | 26 ++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index 7af996abe294..7b29e147b19e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -1477,11 +1477,12 @@ mt7925_vif_connect_iter(void *priv, u8 *mac,
 	struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
 	unsigned long valid = ieee80211_vif_is_mld(vif) ?
 			      mvif->valid_links : BIT(0);
+	unsigned long restored = 0;
 	struct mt792x_dev *dev = mvif->phy->dev;
 	struct ieee80211_hw *hw = mt76_hw(dev);
 	struct ieee80211_bss_conf *bss_conf;
 	struct mt792x_bss_conf *mconf;
-	int i;
+	int i, ret;
 
 	if (vif->type == NL80211_IFTYPE_STATION)
 		ieee80211_disconnect(vif, true);
@@ -1493,8 +1494,13 @@ mt7925_vif_connect_iter(void *priv, u8 *mac,
 
 		mconf = mt792x_vif_to_link(mvif, i);
 
-		mt76_connac_mcu_uni_add_dev(&dev->mphy, bss_conf, &mconf->mt76,
-					    &mvif->sta.deflink.wcid, true);
+		restored |= BIT(i);
+		ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, bss_conf,
+						  &mconf->mt76,
+						 &mvif->sta.deflink.wcid, true);
+		if (ret)
+			goto rollback;
+
 		mt7925_mcu_set_tx(dev, bss_conf);
 	}
 
@@ -1506,6 +1512,20 @@ mt7925_vif_connect_iter(void *priv, u8 *mac,
 				      MT76_STA_INFO_STATE_NONE, NULL);
 		mt7925_mcu_uni_add_beacon_offload(dev, hw, vif, true);
 	}
+
+	return;
+
+rollback:
+	dev_err(dev->mt76.dev, "failed to restore link after reset: %d\n", ret);
+	for_each_set_bit(i, &restored, IEEE80211_MLD_MAX_NUM_LINKS) {
+		bss_conf = mt792x_vif_to_bss_conf(vif, i);
+		if (!bss_conf)
+			continue;
+
+		mconf = mt792x_vif_to_link(mvif, i);
+		mt76_connac_mcu_uni_add_dev(&dev->mphy, bss_conf, &mconf->mt76,
+					    &mvif->sta.deflink.wcid, false);
+	}
 }
 
 /* system error recovery */
-- 
2.34.1




More information about the Linux-mediatek mailing list