* [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler
@ 2026-11-17 18:01 Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 02/19] wifi: mt76: mt7996: return a negative error for a firmware status Felix Fietkau
` (18 more replies)
0 siblings, 19 replies; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
A power save station whose buffered frames cannot be delivered consumes
no airtime, so its airtime deficit never goes negative, and
ieee80211_return_txq() keeps it at the head of the active_txqs list.
With all bands on one ieee80211_hw, each scheduling round then ends at
that station, and all other stations starve.
Return the txq only when it sent frames or its queue is stopped.
__mt76_tx_complete_skb() schedules it again when a buffered frame
completes.
Fixes: a547b414bf7e ("wifi: mt76: add PS buffering support for HW-managed TIM drivers")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/tx.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
index ea9993e9a199..0085b7a29fce 100644
--- a/drivers/net/wireless/mediatek/mt76/tx.c
+++ b/drivers/net/wireless/mediatek/mt76/tx.c
@@ -625,10 +625,13 @@ mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid)
if (!mt76_txq_stopped(q))
n_frames = mt76_txq_send_burst(phy, q, mtxq, wcid);
- ieee80211_return_txq(phy->hw, txq, false);
-
if (unlikely(n_frames < 0))
return n_frames;
+
+ /* an undrainable PS station would starve all others */
+ if (n_frames > 0 || mt76_txq_stopped(q))
+ ieee80211_return_txq(phy->hw, txq, false);
+
ret += n_frames;
continue;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 02/19] wifi: mt76: mt7996: return a negative error for a firmware status
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 03/19] wifi: mt76: mt7996: use the default timeout for STA_REC and BSS_INFO Felix Fietkau
` (17 subsequent siblings)
18 siblings, 0 replies; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt7996_mcu_parse_response() returns the status of a UNI event as a
positive value. Callers that test for a negative return take a firmware
failure as success, and callers that pass the value on hand a positive
error to mac80211 and nl80211, which leaves hostapd waiting for a
further netlink reply.
Return -EREMOTEIO for a non-zero firmware status.
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index 34ac25c22b01..94e88455c732 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -258,10 +258,11 @@ mt7996_mcu_parse_response(struct mt76_dev *mdev, int cmd,
skb_pull(skb, sizeof(*rxd));
event = (struct mt7996_mcu_uni_event *)skb->data;
- ret = le32_to_cpu(event->status);
/* skip invalid event */
if (mcu_cmd != le16_to_cpu(event->cid))
ret = -EAGAIN;
+ else if (le32_to_cpu(event->status))
+ ret = -EREMOTEIO;
} else {
skb_pull(skb, sizeof(struct mt7996_mcu_rxd));
}
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 03/19] wifi: mt76: mt7996: use the default timeout for STA_REC and BSS_INFO
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 02/19] wifi: mt76: mt7996: return a negative error for a firmware status Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-18 8:22 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 04/19] wifi: mt76: mt7915: " Felix Fietkau
` (16 subsequent siblings)
18 siblings, 1 reply; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt7996_mcu_set_timeout() gives STA_REC_UPDATE and BSS_INFO_UPDATE a
timeout of 2 seconds. Their payload grows with the beacon templates of
MBSS and MLD configurations, the firmware can take longer to process
them, and an MCU timeout resets the device.
Use the default timeout for both commands.
Fixes: beb01caa570c ("wifi: mt76: mt7996: decrease timeout for commonly issued MCU commands")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index 94e88455c732..e56b60346fc4 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -282,8 +282,6 @@ mt7996_mcu_set_timeout(struct mt76_dev *mdev, int cmd)
case MCU_UNI_CMD_THERMAL:
case MCU_UNI_CMD_TWT:
case MCU_UNI_CMD_GET_MIB_INFO:
- case MCU_UNI_CMD_STA_REC_UPDATE:
- case MCU_UNI_CMD_BSS_INFO_UPDATE:
mdev->mcu.timeout = 2 * HZ;
return;
case MCU_UNI_CMD_EFUSE_CTRL:
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 04/19] wifi: mt76: mt7915: use the default timeout for STA_REC and BSS_INFO
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 02/19] wifi: mt76: mt7996: return a negative error for a firmware status Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 03/19] wifi: mt76: mt7996: use the default timeout for STA_REC and BSS_INFO Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-18 8:23 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 05/19] wifi: mt76: delete only the RX NAPIs that were added Felix Fietkau
` (15 subsequent siblings)
18 siblings, 1 reply; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt7915_mcu_set_timeout() gives STA_REC_UPDATE and BSS_INFO_UPDATE a
timeout of 2 seconds. Their payload grows with the beacon templates of
MBSS configurations, the firmware can take longer to process them, and
an MCU timeout resets the device.
Use the default timeout for both commands, like mt7996.
Fixes: 1254c66356d1 ("wifi: mt76: mt7915: decrease timeout for commonly issued MCU commands")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index e66968b819da..9b748b37624d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -214,8 +214,6 @@ mt7915_mcu_set_timeout(struct mt76_dev *mdev, int cmd)
case MCU_EXT_CMD_THERMAL_CTRL:
case MCU_EXT_CMD_GET_MIB_INFO:
case MCU_EXT_CMD_PHY_STAT_INFO:
- case MCU_EXT_CMD_STA_REC_UPDATE:
- case MCU_EXT_CMD_BSS_INFO_UPDATE:
mdev->mcu.timeout = 2 * HZ;
return;
case MCU_EXT_CMD_EFUSE_BUFFER_MODE:
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 05/19] wifi: mt76: delete only the RX NAPIs that were added
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (2 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 04/19] wifi: mt76: mt7915: " Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-18 8:32 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 06/19] wifi: mt76: mt7996: report radar on the channel context of its band Felix Fietkau
` (14 subsequent siblings)
18 siblings, 1 reply; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt76_dma_cleanup() calls netif_napi_del() for every RX queue, also for
the WED RRO queues of mt7996, which get no NAPI while WED is active.
__netif_napi_del() then locks the NULL netdev of that NAPI, and rmmod
of mt7996e with WED crashes.
Delete only the RX NAPIs that have a netdev.
Fixes: 6b470f36616e ("wifi: mt76: Fix memory leak destroying device")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/dma.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index a67880a9281c..8c0403820299 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -1217,7 +1217,8 @@ void mt76_dma_cleanup(struct mt76_dev *dev)
mt76_for_each_q_rx(dev, i) {
struct mt76_queue *q = &dev->q_rx[i];
- netif_napi_del(&dev->napi[i]);
+ if (dev->napi[i].dev)
+ netif_napi_del(&dev->napi[i]);
mt76_dma_rx_cleanup(dev, q);
page_pool_destroy(q->page_pool);
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 06/19] wifi: mt76: mt7996: report radar on the channel context of its band
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (3 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 05/19] wifi: mt76: delete only the RX NAPIs that were added Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 07/19] wifi: mt76: mt7996: stop WED before the DMA reset of a full reset Felix Fietkau
` (13 subsequent siblings)
18 siblings, 0 replies; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt7996_mcu_rx_radar_detected() reports a radar with a NULL channel
context, so mac80211 marks every channel context of the multi-radio
wiphy. A radar on the 5 GHz band thus also ends the CAC on the other
bands and is reported on their channels.
Report the radar on the channel context of the radio that detected it.
Fixes: 69d54ce7491d ("wifi: mt76: mt7996: switch to single multi-radio wiphy")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index e56b60346fc4..b082998a4170 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -572,10 +572,16 @@ mt7996_mcu_rx_radar_detected(struct mt7996_dev *dev, struct sk_buff *skb)
&dev->rdd2_chandef,
GFP_ATOMIC);
} else {
+ struct mt76_chanctx *ctx = READ_ONCE(mphy->chanctx);
struct mt7996_phy *phy = mphy->priv;
+ struct ieee80211_chanctx_conf *conf;
phy->rdd_tx_paused = true;
- ieee80211_radar_detected(mphy->hw, NULL);
+ if (ctx) {
+ conf = container_of((void *)ctx,
+ struct ieee80211_chanctx_conf, drv_priv);
+ ieee80211_radar_detected(mphy->hw, conf);
+ }
}
dev->hw_pattern++;
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 07/19] wifi: mt76: mt7996: stop WED before the DMA reset of a full reset
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (4 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 06/19] wifi: mt76: mt7996: report radar on the channel context of its band Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-18 8:38 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 08/19] wifi: mt76: skip the radiotap TLVs in mt76_skb_get_hdr() Felix Fietkau
` (12 subsequent siblings)
18 siblings, 1 reply; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
Unlike the L1 SER path, mt7996_mac_restart() resets the WFSYS while the
attached WEDs still access it over PCIe. Their reads during the reset
get no completion, and MT7988 reports uncorrectable PCIe completion
timeouts on both root ports.
Stop both WEDs at the start of the restart, and disable the WED
interrupt agent and wait for it to go idle before the WFSYS reset. The
other agents stay enabled, since TX through WED stops after the restart
otherwise.
Fixes: 83eafc9251d6 ("wifi: mt76: mt7996: add wed tx support")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7996/dma.c | 25 ++++++++++++++++++-
.../net/wireless/mediatek/mt76/mt7996/mac.c | 19 +++++++++-----
.../net/wireless/mediatek/mt76/mt7996/regs.h | 5 ++++
3 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/dma.c b/drivers/net/wireless/mediatek/mt76/mt7996/dma.c
index 3d9353811a02..4450d35e9439 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/dma.c
@@ -3,6 +3,7 @@
* Copyright (C) 2022 MediaTek Inc.
*/
+#include <linux/iopoll.h>
#include "mt7996.h"
#include "../dma.h"
#include "mac.h"
@@ -957,6 +958,25 @@ int mt7996_dma_init(struct mt7996_dev *dev)
return 0;
}
+static void
+mt7996_wed_int_agent_disable(struct mt7996_dev *dev,
+ struct mtk_wed_device *wed)
+{
+ u32 val;
+
+ if (!mtk_wed_device_active(wed))
+ return;
+
+ val = mtk_wed_device_reg_read(wed, MT_WED_CTRL);
+ mtk_wed_device_reg_write(wed, MT_WED_CTRL,
+ val & ~MT_WED_CTRL_WPDMA_INT_AGENT_EN);
+
+ if (read_poll_timeout(mtk_wed_device_reg_read, val,
+ !(val & MT_WED_CTRL_WPDMA_INT_AGENT_BUSY),
+ 100, 20000, false, wed, MT_WED_CTRL))
+ dev_warn(dev->mt76.dev, "WED interrupt agent still busy\n");
+}
+
void mt7996_dma_reset(struct mt7996_dev *dev, bool force)
{
struct mt76_phy *phy2 = dev->mt76.phys[MT_BAND1];
@@ -996,8 +1016,11 @@ void mt7996_dma_reset(struct mt7996_dev *dev, bool force)
mt7996_rro_msdu_page_map_free(dev);
/* reset wfsys */
- if (force)
+ if (force) {
+ mt7996_wed_int_agent_disable(dev, &dev->mt76.mmio.wed_hif2);
+ mt7996_wed_int_agent_disable(dev, &dev->mt76.mmio.wed);
mt7996_wfsys_reset(dev);
+ }
if (dev->hif2 && mtk_wed_device_active(&dev->mt76.mmio.wed_hif2))
mtk_wed_device_dma_reset(&dev->mt76.mmio.wed_hif2);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index 03670293a78f..2e1d98bf823a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -2291,6 +2291,16 @@ void mt7996_tx_token_put(struct mt7996_dev *dev)
}
}
+static void
+mt7996_wed_stop(struct mt7996_dev *dev)
+{
+ if (mtk_wed_device_active(&dev->mt76.mmio.wed_hif2))
+ mtk_wed_device_stop(&dev->mt76.mmio.wed_hif2);
+
+ if (mtk_wed_device_active(&dev->mt76.mmio.wed))
+ mtk_wed_device_stop(&dev->mt76.mmio.wed);
+}
+
static int
mt7996_mac_restart(struct mt7996_dev *dev)
{
@@ -2298,6 +2308,8 @@ mt7996_mac_restart(struct mt7996_dev *dev)
struct mt7996_phy *phy;
int i, ret;
+ mt7996_wed_stop(dev);
+
if (dev->hif2) {
mt76_wr(dev, MT_INT1_MASK_CSR, 0x0);
mt76_wr(dev, MT_INT1_SOURCE_CSR, ~0);
@@ -2573,12 +2585,7 @@ void mt7996_mac_reset_work(struct work_struct *work)
dev_info(dev->mt76.dev,"\n%s L1 SER recovery start.",
wiphy_name(hw->wiphy));
- if (mtk_wed_device_active(&dev->mt76.mmio.wed_hif2))
- mtk_wed_device_stop(&dev->mt76.mmio.wed_hif2);
-
- if (mtk_wed_device_active(&dev->mt76.mmio.wed))
- mtk_wed_device_stop(&dev->mt76.mmio.wed);
-
+ mt7996_wed_stop(dev);
mt7996_npu_hw_stop(dev);
ieee80211_stop_queues(mt76_hw(dev));
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/regs.h b/drivers/net/wireless/mediatek/mt76/mt7996/regs.h
index 6df6e4c3d45d..e82a281a773a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/regs.h
@@ -782,6 +782,11 @@ enum offs_rev {
#define MT_WF_SUBSYS_RST_BYPASS_WFDMA2_SLP_PROT BIT(16)
#define MT_WF_SUBSYS_RST_WHOLE_PATH_RST_REVERT_CYCLE GENMASK(15, 8)
+/* WED registers, offsets for mtk_wed_device_reg_read() */
+#define MT_WED_CTRL 0x00c
+#define MT_WED_CTRL_WPDMA_INT_AGENT_EN BIT(0)
+#define MT_WED_CTRL_WPDMA_INT_AGENT_BUSY BIT(1)
+
/* PCIE MAC */
#define MT_PCIE_MAC_BASE 0x74030000
#define MT_PCIE_MAC(ofs) (MT_PCIE_MAC_BASE + (ofs))
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 08/19] wifi: mt76: skip the radiotap TLVs in mt76_skb_get_hdr()
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (5 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 07/19] wifi: mt76: mt7996: stop WED before the DMA reset of a full reset Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 09/19] wifi: mt76: find the first A-MSDU subframe behind the radiotap data Felix Fietkau
` (11 subsequent siblings)
18 siblings, 0 replies; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt76_skb_get_hdr() skips only the HE radiotap fields, so for a frame
with EHT radiotap TLVs in front of the 802.11 header it returns the
first TLV. mt76_check_ccmp_pn() then checks QoS Data of EHT PPDUs
against the counter of robust Management frames, and
mt76_rx_aggr_check_ctl() does not see a BlockAckReq.
Return the mac header for a frame with RX_FLAG_RADIOTAP_TLV_AT_END,
which mac80211 requires to point to the 802.11 header.
Fixes: 97d7ab9f51ec ("wifi: mt76: mt7925: add EHT radiotap support in monitor mode")
Fixes: e016239fcb98 ("wifi: mt76: mt7996: Add eht radiotap tlv")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt76.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index da135e76aabb..8f8388d44aa9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -1485,6 +1485,9 @@ static inline void *mt76_skb_get_hdr(struct sk_buff *skb)
mstat = *((struct mt76_rx_status *)skb->cb);
+ if (mstat.flag & RX_FLAG_RADIOTAP_TLV_AT_END)
+ return skb_mac_header(skb);
+
if (mstat.flag & RX_FLAG_RADIOTAP_HE)
data += sizeof(struct ieee80211_radiotap_he);
if (mstat.flag & RX_FLAG_RADIOTAP_HE_MU)
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 09/19] wifi: mt76: find the first A-MSDU subframe behind the radiotap data
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (6 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 08/19] wifi: mt76: skip the radiotap TLVs in mt76_skb_get_hdr() Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-18 8:43 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 10/19] wifi: mt76: mark all but the last subframe of an A-MSDU chain Felix Fietkau
` (10 subsequent siblings)
18 siblings, 1 reply; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt76_rx_release_amsdu() reads the first subframe relative to
skb->data, which points to the radiotap data where the driver pushed HE
fields or EHT TLVs. It then misses an RFC1042 header in place of the
destination address, so an A-MSDU of an HE or EHT PPDU in 802.11 format
passes the mitigation of CVE-2020-24588.
Locate the subframe behind the header that mt76_skb_get_hdr() returns.
Fixes: 2c2bdd2372af ("mt76: validate rx A-MSDU subframes")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mac80211.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index bd822193e769..271fbd4711f7 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -965,18 +965,21 @@ static void mt76_rx_release_amsdu(struct mt76_phy *phy, enum mt76_rxq_id q)
* address.
*/
if (skb_shinfo(skb)->frag_list) {
- int offset = 0;
+ u8 *subframe = skb->data;
if (!(status->flag & RX_FLAG_8023)) {
- offset = ieee80211_get_hdrlen_from_skb(skb);
+ struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb);
+
+ subframe = (u8 *)hdr +
+ ieee80211_hdrlen(hdr->frame_control);
if ((status->flag &
(RX_FLAG_DECRYPTED | RX_FLAG_IV_STRIPPED)) ==
RX_FLAG_DECRYPTED)
- offset += 8;
+ subframe += 8;
}
- if (ether_addr_equal(skb->data + offset, rfc1042_header)) {
+ if (ether_addr_equal(subframe, rfc1042_header)) {
dev_kfree_skb(skb);
return;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 10/19] wifi: mt76: mark all but the last subframe of an A-MSDU chain
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (7 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 09/19] wifi: mt76: find the first A-MSDU subframe behind the radiotap data Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-18 8:47 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 11/19] wifi: mt76: mt7996: set qos_ctl of a frame that hardware reordered Felix Fietkau
` (9 subsequent siblings)
18 siblings, 1 reply; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt76_rx_complete() passes the subframes of a hardware-split A-MSDU to
mac80211 without RX_FLAG_AMSDU_MORE. They share the sequence control of
the MPDU, so in 802.11 format ieee80211_rx_h_check_dup() drops the later
subframes of a retransmitted A-MSDU as duplicates.
Set RX_FLAG_AMSDU_MORE on every subframe but the last.
Fixes: cc4b3c139ad3 ("mt76: mt7915: enable hw rx-amsdu de-aggregation")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mac80211.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 271fbd4711f7..d72ade2d46cb 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -1625,6 +1625,8 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
mt76_check_ccmp_pn(skb);
skb_shinfo(skb)->frag_list = NULL;
mt76_rx_convert(dev, skb, &hw, &link_sta);
+ if (nskb)
+ IEEE80211_SKB_RXCB(skb)->flag |= RX_FLAG_AMSDU_MORE;
ieee80211_rx_list(hw, link_sta, skb, &list);
/* subsequent amsdu frames */
@@ -1634,6 +1636,8 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
skb->next = NULL;
mt76_rx_convert(dev, skb, &hw, &link_sta);
+ if (nskb)
+ IEEE80211_SKB_RXCB(skb)->flag |= RX_FLAG_AMSDU_MORE;
ieee80211_rx_list(hw, link_sta, skb, &list);
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 11/19] wifi: mt76: mt7996: set qos_ctl of a frame that hardware reordered
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (8 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 10/19] wifi: mt76: mark all but the last subframe of an A-MSDU chain Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-18 8:50 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 12/19] wifi: mt76: check the PN of a BA session frame at its release Felix Fietkau
` (8 subsequent siblings)
18 siblings, 1 reply; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt7996_mac_fill_rx() returns before it sets status->qos_ctl for a frame
that the hardware reordered. mt76_check_ccmp_pn() then checks every
such frame against the counter of TID 0, so frames of different TIDs
read as replays.
Set qos_ctl for these frames as well.
Fixes: 950d0abb5cd9 ("wifi: mt76: mt7996: add wed rx support")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index 2e1d98bf823a..c70e429ab419 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -707,12 +707,15 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
}
}
- if (!status->wcid || !ieee80211_is_data_qos(fc) || hw_aggr)
+ if (!status->wcid || !ieee80211_is_data_qos(fc))
+ return 0;
+
+ status->qos_ctl = qos_ctl;
+ if (hw_aggr)
return 0;
status->aggr = unicast &&
!ieee80211_is_qos_nullfunc(fc);
- status->qos_ctl = qos_ctl;
status->seqno = IEEE80211_SEQ_TO_SN(seq_ctrl);
return 0;
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 12/19] wifi: mt76: check the PN of a BA session frame at its release
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (9 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 11/19] wifi: mt76: mt7996: set qos_ctl of a frame that hardware reordered Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-18 8:55 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 13/19] wifi: mt76: check the RX PN of CCMP-256, GCMP and GCMP-256 keys Felix Fietkau
` (7 subsequent siblings)
18 siblings, 1 reply; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt76_rx_complete() checks the PN after a frame left the reorder buffer,
outside tid->lock. The links of an MLD peer share one PN state, so a
frame released on one RX ring can be checked before an earlier frame of
the same TID on another ring, which then reads as a replay. The reorder
work has the same gap on a single link.
Check the PN of a BA session frame where it leaves the reorder buffer,
under tid->lock. mt76_rx_complete() still checks all other frames.
Fixes: 30ce7f4456ae ("mt76: validate rx CCMP PN")
Fixes: 62694ed0b76f ("wifi: mt76: check the RX PN of an MLD peer once per peer")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/agg-rx.c | 11 +++++++++++
drivers/net/wireless/mediatek/mt76/mac80211.c | 6 ++++--
drivers/net/wireless/mediatek/mt76/mt76.h | 3 ++-
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/agg-rx.c b/drivers/net/wireless/mediatek/mt76/agg-rx.c
index bf1babac3895..49721b4faab1 100644
--- a/drivers/net/wireless/mediatek/mt76/agg-rx.c
+++ b/drivers/net/wireless/mediatek/mt76/agg-rx.c
@@ -12,6 +12,15 @@ static unsigned long mt76_aggr_tid_to_timeo(u8 tidno)
return HZ / (tidno >= 4 ? 25 : 10);
}
+static void
+mt76_rx_aggr_pn_check(struct sk_buff *skb)
+{
+ struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
+
+ mt76_check_ccmp_pn(skb);
+ status->skip_pn_check = true;
+}
+
static void
mt76_aggr_release(struct mt76_rx_tid *tid, struct sk_buff_head *frames, int idx)
{
@@ -25,6 +34,7 @@ mt76_aggr_release(struct mt76_rx_tid *tid, struct sk_buff_head *frames, int idx)
tid->reorder_buf[idx] = NULL;
tid->nframes--;
+ mt76_rx_aggr_pn_check(skb);
__skb_queue_tail(frames, skb);
}
@@ -204,6 +214,7 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames)
}
if (seqno == head) {
+ mt76_rx_aggr_pn_check(skb);
tid->head = ieee80211_sn_inc(head);
if (tid->nframes)
mt76_rx_aggr_release_head(tid, frames);
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index d72ade2d46cb..b1789be134d6 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -1387,8 +1387,7 @@ mt76_rx_convert(struct mt76_dev *dev, struct sk_buff *skb,
*hw = mt76_phy_hw(dev, mstat.phy_idx);
}
-static void
-mt76_check_ccmp_pn(struct sk_buff *skb)
+void mt76_check_ccmp_pn(struct sk_buff *skb)
{
struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
struct mt76_wcid *wcid = status->wcid;
@@ -1403,6 +1402,9 @@ mt76_check_ccmp_pn(struct sk_buff *skb)
if (status->flag & RX_FLAG_ONLY_MONITOR)
return;
+ if (status->skip_pn_check)
+ return;
+
if (!wcid || !wcid->rx_check_pn)
return;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 8f8388d44aa9..0b16567920fa 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -774,7 +774,7 @@ struct mt76_rx_status {
} eht;
};
- u8 amsdu:1, first_amsdu:1, last_amsdu:1;
+ u8 amsdu:1, first_amsdu:1, last_amsdu:1, skip_pn_check:1;
u8 rate_idx;
u8 nss:5, band:3;
u8 chains;
@@ -1842,6 +1842,7 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
struct napi_struct *napi);
void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames);
+void mt76_check_ccmp_pn(struct sk_buff *skb);
void mt76_testmode_tx_pending(struct mt76_phy *phy);
void mt76_queue_tx_complete(struct mt76_dev *dev, struct mt76_queue *q,
struct mt76_queue_entry *e);
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 13/19] wifi: mt76: check the RX PN of CCMP-256, GCMP and GCMP-256 keys
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (10 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 12/19] wifi: mt76: check the PN of a BA session frame at its release Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 14/19] wifi: mt76: connac: return a negative error for a firmware status Felix Fietkau
` (6 subsequent siblings)
18 siblings, 0 replies; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt76_wcid_key_link_setup() enables the RX PN check for CCMP keys only.
mac80211 does not check the PN either, because the IV is stripped, so
on mt7996, whose hardware does not check it, replayed frames of the
other AES ciphers reach the stack.
Check the PN for all four ciphers. Keep the PN state of a wcid when an
IGTK or BIGTK is installed on it, since these keys do not use it.
Fixes: 04b8e65922f6 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mac80211.c | 13 +++++--
drivers/net/wireless/mediatek/mt76/mt76.h | 34 ++++++++++++++++++-
2 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index b1789be134d6..6b496dfda5cc 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -1279,21 +1279,28 @@ void mt76_wcid_key_setup(struct mt76_dev *dev, struct mt76_wcid *wcid,
struct ieee80211_key_conf *key)
{
struct ieee80211_key_seq seq;
+ u8 *pn;
int i;
mt76_wcid_key_link_setup(wcid, key);
- if (!wcid->rx_check_pn)
+ if (!key || !mt76_key_has_rx_pn(key))
return;
+ if (key->cipher == WLAN_CIPHER_SUITE_GCMP ||
+ key->cipher == WLAN_CIPHER_SUITE_GCMP_256)
+ pn = seq.gcmp.pn;
+ else
+ pn = seq.ccmp.pn;
+
/* data frame */
for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
ieee80211_get_key_rx_seq(key, i, &seq);
- memcpy(wcid->rx_key_pn[i], seq.ccmp.pn, sizeof(seq.ccmp.pn));
+ memcpy(wcid->rx_key_pn[i], pn, sizeof(wcid->rx_key_pn[i]));
}
/* robust management frame */
ieee80211_get_key_rx_seq(key, -1, &seq);
- memcpy(wcid->rx_key_pn[i], seq.ccmp.pn, sizeof(seq.ccmp.pn));
+ memcpy(wcid->rx_key_pn[i], pn, sizeof(wcid->rx_key_pn[i]));
}
EXPORT_SYMBOL(mt76_wcid_key_setup);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 0b16567920fa..7a2a6afc3c21 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -1590,11 +1590,43 @@ int mt76_rx_aggr_start(struct mt76_dev *dev, struct mt76_wcid *wcid, u8 tid,
u16 ssn, u16 size);
void mt76_rx_aggr_stop(struct mt76_dev *dev, struct mt76_wcid *wcid, u8 tid);
+static inline bool
+mt76_key_has_rx_pn(struct ieee80211_key_conf *key)
+{
+ switch (key->cipher) {
+ case WLAN_CIPHER_SUITE_CCMP:
+ case WLAN_CIPHER_SUITE_CCMP_256:
+ case WLAN_CIPHER_SUITE_GCMP:
+ case WLAN_CIPHER_SUITE_GCMP_256:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static inline bool
+mt76_key_is_bip(struct ieee80211_key_conf *key)
+{
+ switch (key->cipher) {
+ case WLAN_CIPHER_SUITE_AES_CMAC:
+ case WLAN_CIPHER_SUITE_BIP_CMAC_256:
+ case WLAN_CIPHER_SUITE_BIP_GMAC_128:
+ case WLAN_CIPHER_SUITE_BIP_GMAC_256:
+ return true;
+ default:
+ return false;
+ }
+}
+
static inline void
mt76_wcid_key_link_setup(struct mt76_wcid *wcid,
struct ieee80211_key_conf *key)
{
- wcid->rx_check_pn = key && key->cipher == WLAN_CIPHER_SUITE_CCMP;
+ /* an IGTK or BIGTK shares the wcid of the GTK */
+ if (key && mt76_key_is_bip(key))
+ return;
+
+ wcid->rx_check_pn = key && mt76_key_has_rx_pn(key);
}
void mt76_wcid_key_setup(struct mt76_dev *dev, struct mt76_wcid *wcid,
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 14/19] wifi: mt76: connac: return a negative error for a firmware status
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (11 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 13/19] wifi: mt76: check the RX PN of CCMP-256, GCMP and GCMP-256 keys Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 15/19] wifi: mt76: guard the tx_list of every phy with one lock Felix Fietkau
` (5 subsequent siblings)
18 siblings, 0 replies; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
The parse_response functions of mt7615, mt7921 and mt7925 return the
status of a UNI event unchanged, so callers that test for a negative
return take a firmware failure as success. For example,
mt76_connac_mcu_uni_add_dev() activates the BSS after the firmware
failed the device activation.
Return -EREMOTEIO for a non-zero status, and -ENOLINK for the WLAN
failure status, which mt76_connac_mcu_bss_deact_err() ignores because
the firmware also returns it for the deactivation of an inactive BSS.
Fixes: df5ab0d58b2e ("mt76: mt7615: parse mcu return code for unified commands")
Fixes: 1c099ab44727 ("mt76: mt7921: add MCU support")
Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 2 +-
.../net/wireless/mediatek/mt76/mt76_connac_mcu.h | 14 +++++++++++++-
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 3 ++-
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 3 ++-
4 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index e5c2ad5fb458..65c57d5a480a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -178,7 +178,7 @@ int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,
return -EMSGSIZE;
skb_pull(skb, sizeof(*rxd));
event = (struct mt76_connac_mcu_uni_event *)skb->data;
- ret = le32_to_cpu(event->status);
+ ret = mt76_connac_mcu_status_err(le32_to_cpu(event->status));
} else if (cmd == MCU_CE_QUERY(REG_READ)) {
struct mt76_connac_mcu_reg_event *event;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index 2acaae9830fb..cac47c8702e3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -1960,10 +1960,22 @@ mt76_connac_mcu_get_wlan_idx(struct mt76_dev *dev, struct mt76_wcid *wcid,
#define MT76_CONNAC_MCU_STATUS_WLAN_FAILURE 0xc0000001
+static inline int
+mt76_connac_mcu_status_err(u32 status)
+{
+ if (!status)
+ return 0;
+
+ if (status == MT76_CONNAC_MCU_STATUS_WLAN_FAILURE)
+ return -ENOLINK;
+
+ return -EREMOTEIO;
+}
+
static inline int
mt76_connac_mcu_bss_deact_err(struct mt76_dev *mdev, int err, bool enable)
{
- if (err != (int)MT76_CONNAC_MCU_STATUS_WLAN_FAILURE)
+ if (err != -ENOLINK)
return err;
/* Ignore wlan_failure state false alarm when deactivating an
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index 2bcd5f085cd4..a16f41eda2bb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -62,10 +62,11 @@ int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd,
skb_pull(skb, sizeof(*rxd));
event = (struct mt76_connac_mcu_uni_event *)skb->data;
- ret = le32_to_cpu(event->status);
/* skip invalid event */
if (mcu_cmd != event->cid)
ret = -EAGAIN;
+ else
+ ret = mt76_connac_mcu_status_err(le32_to_cpu(event->status));
} else if (cmd == MCU_CE_QUERY(REG_READ)) {
struct mt76_connac_mcu_reg_event *event;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index d3806d8dfbbf..bf8cc4b1f539 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -77,10 +77,11 @@ int mt7925_mcu_parse_response(struct mt76_dev *mdev, int cmd,
skb_pull(skb, sizeof(*rxd));
event = (struct mt7925_mcu_uni_event *)skb->data;
- ret = le32_to_cpu(event->status);
/* skip invalid event */
if (mcu_cmd != event->cid)
ret = -EAGAIN;
+ else
+ ret = mt76_connac_mcu_status_err(le32_to_cpu(event->status));
} else {
skb_pull(skb, sizeof(*rxd));
}
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 15/19] wifi: mt76: guard the tx_list of every phy with one lock
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (12 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 14/19] wifi: mt76: connac: return a negative error for a firmware status Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-18 8:52 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 16/19] wifi: mt76: keep an unpublished wcid off the TX and poll lists Felix Fietkau
` (4 subsequent siblings)
18 siblings, 1 reply; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt76_tx() lists a wcid on the tx_list of the phy its caller passes,
under the tx_lock of that phy, while mt76_wcid_cleanup() unlists it
under the tx_lock of wcid->phy_idx. mt7996_tx() and
mt76_offchannel_send_nullfunc() can list a wcid on the phy of another
link, so no common lock guards its node, and the tx_list gets corrupted.
Guard the tx_list of every phy with one lock per device.
Fixes: ce35ecffc96e ("wifi: mt76: mt7996: fix MLD ID in MAC TXD and HIF TXP")
Fixes: 381733b3a14a ("wifi: mt76: send nullfunc PS frames on offchannel transitions")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mac80211.c | 7 +++----
drivers/net/wireless/mediatek/mt76/mt76.h | 3 ++-
drivers/net/wireless/mediatek/mt76/tx.c | 13 +++++++------
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 6b496dfda5cc..da1da160909a 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -431,7 +431,6 @@ mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw)
int i;
INIT_LIST_HEAD(&phy->tx_list);
- spin_lock_init(&phy->tx_lock);
for (i = 0; i < ARRAY_SIZE(phy->rx_amsdu); i++)
spin_lock_init(&phy->rx_amsdu[i].lock);
INIT_DELAYED_WORK(&phy->roc_work, mt76_roc_complete_work);
@@ -753,6 +752,7 @@ mt76_alloc_device(struct device *pdev, unsigned int size,
spin_lock_init(&dev->cc_lock);
spin_lock_init(&dev->status_lock);
spin_lock_init(&dev->wed_lock);
+ spin_lock_init(&dev->tx_lock);
mutex_init(&dev->mutex);
init_waitqueue_head(&dev->tx_wait);
@@ -1837,7 +1837,6 @@ EXPORT_SYMBOL_GPL(mt76_wcid_init);
void mt76_wcid_cleanup(struct mt76_dev *dev, struct mt76_wcid *wcid)
{
- struct mt76_phy *phy = mt76_dev_phy(dev, wcid->phy_idx);
struct ieee80211_hw *hw;
struct sk_buff_head list;
struct sk_buff *skb;
@@ -1859,7 +1858,7 @@ void mt76_wcid_cleanup(struct mt76_dev *dev, struct mt76_wcid *wcid)
list_del_init(&wcid->poll_list);
spin_unlock_bh(&dev->sta_poll_lock);
- spin_lock_bh(&phy->tx_lock);
+ spin_lock_bh(&dev->tx_lock);
if (!list_empty(&wcid->tx_list))
list_del_init(&wcid->tx_list);
@@ -1872,7 +1871,7 @@ void mt76_wcid_cleanup(struct mt76_dev *dev, struct mt76_wcid *wcid)
skb_queue_splice_tail_init(&wcid->tx_offchannel, &list);
spin_unlock(&wcid->tx_offchannel.lock);
- spin_unlock_bh(&phy->tx_lock);
+ spin_unlock_bh(&dev->tx_lock);
while ((skb = __skb_dequeue(&list)) != NULL) {
hw = mt76_tx_status_get_hw(dev, skb);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 7a2a6afc3c21..77bfecb7d49b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -872,7 +872,6 @@ struct mt76_phy {
unsigned int num_sta;
u8 band_idx;
- spinlock_t tx_lock;
struct list_head tx_list;
struct mt76_queue *q_tx[__MT_TXQ_MAX];
@@ -988,6 +987,8 @@ struct mt76_dev {
struct mt76_worker tx_worker;
struct napi_struct tx_napi;
+ /* protects the tx_list of every phy */
+ spinlock_t tx_lock;
spinlock_t token_lock;
struct idr token;
diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
index 0085b7a29fce..9eafc86ec288 100644
--- a/drivers/net/wireless/mediatek/mt76/tx.c
+++ b/drivers/net/wireless/mediatek/mt76/tx.c
@@ -392,10 +392,10 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
__skb_queue_tail(head, skb);
spin_unlock_bh(&head->lock);
- spin_lock_bh(&phy->tx_lock);
+ spin_lock_bh(&phy->dev->tx_lock);
if (list_empty(&wcid->tx_list))
list_add_tail(&wcid->tx_list, &phy->tx_list);
- spin_unlock_bh(&phy->tx_lock);
+ spin_unlock_bh(&phy->dev->tx_lock);
mt76_worker_schedule(&phy->dev->tx_worker);
}
@@ -740,6 +740,7 @@ mt76_txq_schedule_pending_wcid(struct mt76_phy *phy, struct mt76_wcid *wcid,
void mt76_txq_schedule_pending(struct mt76_phy *phy)
{
+ struct mt76_dev *dev = phy->dev;
LIST_HEAD(tx_list);
int ret = 0;
@@ -749,7 +750,7 @@ void mt76_txq_schedule_pending(struct mt76_phy *phy)
local_bh_disable();
rcu_read_lock();
- spin_lock(&phy->tx_lock);
+ spin_lock(&dev->tx_lock);
list_splice_init(&phy->tx_list, &tx_list);
while (!list_empty(&tx_list)) {
struct mt76_wcid *wcid;
@@ -757,19 +758,19 @@ void mt76_txq_schedule_pending(struct mt76_phy *phy)
wcid = list_first_entry(&tx_list, struct mt76_wcid, tx_list);
list_del_init(&wcid->tx_list);
- spin_unlock(&phy->tx_lock);
+ spin_unlock(&dev->tx_lock);
if (ret >= 0)
ret = mt76_txq_schedule_pending_wcid(phy, wcid, &wcid->tx_offchannel);
if (ret >= 0 && !phy->offchannel)
ret = mt76_txq_schedule_pending_wcid(phy, wcid, &wcid->tx_pending);
- spin_lock(&phy->tx_lock);
+ spin_lock(&dev->tx_lock);
if ((!skb_queue_empty(&wcid->tx_pending) ||
!skb_queue_empty(&wcid->tx_offchannel)) &&
list_empty(&wcid->tx_list))
list_add_tail(&wcid->tx_list, &phy->tx_list);
}
- spin_unlock(&phy->tx_lock);
+ spin_unlock(&dev->tx_lock);
rcu_read_unlock();
local_bh_enable();
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 16/19] wifi: mt76: keep an unpublished wcid off the TX and poll lists
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (13 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 15/19] wifi: mt76: guard the tx_list of every phy with one lock Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 17/19] wifi: mt76: mt7925: do not take iflist_mtx under the mutex Felix Fietkau
` (3 subsequent siblings)
18 siblings, 0 replies; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
A TX or RX path that looked up a wcid before the driver unpublished it
can call mt76_tx() or mt76_wcid_add_poll() after mt76_wcid_cleanup().
This lists the wcid again, and where the driver frees the wcid after
the cleanup, the TX worker or the poll later uses freed memory.
Drop the frame and skip the poll for a wcid that dev->wcid[] no longer
holds, like mt76_tx_status_skb_add() does for a TX status request. Both
tests run under the lock that the cleanup takes to unlist the wcid. The
global wcid lives as long as the device, and mt76x02 never publishes
it, so its frames are always queued. mt7996 unpublishes a station link
that it removes outside of a station removal only after the cleanup, so
unpublish it before.
Fixes: 0335c034e726 ("wifi: mt76: fix race condition related to checking tx queue fill status")
Fixes: f520eceacd24 ("wifi: mt76: mt7996: Add mt7996_mac_sta_change_links callback")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mac80211.c | 3 ++-
.../net/wireless/mediatek/mt76/mt7996/main.c | 4 +++-
drivers/net/wireless/mediatek/mt76/tx.c | 20 +++++++++++++------
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index da1da160909a..12089dca01b2 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -1886,7 +1886,8 @@ void mt76_wcid_add_poll(struct mt76_dev *dev, struct mt76_wcid *wcid)
return;
spin_lock_bh(&dev->sta_poll_lock);
- if (list_empty(&wcid->poll_list))
+ if (rcu_access_pointer(dev->wcid[wcid->idx]) == wcid &&
+ list_empty(&wcid->poll_list))
list_add_tail(&wcid->poll_list, &dev->sta_poll_list);
spin_unlock_bh(&dev->sta_poll_lock);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index 90a074ffa7dc..ba7a0553e34a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -1385,6 +1385,9 @@ void mt7996_mac_sta_remove_link(struct mt7996_dev *dev,
if (!msta_link)
return;
+ if (flush)
+ rcu_assign_pointer(dev->mt76.wcid[msta_link->wcid.idx], NULL);
+
spin_lock_bh(&dev->mt76.sta_poll_lock);
if (!list_empty(&msta_link->wcid.poll_list))
list_del_init(&msta_link->wcid.poll_list);
@@ -1411,7 +1414,6 @@ void mt7996_mac_sta_remove_link(struct mt7996_dev *dev,
phy->mt76->num_sta--;
rcu_assign_pointer(msta->link[link_id], NULL);
- rcu_assign_pointer(dev->mt76.wcid[msta_link->wcid.idx], NULL);
mt76_wcid_mask_clear(dev->mt76.wcid_mask, msta_link->wcid.idx);
if (msta_link != &msta->deflink)
kfree_rcu(msta_link, rcu_head);
diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
index 9eafc86ec288..84ab3d428001 100644
--- a/drivers/net/wireless/mediatek/mt76/tx.c
+++ b/drivers/net/wireless/mediatek/mt76/tx.c
@@ -365,6 +365,7 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
{
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ieee80211_hdr *hdr = (void *)skb->data;
+ struct mt76_dev *dev = phy->dev;
struct sk_buff_head *head;
if (mt76_testmode_enabled(phy)) {
@@ -388,16 +389,23 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
else
head = &wcid->tx_pending;
- spin_lock_bh(&head->lock);
- __skb_queue_tail(head, skb);
- spin_unlock_bh(&head->lock);
+ spin_lock_bh(&dev->tx_lock);
+ if (wcid != &dev->global_wcid &&
+ rcu_access_pointer(dev->wcid[wcid->idx]) != wcid) {
+ spin_unlock_bh(&dev->tx_lock);
+ ieee80211_free_txskb(phy->hw, skb);
+ return;
+ }
+
+ spin_lock(&head->lock);
+ __skb_queue_tail(head, skb);
+ spin_unlock(&head->lock);
- spin_lock_bh(&phy->dev->tx_lock);
if (list_empty(&wcid->tx_list))
list_add_tail(&wcid->tx_list, &phy->tx_list);
- spin_unlock_bh(&phy->dev->tx_lock);
+ spin_unlock_bh(&dev->tx_lock);
- mt76_worker_schedule(&phy->dev->tx_worker);
+ mt76_worker_schedule(&dev->tx_worker);
}
EXPORT_SYMBOL_GPL(mt76_tx);
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 17/19] wifi: mt76: mt7925: do not take iflist_mtx under the mutex
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (14 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 16/19] wifi: mt76: keep an unpublished wcid off the TX and poll lists Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 18/19] wifi: mt76: mt7925: take each polled link under sta_poll_lock Felix Fietkau
` (2 subsequent siblings)
18 siblings, 0 replies; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
The ROC abort paths and the runtime PM write of debugfs walk the
interfaces with iterators that take iflist_mtx while they hold
dev->mt76.mutex. mac80211 calls driver ops under iflist_mtx, and
mt7925_mlo_pm_iter() takes the mutex inside an interface walk, so a ROC
request that reclaims a stale ROC deadlocks against
mt7925_mlo_pm_work().
Collect the BSS indexes with the atomic iterator and send the aborts
after the walk, which leaves out interfaces that are not running. In
the runtime PM write, take the mutex in the walk callback for each
interface, and read the monitor state under it.
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")
Fixes: 7e54ebad64d8 ("wifi: mt76: mt7925: harden the ROC channel-grant handshake")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../wireless/mediatek/mt76/mt7925/debugfs.c | 5 +-
.../net/wireless/mediatek/mt76/mt7925/main.c | 75 ++++++++++---------
.../net/wireless/mediatek/mt76/mt7925/mcu.c | 5 +-
.../wireless/mediatek/mt76/mt7925/mt7925.h | 3 +-
4 files changed, 48 insertions(+), 40 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c
index d01ff49de47a..d0677a24e080 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/debugfs.c
@@ -203,8 +203,11 @@ mt7925_pm_set(void *data, u64 val)
mt76_connac_pm_wake(&dev->mphy, pm);
pm->enable_user = val;
+ mutex_unlock(&dev->mt76.mutex);
+
mt7925_set_runtime_pm(dev);
- mt76_connac_power_save_sched(&dev->mphy, pm);
+
+ return 0;
out:
mutex_unlock(&dev->mt76.mutex);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index 222836699d15..56d2c79cd232 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -520,23 +520,25 @@ static void mt7925_roc_iter(void *priv, u8 *mac,
struct ieee80211_vif *vif)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- struct mt792x_phy *phy = priv;
+ u64 *bss_mask = priv;
- mt7925_mcu_abort_roc(phy, &mvif->bss_conf, phy->roc_token_id);
+ *bss_mask |= BIT_ULL(mvif->bss_conf.mt76.idx);
}
-struct mt7925_roc_abort_data {
- struct mt792x_phy *phy;
- u8 token;
-};
-
-static void mt7925_roc_token_iter(void *priv, u8 *mac,
- struct ieee80211_vif *vif)
+static void mt7925_roc_abort_all(struct mt792x_phy *phy, u8 token)
{
- struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
- struct mt7925_roc_abort_data *data = priv;
+ u64 bss_mask = 0;
+ u8 bss_idx;
- mt7925_mcu_abort_roc(data->phy, &mvif->bss_conf, data->token);
+ ieee80211_iterate_active_interfaces_atomic(phy->mt76->hw,
+ IEEE80211_IFACE_ITER_RESUME_ALL,
+ mt7925_roc_iter, &bss_mask);
+
+ while (bss_mask) {
+ bss_idx = __ffs64(bss_mask);
+ bss_mask &= ~BIT_ULL(bss_idx);
+ mt7925_mcu_abort_roc(phy, bss_idx, token);
+ }
}
void mt7925_roc_abort_sync(struct mt792x_dev *dev)
@@ -550,22 +552,19 @@ void mt7925_roc_abort_sync(struct mt792x_dev *dev)
cancel_work(&phy->roc_work);
- ieee80211_iterate_interfaces(mt76_hw(dev),
- IEEE80211_IFACE_ITER_RESUME_ALL,
- mt7925_roc_iter, (void *)phy);
+ mt7925_roc_abort_all(phy, phy->roc_token_id);
}
EXPORT_SYMBOL_GPL(mt7925_roc_abort_sync);
void mt7925_roc_work(struct work_struct *work)
{
- struct mt7925_roc_abort_data data;
struct mt792x_phy *phy;
+ u8 token;
phy = (struct mt792x_phy *)container_of(work, struct mt792x_phy,
roc_work);
- data.phy = phy;
- data.token = phy->roc_token_id;
+ token = phy->roc_token_id;
if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
return;
@@ -574,9 +573,7 @@ void mt7925_roc_work(struct work_struct *work)
ieee80211_remain_on_channel_expired(phy->mt76->hw);
mt792x_mutex_acquire(phy->dev);
- ieee80211_iterate_active_interfaces(phy->mt76->hw,
- IEEE80211_IFACE_ITER_RESUME_ALL,
- mt7925_roc_token_iter, &data);
+ mt7925_roc_abort_all(phy, token);
mt792x_mutex_release(phy->dev);
}
@@ -590,7 +587,8 @@ static int mt7925_abort_roc(struct mt792x_phy *phy,
mt792x_mutex_acquire(phy->dev);
if (test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
- err = mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id);
+ err = mt7925_mcu_abort_roc(phy, mconf->mt76.idx,
+ phy->roc_token_id);
mt792x_mutex_release(phy->dev);
return err;
@@ -599,10 +597,7 @@ static int mt7925_abort_roc(struct mt792x_phy *phy,
/* Callers hold the mutex that mt7925_roc_work() takes, so no cancel_work_sync() */
static void mt7925_roc_stale_reclaim(struct mt792x_phy *phy)
{
- struct mt7925_roc_abort_data data = {
- .phy = phy,
- .token = phy->roc_token_id,
- };
+ u8 token = phy->roc_token_id;
if (!test_bit(MT76_STATE_ROC, &phy->mt76->state) ||
timer_pending(&phy->roc_timer))
@@ -614,9 +609,7 @@ static void mt7925_roc_stale_reclaim(struct mt792x_phy *phy)
if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
return;
- ieee80211_iterate_active_interfaces(phy->mt76->hw,
- IEEE80211_IFACE_ITER_RESUME_ALL,
- mt7925_roc_token_iter, &data);
+ mt7925_roc_abort_all(phy, token);
if (phy->roc_notify)
ieee80211_remain_on_channel_expired(phy->mt76->hw);
@@ -649,7 +642,7 @@ static int mt7925_set_roc(struct mt792x_phy *phy,
if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, 4 * HZ)) {
clear_bit(MT76_STATE_ROC, &phy->mt76->state);
timer_delete_sync(&phy->roc_timer);
- mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id);
+ mt7925_mcu_abort_roc(phy, mconf->mt76.idx, phy->roc_token_id);
err = -ETIMEDOUT;
}
@@ -680,7 +673,7 @@ static int mt7925_set_mlo_roc(struct mt792x_phy *phy,
if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, 4 * HZ)) {
clear_bit(MT76_STATE_ROC, &phy->mt76->state);
timer_delete_sync(&phy->roc_timer);
- mt7925_mcu_abort_roc(phy, mconf, phy->roc_token_id);
+ mt7925_mcu_abort_roc(phy, mconf->mt76.idx, phy->roc_token_id);
err = -ETIMEDOUT;
}
@@ -872,12 +865,16 @@ mt7925_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
{
struct mt792x_dev *dev = priv;
struct ieee80211_hw *hw = mt76_hw(dev);
- bool pm_enable = dev->pm.enable;
+ bool pm_enable;
int err;
+ mt792x_mutex_acquire(dev);
+
+ pm_enable = dev->pm.enable_user &&
+ !(hw->conf.flags & IEEE80211_CONF_MONITOR);
err = mt7925_mcu_set_beacon_filter(dev, vif, pm_enable);
if (err < 0)
- return;
+ goto out;
if (pm_enable) {
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
@@ -886,6 +883,8 @@ mt7925_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER;
__clear_bit(IEEE80211_HW_CONNECTION_MONITOR, hw->flags);
}
+out:
+ mt792x_mutex_release(dev);
}
static void
@@ -910,14 +909,22 @@ void mt7925_set_runtime_pm(struct mt792x_dev *dev)
{
struct ieee80211_hw *hw = mt76_hw(dev);
struct mt76_connac_pm *pm = &dev->pm;
- bool monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
+ bool monitor;
+ mutex_lock(&dev->mt76.mutex);
+ monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
pm->enable = pm->enable_user && !monitor;
+ mutex_unlock(&dev->mt76.mutex);
+
ieee80211_iterate_active_interfaces(hw,
IEEE80211_IFACE_ITER_RESUME_ALL,
mt7925_pm_interface_iter, dev);
+
+ mt792x_mutex_acquire(dev);
+ monitor = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
pm->ds_enable = pm->ds_enable_user && !monitor;
mt7925_mcu_set_deep_sleep(dev, pm->ds_enable);
+ mt792x_mutex_release(dev);
}
static int mt7925_config(struct ieee80211_hw *hw, int radio_idx, u32 changed)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index bf8cc4b1f539..54e504a76812 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -1714,8 +1714,7 @@ int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf,
&req, sizeof(req), true);
}
-int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf,
- u8 token_id)
+int mt7925_mcu_abort_roc(struct mt792x_phy *phy, u8 bss_idx, u8 token_id)
{
struct mt792x_dev *dev = phy->dev;
struct {
@@ -1735,7 +1734,7 @@ int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf,
.tag = cpu_to_le16(UNI_ROC_ABORT),
.len = cpu_to_le16(sizeof(struct roc_abort_tlv)),
.tokenid = token_id,
- .bss_idx = mconf->mt76.idx,
+ .bss_idx = bss_idx,
.dbdcband = 0xff, /* auto*/
},
};
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
index 1c20b4ae7497..b18fb5d5bb6e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
@@ -416,8 +416,7 @@ int mt7925_mcu_set_mlo_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf
int mt7925_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf,
struct ieee80211_channel *chan, int duration,
enum mt7925_roc_req type, u8 token_id);
-int mt7925_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_bss_conf *mconf,
- u8 token_id);
+int mt7925_mcu_abort_roc(struct mt792x_phy *phy, u8 bss_idx, u8 token_id);
void mt7925_roc_abort_sync(struct mt792x_dev *dev);
int mt7925_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb,
int cmd, int *wait_seq);
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 18/19] wifi: mt76: mt7925: take each polled link under sta_poll_lock
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (15 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 17/19] wifi: mt76: mt7925: do not take iflist_mtx under the mutex Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-18 8:58 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 19/19] wifi: mt76: mt7615: take each polled station " Felix Fietkau
2026-11-18 8:20 ` [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Lorenzo Bianconi
18 siblings, 1 reply; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt7925_mac_sta_poll() tests its local copy of sta_poll_list and reads
the first entry without sta_poll_lock, while a link removal takes the
wcid off that list under the lock. If the removal takes the last link
between the two reads, the poll takes the list head for a link and
writes its airtime counters to the stack.
Test the list and take the link off it in one locked section, as
mt7921_mac_sta_poll() does.
Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
index 5518960e1375..2528c2f5d717 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
@@ -54,12 +54,14 @@ static void mt7925_mac_sta_poll(struct mt792x_dev *dev)
u16 idx;
u8 bw;
- if (list_empty(&sta_poll_list))
+ spin_lock_bh(&dev->mt76.sta_poll_lock);
+ if (list_empty(&sta_poll_list)) {
+ spin_unlock_bh(&dev->mt76.sta_poll_lock);
break;
+ }
mlink = list_first_entry(&sta_poll_list,
struct mt792x_link_sta, wcid.poll_list);
msta = mlink->sta;
- spin_lock_bh(&dev->mt76.sta_poll_lock);
list_del_init(&mlink->wcid.poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH mt76-next 19/19] wifi: mt76: mt7615: take each polled station under sta_poll_lock
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (16 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 18/19] wifi: mt76: mt7925: take each polled link under sta_poll_lock Felix Fietkau
@ 2026-11-17 18:01 ` Felix Fietkau
2026-11-18 8:57 ` Lorenzo Bianconi
2026-11-18 8:20 ` [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Lorenzo Bianconi
18 siblings, 1 reply; 31+ messages in thread
From: Felix Fietkau @ 2026-11-17 18:01 UTC (permalink / raw)
To: linux-wireless
mt7615_mac_sta_poll() tests its local copy of sta_poll_list and reads
the first entry without sta_poll_lock, while a station removal takes
the wcid off that list under the lock. If the removal takes the last
station between the two reads, the poll takes the list head for a
station and writes its airtime counters to the stack.
Test the list and take the station off it in one locked section.
Fixes: a621372a04ac ("mt76: mt7615: rework mt7615_mac_sta_poll for usb code")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
index ada40b8a517a..8e81ebe3e2ca 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
@@ -905,13 +905,16 @@ void mt7615_mac_sta_poll(struct mt7615_dev *dev)
list_splice_init(&dev->mt76.sta_poll_list, &sta_poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);
- while (!list_empty(&sta_poll_list)) {
+ while (true) {
bool clear = false;
+ spin_lock_bh(&dev->mt76.sta_poll_lock);
+ if (list_empty(&sta_poll_list)) {
+ spin_unlock_bh(&dev->mt76.sta_poll_lock);
+ break;
+ }
msta = list_first_entry(&sta_poll_list, struct mt7615_sta,
wcid.poll_list);
-
- spin_lock_bh(&dev->mt76.sta_poll_lock);
list_del_init(&msta->wcid.poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);
--
2.47.3
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
` (17 preceding siblings ...)
2026-11-17 18:01 ` [PATCH mt76-next 19/19] wifi: mt76: mt7615: take each polled station " Felix Fietkau
@ 2026-11-18 8:20 ` Lorenzo Bianconi
18 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:20 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1594 bytes --]
> A power save station whose buffered frames cannot be delivered consumes
> no airtime, so its airtime deficit never goes negative, and
> ieee80211_return_txq() keeps it at the head of the active_txqs list.
> With all bands on one ieee80211_hw, each scheduling round then ends at
> that station, and all other stations starve.
>
> Return the txq only when it sent frames or its queue is stopped.
> __mt76_tx_complete_skb() schedules it again when a buffered frame
> completes.
>
> Fixes: a547b414bf7e ("wifi: mt76: add PS buffering support for HW-managed TIM drivers")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/tx.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
> index ea9993e9a199..0085b7a29fce 100644
> --- a/drivers/net/wireless/mediatek/mt76/tx.c
> +++ b/drivers/net/wireless/mediatek/mt76/tx.c
> @@ -625,10 +625,13 @@ mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid)
> if (!mt76_txq_stopped(q))
> n_frames = mt76_txq_send_burst(phy, q, mtxq, wcid);
>
> - ieee80211_return_txq(phy->hw, txq, false);
> -
> if (unlikely(n_frames < 0))
> return n_frames;
> +
> + /* an undrainable PS station would starve all others */
> + if (n_frames > 0 || mt76_txq_stopped(q))
> + ieee80211_return_txq(phy->hw, txq, false);
> +
> ret += n_frames;
> continue;
> }
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 03/19] wifi: mt76: mt7996: use the default timeout for STA_REC and BSS_INFO
2026-11-17 18:01 ` [PATCH mt76-next 03/19] wifi: mt76: mt7996: use the default timeout for STA_REC and BSS_INFO Felix Fietkau
@ 2026-11-18 8:22 ` Lorenzo Bianconi
0 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:22 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1250 bytes --]
> mt7996_mcu_set_timeout() gives STA_REC_UPDATE and BSS_INFO_UPDATE a
> timeout of 2 seconds. Their payload grows with the beacon templates of
> MBSS and MLD configurations, the firmware can take longer to process
> them, and an MCU timeout resets the device.
>
> Use the default timeout for both commands.
>
> Fixes: beb01caa570c ("wifi: mt76: mt7996: decrease timeout for commonly issued MCU commands")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
> index 94e88455c732..e56b60346fc4 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
> @@ -282,8 +282,6 @@ mt7996_mcu_set_timeout(struct mt76_dev *mdev, int cmd)
> case MCU_UNI_CMD_THERMAL:
> case MCU_UNI_CMD_TWT:
> case MCU_UNI_CMD_GET_MIB_INFO:
> - case MCU_UNI_CMD_STA_REC_UPDATE:
> - case MCU_UNI_CMD_BSS_INFO_UPDATE:
> mdev->mcu.timeout = 2 * HZ;
> return;
> case MCU_UNI_CMD_EFUSE_CTRL:
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 04/19] wifi: mt76: mt7915: use the default timeout for STA_REC and BSS_INFO
2026-11-17 18:01 ` [PATCH mt76-next 04/19] wifi: mt76: mt7915: " Felix Fietkau
@ 2026-11-18 8:23 ` Lorenzo Bianconi
0 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:23 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1277 bytes --]
> mt7915_mcu_set_timeout() gives STA_REC_UPDATE and BSS_INFO_UPDATE a
> timeout of 2 seconds. Their payload grows with the beacon templates of
> MBSS configurations, the firmware can take longer to process them, and
> an MCU timeout resets the device.
>
> Use the default timeout for both commands, like mt7996.
>
> Fixes: 1254c66356d1 ("wifi: mt76: mt7915: decrease timeout for commonly issued MCU commands")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
> index e66968b819da..9b748b37624d 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
> @@ -214,8 +214,6 @@ mt7915_mcu_set_timeout(struct mt76_dev *mdev, int cmd)
> case MCU_EXT_CMD_THERMAL_CTRL:
> case MCU_EXT_CMD_GET_MIB_INFO:
> case MCU_EXT_CMD_PHY_STAT_INFO:
> - case MCU_EXT_CMD_STA_REC_UPDATE:
> - case MCU_EXT_CMD_BSS_INFO_UPDATE:
> mdev->mcu.timeout = 2 * HZ;
> return;
> case MCU_EXT_CMD_EFUSE_BUFFER_MODE:
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 05/19] wifi: mt76: delete only the RX NAPIs that were added
2026-11-17 18:01 ` [PATCH mt76-next 05/19] wifi: mt76: delete only the RX NAPIs that were added Felix Fietkau
@ 2026-11-18 8:32 ` Lorenzo Bianconi
0 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:32 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1233 bytes --]
On Nov 17, Felix Fietkau wrote:
> mt76_dma_cleanup() calls netif_napi_del() for every RX queue, also for
> the WED RRO queues of mt7996, which get no NAPI while WED is active.
> __netif_napi_del() then locks the NULL netdev of that NAPI, and rmmod
> of mt7996e with WED crashes.
>
> Delete only the RX NAPIs that have a netdev.
>
> Fixes: 6b470f36616e ("wifi: mt76: Fix memory leak destroying device")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/dma.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
> index a67880a9281c..8c0403820299 100644
> --- a/drivers/net/wireless/mediatek/mt76/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/dma.c
> @@ -1217,7 +1217,8 @@ void mt76_dma_cleanup(struct mt76_dev *dev)
> mt76_for_each_q_rx(dev, i) {
> struct mt76_queue *q = &dev->q_rx[i];
>
> - netif_napi_del(&dev->napi[i]);
> + if (dev->napi[i].dev)
> + netif_napi_del(&dev->napi[i]);
> mt76_dma_rx_cleanup(dev, q);
>
> page_pool_destroy(q->page_pool);
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 07/19] wifi: mt76: mt7996: stop WED before the DMA reset of a full reset
2026-11-17 18:01 ` [PATCH mt76-next 07/19] wifi: mt76: mt7996: stop WED before the DMA reset of a full reset Felix Fietkau
@ 2026-11-18 8:38 ` Lorenzo Bianconi
0 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:38 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 4954 bytes --]
> Unlike the L1 SER path, mt7996_mac_restart() resets the WFSYS while the
> attached WEDs still access it over PCIe. Their reads during the reset
> get no completion, and MT7988 reports uncorrectable PCIe completion
> timeouts on both root ports.
>
> Stop both WEDs at the start of the restart, and disable the WED
> interrupt agent and wait for it to go idle before the WFSYS reset. The
> other agents stay enabled, since TX through WED stops after the restart
> otherwise.
>
> Fixes: 83eafc9251d6 ("wifi: mt76: mt7996: add wed tx support")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> .../net/wireless/mediatek/mt76/mt7996/dma.c | 25 ++++++++++++++++++-
> .../net/wireless/mediatek/mt76/mt7996/mac.c | 19 +++++++++-----
> .../net/wireless/mediatek/mt76/mt7996/regs.h | 5 ++++
> 3 files changed, 42 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/dma.c b/drivers/net/wireless/mediatek/mt76/mt7996/dma.c
> index 3d9353811a02..4450d35e9439 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/dma.c
> @@ -3,6 +3,7 @@
> * Copyright (C) 2022 MediaTek Inc.
> */
>
> +#include <linux/iopoll.h>
> #include "mt7996.h"
> #include "../dma.h"
> #include "mac.h"
> @@ -957,6 +958,25 @@ int mt7996_dma_init(struct mt7996_dev *dev)
> return 0;
> }
>
> +static void
> +mt7996_wed_int_agent_disable(struct mt7996_dev *dev,
> + struct mtk_wed_device *wed)
> +{
> + u32 val;
> +
> + if (!mtk_wed_device_active(wed))
> + return;
> +
> + val = mtk_wed_device_reg_read(wed, MT_WED_CTRL);
> + mtk_wed_device_reg_write(wed, MT_WED_CTRL,
> + val & ~MT_WED_CTRL_WPDMA_INT_AGENT_EN);
> +
> + if (read_poll_timeout(mtk_wed_device_reg_read, val,
> + !(val & MT_WED_CTRL_WPDMA_INT_AGENT_BUSY),
> + 100, 20000, false, wed, MT_WED_CTRL))
> + dev_warn(dev->mt76.dev, "WED interrupt agent still busy\n");
> +}
> +
> void mt7996_dma_reset(struct mt7996_dev *dev, bool force)
> {
> struct mt76_phy *phy2 = dev->mt76.phys[MT_BAND1];
> @@ -996,8 +1016,11 @@ void mt7996_dma_reset(struct mt7996_dev *dev, bool force)
> mt7996_rro_msdu_page_map_free(dev);
>
> /* reset wfsys */
> - if (force)
> + if (force) {
> + mt7996_wed_int_agent_disable(dev, &dev->mt76.mmio.wed_hif2);
> + mt7996_wed_int_agent_disable(dev, &dev->mt76.mmio.wed);
> mt7996_wfsys_reset(dev);
> + }
>
> if (dev->hif2 && mtk_wed_device_active(&dev->mt76.mmio.wed_hif2))
> mtk_wed_device_dma_reset(&dev->mt76.mmio.wed_hif2);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> index 03670293a78f..2e1d98bf823a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> @@ -2291,6 +2291,16 @@ void mt7996_tx_token_put(struct mt7996_dev *dev)
> }
> }
>
> +static void
> +mt7996_wed_stop(struct mt7996_dev *dev)
> +{
> + if (mtk_wed_device_active(&dev->mt76.mmio.wed_hif2))
> + mtk_wed_device_stop(&dev->mt76.mmio.wed_hif2);
> +
> + if (mtk_wed_device_active(&dev->mt76.mmio.wed))
> + mtk_wed_device_stop(&dev->mt76.mmio.wed);
> +}
> +
> static int
> mt7996_mac_restart(struct mt7996_dev *dev)
> {
> @@ -2298,6 +2308,8 @@ mt7996_mac_restart(struct mt7996_dev *dev)
> struct mt7996_phy *phy;
> int i, ret;
>
> + mt7996_wed_stop(dev);
> +
> if (dev->hif2) {
> mt76_wr(dev, MT_INT1_MASK_CSR, 0x0);
> mt76_wr(dev, MT_INT1_SOURCE_CSR, ~0);
> @@ -2573,12 +2585,7 @@ void mt7996_mac_reset_work(struct work_struct *work)
> dev_info(dev->mt76.dev,"\n%s L1 SER recovery start.",
> wiphy_name(hw->wiphy));
>
> - if (mtk_wed_device_active(&dev->mt76.mmio.wed_hif2))
> - mtk_wed_device_stop(&dev->mt76.mmio.wed_hif2);
> -
> - if (mtk_wed_device_active(&dev->mt76.mmio.wed))
> - mtk_wed_device_stop(&dev->mt76.mmio.wed);
> -
> + mt7996_wed_stop(dev);
> mt7996_npu_hw_stop(dev);
> ieee80211_stop_queues(mt76_hw(dev));
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/regs.h b/drivers/net/wireless/mediatek/mt76/mt7996/regs.h
> index 6df6e4c3d45d..e82a281a773a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/regs.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/regs.h
> @@ -782,6 +782,11 @@ enum offs_rev {
> #define MT_WF_SUBSYS_RST_BYPASS_WFDMA2_SLP_PROT BIT(16)
> #define MT_WF_SUBSYS_RST_WHOLE_PATH_RST_REVERT_CYCLE GENMASK(15, 8)
>
> +/* WED registers, offsets for mtk_wed_device_reg_read() */
> +#define MT_WED_CTRL 0x00c
> +#define MT_WED_CTRL_WPDMA_INT_AGENT_EN BIT(0)
> +#define MT_WED_CTRL_WPDMA_INT_AGENT_BUSY BIT(1)
> +
> /* PCIE MAC */
> #define MT_PCIE_MAC_BASE 0x74030000
> #define MT_PCIE_MAC(ofs) (MT_PCIE_MAC_BASE + (ofs))
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 09/19] wifi: mt76: find the first A-MSDU subframe behind the radiotap data
2026-11-17 18:01 ` [PATCH mt76-next 09/19] wifi: mt76: find the first A-MSDU subframe behind the radiotap data Felix Fietkau
@ 2026-11-18 8:43 ` Lorenzo Bianconi
0 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:43 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1913 bytes --]
> mt76_rx_release_amsdu() reads the first subframe relative to
> skb->data, which points to the radiotap data where the driver pushed HE
> fields or EHT TLVs. It then misses an RFC1042 header in place of the
> destination address, so an A-MSDU of an HE or EHT PPDU in 802.11 format
> passes the mitigation of CVE-2020-24588.
>
> Locate the subframe behind the header that mt76_skb_get_hdr() returns.
>
> Fixes: 2c2bdd2372af ("mt76: validate rx A-MSDU subframes")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> ---
> drivers/net/wireless/mediatek/mt76/mac80211.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
> index bd822193e769..271fbd4711f7 100644
> --- a/drivers/net/wireless/mediatek/mt76/mac80211.c
> +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
> @@ -965,18 +965,21 @@ static void mt76_rx_release_amsdu(struct mt76_phy *phy, enum mt76_rxq_id q)
> * address.
> */
> if (skb_shinfo(skb)->frag_list) {
> - int offset = 0;
> + u8 *subframe = skb->data;
>
> if (!(status->flag & RX_FLAG_8023)) {
> - offset = ieee80211_get_hdrlen_from_skb(skb);
> + struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb);
> +
> + subframe = (u8 *)hdr +
> + ieee80211_hdrlen(hdr->frame_control);
>
> if ((status->flag &
> (RX_FLAG_DECRYPTED | RX_FLAG_IV_STRIPPED)) ==
> RX_FLAG_DECRYPTED)
> - offset += 8;
> + subframe += 8;
> }
>
> - if (ether_addr_equal(skb->data + offset, rfc1042_header)) {
> + if (ether_addr_equal(subframe, rfc1042_header)) {
maybe I am too paranoic, but should we check this is part of the skb head
running pskb_may_pull()? Otherwise I am fine with the patch.
Regards,
Lorenzo
> dev_kfree_skb(skb);
> return;
> }
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 10/19] wifi: mt76: mark all but the last subframe of an A-MSDU chain
2026-11-17 18:01 ` [PATCH mt76-next 10/19] wifi: mt76: mark all but the last subframe of an A-MSDU chain Felix Fietkau
@ 2026-11-18 8:47 ` Lorenzo Bianconi
0 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:47 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1626 bytes --]
> mt76_rx_complete() passes the subframes of a hardware-split A-MSDU to
> mac80211 without RX_FLAG_AMSDU_MORE. They share the sequence control of
> the MPDU, so in 802.11 format ieee80211_rx_h_check_dup() drops the later
> subframes of a retransmitted A-MSDU as duplicates.
>
> Set RX_FLAG_AMSDU_MORE on every subframe but the last.
>
> Fixes: cc4b3c139ad3 ("mt76: mt7915: enable hw rx-amsdu de-aggregation")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/mac80211.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
> index 271fbd4711f7..d72ade2d46cb 100644
> --- a/drivers/net/wireless/mediatek/mt76/mac80211.c
> +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
> @@ -1625,6 +1625,8 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
> mt76_check_ccmp_pn(skb);
> skb_shinfo(skb)->frag_list = NULL;
> mt76_rx_convert(dev, skb, &hw, &link_sta);
> + if (nskb)
> + IEEE80211_SKB_RXCB(skb)->flag |= RX_FLAG_AMSDU_MORE;
> ieee80211_rx_list(hw, link_sta, skb, &list);
>
> /* subsequent amsdu frames */
> @@ -1634,6 +1636,8 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
> skb->next = NULL;
>
> mt76_rx_convert(dev, skb, &hw, &link_sta);
> + if (nskb)
> + IEEE80211_SKB_RXCB(skb)->flag |= RX_FLAG_AMSDU_MORE;
> ieee80211_rx_list(hw, link_sta, skb, &list);
> }
> }
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 11/19] wifi: mt76: mt7996: set qos_ctl of a frame that hardware reordered
2026-11-17 18:01 ` [PATCH mt76-next 11/19] wifi: mt76: mt7996: set qos_ctl of a frame that hardware reordered Felix Fietkau
@ 2026-11-18 8:50 ` Lorenzo Bianconi
0 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:50 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1411 bytes --]
On Nov 17, Felix Fietkau wrote:
> mt7996_mac_fill_rx() returns before it sets status->qos_ctl for a frame
> that the hardware reordered. mt76_check_ccmp_pn() then checks every
> such frame against the counter of TID 0, so frames of different TIDs
> read as replays.
>
> Set qos_ctl for these frames as well.
>
> Fixes: 950d0abb5cd9 ("wifi: mt76: mt7996: add wed rx support")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> index 2e1d98bf823a..c70e429ab419 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
> @@ -707,12 +707,15 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
> }
> }
>
> - if (!status->wcid || !ieee80211_is_data_qos(fc) || hw_aggr)
> + if (!status->wcid || !ieee80211_is_data_qos(fc))
> + return 0;
> +
> + status->qos_ctl = qos_ctl;
> + if (hw_aggr)
> return 0;
>
> status->aggr = unicast &&
> !ieee80211_is_qos_nullfunc(fc);
> - status->qos_ctl = qos_ctl;
> status->seqno = IEEE80211_SEQ_TO_SN(seq_ctrl);
>
> return 0;
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 15/19] wifi: mt76: guard the tx_list of every phy with one lock
2026-11-17 18:01 ` [PATCH mt76-next 15/19] wifi: mt76: guard the tx_list of every phy with one lock Felix Fietkau
@ 2026-11-18 8:52 ` Lorenzo Bianconi
0 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:52 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 5668 bytes --]
> mt76_tx() lists a wcid on the tx_list of the phy its caller passes,
> under the tx_lock of that phy, while mt76_wcid_cleanup() unlists it
> under the tx_lock of wcid->phy_idx. mt7996_tx() and
> mt76_offchannel_send_nullfunc() can list a wcid on the phy of another
> link, so no common lock guards its node, and the tx_list gets corrupted.
>
> Guard the tx_list of every phy with one lock per device.
>
> Fixes: ce35ecffc96e ("wifi: mt76: mt7996: fix MLD ID in MAC TXD and HIF TXP")
> Fixes: 381733b3a14a ("wifi: mt76: send nullfunc PS frames on offchannel transitions")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/mac80211.c | 7 +++----
> drivers/net/wireless/mediatek/mt76/mt76.h | 3 ++-
> drivers/net/wireless/mediatek/mt76/tx.c | 13 +++++++------
> 3 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
> index 6b496dfda5cc..da1da160909a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mac80211.c
> +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
> @@ -431,7 +431,6 @@ mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw)
> int i;
>
> INIT_LIST_HEAD(&phy->tx_list);
> - spin_lock_init(&phy->tx_lock);
> for (i = 0; i < ARRAY_SIZE(phy->rx_amsdu); i++)
> spin_lock_init(&phy->rx_amsdu[i].lock);
> INIT_DELAYED_WORK(&phy->roc_work, mt76_roc_complete_work);
> @@ -753,6 +752,7 @@ mt76_alloc_device(struct device *pdev, unsigned int size,
> spin_lock_init(&dev->cc_lock);
> spin_lock_init(&dev->status_lock);
> spin_lock_init(&dev->wed_lock);
> + spin_lock_init(&dev->tx_lock);
> mutex_init(&dev->mutex);
> init_waitqueue_head(&dev->tx_wait);
>
> @@ -1837,7 +1837,6 @@ EXPORT_SYMBOL_GPL(mt76_wcid_init);
>
> void mt76_wcid_cleanup(struct mt76_dev *dev, struct mt76_wcid *wcid)
> {
> - struct mt76_phy *phy = mt76_dev_phy(dev, wcid->phy_idx);
> struct ieee80211_hw *hw;
> struct sk_buff_head list;
> struct sk_buff *skb;
> @@ -1859,7 +1858,7 @@ void mt76_wcid_cleanup(struct mt76_dev *dev, struct mt76_wcid *wcid)
> list_del_init(&wcid->poll_list);
> spin_unlock_bh(&dev->sta_poll_lock);
>
> - spin_lock_bh(&phy->tx_lock);
> + spin_lock_bh(&dev->tx_lock);
>
> if (!list_empty(&wcid->tx_list))
> list_del_init(&wcid->tx_list);
> @@ -1872,7 +1871,7 @@ void mt76_wcid_cleanup(struct mt76_dev *dev, struct mt76_wcid *wcid)
> skb_queue_splice_tail_init(&wcid->tx_offchannel, &list);
> spin_unlock(&wcid->tx_offchannel.lock);
>
> - spin_unlock_bh(&phy->tx_lock);
> + spin_unlock_bh(&dev->tx_lock);
>
> while ((skb = __skb_dequeue(&list)) != NULL) {
> hw = mt76_tx_status_get_hw(dev, skb);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
> index 7a2a6afc3c21..77bfecb7d49b 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76.h
> @@ -872,7 +872,6 @@ struct mt76_phy {
> unsigned int num_sta;
> u8 band_idx;
>
> - spinlock_t tx_lock;
> struct list_head tx_list;
> struct mt76_queue *q_tx[__MT_TXQ_MAX];
>
> @@ -988,6 +987,8 @@ struct mt76_dev {
>
> struct mt76_worker tx_worker;
> struct napi_struct tx_napi;
> + /* protects the tx_list of every phy */
> + spinlock_t tx_lock;
>
> spinlock_t token_lock;
> struct idr token;
> diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
> index 0085b7a29fce..9eafc86ec288 100644
> --- a/drivers/net/wireless/mediatek/mt76/tx.c
> +++ b/drivers/net/wireless/mediatek/mt76/tx.c
> @@ -392,10 +392,10 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
> __skb_queue_tail(head, skb);
> spin_unlock_bh(&head->lock);
>
> - spin_lock_bh(&phy->tx_lock);
> + spin_lock_bh(&phy->dev->tx_lock);
> if (list_empty(&wcid->tx_list))
> list_add_tail(&wcid->tx_list, &phy->tx_list);
> - spin_unlock_bh(&phy->tx_lock);
> + spin_unlock_bh(&phy->dev->tx_lock);
>
> mt76_worker_schedule(&phy->dev->tx_worker);
> }
> @@ -740,6 +740,7 @@ mt76_txq_schedule_pending_wcid(struct mt76_phy *phy, struct mt76_wcid *wcid,
>
> void mt76_txq_schedule_pending(struct mt76_phy *phy)
> {
> + struct mt76_dev *dev = phy->dev;
> LIST_HEAD(tx_list);
> int ret = 0;
>
> @@ -749,7 +750,7 @@ void mt76_txq_schedule_pending(struct mt76_phy *phy)
> local_bh_disable();
> rcu_read_lock();
>
> - spin_lock(&phy->tx_lock);
> + spin_lock(&dev->tx_lock);
> list_splice_init(&phy->tx_list, &tx_list);
> while (!list_empty(&tx_list)) {
> struct mt76_wcid *wcid;
> @@ -757,19 +758,19 @@ void mt76_txq_schedule_pending(struct mt76_phy *phy)
> wcid = list_first_entry(&tx_list, struct mt76_wcid, tx_list);
> list_del_init(&wcid->tx_list);
>
> - spin_unlock(&phy->tx_lock);
> + spin_unlock(&dev->tx_lock);
> if (ret >= 0)
> ret = mt76_txq_schedule_pending_wcid(phy, wcid, &wcid->tx_offchannel);
> if (ret >= 0 && !phy->offchannel)
> ret = mt76_txq_schedule_pending_wcid(phy, wcid, &wcid->tx_pending);
> - spin_lock(&phy->tx_lock);
> + spin_lock(&dev->tx_lock);
>
> if ((!skb_queue_empty(&wcid->tx_pending) ||
> !skb_queue_empty(&wcid->tx_offchannel)) &&
> list_empty(&wcid->tx_list))
> list_add_tail(&wcid->tx_list, &phy->tx_list);
> }
> - spin_unlock(&phy->tx_lock);
> + spin_unlock(&dev->tx_lock);
>
> rcu_read_unlock();
> local_bh_enable();
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 12/19] wifi: mt76: check the PN of a BA session frame at its release
2026-11-17 18:01 ` [PATCH mt76-next 12/19] wifi: mt76: check the PN of a BA session frame at its release Felix Fietkau
@ 2026-11-18 8:55 ` Lorenzo Bianconi
0 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:55 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 4149 bytes --]
On Nov 17, Felix Fietkau wrote:
> mt76_rx_complete() checks the PN after a frame left the reorder buffer,
> outside tid->lock. The links of an MLD peer share one PN state, so a
> frame released on one RX ring can be checked before an earlier frame of
> the same TID on another ring, which then reads as a replay. The reorder
> work has the same gap on a single link.
>
> Check the PN of a BA session frame where it leaves the reorder buffer,
> under tid->lock. mt76_rx_complete() still checks all other frames.
>
> Fixes: 30ce7f4456ae ("mt76: validate rx CCMP PN")
> Fixes: 62694ed0b76f ("wifi: mt76: check the RX PN of an MLD peer once per peer")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/agg-rx.c | 11 +++++++++++
> drivers/net/wireless/mediatek/mt76/mac80211.c | 6 ++++--
> drivers/net/wireless/mediatek/mt76/mt76.h | 3 ++-
> 3 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/agg-rx.c b/drivers/net/wireless/mediatek/mt76/agg-rx.c
> index bf1babac3895..49721b4faab1 100644
> --- a/drivers/net/wireless/mediatek/mt76/agg-rx.c
> +++ b/drivers/net/wireless/mediatek/mt76/agg-rx.c
> @@ -12,6 +12,15 @@ static unsigned long mt76_aggr_tid_to_timeo(u8 tidno)
> return HZ / (tidno >= 4 ? 25 : 10);
> }
>
> +static void
> +mt76_rx_aggr_pn_check(struct sk_buff *skb)
> +{
> + struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
> +
> + mt76_check_ccmp_pn(skb);
> + status->skip_pn_check = true;
> +}
> +
> static void
> mt76_aggr_release(struct mt76_rx_tid *tid, struct sk_buff_head *frames, int idx)
> {
> @@ -25,6 +34,7 @@ mt76_aggr_release(struct mt76_rx_tid *tid, struct sk_buff_head *frames, int idx)
>
> tid->reorder_buf[idx] = NULL;
> tid->nframes--;
> + mt76_rx_aggr_pn_check(skb);
> __skb_queue_tail(frames, skb);
> }
>
> @@ -204,6 +214,7 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames)
> }
>
> if (seqno == head) {
> + mt76_rx_aggr_pn_check(skb);
> tid->head = ieee80211_sn_inc(head);
> if (tid->nframes)
> mt76_rx_aggr_release_head(tid, frames);
> diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
> index d72ade2d46cb..b1789be134d6 100644
> --- a/drivers/net/wireless/mediatek/mt76/mac80211.c
> +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
> @@ -1387,8 +1387,7 @@ mt76_rx_convert(struct mt76_dev *dev, struct sk_buff *skb,
> *hw = mt76_phy_hw(dev, mstat.phy_idx);
> }
>
> -static void
> -mt76_check_ccmp_pn(struct sk_buff *skb)
> +void mt76_check_ccmp_pn(struct sk_buff *skb)
> {
> struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
> struct mt76_wcid *wcid = status->wcid;
> @@ -1403,6 +1402,9 @@ mt76_check_ccmp_pn(struct sk_buff *skb)
> if (status->flag & RX_FLAG_ONLY_MONITOR)
> return;
>
> + if (status->skip_pn_check)
> + return;
> +
> if (!wcid || !wcid->rx_check_pn)
> return;
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
> index 8f8388d44aa9..0b16567920fa 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76.h
> @@ -774,7 +774,7 @@ struct mt76_rx_status {
> } eht;
> };
>
> - u8 amsdu:1, first_amsdu:1, last_amsdu:1;
> + u8 amsdu:1, first_amsdu:1, last_amsdu:1, skip_pn_check:1;
> u8 rate_idx;
> u8 nss:5, band:3;
> u8 chains;
> @@ -1842,6 +1842,7 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
> void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
> struct napi_struct *napi);
> void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames);
> +void mt76_check_ccmp_pn(struct sk_buff *skb);
> void mt76_testmode_tx_pending(struct mt76_phy *phy);
> void mt76_queue_tx_complete(struct mt76_dev *dev, struct mt76_queue *q,
> struct mt76_queue_entry *e);
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 19/19] wifi: mt76: mt7615: take each polled station under sta_poll_lock
2026-11-17 18:01 ` [PATCH mt76-next 19/19] wifi: mt76: mt7615: take each polled station " Felix Fietkau
@ 2026-11-18 8:57 ` Lorenzo Bianconi
0 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:57 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1709 bytes --]
> mt7615_mac_sta_poll() tests its local copy of sta_poll_list and reads
> the first entry without sta_poll_lock, while a station removal takes
> the wcid off that list under the lock. If the removal takes the last
> station between the two reads, the poll takes the list head for a
> station and writes its airtime counters to the stack.
>
> Test the list and take the station off it in one locked section.
>
> Fixes: a621372a04ac ("mt76: mt7615: rework mt7615_mac_sta_poll for usb code")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> index ada40b8a517a..8e81ebe3e2ca 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> @@ -905,13 +905,16 @@ void mt7615_mac_sta_poll(struct mt7615_dev *dev)
> list_splice_init(&dev->mt76.sta_poll_list, &sta_poll_list);
> spin_unlock_bh(&dev->mt76.sta_poll_lock);
>
> - while (!list_empty(&sta_poll_list)) {
> + while (true) {
> bool clear = false;
>
> + spin_lock_bh(&dev->mt76.sta_poll_lock);
> + if (list_empty(&sta_poll_list)) {
> + spin_unlock_bh(&dev->mt76.sta_poll_lock);
> + break;
> + }
> msta = list_first_entry(&sta_poll_list, struct mt7615_sta,
> wcid.poll_list);
> -
> - spin_lock_bh(&dev->mt76.sta_poll_lock);
> list_del_init(&msta->wcid.poll_list);
> spin_unlock_bh(&dev->mt76.sta_poll_lock);
>
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH mt76-next 18/19] wifi: mt76: mt7925: take each polled link under sta_poll_lock
2026-11-17 18:01 ` [PATCH mt76-next 18/19] wifi: mt76: mt7925: take each polled link under sta_poll_lock Felix Fietkau
@ 2026-11-18 8:58 ` Lorenzo Bianconi
0 siblings, 0 replies; 31+ messages in thread
From: Lorenzo Bianconi @ 2026-11-18 8:58 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1664 bytes --]
On Nov 17, Felix Fietkau wrote:
> mt7925_mac_sta_poll() tests its local copy of sta_poll_list and reads
> the first entry without sta_poll_lock, while a link removal takes the
> wcid off that list under the lock. If the removal takes the last link
> between the two reads, the poll takes the list head for a link and
> writes its airtime counters to the stack.
>
> Test the list and take the link off it in one locked section, as
> mt7921_mac_sta_poll() does.
>
> Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
> index 5518960e1375..2528c2f5d717 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
> @@ -54,12 +54,14 @@ static void mt7925_mac_sta_poll(struct mt792x_dev *dev)
> u16 idx;
> u8 bw;
>
> - if (list_empty(&sta_poll_list))
> + spin_lock_bh(&dev->mt76.sta_poll_lock);
> + if (list_empty(&sta_poll_list)) {
> + spin_unlock_bh(&dev->mt76.sta_poll_lock);
> break;
> + }
> mlink = list_first_entry(&sta_poll_list,
> struct mt792x_link_sta, wcid.poll_list);
> msta = mlink->sta;
> - spin_lock_bh(&dev->mt76.sta_poll_lock);
> list_del_init(&mlink->wcid.poll_list);
> spin_unlock_bh(&dev->mt76.sta_poll_lock);
>
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2026-11-18 8:58 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 18:01 [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 02/19] wifi: mt76: mt7996: return a negative error for a firmware status Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 03/19] wifi: mt76: mt7996: use the default timeout for STA_REC and BSS_INFO Felix Fietkau
2026-11-18 8:22 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 04/19] wifi: mt76: mt7915: " Felix Fietkau
2026-11-18 8:23 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 05/19] wifi: mt76: delete only the RX NAPIs that were added Felix Fietkau
2026-11-18 8:32 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 06/19] wifi: mt76: mt7996: report radar on the channel context of its band Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 07/19] wifi: mt76: mt7996: stop WED before the DMA reset of a full reset Felix Fietkau
2026-11-18 8:38 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 08/19] wifi: mt76: skip the radiotap TLVs in mt76_skb_get_hdr() Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 09/19] wifi: mt76: find the first A-MSDU subframe behind the radiotap data Felix Fietkau
2026-11-18 8:43 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 10/19] wifi: mt76: mark all but the last subframe of an A-MSDU chain Felix Fietkau
2026-11-18 8:47 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 11/19] wifi: mt76: mt7996: set qos_ctl of a frame that hardware reordered Felix Fietkau
2026-11-18 8:50 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 12/19] wifi: mt76: check the PN of a BA session frame at its release Felix Fietkau
2026-11-18 8:55 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 13/19] wifi: mt76: check the RX PN of CCMP-256, GCMP and GCMP-256 keys Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 14/19] wifi: mt76: connac: return a negative error for a firmware status Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 15/19] wifi: mt76: guard the tx_list of every phy with one lock Felix Fietkau
2026-11-18 8:52 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 16/19] wifi: mt76: keep an unpublished wcid off the TX and poll lists Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 17/19] wifi: mt76: mt7925: do not take iflist_mtx under the mutex Felix Fietkau
2026-11-17 18:01 ` [PATCH mt76-next 18/19] wifi: mt76: mt7925: take each polled link under sta_poll_lock Felix Fietkau
2026-11-18 8:58 ` Lorenzo Bianconi
2026-11-17 18:01 ` [PATCH mt76-next 19/19] wifi: mt76: mt7615: take each polled station " Felix Fietkau
2026-11-18 8:57 ` Lorenzo Bianconi
2026-11-18 8:20 ` [PATCH mt76-next 01/19] wifi: mt76: don't pin undrainable PS stations in the tx scheduler Lorenzo Bianconi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox