Linux wireless drivers development
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH mt76-next 11/17] wifi: mt76: mt7996: restore the operating channel after an L1 SER
Date: Sat, 21 Nov 2026 13:09:20 +0100	[thread overview]
Message-ID: <20261121120926.3603979-11-nbd@nbd.name> (raw)
In-Reply-To: <20261121120926.3603979-1-nbd@nbd.name>

Since commit b36d55610215 ("wifi: mt76: abort scan/roc on hw restart"),
the L1 SER aborts a running ROC or scan with MT76_MCU_RESET set. Neither
the completion nor the rest of the recovery then sets a channel, so the
firmware stays on the off-channel in its scan state. In that state the
firmware keeps the station queues of the band stopped until the next
channel switch. A ROC or scan that ends between the SER interrupt and
the reset work has the same effect. A scan of a DFS operating channel
also leaves radar detection off, since only the channel set that the
aborted completion skips would start it again.

After the recovery, switch each band that the firmware still holds in
the scan state back to its operating channel. Also switch back a band
whose DFS state the aborted scan left stale. Count a scan switch as
soon as it is sent, since the firmware can act on a switch whose answer
the reset loses.

Fixes: b36d55610215 ("wifi: mt76: abort scan/roc on hw restart")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mac80211.c |  1 +
 .../net/wireless/mediatek/mt76/mt7996/mac.c   | 46 +++++++++++++++++--
 .../net/wireless/mediatek/mt76/mt7996/mcu.c   | 17 ++++++-
 .../wireless/mediatek/mt76/mt7996/mt7996.h    |  1 +
 4 files changed, 58 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index db604ffde216..77116d9f4125 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -1179,6 +1179,7 @@ int __mt76_set_channel(struct mt76_phy *phy, struct cfg80211_chan_def *chandef,
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(__mt76_set_channel);
 
 int mt76_set_channel(struct mt76_phy *phy, struct cfg80211_chan_def *chandef,
 		     bool offchannel)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index 7873b87c74d7..62f3ac2b2cd2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -2263,19 +2263,50 @@ void mt7996_mac_update_beacons(struct mt7996_phy *phy)
 }
 
 static void
-mt7996_update_beacons(struct mt7996_dev *dev)
+mt7996_update_band_beacons(struct mt7996_phy *phy, unsigned long skip)
+{
+	if (!test_bit(phy->mt76->band_idx, &skip))
+		mt7996_mac_update_beacons(phy);
+}
+
+static void
+mt7996_update_beacons(struct mt7996_dev *dev, unsigned long skip)
 {
 	struct mt76_phy *phy2, *phy3;
 
-	mt7996_mac_update_beacons(&dev->phy);
+	mt7996_update_band_beacons(&dev->phy, skip);
 
 	phy2 = dev->mt76.phys[MT_BAND1];
 	if (phy2)
-		mt7996_mac_update_beacons(phy2->priv);
+		mt7996_update_band_beacons(phy2->priv, skip);
 
 	phy3 = dev->mt76.phys[MT_BAND2];
 	if (phy3)
-		mt7996_mac_update_beacons(phy3->priv);
+		mt7996_update_band_beacons(phy3->priv, skip);
+}
+
+static bool
+mt7996_mac_reset_channel_restore(struct mt7996_phy *phy)
+{
+	bool bcn_stopped = phy->offchan_bcn_stopped;
+	bool offchannel = phy->fw_offchannel;
+	struct mt76_phy *mphy = phy->mt76;
+
+	if (!mphy->chanctx)
+		return false;
+
+	if (!offchannel &&
+	    (mt7996_get_rdd_idx(phy, false) < 0 ||
+	     mphy->dfs_state == mt76_phy_dfs_state(mphy)))
+		return false;
+
+	if (__mt76_set_channel(mphy, &mphy->main_chandef, false))
+		return false;
+
+	if (offchannel)
+		mt76_offchannel_notify(mphy, false);
+
+	return bcn_stopped;
 }
 
 void mt7996_tx_token_put(struct mt7996_dev *dev)
@@ -2579,6 +2610,7 @@ mt7996_mac_full_reset(struct mt7996_dev *dev)
 
 void mt7996_mac_reset_work(struct work_struct *work)
 {
+	unsigned long bcn_restored = 0;
 	struct ieee80211_hw *hw;
 	struct mt7996_dev *dev;
 	struct mt7996_phy *phy;
@@ -2724,8 +2756,12 @@ void mt7996_mac_reset_work(struct work_struct *work)
 	napi_schedule(&dev->mt76.tx_napi);
 	local_bh_enable();
 
+	mt7996_for_each_phy(dev, phy)
+		if (mt7996_mac_reset_channel_restore(phy))
+			bcn_restored |= BIT(phy->mt76->band_idx);
+
 	ieee80211_wake_queues(hw);
-	mt7996_update_beacons(dev);
+	mt7996_update_beacons(dev, bcn_restored);
 
 	mutex_unlock(&dev->mt76.mutex);
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index 0eeac9084de7..e4f52cb81470 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -4394,6 +4394,8 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag)
 	struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
 	int freq1 = chandef->center_freq1;
 	u8 band_idx = phy->mt76->band_idx;
+	bool scan;
+	int ret;
 	struct {
 		/* fixed field */
 		u8 __rsv[4];
@@ -4448,8 +4450,19 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag)
 		req.center_ch2 = ieee80211_frequency_to_channel(freq2);
 	}
 
-	return mt76_mcu_send_msg(&dev->mt76, MCU_WMWA_UNI_CMD(CHANNEL_SWITCH),
-				 &req, sizeof(req), true);
+	/* the firmware stops the station queues of the band at a scan switch
+	 * and starts them again only at a normal or DFS switch
+	 */
+	scan = req.switch_reason == CH_SWITCH_SCAN_BYPASS_DPD;
+	if (tag == UNI_CHANNEL_SWITCH && scan)
+		phy->fw_offchannel = true;
+
+	ret = mt76_mcu_send_msg(&dev->mt76, MCU_WMWA_UNI_CMD(CHANNEL_SWITCH),
+				&req, sizeof(req), true);
+	if (!ret && tag == UNI_CHANNEL_SWITCH && !scan)
+		phy->fw_offchannel = false;
+
+	return ret;
 }
 
 int mt7996_mcu_set_punct(struct mt7996_phy *phy)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
index 5ee8bf12f73b..1e01e6075193 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
@@ -421,6 +421,7 @@ struct mt7996_phy {
 	bool counter_reset;
 	bool rdd_tx_paused;
 	bool offchan_bcn_stopped;
+	bool fw_offchannel;
 };
 
 struct mt7996_dev {
-- 
2.47.3


  parent reply	other threads:[~2026-11-21 12:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 12:09 [PATCH mt76-next 01/17] wifi: mt76: mt7996: name a new secondary link to the firmware first Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 02/17] wifi: mt76: add a helper to point the TXQs of a station at a wcid Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 03/17] wifi: mt76: mt7925: move the default link to a remaining link Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 04/17] wifi: mt76: mt7925: keep the deflink wcid index until station removal Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 05/17] wifi: mt76: mt792x: look up the TX links under RCU Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 06/17] wifi: mt76: mt7925: read the links under RCU in the IPv6 notifier Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 07/17] wifi: mt76: mt7925: abort a ROC on the BSS that requested it Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 08/17] wifi: mt76: mt7925: take the link conf of a removed link from old[] Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 09/17] wifi: mt76: mt7925: send the MLO ROC only for a station vif Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 10/17] wifi: mt76: mt7996: send the Beacon rate table again after a full reset Felix Fietkau
2026-11-21 12:09 ` Felix Fietkau [this message]
2026-11-21 12:09 ` [PATCH mt76-next 12/17] wifi: mt76: reset the DFS state of a phy at " Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 13/17] wifi: mt76: mt7996: abort a background CAC " Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 14/17] wifi: mt76: mt7915: " Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 15/17] wifi: mt76: mt7996: clear the airtime counts with the WTBL counters Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 16/17] wifi: mt76: mt7996: drop the host WTBL write of a fixed GI Felix Fietkau
2026-11-21 12:09 ` [PATCH mt76-next 17/17] wifi: mt76: mt7925: don't reset the USB device on probe Felix Fietkau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261121120926.3603979-11-nbd@nbd.name \
    --to=nbd@nbd.name \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox