[PATCH v2] wifi: mt76: mt792x: tell mac80211 when a disconnect cancels its ROC
Devin Wittmayer
lucid_duck at justthetip.ca
Mon Nov 9 16:58:46 PST 2026
A disconnect during a remain-on-channel (ROC) cancels the ROC in
firmware without telling mac80211, which then waits for a ROC that is
already gone. Scans stall, and after an AP deauth the station does not
reconnect.
Tell mac80211 when the driver cancels a ROC that mac80211 started.
Fixes: 41ac53c899bd ("wifi: mt76: mt7921: introduce chanctx support")
Fixes: 5ed54896b6bd ("wifi: mt76: mt7921: fix a potential scan no APs")
Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Fixes: 45064d19fd3a ("wifi: mt76: mt7925: fix a potential association failure upon resuming")
Signed-off-by: Devin Wittmayer <lucid_duck at justthetip.ca>
---
v2: rebased on Felix's mt76 branch (8739e5b44b23), where v1 no longer
applies. There, 2466ffac172d added a flag on mt7925 for a ROC that
mac80211 is waiting to see end. This uses that flag, and sets it on
mt7921 as well.
Tested on that branch with an MT7922 and an MT7925U:
disconnect while a ROC is held without this with it
AP deauth no reconnect, scans back in 4.2 s
stall
the station disconnects scans stall scan in 3.3 to
3.5 s
the same, MT7925U on two links no reconnect, scans back in 9.1 to
stall 9.4 s, 3 of 3
Each cancelled ROC is reported once, and a P2P find ends its ROCs as
before on both chips.
v1: https://lore.kernel.org/all/20261023014827.57411-1-lucid_duck@justthetip.ca/
drivers/net/wireless/mediatek/mt76/mt7921/main.c | 14 +++++++++++++-
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 13 ++++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 09574d4417cd..58df080a342e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -381,6 +381,9 @@ void mt7921_roc_abort_sync(struct mt792x_dev *dev)
ieee80211_iterate_interfaces(mt76_hw(dev),
IEEE80211_IFACE_ITER_RESUME_ALL,
mt7921_roc_iter, (void *)phy);
+
+ if (phy->roc_notify)
+ ieee80211_remain_on_channel_expired(mt76_hw(dev));
}
EXPORT_SYMBOL_GPL(mt7921_roc_abort_sync);
@@ -405,16 +408,21 @@ void mt7921_roc_work(struct work_struct *work)
static int mt7921_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif)
{
+ bool aborted;
int err = 0;
timer_delete_sync(&phy->roc_timer);
cancel_work_sync(&phy->roc_work);
mt792x_mutex_acquire(phy->dev);
- if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
+ aborted = test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state);
+ if (aborted)
err = mt7921_mcu_abort_roc(phy, vif, phy->roc_token_id);
mt792x_mutex_release(phy->dev);
+ if (aborted && phy->roc_notify)
+ ieee80211_remain_on_channel_expired(phy->mt76->hw);
+
return err;
}
@@ -430,6 +438,7 @@ static int mt7921_set_roc(struct mt792x_phy *phy,
return -EBUSY;
phy->roc_grant = false;
+ phy->roc_notify = type == MT7921_ROC_REQ_ROC;
err = mt7921_mcu_set_roc(phy, vif, chan, duration, type,
++phy->roc_token_id);
@@ -471,6 +480,9 @@ static int mt7921_cancel_remain_on_channel(struct ieee80211_hw *hw,
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_phy *phy = mt792x_hw_phy(hw);
+ /* mac80211 ends this ROC itself */
+ phy->roc_notify = false;
+
return mt7921_abort_roc(phy, mvif);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 222836699d15..01c08b80ea14 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -553,6 +553,9 @@ void mt7925_roc_abort_sync(struct mt792x_dev *dev)
ieee80211_iterate_interfaces(mt76_hw(dev),
IEEE80211_IFACE_ITER_RESUME_ALL,
mt7925_roc_iter, (void *)phy);
+
+ if (phy->roc_notify)
+ ieee80211_remain_on_channel_expired(mt76_hw(dev));
}
EXPORT_SYMBOL_GPL(mt7925_roc_abort_sync);
@@ -583,16 +586,21 @@ void mt7925_roc_work(struct work_struct *work)
static int mt7925_abort_roc(struct mt792x_phy *phy,
struct mt792x_bss_conf *mconf)
{
+ bool aborted;
int err = 0;
timer_delete_sync(&phy->roc_timer);
cancel_work_sync(&phy->roc_work);
mt792x_mutex_acquire(phy->dev);
- if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
+ aborted = test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state);
+ if (aborted)
err = mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id);
mt792x_mutex_release(phy->dev);
+ if (aborted && phy->roc_notify)
+ ieee80211_remain_on_channel_expired(phy->mt76->hw);
+
return err;
}
@@ -712,6 +720,9 @@ static int mt7925_cancel_remain_on_channel(struct ieee80211_hw *hw,
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_phy *phy = mt792x_hw_phy(hw);
+ /* mac80211 ends this ROC itself */
+ phy->roc_notify = false;
+
return mt7925_abort_roc(phy, &mvif->bss_conf);
}
--
2.56.0
More information about the Linux-mediatek
mailing list