]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mt76: mt7925: sync MT7927 BSS band assignment
authorSean Wang <sean.wang@mediatek.com>
Sat, 25 Apr 2026 19:50:07 +0000 (14:50 -0500)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jun 2026 10:15:21 +0000 (10:15 +0000)
MT7927 needs DBDC enabled and uses a fixed firmware band assignment for
2.4GHz and 5/6GHz BSS contexts.

Reprogram the STA dev context when the channel context is assigned so the
firmware sees the updated band_idx before the BSS is used. This avoids
stale band programming after band changes.

Co-developed-by: Javier Tia <floss@jetm.me>
Signed-off-by: Javier Tia <floss@jetm.me>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Link: https://patch.msgid.link/20260425195011.790265-18-sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7925/init.c
drivers/net/wireless/mediatek/mt76/mt7925/main.c
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
drivers/net/wireless/mediatek/mt76/mt7925/pci_mac.c

index a8c2ca7c0efc62e81dc58a4897d27dda49643843..e85b0d104fbe700efe2bd67e6f44b743b1494f46 100644 (file)
@@ -117,6 +117,15 @@ static int __mt7925_init_hardware(struct mt792x_dev *dev)
        if (ret)
                goto out;
 
+       if (is_mt7927(&dev->mt76)) {
+               ret = mt7925_mcu_set_dbdc(&dev->mphy, true);
+               if (ret) {
+                       dev_warn(dev->mt76.dev,
+                                "MT7927 DBDC enable failed: %d\n", ret);
+                       ret = 0;
+               }
+       }
+
 out:
        return ret;
 }
index 74d65497cf9bbcafb6ef784ec8a5e3fb91f1812b..2599b738496fda9c281724749ac3e7299a61dbb0 100644 (file)
@@ -396,6 +396,18 @@ 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;
+
+       if (is_mt7927(&dev->mt76)) {
+               struct ieee80211_channel *chan;
+
+               if (link_conf->chanreq.oper.chan)
+                       chan = link_conf->chanreq.oper.chan;
+               else
+                       chan = mvif->phy->mt76->chandef.chan;
+
+               mconf->mt76.band_idx = mt7927_band_idx(chan->band);
+       }
+
        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);
@@ -2244,6 +2256,29 @@ out:
        return err;
 }
 
+static int
+mt7927_reconfig_band(struct mt792x_dev *dev, struct ieee80211_vif *vif,
+                    struct ieee80211_bss_conf *link_conf,
+                    struct mt792x_bss_conf *mconf,
+                    u8 band_idx)
+{
+       struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+       struct mt792x_link_sta *mlink = &mvif->sta.deflink;
+       int ret;
+
+       ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, link_conf,
+                                         &mconf->mt76, &mlink->wcid,
+                                         false);
+       if (ret)
+               return ret;
+
+       mconf->mt76.band_idx = band_idx;
+
+       return mt76_connac_mcu_uni_add_dev(&dev->mphy, link_conf,
+                                          &mconf->mt76, &mlink->wcid,
+                                          true);
+}
+
 static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
                                     struct ieee80211_vif *vif,
                                     struct ieee80211_bss_conf *link_conf,
@@ -2254,6 +2289,7 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
        struct mt792x_dev *dev = mt792x_hw_dev(hw);
        struct ieee80211_bss_conf *pri_link_conf;
        struct mt792x_bss_conf *mconf;
+       u8 band_idx;
 
        mutex_lock(&dev->mt76.mutex);
 
@@ -2267,6 +2303,12 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
                                                NULL, true);
        } else {
                mconf = &mvif->bss_conf;
+
+               if (is_mt7927(&dev->mt76)) {
+                       band_idx = mt7927_band_idx(ctx->def.chan->band);
+
+                       mt7927_reconfig_band(dev, vif, link_conf, mconf, band_idx);
+               }
        }
 
        mconf->mt76.ctx = ctx;
index 9a1891c653c0626288c7c27d3d4ef0f1e0c62a77..1cd234737adb102d446e77a7c2bea3b8362e29c5 100644 (file)
@@ -2923,6 +2923,7 @@ int mt7925_mcu_set_dbdc(struct mt76_phy *phy, bool enable)
 
        return err;
 }
+EXPORT_SYMBOL_GPL(mt7925_mcu_set_dbdc);
 
 static void
 mt7925_mcu_build_scan_ie_tlv(struct mt76_dev *mdev,
index 984be40ca76d90a1c2c3214bdbdf5ba2cfe03abb..242f83f90dd41598aab4241fd41566e01de0ac1b 100644 (file)
@@ -252,6 +252,18 @@ struct mt7925_txpwr {
        s8 eht996x3_484[16][2];
 };
 
+static inline u8 mt7927_band_idx(enum nl80211_band band)
+{
+       switch (band) {
+       case NL80211_BAND_2GHZ:
+               return 0;
+       case NL80211_BAND_5GHZ:
+       case NL80211_BAND_6GHZ:
+       default:
+               return 1;
+       }
+}
+
 extern const struct ieee80211_ops mt7925_ops;
 
 int __mt7925_start(struct mt792x_phy *phy);
index 1626a368408280be06929d66aab2d2e66976b41e..97683949a305d9a0e1f3c7fb43dadd13c9b4dc8a 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "mt7925.h"
 #include "../dma.h"
+#include "mcu.h"
 #include "mac.h"
 
 int mt7925e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
@@ -144,6 +145,12 @@ int mt7925e_mac_reset(struct mt792x_dev *dev)
        if (err)
                goto out;
 
+       if (is_mt7927(&dev->mt76)) {
+               err = mt7925_mcu_set_dbdc(&dev->mphy, true);
+               if (err)
+                       goto out;
+       }
+
        err = __mt7925_start(&dev->phy);
 out:
        clear_bit(MT76_RESET, &dev->mphy.state);