From: Javier Tia <floss@jetm.me>
To: Felix Fietkau <nbd@nbd.name>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Ryder Lee <ryder.lee@mediatek.com>,
Shayne Chen <shayne.chen@mediatek.com>,
Sean Wang <sean.wang@mediatek.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Ming Yen Hsieh <mingyen.hsieh@mediatek.com>,
Deren Wu <deren.wu@mediatek.com>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, "Marcin FM" <marcin@lgic.pl>,
张旭涵 <Loong.0x00@gmail.com>,
"Cristian-Florin Radoi" <radoi.chris@gmail.com>,
"George Salukvadze" <giosal90@gmail.com>,
"Evgeny Kapusta" <3193631@gmail.com>,
"Samu Toljamo" <samu.toljamo@gmail.com>,
"Ariel Rosenfeld" <ariel.rosenfeld.750@gmail.com>,
"Chapuis Dario" <chapuisdario4@gmail.com>,
"Thibaut François" <tibo@humeurlibre.fr>
Subject: [PATCH v3 11/13] wifi: mt76: mt7925: fix band_idx for stable 5GHz/6GHz operation
Date: Wed, 25 Mar 2026 16:11:00 -0600 [thread overview]
Message-ID: <20260325-mt7927-wifi-support-v2-v3-11-5ca66c97a755@jetm.me> (raw)
In-Reply-To: <20260325-mt7927-wifi-support-v2-v3-0-5ca66c97a755@jetm.me>
The MT7927 firmware requires explicit band_idx assignment (0 for 2.4GHz,
1 for 5GHz/6GHz) instead of 0xff (auto-select) used by MT7925. Without
this, the firmware selects the wrong radio for 5GHz and 6GHz
connections, causing WPA 4-way handshake timeout and data plane failures
on those bands.
Introduce mt7925_band_idx(dev, band) helper that encapsulates the
chip check: returns the hardware band index for MT7927, or 0xff
(auto-select) for MT7925. Replace all scattered is_mt7927() + band
mapping patterns with the unified helper across BSS creation, channel
context assignment, ROC requests, and BSS info TLVs.
For ROC requests on MT7925, the helper returns 0xff which is then
refined to 0xfe (BAND_ALL with DBDC) for JOIN-type requests.
Also clamp invalid grant band_idx values using rfband as fallback, and
process grants for all MT7927 request types (not just JOIN).
Originally discovered and fixed by marcin-fm; Loong0x00 contributed
additional improvements based on marcin-fm's patch.
Co-developed-by: Marcin FM <marcin@lgic.pl>
Signed-off-by: Marcin FM <marcin@lgic.pl>
Co-developed-by: 张旭涵 <Loong.0x00@gmail.com>
Signed-off-by: 张旭涵 <Loong.0x00@gmail.com>
Tested-by: Marcin FM <marcin@lgic.pl>
Tested-by: Cristian-Florin Radoi <radoi.chris@gmail.com>
Tested-by: George Salukvadze <giosal90@gmail.com>
Tested-by: Evgeny Kapusta <3193631@gmail.com>
Tested-by: Samu Toljamo <samu.toljamo@gmail.com>
Tested-by: Ariel Rosenfeld <ariel.rosenfeld.750@gmail.com>
Tested-by: Chapuis Dario <chapuisdario4@gmail.com>
Tested-by: Thibaut François <tibo@humeurlibre.fr>
Tested-by: 张旭涵 <Loong.0x00@gmail.com>
Signed-off-by: Javier Tia <floss@jetm.me>
---
drivers/net/wireless/mediatek/mt76/mt7925/main.c | 35 ++++++++++++++-
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 50 +++++++++++++++++-----
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h | 7 +++
3 files changed, 80 insertions(+), 12 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index cfce851a94e2..f36638b35481 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -394,7 +394,19 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,
mconf->mt76.omac_idx = ieee80211_vif_is_mld(vif) ?
0 : mconf->mt76.idx;
- mconf->mt76.band_idx = 0xff;
+
+ {
+ struct ieee80211_channel *chan = NULL;
+
+ if (link_conf->chanreq.oper.chan)
+ chan = link_conf->chanreq.oper.chan;
+ else if (mvif->phy->mt76->chandef.chan)
+ chan = mvif->phy->mt76->chandef.chan;
+
+ mconf->mt76.band_idx = chan ?
+ mt7925_band_idx(&dev->mt76, chan->band) : 0xff;
+ }
+
mconf->mt76.wmm_idx = ieee80211_vif_is_mld(vif) ?
0 : mconf->mt76.idx % MT76_CONNAC_MAX_WMM_SETS;
mconf->mt76.link_idx = hweight16(mvif->valid_links);
@@ -411,7 +423,8 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,
mlink->wcid.idx = idx;
mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
- mt76_wcid_init(&mlink->wcid, 0);
+ mt76_wcid_init(&mlink->wcid,
+ mconf->mt76.band_idx == 0xff ? 0 : mconf->mt76.band_idx);
mt7925_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
@@ -2113,9 +2126,12 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
{
struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+ struct mt792x_link_sta *mlink;
struct mt792x_dev *dev = mt792x_hw_dev(hw);
struct ieee80211_bss_conf *pri_link_conf;
struct mt792x_bss_conf *mconf;
+ u8 band_idx;
+ u8 old_band;
mutex_lock(&dev->mt76.mutex);
@@ -2131,6 +2147,21 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
mconf = &mvif->bss_conf;
}
+ old_band = mconf->mt76.band_idx;
+ if (ctx->def.chan) {
+ band_idx = mt7925_band_idx(&dev->mt76, ctx->def.chan->band);
+ mconf->mt76.band_idx = band_idx;
+ mlink = mt792x_sta_to_link(&mvif->sta, mconf->link_id);
+ if (mlink)
+ mlink->wcid.phy_idx = band_idx;
+
+ if (old_band != band_idx && vif->type == NL80211_IFTYPE_STATION &&
+ mlink)
+ mt76_connac_mcu_uni_add_dev(&dev->mphy, link_conf,
+ &mconf->mt76, &mlink->wcid,
+ true);
+ }
+
mconf->mt76.ctx = ctx;
mctx->bss_conf = mconf;
mutex_unlock(&dev->mt76.mutex);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index a7f27c5014d5..0755fee6cdff 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -301,16 +301,36 @@ mt7925_mcu_connection_loss_event(struct mt792x_dev *dev, struct sk_buff *skb)
static void
mt7925_mcu_roc_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
{
- struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv;
+ struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt7925_roc_grant_tlv *grant = priv;
+ u8 band_idx = grant->dbdcband;
if (ieee80211_vif_is_mld(vif) && vif->type == NL80211_IFTYPE_STATION)
return;
- if (mvif->idx != grant->bss_idx)
+ if (mvif->bss_conf.mt76.idx != grant->bss_idx)
return;
- mvif->band_idx = grant->dbdcband;
+ /* MT7927 firmware requires band_idx 0 (2.4G) or 1 (5/6G).
+ * Clamp invalid grant values using rfband as fallback.
+ */
+ if (is_mt7927(&mvif->phy->dev->mt76) && band_idx > 1) {
+ switch (grant->rfband) {
+ case 1: /* 2.4 GHz */
+ band_idx = 0;
+ break;
+ case 2: /* 5 GHz */
+ case 3: /* 6 GHz */
+ band_idx = 1;
+ break;
+ default:
+ band_idx = mvif->bss_conf.mt76.band_idx <= 1 ?
+ mvif->bss_conf.mt76.band_idx : 0;
+ break;
+ }
+ }
+
+ mvif->bss_conf.mt76.band_idx = band_idx;
}
static void mt7925_mcu_roc_handle_grant(struct mt792x_dev *dev,
@@ -327,10 +347,11 @@ static void mt7925_mcu_roc_handle_grant(struct mt792x_dev *dev,
if (grant->reqtype == MT7925_ROC_REQ_ROC)
ieee80211_ready_on_channel(hw);
- else if (grant->reqtype == MT7925_ROC_REQ_JOIN)
+ else if (is_mt7927(&dev->mt76) || grant->reqtype == MT7925_ROC_REQ_JOIN)
ieee80211_iterate_active_interfaces_atomic(hw,
IEEE80211_IFACE_ITER_RESUME_ALL,
mt7925_mcu_roc_iter, grant);
+
dev->phy.roc_grant = true;
wake_up(&dev->phy.roc_wait);
duration = le32_to_cpu(grant->max_interval);
@@ -1378,10 +1399,14 @@ int mt7925_mcu_set_mlo_roc(struct mt792x_bss_conf *mconf, u16 sel_links,
req.roc[i].center_chan2 = 0;
req.roc[i].center_chan2_from_ap = 0;
- /* STR : 0xfe indicates BAND_ALL with enabling DBDC
- * EMLSR : 0xff indicates (BAND_AUTO) without DBDC
- */
- req.roc[i].dbdcband = type == MT7925_ROC_REQ_JOIN ? 0xfe : 0xff;
+ req.roc[i].dbdcband =
+ mt7925_band_idx(&mvif->phy->dev->mt76, chan->band);
+ if (req.roc[i].dbdcband == 0xff)
+ /* STR : 0xfe indicates BAND_ALL with enabling DBDC
+ * EMLSR : 0xff indicates (BAND_AUTO) without DBDC
+ */
+ req.roc[i].dbdcband = type == MT7925_ROC_REQ_JOIN ?
+ 0xfe : 0xff;
if (chan->hw_value < center_ch)
req.roc[i].sco = 1; /* SCA */
@@ -1419,7 +1444,8 @@ int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf,
.bw_from_ap = CMD_CBW_20MHZ,
.center_chan = center_ch,
.center_chan_from_ap = center_ch,
- .dbdcband = 0xff, /* auto */
+ .dbdcband = mt7925_band_idx(&dev->mt76,
+ chan->band),
},
};
@@ -1466,7 +1492,9 @@ int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf,
.len = cpu_to_le16(sizeof(struct roc_abort_tlv)),
.tokenid = token_id,
.bss_idx = mconf->mt76.idx,
- .dbdcband = 0xff, /* auto*/
+ .dbdcband = mconf->mt76.band_idx <= 1 ?
+ mconf->mt76.band_idx :
+ 0xff, /* auto */
},
};
@@ -2499,6 +2527,8 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
basic_req->phymode_ext = mt7925_get_phy_mode_ext(phy, vif, band,
link_sta);
+ mconf->mt76.band_idx = mt7925_band_idx(phy->dev, band);
+
if (band == NL80211_BAND_2GHZ)
basic_req->nonht_basic_phy = cpu_to_le16(PHY_TYPE_ERP_INDEX);
else
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
index 6b9bf1b89032..2f908d159e30 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
@@ -63,6 +63,13 @@ enum mt7925_roc_req {
MT7925_ROC_REQ_NUM
};
+static inline u8 mt7925_band_idx(struct mt76_dev *dev, enum nl80211_band band)
+{
+ if (is_mt7927(dev))
+ return band == NL80211_BAND_2GHZ ? 0 : 1;
+ return 0xff; /* auto-select for mt7925 */
+}
+
enum {
UNI_EVENT_ROC_GRANT = 0,
UNI_EVENT_ROC_GRANT_SUB_LINK = 4,
--
2.53.0
next prev parent reply other threads:[~2026-03-25 22:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 22:10 [PATCH v3 00/13] This series adds support for the MediaTek MT7927 (Filogic 380) combo Javier Tia
2026-03-25 22:10 ` [PATCH v3 01/13] wifi: mt76: mt7925: fix stale pointer comparisons in change_vif_links Javier Tia
2026-03-25 22:10 ` [PATCH v3 02/13] wifi: mt76: mt7925: add 320MHz bandwidth to bss_rlm_tlv Javier Tia
2026-03-25 22:10 ` [PATCH v3 03/13] wifi: mt76: mt7925: handle 320MHz bandwidth in RXV and TXS Javier Tia
2026-03-25 22:10 ` [PATCH v3 04/13] wifi: mt76: mt7925: populate EHT 320MHz MCS map in sta_rec Javier Tia
2026-03-25 22:10 ` [PATCH v3 05/13] wifi: mt76: mt7925: advertise EHT 320MHz capabilities for 6GHz band Javier Tia
2026-03-26 6:08 ` Sean Wang
2026-03-25 22:10 ` [PATCH v3 06/13] wifi: mt76: mt7925: add MT7927 chip ID helpers Javier Tia
2026-03-25 22:10 ` [PATCH v3 07/13] wifi: mt76: mt7925: add MT7927 firmware paths Javier Tia
2026-03-25 22:10 ` [PATCH v3 08/13] wifi: mt76: mt7925: use irq_map for chip-specific interrupt handling Javier Tia
2026-03-25 22:10 ` [PATCH v3 09/13] wifi: mt76: mt7925: add chip-specific DMA configuration Javier Tia
2026-03-25 22:10 ` [PATCH v3 10/13] wifi: mt76: mt7925: add MT7927 hardware initialization Javier Tia
2026-03-25 22:11 ` Javier Tia [this message]
2026-03-25 22:11 ` [PATCH v3 12/13] wifi: mt76: mt7925: disable ASPM and runtime PM for MT7927 Javier Tia
2026-03-26 6:14 ` Sean Wang
2026-03-25 22:11 ` [PATCH v3 13/13] wifi: mt76: mt7925: enable MT7927 PCI device IDs Javier Tia
2026-03-26 6:26 ` Sean Wang
2026-03-26 5:56 ` [PATCH v3 00/13] This series adds support for the MediaTek MT7927 (Filogic 380) combo Sean Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260325-mt7927-wifi-support-v2-v3-11-5ca66c97a755@jetm.me \
--to=floss@jetm.me \
--cc=3193631@gmail.com \
--cc=Loong.0x00@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=ariel.rosenfeld.750@gmail.com \
--cc=chapuisdario4@gmail.com \
--cc=deren.wu@mediatek.com \
--cc=giosal90@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=marcin@lgic.pl \
--cc=matthias.bgg@gmail.com \
--cc=mingyen.hsieh@mediatek.com \
--cc=nbd@nbd.name \
--cc=radoi.chris@gmail.com \
--cc=ryder.lee@mediatek.com \
--cc=samu.toljamo@gmail.com \
--cc=sean.wang@mediatek.com \
--cc=shayne.chen@mediatek.com \
--cc=tibo@humeurlibre.fr \
/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