[PATCH 10/28] wifi: mt76: mt7925: reactivate the DEV before (re)connect, scan and off-channel

Emery Hsin emery.hsin at mediatek.com
Mon Nov 9 19:12:26 PST 2026


On disconnect the DEV is deactivated and firmware then drops the BSS
management frames, so a legacy reconnect, a scan or an off-channel
operation fails. Reactivate the DEV first through the gated helper.

The MLO to legacy switch fixed by commit 8f9e5807671e ("wifi: mt76:
mt7925: restore the legacy BSS after MLO teardown") is now covered by
this and the previous patch. Keep only a DEV deactivate on teardown for
a failed connection setup, and restore the legacy WMM index.

This is a preparation patch before the MT7925 MLO hybrid/EMLSR work.

Signed-off-by: Jacobs Wu <jacobs.wu at mediatek.com>
Signed-off-by: Emery Hsin <emery.hsin at mediatek.com>
---
 .../net/wireless/mediatek/mt76/mt7925/main.c  | 42 +++++++++++++------
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 4889d3bfe08d..702e4f01b0ed 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -699,6 +699,8 @@ static int mt7925_remain_on_channel(struct ieee80211_hw *hw,
 	int err;
 
 	mt792x_mutex_acquire(phy->dev);
+	mt792x_mcu_set_dev_active(phy->dev, &vif->bss_conf, &mvif->bss_conf,
+				  &mvif->sta.deflink.wcid, true);
 	err = mt7925_set_roc(phy, &mvif->bss_conf,
 			     chan, duration, MT7925_ROC_REQ_ROC);
 	mt792x_mutex_release(phy->dev);
@@ -1408,16 +1410,20 @@ static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev,
 
 		/* reset to auto band so the deactivate drops the band binding */
 		mconf->mt76.band_idx = MT792x_BAND_AUTO;
+		/* back to the legacy WMM index, MLO uses 0 */
+		mconf->mt76.wmm_idx = mconf->mt76.idx %
+				      MT76_CONNAC_MAX_WMM_SETS;
 
 		if (ieee80211_vif_is_mld(vif)) {
 			/* Sub-links are removed. The primary link is kept for
 			 * reconnect but deactivated in firmware.
 			 */
-			if (mconf != &mvif->bss_conf)
+			if (mconf != &mvif->bss_conf) {
 				mt792x_mac_link_bss_remove(dev, mconf, mlink);
-			else
+			} else {
 				mt792x_mcu_set_dev_active(dev, link_conf, mconf,
 							  &mlink->wcid, false);
+			}
 		} else {
 			/* deactivate DEV and BSS, re-activated on the next connect */
 			mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, link_conf,
@@ -1732,10 +1738,13 @@ mt7925_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	       struct ieee80211_scan_request *req)
 {
 	struct mt792x_dev *dev = mt792x_hw_dev(hw);
+	struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
 	struct mt76_phy *mphy = hw->priv;
 	int err;
 
 	mt792x_mutex_acquire(dev);
+	mt792x_mcu_set_dev_active(dev, &vif->bss_conf, &mvif->bss_conf,
+				  &mvif->sta.deflink.wcid, true);
 	err = mt7925_mcu_hw_scan(mphy, vif, req);
 	mt792x_mutex_release(dev);
 
@@ -1759,11 +1768,15 @@ mt7925_start_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			struct ieee80211_scan_ies *ies)
 {
 	struct mt792x_dev *dev = mt792x_hw_dev(hw);
+	struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
 	struct mt76_phy *mphy = hw->priv;
 	int err;
 
 	mt792x_mutex_acquire(dev);
 
+	mt792x_mcu_set_dev_active(dev, &vif->bss_conf, &mvif->bss_conf,
+				  &mvif->sta.deflink.wcid, true);
+
 	err = mt7925_mcu_sched_scan_req(mphy, vif, req, ies);
 	if (err < 0)
 		goto out;
@@ -2471,16 +2484,18 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 
 	mvif->valid_links = new_links;
 
-	/* Restore the legacy BSS after disabling MLO */
-	if (old_links && !new_links) {
-		mt792x_mac_link_bss_remove(dev, &mvif->bss_conf,
-					   &mvif->sta.deflink);
-		err = mt7925_mac_link_bss_add(dev, &vif->bss_conf,
-					      &mvif->sta.deflink);
-		if (err < 0) {
-			mt792x_mutex_release(dev);
-			return err;
-		}
+	/* The normal MLO to legacy switch is handled on the sta_remove path,
+	 * which deactivates the DEV and restores the legacy WMM index; the
+	 * next connect, scan or off-channel reactivates the DEV with the
+	 * legacy address. This only covers a failed connection setup in
+	 * ieee80211_prep_connection(), where the links are torn down without
+	 * a station removal.
+	 */
+	if (!new_links) {
+		mvif->bss_conf.mt76.wmm_idx = mvif->bss_conf.mt76.idx %
+					      MT76_CONNAC_MAX_WMM_SETS;
+		mt792x_mcu_set_dev_active(dev, &vif->bss_conf, &mvif->bss_conf,
+					  &mvif->sta.deflink.wcid, false);
 	}
 
 	mt792x_mutex_release(dev);
@@ -2579,6 +2594,9 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
 	} else {
 		mconf = &mvif->bss_conf;
 
+		mt792x_mcu_set_dev_active(dev, link_conf, mconf,
+					  &mvif->sta.deflink.wcid, true);
+
 		if (is_mt7927(&dev->mt76)) {
 			band_idx = mt7927_band_idx(ctx->def.chan->band);
 
-- 
2.45.2




More information about the Linux-mediatek mailing list