* [PATCH mt76-next 02/20] wifi: mt76: mt7925: free removed vif links after an RCU grace period
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 03/20] wifi: mt76: remove a replayed station from the driver before the add Felix Fietkau
` (17 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt7925_change_vif_links() frees the mconf and mlink of a removed link
with devm_kfree() before it clears mvif->link_conf[] and
mvif->sta.link[], and without a grace period. Readers such as
mt7925_mcu_bss_absence_iter() hold RCU alone, so a change of the active
links can cause a use after free. The error path of a link add frees
the same way, and leaves dev->mt76.wcid[] naming the freed mlink.
Free the links with kfree_rcu() after every pointer to them is cleared,
as mt7996_vif_link_free() does. On the error path, also remove the BSS
of each link whose add completed, and make mt7925_mac_link_bss_add()
undo its setup of an allocated link when the firmware command fails.
The embedded link keeps its state until mt7925_remove_interface()
releases it.
Fixes: 69acd6d910b0 ("wifi: mt76: mt7925: add mt7925_change_vif_links")
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 | 70 ++++++++++++-------
1 file changed, 45 insertions(+), 25 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index d892434de54c..1fac66e8c50a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -449,6 +449,12 @@ 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);
+ }
mt7925_p2p_bmc_remove(dev, mconf);
goto out;
}
@@ -2474,6 +2480,25 @@ static void mt7925_link_info_changed(struct ieee80211_hw *hw,
mt792x_mutex_release(dev);
}
+static void
+mt7925_vif_link_remove(struct mt792x_dev *dev, struct mt792x_vif *mvif,
+ unsigned int link_id, struct mt792x_bss_conf *mconf,
+ struct mt792x_link_sta *mlink, bool bss_remove)
+{
+ rcu_assign_pointer(mvif->link_conf[link_id], NULL);
+ rcu_assign_pointer(mvif->sta.link[link_id], NULL);
+
+ if (bss_remove)
+ mt792x_mac_link_bss_remove(dev, mconf, mlink);
+
+ if (mconf != &mvif->bss_conf) {
+ mt7925_p2p_bmc_remove(dev, mconf);
+ kfree_rcu(mconf, mt76.rcu_head);
+ }
+ if (mlink != &mvif->sta.deflink)
+ kfree_rcu(mlink, rcu_head);
+}
+
static int
mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
u16 old_links, u16 new_links,
@@ -2487,6 +2512,7 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct mt792x_dev *dev = mt792x_hw_dev(hw);
struct mt792x_phy *phy = mt792x_hw_phy(hw);
struct ieee80211_bss_conf *link_conf;
+ unsigned long added = 0;
unsigned int link_id;
int err;
@@ -2502,15 +2528,8 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
if (!mconf || !mlink)
continue;
- if (mconf != &mvif->bss_conf) {
- mt792x_mac_link_bss_remove(dev, mconf, mlink);
- mt7925_p2p_bmc_remove(dev, mconf);
- devm_kfree(dev->mt76.dev, mconf);
- devm_kfree(dev->mt76.dev, mlink);
- }
-
- rcu_assign_pointer(mvif->link_conf[link_id], NULL);
- rcu_assign_pointer(mvif->sta.link[link_id], NULL);
+ mt7925_vif_link_remove(dev, mvif, link_id, mconf, mlink,
+ mconf != &mvif->bss_conf);
}
for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {
@@ -2519,13 +2538,13 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
mconf = &mvif->bss_conf;
mlink = &mvif->sta.deflink;
} else {
- mconf = devm_kzalloc(dev->mt76.dev, sizeof(*mconf),
- GFP_KERNEL);
- mlink = devm_kzalloc(dev->mt76.dev, sizeof(*mlink),
- GFP_KERNEL);
+ mconf = kzalloc_obj(*mconf);
+ mlink = kzalloc_obj(*mlink);
if (!mconf || !mlink) {
- mt792x_mutex_release(dev);
- return -ENOMEM;
+ kfree(mconf);
+ kfree(mlink);
+ err = -ENOMEM;
+ goto free_unpublished;
}
}
@@ -2554,6 +2573,8 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
if (err < 0)
goto free;
+ added |= BIT(link_id);
+
if (mconf != &mvif->bss_conf) {
err = mt7925_set_mlo_roc(phy, &mvif->bss_conf,
vif->active_links);
@@ -2581,18 +2602,17 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
return 0;
free:
+ for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS)
+ mt7925_vif_link_remove(dev, mvif, link_id, mconfs[link_id],
+ mlinks[link_id], added & BIT(link_id));
+ goto out;
+
+free_unpublished:
for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {
- rcu_assign_pointer(mvif->link_conf[link_id], NULL);
- rcu_assign_pointer(mvif->sta.link[link_id], NULL);
-
- if (mconfs[link_id] != &mvif->bss_conf) {
- mt7925_p2p_bmc_remove(dev, mconfs[link_id]);
- devm_kfree(dev->mt76.dev, mconfs[link_id]);
- }
- if (mlinks[link_id] != &mvif->sta.deflink)
- devm_kfree(dev->mt76.dev, mlinks[link_id]);
+ kfree(mconfs[link_id]);
+ kfree(mlinks[link_id]);
}
-
+out:
mt792x_mutex_release(dev);
return err;
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 03/20] wifi: mt76: remove a replayed station from the driver before the add
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 02/20] wifi: mt76: mt7925: free removed vif links after an RCU grace period Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 04/20] wifi: mt76: mt7925: run the reset link replay under the wiphy lock Felix Fietkau
` (16 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
A write to the mac80211 debugfs file "reset" leaves the stations of
every interface other than a managed one in place.
ieee80211_reconfig() then adds them again on their old drv_priv, and
the sta_add of most drivers allocates a new WLAN index for them. The
old index leaks, and its dev->wcid[] entry still points at the station
after the station is freed.
Treat the replay of a station that the driver still holds as a removal
followed by a fresh add. The driver holds a station whose sta flag is
set or whose wcid is published, since a new station has a zeroed
drv_priv. Unpublish the wcid for an RCU grace period first, as for a
station that mac80211 destroys. The station keeps its count, since
mac80211 removes it through the driver later, also if the add fails.
mt76x0 and mt76x2 opt out, since their sta_add restores a replayed
station.
Fixes: c8846e101502 ("mt76: add driver for MT7603E and MT7628/7688")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mac80211.c | 58 ++++++++++++++-----
drivers/net/wireless/mediatek/mt76/mt76.h | 1 +
.../net/wireless/mediatek/mt76/mt76x0/pci.c | 3 +-
.../net/wireless/mediatek/mt76/mt76x0/usb.c | 3 +-
.../net/wireless/mediatek/mt76/mt76x2/pci.c | 3 +-
.../net/wireless/mediatek/mt76/mt76x2/usb.c | 3 +-
6 files changed, 52 insertions(+), 19 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 2957f5694dc2..b8a568e0ae27 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -1713,6 +1713,42 @@ void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
}
EXPORT_SYMBOL_GPL(mt76_rx_poll_complete);
+static void
+mt76_sta_teardown(struct mt76_phy *phy, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta)
+{
+ struct mt76_dev *dev = phy->dev;
+ struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
+ int i, idx = wcid->idx;
+
+ for (i = 0; i < ARRAY_SIZE(wcid->aggr); i++)
+ mt76_rx_aggr_stop(dev, wcid, i);
+
+ if (dev->drv->sta_remove)
+ dev->drv->sta_remove(dev, vif, sta);
+
+ mt76_wcid_cleanup(dev, wcid);
+
+ mt76_wcid_mask_clear(dev->wcid_mask, idx);
+}
+
+static void
+mt76_sta_replay_drop(struct mt76_phy *phy, struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta)
+{
+ struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
+ struct mt76_dev *dev = phy->dev;
+
+ spin_lock_bh(&dev->status_lock);
+ if (rcu_access_pointer(dev->wcid[wcid->idx]) == wcid)
+ rcu_assign_pointer(dev->wcid[wcid->idx], NULL);
+ spin_unlock_bh(&dev->status_lock);
+ synchronize_net();
+
+ mt76_sta_teardown(phy, vif, sta);
+ wcid->sta = 0;
+}
+
static int
mt76_sta_add(struct mt76_phy *phy, struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
@@ -1726,8 +1762,12 @@ mt76_sta_add(struct mt76_phy *phy, struct ieee80211_vif *vif,
mutex_lock(&dev->mutex);
- /* drv_priv of a new station is zeroed, so only a replay has it set */
- registered = wcid->sta;
+ published = rcu_dereference_protected(dev->wcid[wcid->idx],
+ lockdep_is_held(&dev->mutex));
+ registered = wcid->sta || published == wcid;
+ if (registered && !(dev->drv->drv_flags & MT_DRV_KEEP_REPLAYED_STA))
+ mt76_sta_replay_drop(phy, vif, sta);
+
ret = dev->drv->sta_add(dev, vif, sta);
if (ret)
goto out;
@@ -1765,19 +1805,7 @@ mt76_sta_add(struct mt76_phy *phy, struct ieee80211_vif *vif,
void __mt76_sta_remove(struct mt76_phy *phy, struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
- struct mt76_dev *dev = phy->dev;
- struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
- int i, idx = wcid->idx;
-
- for (i = 0; i < ARRAY_SIZE(wcid->aggr); i++)
- mt76_rx_aggr_stop(dev, wcid, i);
-
- if (dev->drv->sta_remove)
- dev->drv->sta_remove(dev, vif, sta);
-
- mt76_wcid_cleanup(dev, wcid);
-
- mt76_wcid_mask_clear(dev->wcid_mask, idx);
+ mt76_sta_teardown(phy, vif, sta);
phy->num_sta--;
}
EXPORT_SYMBOL_GPL(__mt76_sta_remove);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 548632fe884a..ddada6834170 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -541,6 +541,7 @@ struct mt76_hw_cap {
#define MT_DRV_AMSDU_OFFLOAD BIT(5)
#define MT_DRV_IGNORE_TXS_FAILED BIT(6)
#define MT_DRV_HW_PS_BUFFERING BIT(7)
+#define MT_DRV_KEEP_REPLAYED_STA BIT(8)
struct mt76_driver_ops {
u32 drv_flags;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
index 3c4948522c5b..49ff52fe2ccb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
@@ -158,7 +158,8 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
.txwi_size = sizeof(struct mt76x02_txwi),
.drv_flags = MT_DRV_TX_ALIGNED4_SKBS |
MT_DRV_SW_RX_AIRTIME |
- MT_DRV_IGNORE_TXS_FAILED,
+ MT_DRV_IGNORE_TXS_FAILED |
+ MT_DRV_KEEP_REPLAYED_STA,
.survey_flags = SURVEY_INFO_TIME_TX,
.update_survey = mt76x02_update_channel,
.set_channel = mt76x0_set_channel,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
index 2acce121fb14..f51a7e0d147f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
@@ -215,7 +215,8 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,
{
static const struct mt76_driver_ops drv_ops = {
.drv_flags = MT_DRV_SW_RX_AIRTIME |
- MT_DRV_IGNORE_TXS_FAILED,
+ MT_DRV_IGNORE_TXS_FAILED |
+ MT_DRV_KEEP_REPLAYED_STA,
.survey_flags = SURVEY_INFO_TIME_TX,
.update_survey = mt76x02_update_channel,
.set_channel = mt76x0_set_channel,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c
index 491a32921a06..6df9f5110b7b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c
@@ -23,7 +23,8 @@ mt76x2e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
.txwi_size = sizeof(struct mt76x02_txwi),
.drv_flags = MT_DRV_TX_ALIGNED4_SKBS |
MT_DRV_SW_RX_AIRTIME |
- MT_DRV_IGNORE_TXS_FAILED,
+ MT_DRV_IGNORE_TXS_FAILED |
+ MT_DRV_KEEP_REPLAYED_STA,
.survey_flags = SURVEY_INFO_TIME_TX,
.update_survey = mt76x02_update_channel,
.set_channel = mt76x2e_set_channel,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c
index ade15bddefc5..23b4e020c5b7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c
@@ -34,7 +34,8 @@ static int mt76x2u_probe(struct usb_interface *intf,
{
static const struct mt76_driver_ops drv_ops = {
.drv_flags = MT_DRV_SW_RX_AIRTIME |
- MT_DRV_IGNORE_TXS_FAILED,
+ MT_DRV_IGNORE_TXS_FAILED |
+ MT_DRV_KEEP_REPLAYED_STA,
.survey_flags = SURVEY_INFO_TIME_TX,
.update_survey = mt76x02_update_channel,
.set_channel = mt76x2u_set_channel,
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 04/20] wifi: mt76: mt7925: run the reset link replay under the wiphy lock
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 02/20] wifi: mt76: mt7925: free removed vif links after an RCU grace period Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 03/20] wifi: mt76: remove a replayed station from the driver before the add Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 05/20] wifi: mt76: mt7925: take the mutex before the link_info_changed lookup Felix Fietkau
` (15 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt7925_mac_reset_work() replays the links of each interface without the
wiphy lock or dev->mt76.mutex, so a link can go while
mt7925_vif_connect_iter() still uses it. For a station, the replay
itself queues the disconnect that removes the links. The check that
commit bd8b2ec83818 ("wifi: mt76: mt7925: fix crash in reset link
replay") added only skips a link that is gone before the replay, so a
use after free remains.
Run the replay as a wiphy work, with the mutex held. Every link change
runs under the wiphy lock, so the links stay valid until the replay
ends. The reset work cannot take the wiphy lock itself, since
mt792x_stop() waits for it under that lock.
Fixes: 14061994184d ("wifi: mt76: mt7925: add link handling in mt7925_vif_connect_iter")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7925/init.c | 1 +
.../net/wireless/mediatek/mt76/mt7925/mac.c | 20 +++++++++++++++----
.../net/wireless/mediatek/mt76/mt7925/main.c | 1 +
.../wireless/mediatek/mt76/mt7925/mt7925.h | 1 +
.../net/wireless/mediatek/mt76/mt7925/pci.c | 1 +
.../net/wireless/mediatek/mt76/mt7925/usb.c | 1 +
drivers/net/wireless/mediatek/mt76/mt792x.h | 10 ++++++++++
.../net/wireless/mediatek/mt76/mt792x_usb.c | 2 ++
8 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/init.c b/drivers/net/wireless/mediatek/mt76/mt7925/init.c
index 5c81574e5283..ad51f71babd7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/init.c
@@ -320,6 +320,7 @@ int mt7925_register_device(struct mt792x_dev *dev)
skb_queue_head_init(&dev->coredump.msg_list);
INIT_WORK(&dev->reset_work, mt7925_mac_reset_work);
+ wiphy_work_init(&dev->reset_vif_work, mt7925_mac_reset_vif_work);
INIT_WORK(&dev->init_work, mt7925_init_work);
INIT_WORK(&dev->nan_deferred_work, mt7925_nan_deferred_work);
spin_lock_init(&dev->nan_deferred_lock);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index c342559a133b..30deb675c5ff 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -1640,10 +1640,22 @@ void mt7925_mac_reset_work(struct work_struct *work)
return;
ieee80211_wake_queues(hw);
- ieee80211_iterate_active_interfaces(hw,
- IEEE80211_IFACE_ITER_RESUME_ALL,
- mt7925_vif_connect_iter, NULL);
- mt76_connac_power_save_sched(&dev->mt76.phy, pm);
+ wiphy_work_queue(hw->wiphy, &dev->reset_vif_work);
+}
+
+void mt7925_mac_reset_vif_work(struct wiphy *wiphy, struct wiphy_work *work)
+{
+ struct mt792x_dev *dev = container_of(work, struct mt792x_dev,
+ reset_vif_work);
+
+ if (test_bit(MT76_REMOVED, &dev->mphy.state))
+ return;
+
+ mt792x_mutex_acquire(dev);
+ ieee80211_iterate_active_interfaces_mtx(mt76_hw(dev),
+ IEEE80211_IFACE_ITER_RESUME_ALL,
+ mt7925_vif_connect_iter, NULL);
+ mt792x_mutex_release(dev);
mt7925_regd_change(&dev->phy, "00");
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 1fac66e8c50a..61dc02e8aa68 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -3063,6 +3063,7 @@ static void mt7925_stop(struct ieee80211_hw *hw, bool suspend)
cancel_delayed_work_sync(&dev->mlo_pm_work);
mt792x_stop(hw, suspend);
+ wiphy_work_cancel(hw->wiphy, &dev->reset_vif_work);
}
const struct ieee80211_ops mt7925_ops = {
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
index 1710d97c5d25..228b74721ed7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
@@ -333,6 +333,7 @@ int mt7925_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif,
void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta);
void mt7925_mac_reset_work(struct work_struct *work);
+void mt7925_mac_reset_vif_work(struct wiphy *wiphy, struct wiphy_work *work);
int mt7925e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
enum mt76_txq_id qid, struct mt76_wcid *wcid,
struct ieee80211_sta *sta,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c b/drivers/net/wireless/mediatek/mt76/mt7925/pci.c
index 736457aa10bb..a7877c408736 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/pci.c
@@ -120,6 +120,7 @@ static void mt7925e_unregister_device(struct mt792x_dev *dev)
mt76_unregister_device(&dev->mt76);
set_bit(MT76_REMOVED, &dev->mphy.state);
cancel_work_sync(&dev->reset_work);
+ mt792x_reset_vif_work_cancel(dev);
mt76_for_each_q_rx(&dev->mt76, i)
napi_disable(&dev->mt76.napi[i]);
cancel_delayed_work_sync(&pm->ps_work);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/usb.c b/drivers/net/wireless/mediatek/mt76/mt7925/usb.c
index f97f787b2198..ee5306c29427 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/usb.c
@@ -154,6 +154,7 @@ static void mt7925u_stop(struct ieee80211_hw *hw, bool suspend)
cancel_delayed_work_sync(&dev->mlo_pm_work);
mt792xu_stop(hw, suspend);
+ wiphy_work_cancel(hw->wiphy, &dev->reset_vif_work);
}
static int mt7925u_probe(struct usb_interface *usb_intf,
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index c2d6ebb2ca3a..8dfe10cbb6d1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -374,6 +374,7 @@ struct mt792x_dev {
struct mt792x_phy phy;
struct work_struct reset_work;
+ struct wiphy_work reset_vif_work;
bool hw_full_reset:1;
bool hw_init_done:1;
bool fw_assert:1;
@@ -526,6 +527,15 @@ mt792x_hw_phy(struct ieee80211_hw *hw)
return phy->priv;
}
+static inline void mt792x_reset_vif_work_cancel(struct mt792x_dev *dev)
+{
+ struct wiphy *wiphy = mt76_hw(dev)->wiphy;
+
+ wiphy_lock(wiphy);
+ wiphy_work_cancel(wiphy, &dev->reset_vif_work);
+ wiphy_unlock(wiphy);
+}
+
static inline void
mt792x_get_status_freq_info(struct mt76_rx_status *status, u8 chfreq)
{
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_usb.c b/drivers/net/wireless/mediatek/mt76/mt792x_usb.c
index feedb66d4b6e..d5a6fe33d09c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_usb.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_usb.c
@@ -524,6 +524,8 @@ void mt792xu_disconnect(struct usb_interface *usb_intf)
wake_up(&dev->mt76.mcu.wait);
skb_queue_purge(&dev->mt76.mcu.res_q);
cancel_work_sync(&dev->reset_work);
+ if (!is_connac2(&dev->mt76))
+ mt792x_reset_vif_work_cancel(dev);
mt792xu_cleanup(dev);
set_bit(MT76_REMOVED, &dev->mphy.state);
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 05/20] wifi: mt76: mt7925: take the mutex before the link_info_changed lookup
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (2 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 04/20] wifi: mt76: mt7925: run the reset link replay under the wiphy lock Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 06/20] wifi: mt76: mt7925: hold the mutex for the link lookup in conf_tx Felix Fietkau
` (14 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt7925_link_info_changed() looks up the driver link before it takes
dev->mt76.mutex, which mt792x_vif_to_link() requires. The first link
info change of an MLD interface thus triggers a suspicious RCU usage
warning. The link stays valid, as its only writer,
mt7925_change_vif_links(), runs under the wiphy lock that this op
holds.
Look up the link under the mutex, like commit beec58f36983 ("wifi: mt76:
mt7925: resolve link after acquiring mt76 mutex") did for the station
links, and like mt7996_link_info_changed() does.
Fixes: 3fa01f055c41 ("wifi: mt76: mt7925: update rate index according to link id")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 61dc02e8aa68..71e441f631d1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -2432,10 +2432,10 @@ static void mt7925_link_info_changed(struct ieee80211_hw *hw,
struct mt792x_dev *dev = mt792x_hw_dev(hw);
struct mt792x_bss_conf *mconf;
- mconf = mt792x_vif_to_link(mvif, info->link_id);
-
mt792x_mutex_acquire(dev);
+ mconf = mt792x_vif_to_link(mvif, info->link_id);
+
if (changed & BSS_CHANGED_ERP_SLOT) {
int slottime = info->use_short_slot ? 9 : 20;
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 06/20] wifi: mt76: mt7925: hold the mutex for the link lookup in conf_tx
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (3 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 05/20] wifi: mt76: mt7925: take the mutex before the link_info_changed lookup Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 07/20] wifi: mt76: mt7925: skip a polled link without a station Felix Fietkau
` (13 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt7925_conf_tx() looks up the driver link and writes its queue
parameters without dev->mt76.mutex, which mt792x_vif_to_link()
requires. The first queue setup of an MLD interface thus triggers a
suspicious RCU usage warning. The link stays valid, as its only writer,
mt7925_change_vif_links(), runs under the wiphy lock that this op
holds.
Hold the mutex for the lookup and the write, like mt7603_conf_tx(). The
op only writes driver memory, so it takes the mutex without a chip
wakeup, like mt792x_assign_vif_chanctx().
Fixes: 882b97c16ab8 ("wifi: mt76: mt7925: set Tx queue parameters according to link id")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 71e441f631d1..644591b994ec 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -2149,16 +2149,20 @@ mt7925_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
const struct ieee80211_tx_queue_params *params)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- struct mt792x_bss_conf *mconf = mt792x_vif_to_link(mvif, link_id);
+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
static const u8 mq_to_aci[] = {
[IEEE80211_AC_VO] = 3,
[IEEE80211_AC_VI] = 2,
[IEEE80211_AC_BE] = 0,
[IEEE80211_AC_BK] = 1,
};
+ struct mt792x_bss_conf *mconf;
+ mutex_lock(&dev->mt76.mutex);
+ mconf = mt792x_vif_to_link(mvif, link_id);
/* firmware uses access class index */
mconf->queue_params[mq_to_aci[queue]] = *params;
+ mutex_unlock(&dev->mt76.mutex);
return 0;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 07/20] wifi: mt76: mt7925: skip a polled link without a station
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (4 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 06/20] wifi: mt76: mt7925: hold the mutex for the link lookup in conf_tx Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 08/20] wifi: mt76: mt7925: skip a link without a link conf in the MLO PS update Felix Fietkau
` (12 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
Since the WCID teardown moved into mt7925_mac_link_sta_remove(),
mt7925_mac_sta_remove_links() clears mlink->sta of a removed link while
the link is still on sta_poll_list. On PCIe, mt7925_mac_sta_poll() runs
from the TX free event without dev->mt76.mutex. It can thus take such a
link off the list and dereference the NULL station.
Skip a polled link without a station.
Fixes: 52f088a2e6bf ("wifi: mt76: mt7925: move WCID teardown into link_sta_remove()")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index 30deb675c5ff..ca54d71db4c7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -90,7 +90,7 @@ static void mt7925_mac_sta_poll(struct mt792x_dev *dev)
memset(mlink->airtime_ac, 0, sizeof(mlink->airtime_ac));
}
- if (!mlink->wcid.sta)
+ if (!msta || !mlink->wcid.sta)
continue;
sta = container_of((void *)msta, struct ieee80211_sta,
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 08/20] wifi: mt76: mt7925: skip a link without a link conf in the MLO PS update
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (5 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 07/20] wifi: mt76: mt7925: skip a polled link without a station Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 09/20] wifi: mt76: mt7925: restore the beacon filter when monitor mode ends Felix Fietkau
` (11 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
During a link removal, mvif->valid_links still holds the link after
mac80211 cleared its link conf, until mt7925_change_vif_links() runs.
mt7925_mlo_pm_work() runs without the wiphy lock, so
mt7925_mlo_pm_iter() can pass the NULL link conf of such a link to
mt7925_mcu_uni_bss_ps(), which dereferences it. Reachable through the
power save update that mt7925_link_info_changed() schedules after a PS
change of an MLO station.
Skip a link without a link conf, as mt7925_vif_connect_iter() does. A
link conf that the iterator finds under dev->mt76.mutex stays valid,
since mac80211 frees it only after mt7925_change_vif_links(), which
takes the mutex.
While here, read the PS state and the links under the mutex that their
writers hold.
Fixes: 276a56883257 ("wifi: mt76: mt7925: update the power-saving flow")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 644591b994ec..188e3ad06c37 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -1736,19 +1736,24 @@ mt7925_mlo_pm_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
{
struct mt792x_dev *dev = priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- unsigned long valid = ieee80211_vif_is_mld(vif) ?
- mvif->valid_links : BIT(0);
struct ieee80211_bss_conf *bss_conf;
+ unsigned long valid;
int i;
- if (mvif->mlo_pm_state != MT792x_MLO_CHANGED_PS)
- return;
-
mt792x_mutex_acquire(dev);
+
+ if (mvif->mlo_pm_state != MT792x_MLO_CHANGED_PS)
+ goto out;
+
+ valid = ieee80211_vif_is_mld(vif) ? mvif->valid_links : BIT(0);
for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) {
bss_conf = mt792x_vif_to_bss_conf(vif, i);
+ if (!bss_conf)
+ continue;
+
mt7925_mcu_uni_bss_ps(dev, bss_conf);
}
+out:
mt792x_mutex_release(dev);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 09/20] wifi: mt76: mt7925: restore the beacon filter when monitor mode ends
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (6 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 08/20] wifi: mt76: mt7925: skip a link without a link conf in the MLO PS update Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 10/20] wifi: mt76: usb: do not park the TX worker again under MT76_RESET Felix Fietkau
` (10 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt7925_sniffer_interface_iter() turns the beacon filter of each running
interface off when monitor mode starts, but not on again when it ends.
An associated station then keeps the filter off while
IEEE80211_VIF_BEACON_FILTER stays set, so mac80211 leaves beacon loss
detection to the device.
When monitor mode ends, turn the filter of each associated station back
on, unless runtime PM is off and a runtime PM write turned the filter
off. Stations that are not associated stay off, since the firmware
expects the filter only after the association.
Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7925/main.c | 41 ++++++++++++-------
1 file changed, 27 insertions(+), 14 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 188e3ad06c37..d3b1f5e7850b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -916,29 +916,36 @@ static int mt7925_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
}
static void
-mt7925_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
+mt7925_vif_set_beacon_filter(struct mt792x_dev *dev, struct ieee80211_vif *vif,
+ bool enable)
{
- struct mt792x_dev *dev = priv;
struct ieee80211_hw *hw = mt76_hw(dev);
- bool pm_enable;
- int err;
- mt792x_mutex_acquire(dev);
+ if (mt7925_mcu_set_beacon_filter(dev, vif, enable) < 0)
+ return;
- pm_enable = dev->pm.enable_user &&
- !(hw->conf.flags & IEEE80211_CONF_MONITOR);
- err = mt7925_mcu_set_beacon_filter(dev, vif, pm_enable);
- if (err < 0)
- goto out;
-
- if (pm_enable) {
+ if (enable) {
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
ieee80211_hw_set(hw, CONNECTION_MONITOR);
} else {
vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER;
__clear_bit(IEEE80211_HW_CONNECTION_MONITOR, hw->flags);
}
-out:
+}
+
+static void
+mt7925_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
+{
+ struct mt792x_dev *dev = priv;
+ struct ieee80211_hw *hw = mt76_hw(dev);
+ bool pm_enable;
+
+ mt792x_mutex_acquire(dev);
+
+ pm_enable = dev->pm.enable_user &&
+ !(hw->conf.flags & IEEE80211_CONF_MONITOR);
+ mt7925_vif_set_beacon_filter(dev, vif, pm_enable);
+
mt792x_mutex_release(dev);
}
@@ -956,8 +963,14 @@ mt7925_sniffer_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
mt7925_mcu_set_deep_sleep(dev, pm->ds_enable);
- if (monitor)
+ if (monitor) {
mt7925_mcu_set_beacon_filter(dev, vif, false);
+ return;
+ }
+
+ if (vif->cfg.assoc &&
+ (pm->enable || (vif->driver_flags & IEEE80211_VIF_BEACON_FILTER)))
+ mt7925_vif_set_beacon_filter(dev, vif, true);
}
void mt7925_set_runtime_pm(struct mt792x_dev *dev)
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 10/20] wifi: mt76: usb: do not park the TX worker again under MT76_RESET
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (7 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 09/20] wifi: mt76: mt7925: restore the beacon filter when monitor mode ends Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 11/20] wifi: mt76: mt7925: keep the default link in the active links Felix Fietkau
` (9 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
When the wait for pending TX in mt76u_stop_tx() times out, its cleanup
parks the TX worker also where the caller parked it already. This is the
case for mt792xu_disconnect(), which reaches mt76u_stop_tx() through
mt76_unregister_device(), and for mt7921u_mac_reset() and
mt7925u_mac_reset(). The second park triggers a WARN, and the cleanup
then unparks the worker, which runs again during the teardown or the
chip reset:
mt7925u 2-4:1.0: timed out waiting for pending tx
WARNING: CPU: 1 PID: 15805 at kthread_park+0x73/0x90
Call Trace:
...
mt792xu_stop+0x15/0x30 [mt792x_usb]
...
drv_stop+0x33/0xd0 [mac80211]
...
ieee80211_unregister_hw+0x45/0x140 [mac80211]
mt76_unregister_device+0x70/0xf0 [mt76]
mt792xu_disconnect+0x7a/0x1c0 [mt792x_usb]
...
Park and unpark the worker in the cleanup only while MT76_RESET is
clear, as mt792x_flush() does. Every caller that holds MT76_RESET has
parked the worker already, or runs before mt76_register_device() starts
it.
Fixes: 7910bd565d8b ("wifi: mt76: mt792x: quiesce USB paths on disconnect")
Fixes: 0d2afe09fad5 ("mt76: mt7921: add mt7921u driver")
Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/usb.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index be48a88a3ad0..9a701840d23a 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -1070,6 +1070,7 @@ void mt76u_stop_tx(struct mt76_dev *dev)
if (!ret) {
struct mt76_queue_entry entry;
struct mt76_queue *q;
+ bool park;
int i, j;
dev_err(dev->dev, "timed out waiting for pending tx\n");
@@ -1083,7 +1084,9 @@ void mt76u_stop_tx(struct mt76_dev *dev)
usb_kill_urb(q->entry[j].urb);
}
- mt76_worker_disable(&dev->tx_worker);
+ park = !test_bit(MT76_RESET, &dev->phy.state);
+ if (park)
+ mt76_worker_disable(&dev->tx_worker);
/* On device removal we maight queue skb's, but mt76u_tx_kick()
* will fail to submit urb, cleanup those skb's manually.
@@ -1100,7 +1103,8 @@ void mt76u_stop_tx(struct mt76_dev *dev)
}
}
- mt76_worker_enable(&dev->tx_worker);
+ if (park)
+ mt76_worker_enable(&dev->tx_worker);
}
cancel_work_sync(&dev->usb.stat_work);
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 11/20] wifi: mt76: mt7925: keep the default link in the active links
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (8 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 10/20] wifi: mt76: usb: do not park the TX worker again under MT76_RESET Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 12/20] wifi: mt76: mt7925: read the monitor state under the mutex for deep sleep Felix Fietkau
` (8 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
Since commit 43aa4033eb18 ("wifi: mt76: mt7925: add
mt7925_change_sta_links"), the driver removes the default link of an
associated AP MLD, the association link, when mac80211 deactivates it.
No other link takes its place, so the interface sends no data on the
links that stay active. Reachable via an advertised TID-to-link mapping
or an ML reconfiguration of the AP MLD.
Refuse an active link set without the default link while an MLD
interface is associated. A move of the default link does not help,
because the firmware sends the uplink of an MLD only on its association
link. Where an advertised mapping or an ML reconfiguration of the AP MLD
leaves that link out, mac80211 now disconnects instead.
Fixes: 43aa4033eb18 ("wifi: mt76: mt7925: add mt7925_change_sta_links")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index d3b1f5e7850b..f8ad3bd16931 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -2715,6 +2715,18 @@ mt7925_change_sta_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
return err;
}
+static bool
+mt7925_can_activate_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+ u16 active_links)
+{
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+
+ if (!ieee80211_vif_is_mld(vif) || !vif->cfg.assoc)
+ return true;
+
+ return active_links & BIT(mvif->deflink_id);
+}
+
static int
mt7927_reconfig_band(struct mt792x_dev *dev, struct ieee80211_vif *vif,
struct ieee80211_bss_conf *link_conf,
@@ -3148,6 +3160,7 @@ const struct ieee80211_ops mt7925_ops = {
.mgd_complete_tx = mt7925_mgd_complete_tx,
.vif_cfg_changed = mt7925_vif_cfg_changed,
.link_info_changed = mt7925_link_info_changed,
+ .can_activate_links = mt7925_can_activate_links,
.change_vif_links = mt7925_change_vif_links,
.change_sta_links = mt7925_change_sta_links,
.rfkill_poll = mt7925_rfkill_poll,
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 12/20] wifi: mt76: mt7925: read the monitor state under the mutex for deep sleep
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (9 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 11/20] wifi: mt76: mt7925: keep the default link in the active links Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 13/20] wifi: mt76: clear roc_link before the ROC link is freed Felix Fietkau
` (7 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt7925_deep_sleep_set() reads IEEE80211_CONF_MONITOR before it takes
the mutex. The value can thus miss a monitor change that mt7925_config()
applied under the mutex, and deep sleep can then go on while a monitor
runs. Reachable via the deep-sleep file in debugfs.
Read the flag under the mutex, as mt7925_set_runtime_pm() does.
Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c
index d0677a24e080..6cfd3c4cac8c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c
@@ -231,8 +231,8 @@ mt7925_deep_sleep_set(void *data, u64 val)
{
struct mt792x_dev *dev = data;
struct mt76_connac_pm *pm = &dev->pm;
- bool monitor = !!(dev->mphy.hw->conf.flags & IEEE80211_CONF_MONITOR);
bool enable = !!val;
+ bool monitor;
if (mt76_is_usb(&dev->mt76))
return -EOPNOTSUPP;
@@ -241,6 +241,7 @@ mt7925_deep_sleep_set(void *data, u64 val)
if (pm->ds_enable_user == enable)
goto out;
+ monitor = !!(dev->mphy.hw->conf.flags & IEEE80211_CONF_MONITOR);
pm->ds_enable_user = enable;
pm->ds_enable = enable && !monitor;
mt7925_mcu_set_deep_sleep(dev, pm->ds_enable);
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 13/20] wifi: mt76: clear roc_link before the ROC link is freed
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (10 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 12/20] wifi: mt76: mt7925: read the monitor state under the mutex for deep sleep Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 14/20] wifi: mt76: mt792x: handle all interfaces of a channel context Felix Fietkau
` (6 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt76_roc_complete() queues the free of the off-channel link while
phy->roc_link still names it. An RCU reader that loads roc_link after
that point can use the link after it is freed.
Clear roc_link before the free is queued, as the error path of
mt76_remain_on_channel() does.
This is currently not reachable: the only lockless reader of roc_link,
mt7996_tx(), finds the phy through mvif->roc_phy, which
mt76_roc_complete() clears before the free. Found by inspection.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/channel.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/channel.c b/drivers/net/wireless/mediatek/mt76/channel.c
index 9638f65a679e..db2d6dfc12a9 100644
--- a/drivers/net/wireless/mediatek/mt76/channel.c
+++ b/drivers/net/wireless/mediatek/mt76/channel.c
@@ -409,9 +409,9 @@ void mt76_roc_complete(struct mt76_phy *phy)
} else {
phy->offchannel = false;
}
- mt76_put_vif_phy_link(phy, phy->roc_vif, phy->roc_link);
- phy->roc_vif = NULL;
phy->roc_link = NULL;
+ mt76_put_vif_phy_link(phy, phy->roc_vif, mlink);
+ phy->roc_vif = NULL;
if (!test_bit(MT76_RESTART, &dev->phy.state))
ieee80211_remain_on_channel_expired(phy->hw);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 14/20] wifi: mt76: mt792x: handle all interfaces of a channel context
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (11 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 13/20] wifi: mt76: clear roc_link before the ROC link is freed Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 15/20] wifi: mt76: mt792x: set up the sniffer when a monitor gets its channel Felix Fietkau
` (5 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
Since commit f3898da2e86e ("wifi: mt76: mt792x: add struct
mt792x_chanctx"), a channel context records only the link that was
assigned to it last. Removing any link clears the record, but a switch
of the recorded link to another context leaves it in place. A bandwidth
change of a context that a station and an AP share thus reaches the
firmware for at most one of them. After such a switch and the removal of
that link, the next change of the old context is a use after free.
Walk the active interfaces when a channel context changes, as the
driver did before that commit.
Fixes: f3898da2e86e ("wifi: mt76: mt792x: add struct mt792x_chanctx")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7921/main.c | 28 +++----
.../net/wireless/mediatek/mt76/mt7925/main.c | 83 +++++++++----------
drivers/net/wireless/mediatek/mt76/mt792x.h | 4 -
.../net/wireless/mediatek/mt76/mt792x_core.c | 5 --
4 files changed, 53 insertions(+), 67 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 6207a875996c..a89b4c7f2239 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -1413,25 +1413,25 @@ mt7921_change_chanctx(struct ieee80211_hw *hw,
struct ieee80211_chanctx_conf *ctx,
u32 changed)
{
- struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
struct mt792x_phy *phy = mt792x_hw_phy(hw);
struct ieee80211_vif *vif;
- struct mt792x_vif *mvif;
-
- if (!mctx->bss_conf)
- return;
-
- mvif = container_of(mctx->bss_conf, struct mt792x_vif, bss_conf);
- vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv);
mt792x_mutex_acquire(phy->dev);
- if (vif->type == NL80211_IFTYPE_MONITOR) {
- mt7921_mcu_set_sniffer(mvif->phy->dev, vif, true);
- mt7921_mcu_config_sniffer(mvif, ctx);
- } else {
- mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, ctx);
+ for_each_active_interface(vif, hw) {
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+
+ if (mvif->bss_conf.mt76.ctx != ctx)
+ continue;
+
+ if (vif->type == NL80211_IFTYPE_MONITOR) {
+ mt7921_mcu_set_sniffer(mvif->phy->dev, vif, true);
+ mt7921_mcu_config_sniffer(mvif, ctx);
+ } else {
+ mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76,
+ &mvif->bss_conf.mt76, ctx);
+ }
+ mt76_phy_chandef_set(mvif->phy->mt76, &ctx->def);
}
- mt76_phy_chandef_set(mvif->phy->mt76, &ctx->def);
mt792x_mutex_release(phy->dev);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index f8ad3bd16931..bd5375705e98 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -2287,58 +2287,57 @@ mt7925_remove_chanctx(struct ieee80211_hw *hw,
}
static void
-mt7925_change_chanctx(struct ieee80211_hw *hw,
- struct ieee80211_chanctx_conf *ctx,
- u32 changed)
+mt7925_link_change_chanctx(struct ieee80211_vif *vif,
+ struct mt792x_bss_conf *mconf,
+ struct ieee80211_chanctx_conf *ctx, u32 changed)
{
- struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
- struct mt792x_phy *phy = mt792x_hw_phy(hw);
- struct mt792x_bss_conf *mconf;
- struct ieee80211_vif *vif;
- struct mt792x_vif *mvif;
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct ieee80211_bss_conf *link_conf;
- if (!mctx->bss_conf)
+ if (!mconf || mconf->mt76.ctx != ctx)
return;
- mconf = mctx->bss_conf;
- mvif = mconf->vif;
- vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv);
-
- mt792x_mutex_acquire(phy->dev);
if (vif->type == NL80211_IFTYPE_MONITOR) {
mt7925_mcu_set_sniffer(mvif->phy->dev, vif, true);
mt7925_mcu_config_sniffer(mvif, ctx);
} else {
- if (ieee80211_vif_is_mld(vif)) {
- unsigned long valid = mvif->valid_links;
- u8 i;
+ link_conf = mt792x_vif_to_bss_conf(vif, mconf->link_id);
+ if (mt7925_p2p_chanctx_bss_programmed(vif, link_conf))
+ mt7925_mcu_set_chctx(mvif->phy->mt76, &mconf->mt76,
+ link_conf, ctx);
- for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) {
- mconf = mt792x_vif_to_link(mvif, i);
- if (mconf && mconf->mt76.ctx == ctx)
- break;
- }
-
- } else {
- mconf = &mvif->bss_conf;
- }
-
- if (mconf) {
- struct ieee80211_bss_conf *link_conf;
-
- link_conf = mt792x_vif_to_bss_conf(vif, mconf->link_id);
-
- if (mt7925_p2p_chanctx_bss_programmed(vif, link_conf))
- mt7925_mcu_set_chctx(mvif->phy->mt76, &mconf->mt76,
- link_conf, ctx);
-
- if (changed & IEEE80211_CHANCTX_CHANGE_PUNCTURING)
- mt7925_mcu_set_eht_pp(mvif->phy->mt76, &mconf->mt76,
- link_conf, ctx);
- }
+ if (changed & IEEE80211_CHANCTX_CHANGE_PUNCTURING)
+ mt7925_mcu_set_eht_pp(mvif->phy->mt76, &mconf->mt76,
+ link_conf, ctx);
}
mt76_phy_chandef_set(mvif->phy->mt76, &ctx->def);
+}
+static void
+mt7925_change_chanctx(struct ieee80211_hw *hw,
+ struct ieee80211_chanctx_conf *ctx,
+ u32 changed)
+{
+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
+ struct ieee80211_vif *vif;
+
+ mt792x_mutex_acquire(phy->dev);
+ for_each_active_interface(vif, hw) {
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ unsigned long valid = mvif->valid_links;
+ u8 i;
+
+ if (!ieee80211_vif_is_mld(vif)) {
+ mt7925_link_change_chanctx(vif, &mvif->bss_conf, ctx,
+ changed);
+ continue;
+ }
+
+ for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS)
+ mt7925_link_change_chanctx(vif,
+ mt792x_vif_to_link(mvif, i),
+ ctx, changed);
+ }
mt792x_mutex_release(phy->dev);
}
@@ -2755,7 +2754,6 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *link_conf,
struct ieee80211_chanctx_conf *ctx)
{
- struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_dev *dev = mt792x_hw_dev(hw);
struct ieee80211_bss_conf *pri_link_conf;
@@ -2783,7 +2781,6 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
}
mconf->mt76.ctx = ctx;
- mctx->bss_conf = mconf;
mt76_phy_chandef_set(mvif->phy->mt76, &ctx->def);
mutex_unlock(&dev->mt76.mutex);
@@ -2795,7 +2792,6 @@ static void mt7925_unassign_vif_chanctx(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *link_conf,
struct ieee80211_chanctx_conf *ctx)
{
- struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_dev *dev = mt792x_hw_dev(hw);
struct mt792x_bss_conf *mconf;
@@ -2813,7 +2809,6 @@ static void mt7925_unassign_vif_chanctx(struct ieee80211_hw *hw,
mconf = &mvif->bss_conf;
}
- mctx->bss_conf = NULL;
mconf->mt76.ctx = NULL;
mutex_unlock(&dev->mt76.mutex);
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index 8dfe10cbb6d1..e37d901575e5 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -163,10 +163,6 @@ struct mt792x_sta {
DECLARE_EWMA(rssi, 10, 8);
-struct mt792x_chanctx {
- struct mt792x_bss_conf *bss_conf;
-};
-
struct mt792x_bss_conf {
struct mt76_vif_link mt76; /* must be first */
struct mt792x_vif *vif;
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
index 2d39f18f4d43..5743c5437863 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -503,13 +503,11 @@ int mt792x_assign_vif_chanctx(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *link_conf,
struct ieee80211_chanctx_conf *ctx)
{
- struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_dev *dev = mt792x_hw_dev(hw);
mutex_lock(&dev->mt76.mutex);
mvif->bss_conf.mt76.ctx = ctx;
- mctx->bss_conf = &mvif->bss_conf;
mt76_phy_chandef_set(&dev->mphy, &ctx->def);
mutex_unlock(&dev->mt76.mutex);
@@ -522,12 +520,10 @@ void mt792x_unassign_vif_chanctx(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *link_conf,
struct ieee80211_chanctx_conf *ctx)
{
- struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_dev *dev = mt792x_hw_dev(hw);
mutex_lock(&dev->mt76.mutex);
- mctx->bss_conf = NULL;
mvif->bss_conf.mt76.ctx = NULL;
mutex_unlock(&dev->mt76.mutex);
@@ -810,7 +806,6 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw)
hw->sta_data_size = sizeof(struct mt792x_sta);
hw->vif_data_size = sizeof(struct mt792x_vif);
- hw->chanctx_data_size = sizeof(struct mt792x_chanctx);
if (dev->fw_features & MT792x_FW_CAP_CNM)
wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 15/20] wifi: mt76: mt792x: set up the sniffer when a monitor gets its channel
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (12 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 14/20] wifi: mt76: mt792x: handle all interfaces of a channel context Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 16/20] wifi: mt76: buffer Disassociation frames for stations in power save Felix Fietkau
` (4 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt7921 and mt7925 tune the sniffer of a monitor only in change_chanctx.
For the new channel context of a monitor, mac80211 calls change_chanctx
only on a device with more than one RX chain. On a device with one RX
chain, the sniffer thus stays off the channel of the monitor.
Set up the sniffer when the channel context is assigned.
Fixes: 41ac53c899bd ("wifi: mt76: mt7921: introduce chanctx support")
Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7921/main.c | 25 +++++++++++++++++--
.../net/wireless/mediatek/mt76/mt7925/main.c | 8 ++++--
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index a89b4c7f2239..9b13e9c25cf3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -1469,12 +1469,33 @@ static void mt7921_mgd_complete_tx(struct ieee80211_hw *hw,
mt7921_abort_roc(mvif->phy, mvif);
}
+static int mt7921_assign_vif_chanctx(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ieee80211_bss_conf *link_conf,
+ struct ieee80211_chanctx_conf *ctx)
+{
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_dev *dev = mt792x_hw_dev(hw);
+ int ret;
+
+ ret = mt792x_assign_vif_chanctx(hw, vif, link_conf, ctx);
+ if (ret || vif->type != NL80211_IFTYPE_MONITOR)
+ return ret;
+
+ mt792x_mutex_acquire(dev);
+ mt7921_mcu_set_sniffer(dev, vif, true);
+ mt7921_mcu_config_sniffer(mvif, ctx);
+ mt792x_mutex_release(dev);
+
+ return 0;
+}
+
static int mt7921_switch_vif_chanctx(struct ieee80211_hw *hw,
struct ieee80211_vif_chanctx_switch *vifs,
int n_vifs,
enum ieee80211_chanctx_switch_mode mode)
{
- return mt792x_assign_vif_chanctx(hw, vifs->vif, vifs->link_conf,
+ return mt7921_assign_vif_chanctx(hw, vifs->vif, vifs->link_conf,
vifs->new_ctx);
}
@@ -1620,7 +1641,7 @@ const struct ieee80211_ops mt7921_ops = {
.add_chanctx = mt7921_add_chanctx,
.remove_chanctx = mt7921_remove_chanctx,
.change_chanctx = mt7921_change_chanctx,
- .assign_vif_chanctx = mt792x_assign_vif_chanctx,
+ .assign_vif_chanctx = mt7921_assign_vif_chanctx,
.unassign_vif_chanctx = mt792x_unassign_vif_chanctx,
.mgd_prepare_tx = mt7921_mgd_prepare_tx,
.mgd_complete_tx = mt7921_mgd_complete_tx,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index bd5375705e98..8c9c77bd97b6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -2760,7 +2760,7 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
struct mt792x_bss_conf *mconf;
u8 band_idx;
- mutex_lock(&dev->mt76.mutex);
+ mt792x_mutex_acquire(dev);
if (ieee80211_vif_is_mld(vif)) {
mconf = mt792x_vif_to_link(mvif, link_conf->link_id);
@@ -2782,7 +2782,11 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
mconf->mt76.ctx = ctx;
mt76_phy_chandef_set(mvif->phy->mt76, &ctx->def);
- mutex_unlock(&dev->mt76.mutex);
+ if (vif->type == NL80211_IFTYPE_MONITOR) {
+ mt7925_mcu_set_sniffer(dev, vif, true);
+ mt7925_mcu_config_sniffer(mvif, ctx);
+ }
+ mt792x_mutex_release(dev);
return 0;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 16/20] wifi: mt76: buffer Disassociation frames for stations in power save
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (13 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 15/20] wifi: mt76: mt792x: set up the sniffer when a monitor gets its channel Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 17/20] wifi: mt76: mt7921: read the monitor state under the mutex for deep sleep Felix Fietkau
` (3 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
Since commit 3999d15cfcc7 ("wifi: mt76: fix queue assignment for
disassoc packets"), a Disassociation frame to an associated station goes
to the ALTX queue. The hardware sends ALTX frames at once, also to a
station in power save. A sleeping station thus misses the frame and
stays associated until it detects the disconnection by itself.
Send Disassociation frames on the AC queue like other bufferable MMPDUs,
so that they wait until the station wakes. If the station does not wake,
hostapd removes it when the wait for the TX status ends. Keep
Deauthentication frames on the ALTX queue, so that hostapd removes a
deauthenticated station at once.
Fixes: 3999d15cfcc7 ("wifi: mt76: fix queue assignment for disassoc packets")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/tx.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
index 72d1021a940f..d8036466f495 100644
--- a/drivers/net/wireless/mediatek/mt76/tx.c
+++ b/drivers/net/wireless/mediatek/mt76/tx.c
@@ -729,7 +729,6 @@ mt76_txq_schedule_pending_wcid(struct mt76_phy *phy, struct mt76_wcid *wcid,
(!(wcid->tx_info & MT_WCID_TX_INFO_SET) ||
!ieee80211_is_bufferable_mmpdu(skb) ||
ieee80211_is_deauth(hdr->frame_control) ||
- ieee80211_is_disassoc(hdr->frame_control) ||
head == &wcid->tx_offchannel))
qid = MT_TXQ_PSD;
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 17/20] wifi: mt76: mt7921: read the monitor state under the mutex for deep sleep
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (14 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 16/20] wifi: mt76: buffer Disassociation frames for stations in power save Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 18/20] wifi: mt76: mt7925: wake the device to unassign a channel context Felix Fietkau
` (2 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt7921_deep_sleep_set() reads IEEE80211_CONF_MONITOR before it takes
the mutex. The value can thus miss a monitor change that mt7921_config()
applied under the mutex, and deep sleep can then go on while a monitor
runs. Reachable via the deep-sleep file in debugfs.
Read the flag under the mutex, as mt7925_deep_sleep_set() does.
Fixes: 4ad65a54617c ("mt76: mt7921: toggle runtime-pm adding a monitor vif")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
index 62bf33347e9e..14c70ffa9665 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
@@ -189,8 +189,8 @@ mt7921_deep_sleep_set(void *data, u64 val)
{
struct mt792x_dev *dev = data;
struct mt76_connac_pm *pm = &dev->pm;
- bool monitor = !!(dev->mphy.hw->conf.flags & IEEE80211_CONF_MONITOR);
bool enable = !!val;
+ bool monitor;
if (mt76_is_usb(&dev->mt76))
return -EOPNOTSUPP;
@@ -199,6 +199,7 @@ mt7921_deep_sleep_set(void *data, u64 val)
if (pm->ds_enable_user == enable)
goto out;
+ monitor = !!(dev->mphy.hw->conf.flags & IEEE80211_CONF_MONITOR);
pm->ds_enable_user = enable;
pm->ds_enable = enable && !monitor;
mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable);
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 18/20] wifi: mt76: mt7925: wake the device to unassign a channel context
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (15 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 17/20] wifi: mt76: mt7921: read the monitor state under the mutex for deep sleep Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 19/20] wifi: mt76: mt7996: keep the firmware log settings across a reload Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 20/20] wifi: mt76: mt7915: " Felix Fietkau
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt7925_unassign_vif_chanctx() takes the mutex with a plain mutex_lock()
and sends mt7925_mcu_add_bss_info() for the default link of an MLD
station without waking the device. With runtime PM on, the BSS removal
can thus reach a device in power save. Reachable whenever mac80211
releases the channel context of the default link of an MLD station, for
example at a disconnect.
Take the mutex with mt792x_mutex_acquire(), as
mt7925_assign_vif_chanctx() does.
Fixes: 621e9e22b8d0 ("wifi: mt76: mt7925: add mt7925_[assign,unassign]_vif_chanctx")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 8c9c77bd97b6..fa5628c06b04 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -2800,7 +2800,7 @@ static void mt7925_unassign_vif_chanctx(struct ieee80211_hw *hw,
struct mt792x_dev *dev = mt792x_hw_dev(hw);
struct mt792x_bss_conf *mconf;
- mutex_lock(&dev->mt76.mutex);
+ mt792x_mutex_acquire(dev);
if (ieee80211_vif_is_mld(vif)) {
mconf = mt792x_vif_to_link(mvif, link_conf->link_id);
@@ -2814,7 +2814,7 @@ static void mt7925_unassign_vif_chanctx(struct ieee80211_hw *hw,
}
mconf->mt76.ctx = NULL;
- mutex_unlock(&dev->mt76.mutex);
+ mt792x_mutex_release(dev);
if (link_conf->csa_active) {
timer_delete_sync(&mvif->csa_timer);
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 19/20] wifi: mt76: mt7996: keep the firmware log settings across a reload
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (16 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 18/20] wifi: mt76: mt7925: wake the device to unassign a channel context Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 20/20] wifi: mt76: mt7915: " Felix Fietkau
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt7996_mcu_init_firmware() turns the WM and WA firmware log off after
each firmware load, while dev->fw_debug_wm, dev->fw_debug_wa and
dev->fw_debug_bin keep the debugfs settings. Since the full system reset
loads the firmware again, a reset silently stops firmware logging, and
the debugfs files still report it as enabled.
Send the stored settings at each firmware load, and, where WM or WA
logging is enabled, the other commands that the debugfs write sends.
With logging off a load sends the same commands as before, so probe is
unchanged.
Fixes: 27015b6fbcca ("wifi: mt76: mt7996: enable full system reset support")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../wireless/mediatek/mt76/mt7996/debugfs.c | 47 +-------------
.../net/wireless/mediatek/mt76/mt7996/mcu.c | 61 ++++++++++++++++++-
.../wireless/mediatek/mt76/mt7996/mt7996.h | 1 +
3 files changed, 62 insertions(+), 47 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c
index 8f1ef19c3876..2ca594618f3b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c
@@ -306,47 +306,10 @@ static int
mt7996_fw_debug_wm_set(void *data, u64 val)
{
struct mt7996_dev *dev = data;
- enum {
- DEBUG_TXCMD = 62,
- DEBUG_CMD_RPT_TX,
- DEBUG_CMD_RPT_TRIG,
- DEBUG_SPL,
- DEBUG_RPT_RX,
- DEBUG_RPT_RA = 68,
- } debug;
- bool tx, rx, en;
- int ret;
dev->fw_debug_wm = val ? MCU_FW_LOG_TO_HOST : 0;
- if (dev->fw_debug_bin)
- val = MCU_FW_LOG_RELAY;
- else
- val = dev->fw_debug_wm;
-
- tx = dev->fw_debug_wm || (dev->fw_debug_bin & BIT(1));
- rx = dev->fw_debug_wm || (dev->fw_debug_bin & BIT(2));
- en = dev->fw_debug_wm || (dev->fw_debug_bin & BIT(0));
-
- ret = mt7996_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, val);
- if (ret)
- return ret;
-
- for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RA; debug++) {
- if (debug == 67)
- continue;
-
- if (debug == DEBUG_RPT_RX)
- val = en && rx;
- else
- val = en && tx;
-
- ret = mt7996_mcu_fw_dbg_ctrl(dev, debug, val);
- if (ret)
- return ret;
- }
-
- return 0;
+ return mt7996_mcu_fw_debug_set(dev, MCU_FW_LOG_WM, false);
}
static int
@@ -366,16 +329,10 @@ static int
mt7996_fw_debug_wa_set(void *data, u64 val)
{
struct mt7996_dev *dev = data;
- int ret;
dev->fw_debug_wa = val ? MCU_FW_LOG_TO_HOST : 0;
- ret = mt7996_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, dev->fw_debug_wa);
- if (ret)
- return ret;
-
- return mt7996_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), MCU_WA_PARAM_PDMA_RX,
- !!dev->fw_debug_wa, 0);
+ return mt7996_mcu_fw_debug_set(dev, MCU_FW_LOG_WA, false);
}
static int
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index 627ca3e93e51..d82a1f659366 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -3885,6 +3885,63 @@ int mt7996_mcu_fw_dbg_ctrl(struct mt7996_dev *dev, u32 module, u8 level)
sizeof(data), false);
}
+int mt7996_mcu_fw_debug_set(struct mt7996_dev *dev, u8 type, bool load)
+{
+ enum {
+ DEBUG_TXCMD = 62,
+ DEBUG_CMD_RPT_TX,
+ DEBUG_CMD_RPT_TRIG,
+ DEBUG_SPL,
+ DEBUG_RPT_RX,
+ DEBUG_RPT_RA = 68,
+ } debug;
+ bool tx, rx, en;
+ u8 ctrl;
+ int ret;
+
+ if (type == MCU_FW_LOG_WA) {
+ ret = mt7996_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA,
+ dev->fw_debug_wa);
+ if (ret || (load && !dev->fw_debug_wa))
+ return ret;
+
+ return mt7996_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
+ MCU_WA_PARAM_PDMA_RX,
+ !!dev->fw_debug_wa, 0);
+ }
+
+ if (dev->fw_debug_bin)
+ ctrl = MCU_FW_LOG_RELAY;
+ else
+ ctrl = dev->fw_debug_wm;
+
+ tx = dev->fw_debug_wm || (dev->fw_debug_bin & BIT(1));
+ rx = dev->fw_debug_wm || (dev->fw_debug_bin & BIT(2));
+ en = dev->fw_debug_wm || (dev->fw_debug_bin & BIT(0));
+
+ ret = mt7996_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, ctrl);
+ if (ret || (load && !en))
+ return ret;
+
+ for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RA; debug++) {
+ u8 level;
+
+ if (debug == 67)
+ continue;
+
+ if (debug == DEBUG_RPT_RX)
+ level = en && rx;
+ else
+ level = en && tx;
+
+ ret = mt7996_mcu_fw_dbg_ctrl(dev, debug, level);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
static int mt7996_mcu_set_mwds(struct mt7996_dev *dev, bool enabled)
{
struct {
@@ -3963,12 +4020,12 @@ int mt7996_mcu_init_firmware(struct mt7996_dev *dev)
return ret;
set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state);
- ret = mt7996_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, 0);
+ ret = mt7996_mcu_fw_debug_set(dev, MCU_FW_LOG_WM, true);
if (ret)
return ret;
if (mt7996_has_wa(dev)) {
- ret = mt7996_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, 0);
+ ret = mt7996_mcu_fw_debug_set(dev, MCU_FW_LOG_WA, true);
if (ret)
return ret;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
index 24048a5ede31..c50fd3c15728 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
@@ -835,6 +835,7 @@ int mt7996_mcu_set_rro(struct mt7996_dev *dev, u16 tag, u16 val);
int mt7996_mcu_wa_cmd(struct mt7996_dev *dev, int cmd, u32 a1, u32 a2, u32 a3);
int mt7996_mcu_fw_log_2_host(struct mt7996_dev *dev, u8 type, u8 ctrl);
int mt7996_mcu_fw_dbg_ctrl(struct mt7996_dev *dev, u32 module, u8 level);
+int mt7996_mcu_fw_debug_set(struct mt7996_dev *dev, u8 type, bool load);
int mt7996_mcu_trigger_assert(struct mt7996_dev *dev);
void mt7996_mcu_rx_event(struct mt7996_dev *dev, struct sk_buff *skb);
void mt7996_mcu_exit(struct mt7996_dev *dev);
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH mt76-next 20/20] wifi: mt76: mt7915: keep the firmware log settings across a reload
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
` (17 preceding siblings ...)
2026-11-20 17:44 ` [PATCH mt76-next 19/20] wifi: mt76: mt7996: keep the firmware log settings across a reload Felix Fietkau
@ 2026-11-20 17:44 ` Felix Fietkau
18 siblings, 0 replies; 20+ messages in thread
From: Felix Fietkau @ 2026-11-20 17:44 UTC (permalink / raw)
To: linux-wireless
mt7915_mcu_init_firmware() turns the WM and WA firmware log off after
each firmware load, while dev->fw.debug_wm, dev->fw.debug_wa and
dev->fw.debug_bin keep the debugfs settings. Since the full system reset
loads the firmware again, a reset silently stops firmware logging, and
the debugfs files still report it as enabled.
Send the stored settings at each firmware load, and, where WM or WA
logging is enabled, the other commands and register writes that the
debugfs write sends. With logging off a load sends the same commands as
before, so probe is unchanged.
Fixes: 8a55712d124f ("wifi: mt76: mt7915: enable full system reset support")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../wireless/mediatek/mt76/mt7915/debugfs.c | 49 +--------------
.../net/wireless/mediatek/mt76/mt7915/mcu.c | 63 ++++++++++++++++++-
.../wireless/mediatek/mt76/mt7915/mt7915.h | 1 +
3 files changed, 64 insertions(+), 49 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
index a4e95073001d..f69457b0154f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
@@ -495,50 +495,11 @@ static int
mt7915_fw_debug_wm_set(void *data, u64 val)
{
struct mt7915_dev *dev = data;
- enum {
- DEBUG_TXCMD = 62,
- DEBUG_CMD_RPT_TX,
- DEBUG_CMD_RPT_TRIG,
- DEBUG_SPL,
- DEBUG_RPT_RX,
- } debug;
- bool tx, rx, en;
int ret;
dev->fw.debug_wm = val ? MCU_FW_LOG_TO_HOST : 0;
- if (dev->fw.debug_bin)
- val = 16;
- else
- val = dev->fw.debug_wm;
-
- tx = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(1));
- rx = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(2));
- en = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(0));
-
- ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, val);
- if (ret)
- goto out;
-
- for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RX; debug++) {
- if (debug == DEBUG_RPT_RX)
- val = en && rx;
- else
- val = en && tx;
-
- ret = mt7915_mcu_fw_dbg_ctrl(dev, debug, val);
- if (ret)
- goto out;
- }
-
- /* WM CPU info record control */
- mt76_clear(dev, MT_CPU_UTIL_CTRL, BIT(0));
- mt76_wr(dev, MT_DIC_CMD_REG_CMD, BIT(2) | BIT(13) |
- (dev->fw.debug_wm ? 0 : BIT(0)));
- mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR, BIT(5));
- mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_SOFT_ADDR, BIT(5));
-
-out:
+ ret = mt7915_mcu_fw_debug_set(dev, MCU_FW_LOG_WM, false);
if (ret)
dev->fw.debug_wm = 0;
@@ -566,13 +527,7 @@ mt7915_fw_debug_wa_set(void *data, u64 val)
dev->fw.debug_wa = val ? MCU_FW_LOG_TO_HOST : 0;
- ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, dev->fw.debug_wa);
- if (ret)
- goto out;
-
- ret = mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
- MCU_WA_PARAM_PDMA_RX, !!dev->fw.debug_wa, 0);
-out:
+ ret = mt7915_mcu_fw_debug_set(dev, MCU_FW_LOG_WA, false);
if (ret)
dev->fw.debug_wa = 0;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 9b748b37624d..6e1c3e5e2fe9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -2221,6 +2221,65 @@ int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level)
sizeof(data), false);
}
+int mt7915_mcu_fw_debug_set(struct mt7915_dev *dev, u8 type, bool load)
+{
+ enum {
+ DEBUG_TXCMD = 62,
+ DEBUG_CMD_RPT_TX,
+ DEBUG_CMD_RPT_TRIG,
+ DEBUG_SPL,
+ DEBUG_RPT_RX,
+ } debug;
+ bool tx, rx, en;
+ u8 ctrl;
+ int ret;
+
+ if (type == MCU_FW_LOG_WA) {
+ ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA,
+ dev->fw.debug_wa);
+ if (ret || (load && !dev->fw.debug_wa))
+ return ret;
+
+ return mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
+ MCU_WA_PARAM_PDMA_RX,
+ !!dev->fw.debug_wa, 0);
+ }
+
+ if (dev->fw.debug_bin)
+ ctrl = 16;
+ else
+ ctrl = dev->fw.debug_wm;
+
+ tx = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(1));
+ rx = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(2));
+ en = dev->fw.debug_wm || (dev->fw.debug_bin & BIT(0));
+
+ ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, ctrl);
+ if (ret || (load && !en))
+ return ret;
+
+ for (debug = DEBUG_TXCMD; debug <= DEBUG_RPT_RX; debug++) {
+ u8 level;
+
+ if (debug == DEBUG_RPT_RX)
+ level = en && rx;
+ else
+ level = en && tx;
+
+ ret = mt7915_mcu_fw_dbg_ctrl(dev, debug, level);
+ if (ret)
+ return ret;
+ }
+
+ mt76_clear(dev, MT_CPU_UTIL_CTRL, BIT(0));
+ mt76_wr(dev, MT_DIC_CMD_REG_CMD, BIT(2) | BIT(13) |
+ (dev->fw.debug_wm ? 0 : BIT(0)));
+ mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR, BIT(5));
+ mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_SOFT_ADDR, BIT(5));
+
+ return 0;
+}
+
int mt7915_mcu_muru_debug_set(struct mt7915_dev *dev, bool enabled)
{
struct {
@@ -2441,11 +2500,11 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev)
return ret;
set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state);
- ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, 0);
+ ret = mt7915_mcu_fw_debug_set(dev, MCU_FW_LOG_WM, true);
if (ret)
return ret;
- ret = mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WA, 0);
+ ret = mt7915_mcu_fw_debug_set(dev, MCU_FW_LOG_WA, true);
if (ret)
return ret;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
index 1a0aeed5073e..afb856febe3a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
@@ -551,6 +551,7 @@ int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
int mt7915_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3);
int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl);
int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level);
+int mt7915_mcu_fw_debug_set(struct mt7915_dev *dev, u8 type, bool load);
void mt7915_mcu_rx_event(struct mt7915_dev *dev, struct sk_buff *skb);
void mt7915_mcu_exit(struct mt7915_dev *dev);
--
2.47.3
^ permalink raw reply related [flat|nested] 20+ messages in thread