Skip to contentSkip to conversation

wifi: mt76: mt792x: tell mac80211 when a disconnect cancels its ROC

PATCH Superseded Devin Wittmayer 2 participants 4 messages Nov 10

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: mt76: mt792x: tell mac80211 when a disconnect cancels its ROC

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")

---
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/[email protected]/

 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(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +13 -1
index 09574d4417cd..58df080a342e 100644
@@ -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);
 }
 
drivers/net/wireless/mediatek/mt76/mt7925/main.c +12 -1
index 222836699d15..01c08b80ea14 100644
@@ -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);
 }
 
Signature · 1 line
2.56.0
#1 lore raw
kernel test robot noticed the following build errors:

Hi Devin,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on wireless/main linus/master v7.4-rc2 next-20261109]
[cannot apply to linux-review/Devin-Wittmayer/wifi-mt76-mt792x-tell-mac80211-when-a-disconnect-cancels-its-ROC/20261022-184827] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Devin-Wittmayer/wifi-mt76-mt792x-tell-mac80211-when-a-disconnect-cancels-its-ROC/20261109-175846
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20261110005846.38432-1-lucid_duck%40justthetip.ca
patch subject: [PATCH v2] wifi: mt76: mt792x: tell mac80211 when a disconnect cancels its ROC
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20261110/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261110/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/net/wireless/mediatek/mt76/mt7921/main.c: In function 'mt7921_roc_abort_sync':

>> drivers/net/wireless/mediatek/mt76/mt7921/main.c:385:16: error: 'struct mt792x_phy' has no member named 'roc_notify'
     385 |         if (phy->roc_notify)
         |                ^~
   drivers/net/wireless/mediatek/mt76/mt7921/main.c: In function 'mt7921_abort_roc':
   drivers/net/wireless/mediatek/mt76/mt7921/main.c:423:27: error: 'struct mt792x_phy' has no member named 'roc_notify'
     423 |         if (aborted && phy->roc_notify)
         |                           ^~
   drivers/net/wireless/mediatek/mt76/mt7921/main.c: In function 'mt7921_set_roc':
   drivers/net/wireless/mediatek/mt76/mt7921/main.c:441:12: error: 'struct mt792x_phy' has no member named 'roc_notify'
     441 |         phy->roc_notify = type == MT7921_ROC_REQ_ROC;
         |            ^~
   drivers/net/wireless/mediatek/mt76/mt7921/main.c: In function 'mt7921_cancel_remain_on_channel':
   drivers/net/wireless/mediatek/mt76/mt7921/main.c:484:12: error: 'struct mt792x_phy' has no member named 'roc_notify'
     484 |         phy->roc_notify = false;
         |            ^~
--
   drivers/net/wireless/mediatek/mt76/mt7925/main.c: In function 'mt7925_roc_abort_sync':
>> drivers/net/wireless/mediatek/mt76/mt7925/main.c:531:16: error: 'struct mt792x_phy' has no member named 'roc_notify'
     531 |         if (phy->roc_notify)
         |                ^~
   drivers/net/wireless/mediatek/mt76/mt7925/main.c: In function 'mt7925_abort_roc':
   drivers/net/wireless/mediatek/mt76/mt7925/main.c:569:27: error: 'struct mt792x_phy' has no member named 'roc_notify'
     569 |         if (aborted && phy->roc_notify)
         |                           ^~
   drivers/net/wireless/mediatek/mt76/mt7925/main.c: In function 'mt7925_cancel_remain_on_channel':
   drivers/net/wireless/mediatek/mt76/mt7925/main.c:657:12: error: 'struct mt792x_phy' has no member named 'roc_notify'
     657 |         phy->roc_notify = false;
         |            ^~

vim +385 drivers/net/wireless/mediatek/mt76/mt7921/main.c

370
371 void mt7921_roc_abort_sync(struct mt792x_dev *dev)
372 {
373 struct mt792x_phy *phy = &dev->phy;
374
375 if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
376 return;
377
378 timer_delete_sync(&phy->roc_timer);
379 cancel_work(&phy->roc_work);
380
381 ieee80211_iterate_interfaces(mt76_hw(dev),
382 IEEE80211_IFACE_ITER_RESUME_ALL,
383 mt7921_roc_iter, (void *)phy);
384

 > 385		if (phy->roc_notify)

386 ieee80211_remain_on_channel_expired(mt76_hw(dev));
387 }
388 EXPORT_SYMBOL_GPL(mt7921_roc_abort_sync);
389

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

#2 lore raw
Quoted 3 lines · kernel test robot

[auto build test ERROR on wireless-next/main]
[also build test ERROR on wireless/main linus/master v7.4-rc2 next-20261109] [If your patch is applied to the wrong git tree, kindly drop us a note.

Wrong tree. v2 is for Felix's mt76 branch:

https://github.com/nbd168/wireless.git mt76
base-commit: 8739e5b44b23

Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/net/wireless/mediatek/mt76/mt7921/main.c:385:16: error: 'struct mt792x_phy' has no member named 'roc_notify'

That flag comes from 2466ffac172d, which is in that branch and has not reached wireless-next yet. The clang report is the same thing.

Devin

#3 lore raw
In reply to Devin Wittmayer
kernel test robot noticed the following build errors:

Hi Devin,

kernel test robot noticed the following build errors:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on wireless/main linus/master v7.4-rc2 next-20261109]
[cannot apply to linux-review/Devin-Wittmayer/wifi-mt76-mt792x-tell-mac80211-when-a-disconnect-cancels-its-ROC/20261022-184827] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Devin-Wittmayer/wifi-mt76-mt792x-tell-mac80211-when-a-disconnect-cancels-its-ROC/20261109-175846
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20261110005846.38432-1-lucid_duck%40justthetip.ca
patch subject: [PATCH v2] wifi: mt76: mt792x: tell mac80211 when a disconnect cancels its ROC
config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20261110/[email protected]/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project b3e2466a7ef2bbc97d31230c3bf39a6fa50a608a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261110/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/net/wireless/mediatek/mt76/mt7921/main.c:385:11: error: no member named 'roc_notify' in 'struct mt792x_phy'
     385 |         if (phy->roc_notify)
         |             ~~~  ^
   drivers/net/wireless/mediatek/mt76/mt7921/main.c:423:22: error: no member named 'roc_notify' in 'struct mt792x_phy'
     423 |         if (aborted && phy->roc_notify)
         |                        ~~~  ^
   drivers/net/wireless/mediatek/mt76/mt7921/main.c:441:7: error: no member named 'roc_notify' in 'struct mt792x_phy'
     441 |         phy->roc_notify = type == MT7921_ROC_REQ_ROC;
         |         ~~~  ^
   drivers/net/wireless/mediatek/mt76/mt7921/main.c:484:7: error: no member named 'roc_notify' in 'struct mt792x_phy'
     484 |         phy->roc_notify = false;
         |         ~~~  ^
   4 errors generated.
--
>> drivers/net/wireless/mediatek/mt76/mt7925/main.c:531:11: error: no member named 'roc_notify' in 'struct mt792x_phy'
     531 |         if (phy->roc_notify)
         |             ~~~  ^
   drivers/net/wireless/mediatek/mt76/mt7925/main.c:569:22: error: no member named 'roc_notify' in 'struct mt792x_phy'
     569 |         if (aborted && phy->roc_notify)
         |                        ~~~  ^
   drivers/net/wireless/mediatek/mt76/mt7925/main.c:657:7: error: no member named 'roc_notify' in 'struct mt792x_phy'
     657 |         phy->roc_notify = false;
         |         ~~~  ^

3 errors generated.

vim +385 drivers/net/wireless/mediatek/mt76/mt7921/main.c

370
371 void mt7921_roc_abort_sync(struct mt792x_dev *dev)
372 {
373 struct mt792x_phy *phy = &dev->phy;
374
375 if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
376 return;
377
378 timer_delete_sync(&phy->roc_timer);
379 cancel_work(&phy->roc_work);
380
381 ieee80211_iterate_interfaces(mt76_hw(dev),
382 IEEE80211_IFACE_ITER_RESUME_ALL,
383 mt7921_roc_iter, (void *)phy);
384

 > 385		if (phy->roc_notify)

386 ieee80211_remain_on_channel_expired(mt76_hw(dev));
387 }
388 EXPORT_SYMBOL_GPL(mt7921_roc_abort_sync);
389

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki