]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: mt76: mt7925: fix the wrong link_idx when a p2p_device is present
authorMing Yen Hsieh <mingyen.hsieh@mediatek.com>
Wed, 5 Mar 2025 00:08:47 +0000 (16:08 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 20 Apr 2025 08:18:06 +0000 (10:18 +0200)
commit 4bada9b0a29c185d45cc9512509edd6069fbfa79 upstream.

When the p2p device and MLO station are running concurrently, the p2p device
will occupy the wrong link_idx when the MLO secondary link is added.

Fixes: 9e4c3a007f01 ("wifi: mt76: connac: Extend mt76_connac_mcu_uni_add_dev for MLO")
Cc: stable@vger.kernel.org
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Tested-by: Caleb Jorden <cjorden@gmail.com>
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Link: https://patch.msgid.link/20250305000851.493671-2-sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/mediatek/mt76/mt76.h
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
drivers/net/wireless/mediatek/mt76/mt7925/main.c

index 0b75a45ad2e821ccc998923f8470c8ff6d5f4667..e2e9b5ece74e2198e91e124e328da711784d0ee0 100644 (file)
@@ -755,6 +755,7 @@ struct mt76_testmode_data {
 
 struct mt76_vif {
        u8 idx;
+       u8 link_idx;
        u8 omac_idx;
        u8 band_idx;
        u8 wmm_idx;
index 7d07e720e4ec1d2aa917cad34f0230c8cc8f8e7d..452579ccc492287329c457fdc4aaf9911b44f757 100644 (file)
@@ -1164,7 +1164,7 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,
                        .tag = cpu_to_le16(DEV_INFO_ACTIVE),
                        .len = cpu_to_le16(sizeof(struct req_tlv)),
                        .active = enable,
-                       .link_idx = mvif->idx,
+                       .link_idx = mvif->link_idx,
                },
        };
        struct {
@@ -1187,7 +1187,7 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,
                        .bmc_tx_wlan_idx = cpu_to_le16(wcid->idx),
                        .sta_idx = cpu_to_le16(wcid->idx),
                        .conn_state = 1,
-                       .link_idx = mvif->idx,
+                       .link_idx = mvif->link_idx,
                },
        };
        int err, idx, cmd, len;
index ddc67423efe2cb8d53875cc8927c32a90c33f3f1..bf0b149055ef8c9112002423f1d56b639d4bd66d 100644 (file)
@@ -356,10 +356,15 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,
        struct mt76_txq *mtxq;
        int idx, ret = 0;
 
-       mconf->mt76.idx = __ffs64(~dev->mt76.vif_mask);
-       if (mconf->mt76.idx >= MT792x_MAX_INTERFACES) {
-               ret = -ENOSPC;
-               goto out;
+       if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
+               mconf->mt76.idx = MT792x_MAX_INTERFACES;
+       } else {
+               mconf->mt76.idx = __ffs64(~dev->mt76.vif_mask);
+
+               if (mconf->mt76.idx >= MT792x_MAX_INTERFACES) {
+                       ret = -ENOSPC;
+                       goto out;
+               }
        }
 
        mconf->mt76.omac_idx = ieee80211_vif_is_mld(vif) ?
@@ -367,6 +372,7 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,
        mconf->mt76.band_idx = 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);
 
        if (mvif->phy->mt76->chandef.chan->band != NL80211_BAND_2GHZ)
                mconf->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL + 4;