Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH mt76-next 01/20] wifi: mt76: mt7925: undo the BSS of a failed interface add
@ 2026-11-23 13:49 Felix Fietkau
  2026-11-23 13:49 ` [PATCH mt76-next 02/20] wifi: mt76: mt7925: keep the embedded link's BMC wcid after a failed add Felix Fietkau
                   ` (18 more replies)
  0 siblings, 19 replies; 21+ messages in thread
From: Felix Fietkau @ 2026-11-23 13:49 UTC (permalink / raw)
  To: linux-wireless

mt7925_mac_link_bss_add() publishes the wcid of the interface and takes
its vif_mask and omac_mask bits before it sends the firmware command,
and it undoes that setup for an allocated link alone. When the command
fails in mt7925_add_interface(), mac80211 calls no remove_interface, so
dev->mt76.wcid[] keeps naming the wcid inside vif->drv_priv, which
mac80211 frees with the interface, and the BSS index stays taken.

Undo the setup of the BSS in mt7925_add_interface() when the add
published its wcid. A failure before that point sets nothing up, and
the index it computed can belong to a P2P device. The add itself still
leaves the BSS of the embedded link set up for
mt7925_change_vif_links(), because the next association or
mt7925_remove_interface() removes that BSS later.

Fixes: ac03e5b82bc6 ("wifi: mt76: mt7925: Enhance mt7925_mac_link_bss_add to support MLO")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 .../net/wireless/mediatek/mt76/mt7925/main.c  | 27 ++++++++++++++-----
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index d99d86bf5be8..0908c22c3dff 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -376,6 +376,16 @@ static int mt7925_start(struct ieee80211_hw *hw)
 	return err;
 }
 
+static void mt7925_mac_link_bss_unwind(struct mt792x_dev *dev,
+				       struct mt792x_bss_conf *mconf,
+				       struct mt792x_link_sta *mlink)
+{
+	rcu_assign_pointer(dev->mt76.wcid[mlink->wcid.idx], NULL);
+	mt76_wcid_cleanup(&dev->mt76, &mlink->wcid);
+	dev->mt76.vif_mask &= ~BIT_ULL(mconf->mt76.idx);
+	mconf->vif->phy->omac_mask &= ~BIT_ULL(mconf->mt76.omac_idx);
+}
+
 static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,
 				   struct ieee80211_bss_conf *link_conf,
 				   struct mt792x_link_sta *mlink)
@@ -449,12 +459,8 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,
 	ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, link_conf, &mconf->mt76,
 					  &mlink->wcid, true);
 	if (ret) {
-		if (mconf != &mvif->bss_conf) {
-			rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
-			mt76_wcid_cleanup(&dev->mt76, &mlink->wcid);
-			dev->mt76.vif_mask &= ~BIT_ULL(mconf->mt76.idx);
-			mvif->phy->omac_mask &= ~BIT_ULL(mconf->mt76.omac_idx);
-		}
+		if (mconf != &mvif->bss_conf)
+			mt7925_mac_link_bss_unwind(dev, mconf, mlink);
 		mt7925_p2p_bmc_remove(dev, mconf);
 		goto out;
 	}
@@ -496,8 +502,15 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 	mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC;
 
 	ret = mt7925_mac_link_bss_add(dev, &vif->bss_conf, &mvif->sta.deflink);
-	if (ret < 0)
+	if (ret < 0) {
+		struct mt76_wcid *wcid = &mvif->sta.deflink.wcid;
+
+		/* mac80211 calls no remove_interface after a failed add */
+		if (rcu_access_pointer(dev->mt76.wcid[wcid->idx]) == wcid)
+			mt7925_mac_link_bss_unwind(dev, &mvif->bss_conf,
+						   &mvif->sta.deflink);
 		goto out;
+	}
 
 	vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
 	if (phy->chip_cap & MT792x_CHIP_CAP_RSSI_NOTIFY_EVT_EN)
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2026-11-23 15:30 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 13:49 [PATCH mt76-next 01/20] wifi: mt76: mt7925: undo the BSS of a failed interface add Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 02/20] wifi: mt76: mt7925: keep the embedded link's BMC wcid after a failed add Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 03/20] wifi: mt76: mt7915: read the PS sync state of mt7986 and mt7981 Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 04/20] wifi: mt76: mt7915: leave the BIP check of a group frame to mac80211 Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 05/20] wifi: mt76: mt7921: " Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 06/20] wifi: mt76: mt7925: " Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 07/20] wifi: mt76: mt7615: " Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 08/20] wifi: mt76: mt7925: use wcid_to_sta() in mt7925_mac_write_txwi_8023() Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 09/20] wifi: mt76: log the firmware status of a failed MCU command Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 10/20] wifi: mt76: mt7996: clear the ADM counters only in the airtime poll Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 11/20] wifi: mt76: mt7915: send mt7981 only the group units its firmware holds Felix Fietkau
2026-11-23 15:30   ` Zhi-Jun You
2026-11-23 13:49 ` [PATCH mt76-next 12/20] wifi: mt76: take the DFS state from the off-channel flag Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 13/20] wifi: mt76: read roc_phy and roc_link once without the mutex Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 14/20] wifi: mt76: mt7996: add only the active links of a station MLD's peer Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 15/20] wifi: mt76: mt7996: resume the radar TX stop at an operating channel set Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 16/20] wifi: mt76: mt7996: divide by the full TWT wake interval Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 17/20] wifi: mt76: mt7915: " Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 18/20] wifi: mt76: mt7996: send the SRG bitmaps in one block per band Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 19/20] wifi: mt76: connac: set the band of an RX block ack scoreboard reset Felix Fietkau
2026-11-23 13:49 ` [PATCH mt76-next 20/20] wifi: mt76: mt7915: reset the CCA statistics of band 1 on mt7916 Felix Fietkau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox