From: Sean Wang <sean.wang@kernel.org>
To: nbd@nbd.name, lorenzo.bianconi@redhat.com
Cc: linux-wireless@vger.kernel.org,
linux-mediatek@lists.infradead.org,
Sean Wang <sean.wang@mediatek.com>
Subject: [PATCH 14/19] wifi: mt76: mt7925: unwind WCID setup on link STA add failure
Date: Fri, 6 Mar 2026 17:22:33 -0600 [thread overview]
Message-ID: <20260306232238.2039675-15-sean.wang@kernel.org> (raw)
In-Reply-To: <20260306232238.2039675-1-sean.wang@kernel.org>
From: Sean Wang <sean.wang@mediatek.com>
Undo the published WCID state when mt7925_mac_link_sta_add() fails after
WCID setup.
The add path can fail after dev->mt76.wcid[] is published, so the error
path must clear the partial host-side WCID state to avoid leaving stale
entries behind.
No functional change intended.
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 53 +++++++++++++------
1 file changed, 38 insertions(+), 15 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 584d989fb4e8..dbde91727cd0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -862,8 +862,10 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
struct ieee80211_bss_conf *link_conf;
struct mt792x_bss_conf *mconf;
u8 link_id = link_sta->link_id;
+ bool wcid_published = false;
struct mt792x_sta *msta;
struct mt76_wcid *wcid;
+ bool pm_woken = false;
int ret, idx;
msta = (struct mt792x_sta *)link_sta->sta->drv_priv;
@@ -888,6 +890,7 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
wcid = &mlink->wcid;
ewma_signal_init(&wcid->rssi);
rcu_assign_pointer(dev->mt76.wcid[wcid->idx], wcid);
+ wcid_published = true;
mt76_wcid_init(wcid, 0);
ewma_avg_signal_init(&mlink->avg_ack_signal);
memset(mlink->airtime_ac, 0,
@@ -895,7 +898,8 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
ret = mt76_connac_pm_wake(&dev->mphy, &dev->pm);
if (ret)
- return ret;
+ goto out_wcid;
+ pm_woken = true;
mt7925_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
@@ -909,15 +913,19 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
mlink_bc = mt792x_sta_to_link(&mvif->sta, mconf->link_id);
if (ieee80211_vif_is_mld(vif)) {
- mt7925_mcu_add_bss_info_sta(&dev->phy, mconf->mt76.ctx,
- link_conf, link_sta,
- mlink_bc->wcid.idx, mlink->wcid.idx,
- link_sta != mlink->pri_link);
+ ret = mt7925_mcu_add_bss_info_sta(&dev->phy, mconf->mt76.ctx,
+ link_conf, link_sta,
+ mlink_bc->wcid.idx, mlink->wcid.idx,
+ link_sta != mlink->pri_link);
+ if (ret)
+ goto out_pm;
} else {
- mt7925_mcu_add_bss_info_sta(&dev->phy, mconf->mt76.ctx,
- link_conf, link_sta,
- mlink_bc->wcid.idx, mlink->wcid.idx,
- false);
+ ret = mt7925_mcu_add_bss_info_sta(&dev->phy, mconf->mt76.ctx,
+ link_conf, link_sta,
+ mlink_bc->wcid.idx, mlink->wcid.idx,
+ false);
+ if (ret)
+ goto out_pm;
}
}
@@ -927,7 +935,7 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
mlink, true,
MT76_STA_INFO_STATE_NONE);
if (ret)
- return ret;
+ goto out_pm;
} else if (ieee80211_vif_is_mld(vif) &&
link_sta != mlink->pri_link) {
struct mt792x_link_sta *pri_mlink;
@@ -940,31 +948,46 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
container_of(pri_wcid, struct mt792x_link_sta, wcid) :
NULL;
- if (WARN_ON_ONCE(!pri_mlink))
- return -EINVAL;
+ if (WARN_ON_ONCE(!pri_mlink)) {
+ ret = -EINVAL;
+ goto out_pm;
+ }
ret = mt7925_mcu_sta_update(dev, mlink->pri_link, vif,
pri_mlink, true,
MT76_STA_INFO_STATE_ASSOC);
if (ret)
- return ret;
+ goto out_pm;
ret = mt7925_mcu_sta_update(dev, link_sta, vif,
mlink, true,
MT76_STA_INFO_STATE_ASSOC);
if (ret)
- return ret;
+ goto out_pm;
} else {
ret = mt7925_mcu_sta_update(dev, link_sta, vif,
mlink, true,
MT76_STA_INFO_STATE_NONE);
if (ret)
- return ret;
+ goto out_pm;
}
mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
return 0;
+
+out_pm:
+ if (pm_woken)
+ mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
+out_wcid:
+ if (wcid_published) {
+ u16 idx = wcid->idx;
+
+ rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
+ mt76_wcid_cleanup(mdev, wcid);
+ mt76_wcid_mask_clear(mdev->wcid_mask, wcid->idx);
+ }
+ return ret;
}
static int
--
2.43.0
next prev parent reply other threads:[~2026-03-06 23:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 23:22 [PATCH 00/19] wifi: mt76: mt7925: fix up MLO link lifetime and error handling Sean Wang
2026-03-06 23:22 ` [PATCH 01/19] wifi: mt76: mt7925: pass mlink to sta_amsdu_tlv() Sean Wang
2026-03-06 23:22 ` [PATCH 02/19] wifi: mt76: mt7925: pass WCID indices to bss_basic_tlv() Sean Wang
2026-03-07 13:45 ` kernel test robot
2026-03-07 17:59 ` kernel test robot
2026-03-06 23:22 ` [PATCH 03/19] wifi: mt76: mt7925: pass mlink and mconf to sta_mld_tlv() Sean Wang
2026-03-06 23:22 ` [PATCH 04/19] wifi: mt76: mt7925: pass mlink to mcu_sta_update() Sean Wang
2026-03-06 23:22 ` [PATCH 05/19] wifi: mt76: mt7925: resolve primary mlink via def_wcid Sean Wang
2026-03-06 23:22 ` [PATCH 06/19] wifi: mt76: mt7925: pass mlink to mac_link_sta_remove() Sean Wang
2026-03-06 23:22 ` [PATCH 07/19] wifi: mt76: mt7925: pass mlink to sta_hdr_trans_tlv() Sean Wang
2026-03-06 23:22 ` [PATCH 08/19] wifi: mt76: mt7925: validate mlink in sta_hdr_trans_tlv() Sean Wang
2026-03-06 23:22 ` [PATCH 09/19] wifi: mt76: mt7925: pass mlink to wtbl_update_hdr_trans() Sean Wang
2026-03-06 23:22 ` [PATCH 10/19] wifi: mt76: mt7925: pass mlink to set_link_key() Sean Wang
2026-03-06 23:22 ` [PATCH 11/19] wifi: mt76: mt7925: resolve link after acquiring mt76 mutex Sean Wang
2026-03-06 23:22 ` [PATCH 12/19] wifi: mt76: mt7925: pass mconf and mlink to wtbl_update_hdr_trans() Sean Wang
2026-03-06 23:22 ` [PATCH 13/19] wifi: mt76: mt7925: make WCID cleanup unconditional in sta_remove_links() Sean Wang
2026-03-06 23:22 ` Sean Wang [this message]
2026-03-06 23:22 ` [PATCH 15/19] wifi: mt76: mt7925: drop WCID reinit after publish Sean Wang
2026-03-06 23:22 ` [PATCH 16/19] wifi: mt76: mt7925: move WCID teardown into link_sta_remove() Sean Wang
2026-03-06 23:22 ` [PATCH 17/19] wifi: mt76: mt7925: switch link STA allocation to RCU lifetime Sean Wang
2026-03-06 23:22 ` [PATCH 18/19] wifi: mt76: mt7925: publish msta->link after successful link add Sean Wang
2026-03-06 23:22 ` [PATCH 19/19] wifi: mt76: mt7925: host-only unwind published links on add failure Sean Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260306232238.2039675-15-sean.wang@kernel.org \
--to=sean.wang@kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=nbd@nbd.name \
--cc=sean.wang@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox