* [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916
@ 2026-11-24 8:42 Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 02/20] wifi: mt76: mt7915: set the LED GPIO mux " Felix Fietkau
` (19 more replies)
0 siblings, 20 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:42 UTC (permalink / raw)
To: linux-wireless
mt7915_coredump_get_mem_layout() selects the mt7916 regions for chip
0x7916, but mt76_chip() returns 0x7906 on mt7916, like is_mt7916()
expects. 0x7916 is the PCI id of the second interface, which
mt7915_pci_probe() hands to mt7915_pci_hif2_probe() without a device
of its own. With the coredump_memdump parameter set, an mt7916
firmware crash thus gives a dump without firmware memory.
Match the chip id of mt7916.
Fixes: 4dbcb9125cc3 ("wifi: mt76: mt7915: enable coredump support")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7915/coredump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/coredump.c b/drivers/net/wireless/mediatek/mt76/mt7915/coredump.c
index db079b274a93..91f02735a882 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/coredump.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/coredump.c
@@ -96,7 +96,7 @@ mt7915_coredump_get_mem_layout(struct mt7915_dev *dev, u32 *num)
case 0x7986:
*num = ARRAY_SIZE(mt798x_mem_regions);
return &mt798x_mem_regions[0];
- case 0x7916:
+ case 0x7906:
*num = ARRAY_SIZE(mt7916_mem_regions);
return &mt7916_mem_regions[0];
default:
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 02/20] wifi: mt76: mt7915: set the LED GPIO mux of mt7916
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
@ 2026-11-24 8:42 ` Felix Fietkau
2026-11-24 8:53 ` Lorenzo Bianconi
2026-11-24 8:42 ` [PATCH mt76-next 03/20] wifi: mt76: fail an MCU command started during an MCU reset Felix Fietkau
` (18 subsequent siblings)
19 siblings, 1 reply; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:42 UTC (permalink / raw)
To: linux-wireless
The three switches of mt7915_init_led_mux() set the mt7916 GPIO mux for
chip 0x7916. But mt76_chip() returns 0x7906 on mt7916, like is_mt7916()
expects. 0x7916 is the PCI id of the second interface, which
mt7915_pci_probe() hands to mt7915_pci_hif2_probe() without a device
of its own. The GPIO mux of the mt7916 LED pins is thus never set.
Match the chip id of mt7916.
Fixes: 9e81c2c7b9af ("wifi: mt76: mt7915: enable per-phy led support")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7915/init.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
index 6d09718ec585..1bb2a938c354 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
@@ -612,7 +612,7 @@ mt7915_init_led_mux(struct mt7915_dev *dev)
mt76_rmw_field(dev, MT_LED_GPIO_MUX0,
GENMASK(11, 8), 1);
break;
- case 0x7916:
+ case 0x7906:
mt76_rmw_field(dev, MT_LED_GPIO_MUX1,
GENMASK(27, 24), 3);
mt76_rmw_field(dev, MT_LED_GPIO_MUX1,
@@ -631,7 +631,7 @@ mt7915_init_led_mux(struct mt7915_dev *dev)
mt76_rmw_field(dev, MT_LED_GPIO_MUX0,
GENMASK(11, 8), 1);
break;
- case 0x7916:
+ case 0x7906:
mt76_rmw_field(dev, MT_LED_GPIO_MUX1,
GENMASK(31, 28), 3);
break;
@@ -648,7 +648,7 @@ mt7915_init_led_mux(struct mt7915_dev *dev)
mt76_rmw_field(dev, MT_LED_GPIO_MUX0,
GENMASK(7, 4), 1);
break;
- case 0x7916:
+ case 0x7906:
mt76_rmw_field(dev, MT_LED_GPIO_MUX1,
GENMASK(27, 24), 3);
break;
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 03/20] wifi: mt76: fail an MCU command started during an MCU reset
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 02/20] wifi: mt76: mt7915: set the LED GPIO mux " Felix Fietkau
@ 2026-11-24 8:42 ` Felix Fietkau
2026-11-24 8:54 ` Lorenzo Bianconi
2026-11-24 8:42 ` [PATCH mt76-next 04/20] wifi: mt76: mark an MCU command that only reads Felix Fietkau
` (17 subsequent siblings)
19 siblings, 1 reply; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:42 UTC (permalink / raw)
To: linux-wireless
While MT76_MCU_RESET is set, mt76_dma_tx_queue_skb_raw() drops a
command with the error of a full ring or a failed DMA mapping. The SDIO
path queues the command, reports success and skips it. The USB path
sends it. The caller thus cannot tell such a command from one whose
answer the reset cut off.
Do not send a command that starts while the bit is set. Return an error
that no other step of the send gives. The interrupt path can set the
bit after this test. Return the same error from the raw TX of the DMA
path for that case.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/dma.c | 6 ++++--
drivers/net/wireless/mediatek/mt76/mcu.c | 6 ++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index 8c0403820299..f5203f39e6b1 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -637,8 +637,10 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q,
struct mt76_queue_buf buf = {};
dma_addr_t addr;
- if (test_bit(MT76_MCU_RESET, &dev->phy.state))
- goto error;
+ if (test_bit(MT76_MCU_RESET, &dev->phy.state)) {
+ dev_kfree_skb(skb);
+ return -ESHUTDOWN;
+ }
if (q->queued + 1 >= q->ndesc - 1)
goto error;
diff --git a/drivers/net/wireless/mediatek/mt76/mcu.c b/drivers/net/wireless/mediatek/mt76/mcu.c
index 7149b2f7aafd..e19fd1bbd911 100644
--- a/drivers/net/wireless/mediatek/mt76/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mcu.c
@@ -91,6 +91,12 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
goto out;
}
+ if (test_bit(MT76_MCU_RESET, &dev->phy.state)) {
+ orig_skb = skb;
+ ret = -ESHUTDOWN;
+ goto out;
+ }
+
if (dev->mcu_ops->mcu_skb_prepare_msg) {
orig_skb = skb;
ret = dev->mcu_ops->mcu_skb_prepare_msg(dev, skb, cmd, &seq);
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 04/20] wifi: mt76: mark an MCU command that only reads
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 02/20] wifi: mt76: mt7915: set the LED GPIO mux " Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 03/20] wifi: mt76: fail an MCU command started during an MCU reset Felix Fietkau
@ 2026-11-24 8:42 ` Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 05/20] wifi: mt76: retry only an MCU command that reads Felix Fietkau
` (16 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:42 UTC (permalink / raw)
To: linux-wireless
The core cannot tell a command that only reads firmware state from one
that changes it. The query bit of the command id does not show it.
Several reads are sent without that bit, and a command that returns
data can still change state.
Add a cmd flag for a command that changes no firmware state. The core
can then handle a lost answer of such a command on its own. The core
strips the flag before any mcu_ops call. A driver compare of the
command id thus needs no mask.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mcu.c | 5 ++++-
drivers/net/wireless/mediatek/mt76/mt76.h | 5 +++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mcu.c b/drivers/net/wireless/mediatek/mt76/mcu.c
index e19fd1bbd911..0a7d82bdeeeb 100644
--- a/drivers/net/wireless/mediatek/mt76/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mcu.c
@@ -59,7 +59,8 @@ int mt76_mcu_send_and_get_msg(struct mt76_dev *dev, int cmd, const void *data,
struct sk_buff *skb;
if (dev->mcu_ops->mcu_send_msg)
- return dev->mcu_ops->mcu_send_msg(dev, cmd, data, len, wait_resp);
+ return dev->mcu_ops->mcu_send_msg(dev, cmd & ~MT76_MCU_CMD_READ,
+ data, len, wait_resp);
skb = mt76_mcu_msg_alloc(dev, data, len);
if (!skb)
@@ -78,6 +79,8 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
unsigned long expires;
int ret, seq;
+ cmd &= ~MT76_MCU_CMD_READ;
+
if (ret_skb)
*ret_skb = NULL;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 648f79c4b6d0..5cb446bdf4be 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -267,6 +267,11 @@ struct mt76_queue {
struct page_pool *page_pool;
};
+/* cmd flag of a command that changes no firmware state; the core strips it
+ * before it calls an mcu_ops function
+ */
+#define MT76_MCU_CMD_READ BIT(30)
+
struct mt76_mcu_ops {
unsigned int max_retry;
u32 headroom;
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 05/20] wifi: mt76: retry only an MCU command that reads
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (2 preceding siblings ...)
2026-11-24 8:42 ` [PATCH mt76-next 04/20] wifi: mt76: mark an MCU command that only reads Felix Fietkau
@ 2026-11-24 8:42 ` Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 06/20] wifi: mt76: report an MCU command whose outcome is unknown Felix Fietkau
` (15 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:42 UTC (permalink / raw)
To: linux-wireless
mt76_mcu_skb_send_and_get_msg() sends a command again after its answer
did not come in time. The firmware keeps no state per sequence number,
so a command whose answer alone was lost runs twice. Not every command
is safe to run twice. A second removal of a station record can clear
the entry of another station.
Retry only a command that is marked as a read. Any other command whose
answer does not come goes to the timeout handling of the driver at
once. As before, a driver gets the retry only with an
mcu_skb_prepare_msg op. A command that changes state and loses its
answer during the probe now fails the probe.
Fixes: 3688c18b65ae ("wifi: mt76: mt7915: retry mcu messages")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mcu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mcu.c b/drivers/net/wireless/mediatek/mt76/mcu.c
index 0a7d82bdeeeb..61b8ced5c11a 100644
--- a/drivers/net/wireless/mediatek/mt76/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mcu.c
@@ -74,6 +74,7 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
int cmd, bool wait_resp,
struct sk_buff **ret_skb)
{
+ bool read = cmd & MT76_MCU_CMD_READ;
unsigned int retry = 0;
struct sk_buff *orig_skb = NULL;
unsigned long expires;
@@ -124,7 +125,8 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
do {
skb = mt76_mcu_get_response(dev, expires);
- if (!skb && !test_bit(MT76_MCU_RESET, &dev->phy.state) &&
+ if (!skb && read &&
+ !test_bit(MT76_MCU_RESET, &dev->phy.state) &&
orig_skb && retry++ < dev->mcu_ops->max_retry) {
dev_err(dev->dev, "Retry message %08x (seq %d)\n",
cmd, seq);
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 06/20] wifi: mt76: report an MCU command whose outcome is unknown
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (3 preceding siblings ...)
2026-11-24 8:42 ` [PATCH mt76-next 05/20] wifi: mt76: retry only an MCU command that reads Felix Fietkau
@ 2026-11-24 8:42 ` Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 07/20] wifi: mt76: mt7996: mark the MCU commands that only read Felix Fietkau
` (14 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:42 UTC (permalink / raw)
To: linux-wireless
A command that an MCU reset keeps from the firmware is not applied. A
command whose answer does not come may have run or not. In both cases
the firmware state that the command was to set is not known to hold.
Only the driver knows how to restore it.
Add an optional op that the core calls for such a command, unless the
command is marked as a read. The core calls it after the response
parser, with the MCU mutex held. An answer with an error status does
not reach the op, and neither does a host error before the send. The
firmware state is known in both cases.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mcu.c | 6 ++++++
drivers/net/wireless/mediatek/mt76/mt76.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mcu.c b/drivers/net/wireless/mediatek/mt76/mcu.c
index 61b8ced5c11a..4f3471b57eb9 100644
--- a/drivers/net/wireless/mediatek/mt76/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mcu.c
@@ -78,6 +78,7 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
unsigned int retry = 0;
struct sk_buff *orig_skb = NULL;
unsigned long expires;
+ bool lost = false;
int ret, seq;
cmd &= ~MT76_MCU_CMD_READ;
@@ -125,6 +126,7 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
do {
skb = mt76_mcu_get_response(dev, expires);
+ lost = !skb;
if (!skb && read &&
!test_bit(MT76_MCU_RESET, &dev->phy.state) &&
orig_skb && retry++ < dev->mcu_ops->max_retry) {
@@ -143,6 +145,10 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
out:
+ if (!read && (lost || ret == -ESHUTDOWN) &&
+ dev->mcu_ops->mcu_cmd_lost)
+ dev->mcu_ops->mcu_cmd_lost(dev, cmd);
+
dev_kfree_skb(orig_skb);
mutex_unlock(&dev->mcu.mutex);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 5cb446bdf4be..688039f2d967 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -285,6 +285,7 @@ struct mt76_mcu_ops {
int cmd, int *seq);
int (*mcu_parse_response)(struct mt76_dev *dev, int cmd,
struct sk_buff *skb, int seq);
+ void (*mcu_cmd_lost)(struct mt76_dev *dev, int cmd);
u32 (*mcu_rr)(struct mt76_dev *dev, u32 offset);
void (*mcu_wr)(struct mt76_dev *dev, u32 offset, u32 val);
int (*mcu_wr_rp)(struct mt76_dev *dev, u32 base,
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 07/20] wifi: mt76: mt7996: mark the MCU commands that only read
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (4 preceding siblings ...)
2026-11-24 8:42 ` [PATCH mt76-next 06/20] wifi: mt76: report an MCU command whose outcome is unknown Felix Fietkau
@ 2026-11-24 8:42 ` Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 08/20] wifi: mt76: mt7996: reset after an MCU reset lost a state command Felix Fietkau
` (13 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:42 UTC (permalink / raw)
To: linux-wireless
A command that only reads firmware state needs the read flag. Without
it, the core takes the loss of its answer as an unknown firmware state.
Set the flag on the reads of the efuse, the chip capabilities, the MIB
counters and the temperature. Set it on the register read, the station
statistics and the WA state query as well.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7996/mcu.c | 37 +++++++++++++------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index 28f932fe049e..52465006a40b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -409,16 +409,19 @@ int mt7996_mcu_wa_cmd(struct mt7996_dev *dev, int cmd, u32 a1, u32 a2, u32 a3)
cpu_to_le32(a3),
},
};
+ int read = 0;
+
+ if (cmd == MCU_WA_PARAM_CMD(QUERY))
+ read = MT76_MCU_CMD_READ;
if (mt7996_has_wa(dev))
- return mt76_mcu_send_msg(&dev->mt76, cmd, &req.args,
+ return mt76_mcu_send_msg(&dev->mt76, cmd | read, &req.args,
sizeof(req.args), false);
- req.tag = cpu_to_le16(cmd == MCU_WA_PARAM_CMD(QUERY) ? UNI_CMD_SDO_QUERY :
- UNI_CMD_SDO_SET);
+ req.tag = cpu_to_le16(read ? UNI_CMD_SDO_QUERY : UNI_CMD_SDO_SET);
req.len = cpu_to_le16(sizeof(req) - 4);
- return mt76_mcu_send_msg(&dev->mt76, MCU_WA_UNI_CMD(SDO), &req,
+ return mt76_mcu_send_msg(&dev->mt76, MCU_WA_UNI_CMD(SDO) | read, &req,
sizeof(req), false);
}
@@ -4714,8 +4717,8 @@ int mt7996_mcu_get_eeprom(struct mt7996_dev *dev, u32 offset, u8 *buf, u32 buf_l
}
req.info.addr = cpu_to_le32(addr);
- ret = mt76_mcu_send_and_get_msg(&dev->mt76, cmd, &req, sizeof(req),
- true, &skb);
+ ret = mt76_mcu_send_and_get_msg(&dev->mt76, cmd | MT76_MCU_CMD_READ,
+ &req, sizeof(req), true, &skb);
if (ret)
return ret;
@@ -4806,7 +4809,9 @@ int mt7996_mcu_get_efuse_free_block(struct mt7996_dev *dev, u8 *block_num)
struct sk_buff *skb;
int ret;
- ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WM_UNI_CMD_QUERY(EFUSE_CTRL), &req,
+ ret = mt76_mcu_send_and_get_msg(&dev->mt76,
+ MCU_WM_UNI_CMD_QUERY(EFUSE_CTRL) |
+ MT76_MCU_CMD_READ, &req,
sizeof(req), true, &skb);
if (ret)
return ret;
@@ -4838,7 +4843,8 @@ int mt7996_mcu_get_chip_config(struct mt7996_dev *dev, u32 *cap)
int ret;
ret = mt76_mcu_send_and_get_msg(&dev->mt76,
- MCU_WM_UNI_CMD_QUERY(CHIP_CONFIG), &req,
+ MCU_WM_UNI_CMD_QUERY(CHIP_CONFIG) |
+ MT76_MCU_CMD_READ, &req,
sizeof(req), true, &skb);
if (ret)
return ret;
@@ -4917,7 +4923,9 @@ int mt7996_mcu_get_chan_mib_info(struct mt7996_phy *phy, bool chan_switch)
req.data[i].offs = cpu_to_le32(offs[i]);
}
- ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WM_UNI_CMD_QUERY(GET_MIB_INFO),
+ ret = mt76_mcu_send_and_get_msg(&dev->mt76,
+ MCU_WM_UNI_CMD_QUERY(GET_MIB_INFO) |
+ MT76_MCU_CMD_READ,
&req, sizeof(req), true, &skb);
if (ret)
return ret;
@@ -4992,7 +5000,9 @@ int mt7996_mcu_get_temperature(struct mt7996_phy *phy)
int ret;
u32 temp;
- ret = mt76_mcu_send_and_get_msg(&phy->dev->mt76, MCU_WM_UNI_CMD(THERMAL),
+ ret = mt76_mcu_send_and_get_msg(&phy->dev->mt76,
+ MCU_WM_UNI_CMD(THERMAL) |
+ MT76_MCU_CMD_READ,
&req, sizeof(req), true, &skb);
if (ret)
return ret;
@@ -5671,7 +5681,8 @@ int mt7996_mcu_rf_regval(struct mt7996_dev *dev, u32 regidx, u32 *val, bool set)
&req, sizeof(req), true);
ret = mt76_mcu_send_and_get_msg(&dev->mt76,
- MCU_WM_UNI_CMD_QUERY(REG_ACCESS),
+ MCU_WM_UNI_CMD_QUERY(REG_ACCESS) |
+ MT76_MCU_CMD_READ,
&req, sizeof(req), true, &skb);
if (ret)
return ret;
@@ -5769,7 +5780,9 @@ int mt7996_mcu_get_all_sta_info(struct mt7996_phy *phy, u16 tag)
.len = cpu_to_le16(sizeof(req) - 4),
};
- return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(ALL_STA_INFO),
+ return mt76_mcu_send_msg(&dev->mt76,
+ MCU_WM_UNI_CMD(ALL_STA_INFO) |
+ MT76_MCU_CMD_READ,
&req, sizeof(req), false);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 08/20] wifi: mt76: mt7996: reset after an MCU reset lost a state command
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (5 preceding siblings ...)
2026-11-24 8:42 ` [PATCH mt76-next 07/20] wifi: mt76: mt7996: mark the MCU commands that only read Felix Fietkau
@ 2026-11-24 8:42 ` Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 09/20] wifi: mt76: mt7915: mark the MCU commands that only read Felix Fietkau
` (12 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:42 UTC (permalink / raw)
To: linux-wireless
An L1 SER sets MT76_MCU_RESET, which ends each command wait and refuses
each new command. The firmware can have run a command that it took
just before the recovery. The state that a cut or refused command sets
is thus unknown or missing. mt7996_mcu_parse_response() starts a full
reset only for a timeout with the bit clear.
Start a full reset where the core reports such a command, unless one is
already queued. The firmware load frees every record, and mac80211 sets
up each key, station and BSS again. Leave out a beacon template, as the
L1 work uploads each template again, and the L1 trigger of a WED reset,
as the pending reset that refuses it takes its place.
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7996/mac.c | 12 +++++++
.../net/wireless/mediatek/mt76/mt7996/mcu.c | 35 ++++++++++++++-----
.../net/wireless/mediatek/mt76/mt7996/mcu.h | 5 +++
.../wireless/mediatek/mt76/mt7996/mt7996.h | 1 +
4 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index d724ac425b42..e507bfd34372 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -2615,6 +2615,18 @@ mt7996_mac_full_reset(struct mt7996_dev *dev)
ieee80211_restart_hw(mt76_hw(dev));
}
+/* MT76_MCU_RESET keeps every command from the firmware until the reload */
+void mt7996_mac_full_reset_queue(struct mt7996_dev *dev)
+{
+ lockdep_assert_held(&dev->mt76.lock);
+
+ set_bit(MT76_MCU_RESET, &dev->mphy.state);
+ dev->recovery.restart = true;
+ wake_up(&dev->mt76.mcu.wait);
+ queue_work(dev->mt76.wq, &dev->reset_work);
+ wake_up(&dev->reset_wait);
+}
+
void mt7996_mac_reset_work(struct work_struct *work)
{
unsigned long bcn_restored = 0;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index 52465006a40b..fc56ce723de5 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -215,6 +215,21 @@ mt7996_mcu_set_sta_ht_mcs(struct ieee80211_link_sta *link_sta,
ht_mcs[nss] = link_sta->ht_cap.mcs.rx_mask[nss] & mask[nss];
}
+/* only the firmware load gives a known state again */
+static void
+mt7996_mcu_cmd_lost(struct mt76_dev *mdev, int cmd)
+{
+ struct mt7996_dev *dev = container_of(mdev, struct mt7996_dev, mt76);
+
+ if (cmd & (MT7996_MCU_CMD_BCN_TEMPLATE | MT7996_MCU_CMD_L1_TRIGGER))
+ return;
+
+ spin_lock_bh(&dev->mt76.lock);
+ if (dev->recovery.hw_init_done && !dev->recovery.restart)
+ mt7996_mac_full_reset_queue(dev);
+ spin_unlock_bh(&dev->mt76.lock);
+}
+
static int
mt7996_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq)
@@ -230,12 +245,10 @@ mt7996_mcu_parse_response(struct mt76_dev *mdev, int cmd,
dev_err(mdev->dev, "Message %08x (seq %d) timeout\n",
cmd, seq);
- if (!test_and_set_bit(MT76_MCU_RESET, &dev->mphy.state)) {
- dev->recovery.restart = true;
- wake_up(&dev->mt76.mcu.wait);
- queue_work(dev->mt76.wq, &dev->reset_work);
- wake_up(&dev->reset_wait);
- }
+ spin_lock_bh(&dev->mt76.lock);
+ if (!test_and_set_bit(MT76_MCU_RESET, &dev->mphy.state))
+ mt7996_mac_full_reset_queue(dev);
+ spin_unlock_bh(&dev->mt76.lock);
return -ETIMEDOUT;
}
@@ -3444,7 +3457,8 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
out:
dev_kfree_skb(skb);
ret = mt76_mcu_skb_send_msg(&dev->mt76, rskb,
- MCU_WMWA_UNI_CMD(BSS_INFO_UPDATE), true);
+ MCU_WMWA_UNI_CMD(BSS_INFO_UPDATE) |
+ MT7996_MCU_CMD_BCN_TEMPLATE, true);
link->csa_bcn_uploaded = !ret && enabled && link_conf->csa_active;
return ret;
@@ -4044,6 +4058,7 @@ int mt7996_mcu_init(struct mt7996_dev *dev)
.headroom = sizeof(struct mt76_connac2_mcu_txd), /* reuse */
.mcu_skb_send_msg = mt7996_mcu_send_message,
.mcu_parse_response = mt7996_mcu_parse_response,
+ .mcu_cmd_lost = mt7996_mcu_cmd_lost,
};
dev->mt76.mcu_ops = &mt7996_mcu_ops;
@@ -5114,6 +5129,7 @@ int mt7996_mcu_set_ser(struct mt7996_dev *dev, u8 action, u8 val, u8 band)
.tag = cpu_to_le16(action),
.len = cpu_to_le16(sizeof(req) - 4),
};
+ int cmd = MCU_WM_UNI_CMD(SER);
switch (action) {
case UNI_CMD_SER_SET:
@@ -5122,13 +5138,14 @@ int mt7996_mcu_set_ser(struct mt7996_dev *dev, u8 action, u8 val, u8 band)
case UNI_CMD_SER_TRIGGER:
req.trigger.method = val;
req.trigger.band = band;
+ if (val == UNI_CMD_SER_SET_RECOVER_FROM_ETH)
+ cmd |= MT7996_MCU_CMD_L1_TRIGGER;
break;
default:
return -EINVAL;
}
- return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(SER),
- &req, sizeof(req), false);
+ return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), false);
}
int mt7996_mcu_set_txbf(struct mt7996_dev *dev, u8 action)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h
index 2fdf82394355..a97fbcce1d47 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h
@@ -30,6 +30,11 @@ struct mt7996_mcu_uni_event {
__le32 status; /* 0: success, others: fail */
} __packed;
+/* host flag: an L1 SER frees every template and the L1 work uploads it again */
+#define MT7996_MCU_CMD_BCN_TEMPLATE BIT(22)
+/* host flag: the pending reset that refuses an L1 trigger takes its place */
+#define MT7996_MCU_CMD_L1_TRIGGER BIT(23)
+
struct mt7996_mcu_thermal_ctrl {
u8 ctrl_id;
u8 band_idx;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
index a9d265c90234..f5bca533c3e1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
@@ -735,6 +735,7 @@ int mt7996_init_tx_queues(struct mt7996_phy *phy, int idx,
void mt7996_init_txpower(struct mt7996_phy *phy);
int mt7996_txbf_init(struct mt7996_dev *dev);
void mt7996_reset(struct mt7996_dev *dev);
+void mt7996_mac_full_reset_queue(struct mt7996_dev *dev);
int mt7996_run(struct mt7996_phy *phy);
int mt7996_mcu_init(struct mt7996_dev *dev);
int mt7996_mcu_init_firmware(struct mt7996_dev *dev);
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 09/20] wifi: mt76: mt7915: mark the MCU commands that only read
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (6 preceding siblings ...)
2026-11-24 8:42 ` [PATCH mt76-next 08/20] wifi: mt76: mt7996: reset after an MCU reset lost a state command Felix Fietkau
@ 2026-11-24 8:42 ` Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 10/20] wifi: mt76: mt7915: hold the device mutex in the rate control work Felix Fietkau
` (11 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:42 UTC (permalink / raw)
To: linux-wireless
The core retries a lost answer only for a command with the read flag.
Without the flag, the core takes the loss as an unknown firmware state.
Set the flag on the reads of the efuse, the MIB counters and the
temperature. Set it on the reads of the TX power table, the RX rate,
an RF register and the MU statistics. Set it on the WA queries and the
SER query as well.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7915/mcu.c | 40 +++++++++++++------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index e9a10606c6aa..ea79eb85d683 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -255,6 +255,9 @@ int mt7915_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3)
},
};
+ if (cmd == MCU_WA_PARAM_CMD(QUERY))
+ cmd |= MT76_MCU_CMD_READ;
+
return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), false);
}
@@ -2325,7 +2328,8 @@ int mt7915_mcu_muru_debug_get(struct mt7915_phy *phy)
.band_idx = phy->mt76->band_idx,
};
- ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL),
+ ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(MURU_CTRL) |
+ MT76_MCU_CMD_READ,
&req, sizeof(req), true, &skb);
if (ret)
return ret;
@@ -3015,7 +3019,8 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf)
int ret;
ret = mt76_mcu_send_and_get_msg(&dev->mt76,
- MCU_EXT_QUERY(EFUSE_ACCESS),
+ MCU_EXT_QUERY(EFUSE_ACCESS) |
+ MT76_MCU_CMD_READ,
&req, sizeof(req), true, &skb);
if (ret)
return ret;
@@ -3060,7 +3065,8 @@ int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num)
int ret;
ret = mt76_mcu_send_and_get_msg(&dev->mt76,
- MCU_EXT_QUERY(EFUSE_FREE_BLOCK),
+ MCU_EXT_QUERY(EFUSE_FREE_BLOCK) |
+ MT76_MCU_CMD_READ,
&req, sizeof(req), true, &skb);
if (ret)
return ret;
@@ -3316,7 +3322,8 @@ int mt7915_mcu_get_chan_mib_info(struct mt7915_phy *phy, bool chan_switch)
req[i].offs = cpu_to_le32(offs[i]);
}
- ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(GET_MIB_INFO),
+ ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(GET_MIB_INFO) |
+ MT76_MCU_CMD_READ,
req, len * sizeof(req[0]), true, &skb);
if (ret)
return ret;
@@ -3370,8 +3377,8 @@ int mt7915_mcu_get_temperature(struct mt7915_phy *phy)
.band_idx = phy->mt76->band_idx,
};
- return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_CTRL), &req,
- sizeof(req), true);
+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_CTRL) |
+ MT76_MCU_CMD_READ, &req, sizeof(req), true);
}
int mt7915_mcu_set_thermal_throttling(struct mt7915_phy *phy, u8 state)
@@ -3664,7 +3671,8 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len,
int ret, i;
ret = mt76_mcu_send_and_get_msg(&dev->mt76,
- MCU_EXT_CMD(TX_POWER_FEATURE_CTRL),
+ MCU_EXT_CMD(TX_POWER_FEATURE_CTRL) |
+ MT76_MCU_CMD_READ,
&req, sizeof(req), true, &skb);
if (ret)
return ret;
@@ -3756,9 +3764,13 @@ int mt7915_mcu_set_ser(struct mt7915_dev *dev, u8 action, u8 set, u8 band)
.set = set,
.band = band,
};
+ int cmd = MCU_EXT_CMD(SET_SER_TRIGGER);
- return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_SER_TRIGGER),
- &req, sizeof(req), false);
+ /* action 0 writes the SER statistics to the firmware log */
+ if (!action)
+ cmd |= MT76_MCU_CMD_READ;
+
+ return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), false);
}
int mt7915_mcu_set_txbf(struct mt7915_dev *dev, u8 action)
@@ -4019,7 +4031,8 @@ int mt7915_mcu_get_rx_rate(struct mt7915_phy *phy, struct ieee80211_vif *vif,
int ret;
bool cck = false;
- ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(PHY_STAT_INFO),
+ ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(PHY_STAT_INFO) |
+ MT76_MCU_CMD_READ,
&req, sizeof(req), true, &skb);
if (ret)
return ret;
@@ -4276,7 +4289,8 @@ int mt7915_mcu_wed_wa_tx_stats(struct mt7915_dev *dev, u16 wlan_idx)
len = sizeof(req);
}
- ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WA_PARAM_CMD(QUERY),
+ ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_WA_PARAM_CMD(QUERY) |
+ MT76_MCU_CMD_READ,
&req, len, true, &skb);
if (ret)
return ret;
@@ -4333,7 +4347,9 @@ int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RF_REG_ACCESS),
&req, sizeof(req), false);
- ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_QUERY(RF_REG_ACCESS),
+ ret = mt76_mcu_send_and_get_msg(&dev->mt76,
+ MCU_EXT_QUERY(RF_REG_ACCESS) |
+ MT76_MCU_CMD_READ,
&req, sizeof(req), true, &skb);
if (ret)
return ret;
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 10/20] wifi: mt76: mt7915: hold the device mutex in the rate control work
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (7 preceding siblings ...)
2026-11-24 8:42 ` [PATCH mt76-next 09/20] wifi: mt76: mt7915: mark the MCU commands that only read Felix Fietkau
@ 2026-11-24 8:42 ` Felix Fietkau
2026-11-24 8:56 ` Lorenzo Bianconi
2026-11-24 8:43 ` [PATCH mt76-next 11/20] wifi: mt76: mt7915: hold the device mutex in the station and regd updates Felix Fietkau
` (10 subsequent siblings)
19 siblings, 1 reply; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:42 UTC (permalink / raw)
To: linux-wireless
mt7915_mac_sta_rc_work() sends its rate control and SMPS updates
without dev->mt76.mutex. The L1 SER work holds the mutex while
MT76_MCU_RESET keeps commands from the firmware. The rate control work
can still run in that window, so its update does not reach the
firmware.
Hold the mutex across the updates, as mt7996_mac_sta_rc_work() does.
The work then waits for the end of the L1 SER.
Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index e9b1704d1289..110d5368a8ee 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -2008,6 +2008,8 @@ void mt7915_mac_sta_rc_work(struct work_struct *work)
u32 changed;
LIST_HEAD(list);
+ mutex_lock(&dev->mt76.mutex);
+
spin_lock_bh(&dev->mt76.sta_poll_lock);
list_splice_init(&dev->sta_rc_list, &list);
@@ -2033,6 +2035,8 @@ void mt7915_mac_sta_rc_work(struct work_struct *work)
}
spin_unlock_bh(&dev->mt76.sta_poll_lock);
+
+ mutex_unlock(&dev->mt76.mutex);
}
void mt7915_mac_work(struct work_struct *work)
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 11/20] wifi: mt76: mt7915: hold the device mutex in the station and regd updates
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (8 preceding siblings ...)
2026-11-24 8:42 ` [PATCH mt76-next 10/20] wifi: mt76: mt7915: hold the device mutex in the rate control work Felix Fietkau
@ 2026-11-24 8:43 ` Felix Fietkau
2026-11-24 8:58 ` Lorenzo Bianconi
2026-11-24 8:43 ` [PATCH mt76-next 12/20] wifi: mt76: mt7915: reset after an MCU reset lost a state command Felix Fietkau
` (9 subsequent siblings)
19 siblings, 1 reply; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:43 UTC (permalink / raw)
To: linux-wireless
The sta_set_4addr and sta_set_decap_offload ops and
mt7915_regd_notifier() send their MCU commands without dev->mt76.mutex.
The L1 SER work holds the mutex while MT76_MCU_RESET keeps commands from
the firmware. An update in that window is thus lost: the header
translation or the radar detector state.
Hold the mutex across the updates, as mt7996 does in its station ops.
mt7915_set_radar_background() already holds it for the background
chain. The callers then wait for the end of the L1 SER.
Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Fixes: e151d71e503d ("mt76: mt7915: add encap offload for 4-address mode stations")
Fixes: 90e3abf07c80 ("mt76: mt7915: add support for rx decapsulation offload")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7915/init.c | 4 ++++
drivers/net/wireless/mediatek/mt76/mt7915/main.c | 16 ++++++++++------
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
index 1bb2a938c354..fb92a0b2e4ab 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
@@ -383,6 +383,8 @@ mt7915_regd_notifier(struct wiphy *wiphy,
struct mt76_phy *mphy = hw->priv;
struct mt7915_phy *phy = mphy->priv;
+ mutex_lock(&dev->mt76.mutex);
+
memcpy(dev->mt76.alpha2, request->alpha2, sizeof(dev->mt76.alpha2));
dev->mt76.region = request->dfs_region;
@@ -393,6 +395,8 @@ mt7915_regd_notifier(struct wiphy *wiphy,
mphy->dfs_state = MT_DFS_STATE_UNKNOWN;
mt7915_dfs_init_radar_detector(phy);
+
+ mutex_unlock(&dev->mt76.mutex);
}
static void
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
index edbb921e63bc..47796e0fa506 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
@@ -1294,15 +1294,17 @@ static void mt7915_sta_set_4addr(struct ieee80211_hw *hw,
struct mt7915_dev *dev = mt7915_hw_dev(hw);
struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
+ mutex_lock(&dev->mt76.mutex);
+
if (enabled)
set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
else
clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
- if (!msta->wcid.sta)
- return;
+ if (msta->wcid.sta)
+ mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
- mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
+ mutex_unlock(&dev->mt76.mutex);
}
static void mt7915_sta_set_decap_offload(struct ieee80211_hw *hw,
@@ -1313,15 +1315,17 @@ static void mt7915_sta_set_decap_offload(struct ieee80211_hw *hw,
struct mt7915_dev *dev = mt7915_hw_dev(hw);
struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
+ mutex_lock(&dev->mt76.mutex);
+
if (enabled)
set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
else
clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
- if (!msta->wcid.sta)
- return;
+ if (msta->wcid.sta)
+ mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
- mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
+ mutex_unlock(&dev->mt76.mutex);
}
static int mt7915_sta_set_txpwr(struct ieee80211_hw *hw,
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 12/20] wifi: mt76: mt7915: reset after an MCU reset lost a state command
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (9 preceding siblings ...)
2026-11-24 8:43 ` [PATCH mt76-next 11/20] wifi: mt76: mt7915: hold the device mutex in the station and regd updates Felix Fietkau
@ 2026-11-24 8:43 ` Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 13/20] wifi: mt76: mt7996: clear the PS state of stations at a reset Felix Fietkau
` (8 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:43 UTC (permalink / raw)
To: linux-wireless
An L1 SER sets MT76_MCU_RESET, which ends each command wait and refuses
each new command. The firmware can have run a command that it took
just before the recovery. The state that a cut or refused command sets
is thus unknown or missing. mt7915_mcu_parse_response() starts a full
reset only for a timeout with the bit clear.
Start a full reset where the core reports such a command, unless one is
already queued. Leave out a beacon template, as the L1 work uploads
each template again, and an L1 trigger, as the pending reset that
refuses it takes its place.
Leave the L1 handshake for the full reset where a wait times out or a
reset is requested. Otherwise the L1 work goes on, clears the bit and
sends the templates before the full reset runs. Enable NAPI and the TX
worker again before the work returns, since mt7915_mac_restart()
disables them itself.
Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7915/mac.c | 94 +++++++++++++------
.../net/wireless/mediatek/mt76/mt7915/mcu.c | 31 ++++--
.../net/wireless/mediatek/mt76/mt7915/mcu.h | 5 +
.../wireless/mediatek/mt76/mt7915/mt7915.h | 1 +
4 files changed, 96 insertions(+), 35 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index 110d5368a8ee..cc3ef641d1c1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -1251,11 +1251,12 @@ mt7915_wait_reset_state(struct mt7915_dev *dev, u32 state)
bool ret;
ret = wait_event_timeout(dev->reset_wait,
- (READ_ONCE(dev->recovery.state) & state),
+ (READ_ONCE(dev->recovery.state) & state) ||
+ dev->recovery.restart,
MT7915_RESET_TIMEOUT);
WARN(!ret, "Timeout waiting for MCU reset state %x\n", state);
- return ret;
+ return ret && !dev->recovery.restart;
}
static void
@@ -1510,6 +1511,54 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)
ieee80211_restart_hw(ext_phy->hw);
}
+static void
+mt7915_mac_reset_napi_enable(struct mt7915_dev *dev)
+{
+ int i;
+
+ mt76_for_each_q_rx(&dev->mt76, i) {
+ napi_enable(&dev->mt76.napi[i]);
+ }
+
+ local_bh_disable();
+ mt76_for_each_q_rx(&dev->mt76, i) {
+ napi_schedule(&dev->mt76.napi[i]);
+ }
+ local_bh_enable();
+
+ tasklet_schedule(&dev->mt76.irq_tasklet);
+
+ mt76_worker_enable(&dev->mt76.tx_worker);
+
+ napi_enable(&dev->mt76.tx_napi);
+ local_bh_disable();
+ napi_schedule(&dev->mt76.tx_napi);
+ local_bh_enable();
+}
+
+static void
+mt7915_mac_reset_l1_abort(struct mt7915_dev *dev)
+{
+ mt7915_mac_reset_napi_enable(dev);
+ mutex_unlock(&dev->mt76.mutex);
+
+ spin_lock_bh(&dev->mt76.lock);
+ mt7915_mac_full_reset_queue(dev);
+ spin_unlock_bh(&dev->mt76.lock);
+}
+
+/* MT76_MCU_RESET keeps every command from the firmware until the reload */
+void mt7915_mac_full_reset_queue(struct mt7915_dev *dev)
+{
+ lockdep_assert_held(&dev->mt76.lock);
+
+ set_bit(MT76_MCU_RESET, &dev->mphy.state);
+ dev->recovery.restart = true;
+ wake_up(&dev->mt76.mcu.wait);
+ queue_work(dev->mt76.wq, &dev->reset_work);
+ wake_up(&dev->reset_wait);
+}
+
/* system error recovery */
void mt7915_mac_reset_work(struct work_struct *work)
{
@@ -1576,19 +1625,21 @@ void mt7915_mac_reset_work(struct work_struct *work)
mtk_wed_device_stop(&dev->mt76.mmio.wed);
mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_DMA_STOPPED);
+ if (!mt7915_wait_reset_state(dev, MT_MCU_CMD_RESET_DONE))
+ goto abort;
- if (mt7915_wait_reset_state(dev, MT_MCU_CMD_RESET_DONE)) {
- mt7915_dma_reset(dev, false);
+ mt7915_dma_reset(dev, false);
- mt76_connac2_tx_token_put(&dev->mt76);
- idr_init(&dev->mt76.token);
+ mt76_connac2_tx_token_put(&dev->mt76);
+ idr_init(&dev->mt76.token);
- mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_DMA_INIT);
- mt7915_wait_reset_state(dev, MT_MCU_CMD_RECOVERY_DONE);
- }
+ mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_DMA_INIT);
+ if (!mt7915_wait_reset_state(dev, MT_MCU_CMD_RECOVERY_DONE))
+ goto abort;
mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_RESET_DONE);
- mt7915_wait_reset_state(dev, MT_MCU_CMD_NORMAL_STATE);
+ if (!mt7915_wait_reset_state(dev, MT_MCU_CMD_NORMAL_STATE))
+ goto abort;
/* enable DMA Tx/Rx and interrupt */
mt7915_dma_start(dev, false, false);
@@ -1598,24 +1649,7 @@ void mt7915_mac_reset_work(struct work_struct *work)
if (phy2)
clear_bit(MT76_RESET, &phy2->mt76->state);
- mt76_for_each_q_rx(&dev->mt76, i) {
- napi_enable(&dev->mt76.napi[i]);
- }
-
- local_bh_disable();
- mt76_for_each_q_rx(&dev->mt76, i) {
- napi_schedule(&dev->mt76.napi[i]);
- }
- local_bh_enable();
-
- tasklet_schedule(&dev->mt76.irq_tasklet);
-
- mt76_worker_enable(&dev->mt76.tx_worker);
-
- napi_enable(&dev->mt76.tx_napi);
- local_bh_disable();
- napi_schedule(&dev->mt76.tx_napi);
- local_bh_enable();
+ mt7915_mac_reset_napi_enable(dev);
ieee80211_wake_queues(mt76_hw(dev));
if (ext_phy)
@@ -1631,6 +1665,10 @@ void mt7915_mac_reset_work(struct work_struct *work)
ieee80211_queue_delayed_work(ext_phy->hw,
&phy2->mt76->mac_work,
MT7915_WATCHDOG_TIME);
+ return;
+
+abort:
+ mt7915_mac_reset_l1_abort(dev);
}
/* firmware coredump */
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index ea79eb85d683..981135c23723 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -153,6 +153,21 @@ mt7915_mcu_set_sta_ht_mcs(struct ieee80211_sta *sta, u8 *ht_mcs,
ht_mcs[nss] = sta->deflink.ht_cap.mcs.rx_mask[nss] & mask[nss];
}
+/* only the firmware load gives a known state again */
+static void
+mt7915_mcu_cmd_lost(struct mt76_dev *mdev, int cmd)
+{
+ struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76);
+
+ if (cmd & (MT7915_MCU_CMD_BCN_TEMPLATE | MT7915_MCU_CMD_L1_TRIGGER))
+ return;
+
+ spin_lock_bh(&dev->mt76.lock);
+ if (dev->recovery.hw_init_done && !dev->recovery.restart)
+ mt7915_mac_full_reset_queue(dev);
+ spin_unlock_bh(&dev->mt76.lock);
+}
+
static int
mt7915_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq)
@@ -165,12 +180,10 @@ mt7915_mcu_parse_response(struct mt76_dev *mdev, int cmd,
dev_err(mdev->dev, "Message %08x (seq %d) timeout\n",
cmd, seq);
- if (!test_and_set_bit(MT76_MCU_RESET, &dev->mphy.state)) {
- dev->recovery.restart = true;
- wake_up(&dev->mt76.mcu.wait);
- queue_work(dev->mt76.wq, &dev->reset_work);
- wake_up(&dev->reset_wait);
- }
+ spin_lock_bh(&dev->mt76.lock);
+ if (!test_and_set_bit(MT76_MCU_RESET, &dev->mphy.state))
+ mt7915_mac_full_reset_queue(dev);
+ spin_unlock_bh(&dev->mt76.lock);
return -ETIMEDOUT;
}
@@ -2131,7 +2144,8 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
out:
return mt76_mcu_skb_send_msg(&phy->dev->mt76, rskb,
- MCU_EXT_CMD(BSS_INFO_UPDATE), true);
+ MCU_EXT_CMD(BSS_INFO_UPDATE) |
+ MT7915_MCU_CMD_BCN_TEMPLATE, true);
}
static int mt7915_driver_own(struct mt7915_dev *dev, u8 band)
@@ -2559,6 +2573,7 @@ int mt7915_mcu_init(struct mt7915_dev *dev)
.mcu_skb_prepare_msg = mt76_connac2_mcu_fill_message,
.mcu_skb_send_msg = mt7915_mcu_send_message,
.mcu_parse_response = mt7915_mcu_parse_response,
+ .mcu_cmd_lost = mt7915_mcu_cmd_lost,
};
dev->mt76.mcu_ops = &mt7915_mcu_ops;
@@ -3769,6 +3784,8 @@ int mt7915_mcu_set_ser(struct mt7915_dev *dev, u8 action, u8 set, u8 band)
/* action 0 writes the SER statistics to the firmware log */
if (!action)
cmd |= MT76_MCU_CMD_READ;
+ else if (action == SER_RECOVER && set == SER_SET_RECOVER_L1)
+ cmd |= MT7915_MCU_CMD_L1_TRIGGER;
return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), false);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
index 7dbe43200fb4..456c452e07c1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
@@ -6,6 +6,11 @@
#include "../mt76_connac_mcu.h"
+/* host flag: an L1 SER frees every template and the L1 work uploads it again */
+#define MT7915_MCU_CMD_BCN_TEMPLATE BIT(21)
+/* host flag: the pending reset that refuses an L1 trigger takes its place */
+#define MT7915_MCU_CMD_L1_TRIGGER BIT(22)
+
enum {
MCU_ATE_SET_TRX = 0x1,
MCU_ATE_SET_FREQ_OFFSET = 0xa,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
index afb856febe3a..cab0ed54ca84 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
@@ -472,6 +472,7 @@ int mt7915_dma_start(struct mt7915_dev *dev, bool reset, bool wed_reset);
int mt7915_txbf_init(struct mt7915_dev *dev);
void mt7915_init_txpower(struct mt7915_phy *phy);
void mt7915_reset(struct mt7915_dev *dev);
+void mt7915_mac_full_reset_queue(struct mt7915_dev *dev);
int mt7915_run(struct ieee80211_hw *hw);
int mt7915_mcu_init(struct mt7915_dev *dev);
int mt7915_mcu_init_firmware(struct mt7915_dev *dev);
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 13/20] wifi: mt76: mt7996: clear the PS state of stations at a reset
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (10 preceding siblings ...)
2026-11-24 8:43 ` [PATCH mt76-next 12/20] wifi: mt76: mt7915: reset after an MCU reset lost a state command Felix Fietkau
@ 2026-11-24 8:43 ` Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 14/20] wifi: mt76: mt7996: apply the PS sync bitmap to MLD stations alone Felix Fietkau
` (7 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:43 UTC (permalink / raw)
To: linux-wireless
MT_WCID_FLAG_PS survives both recoveries: the full reset replay reuses
&msta->deflink in mt7996_mac_sta_init_link() with its flags, and the L1
branch of mt7996_mac_reset_work() writes no wcid flag. The firmware
holds no station in power save after a firmware load. An L1 recovery
clears the PS state of every record, but reports that for the link
records of an MLD alone. Any other station that is awake gets no PS
leave, and mt76 sends it one frame per pass until its next doze and
wake.
Clear the flag when the driver sets up a station link. At the end of an
L1 recovery, clear it for every station before RX takes the first
firmware event. The flag then matches the firmware, which holds no
station in power save after either reset. The next PS enter event of a
station sets the flag again.
Fixes: 2d16caccd278 ("wifi: mt76: mt7996: handle UNI PS sync events")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7996/mac.c | 19 +++++++++++++++++++
.../net/wireless/mediatek/mt76/mt7996/main.c | 1 +
2 files changed, 20 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index e507bfd34372..1b133d74c175 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -2506,6 +2506,24 @@ mt7996_mac_reset_sta_iter(void *data, struct ieee80211_sta *sta)
mt7996_mac_sta_remove_link(dev, sta, i, true);
}
+static void
+mt7996_mac_reset_sta_ps(struct mt7996_dev *dev)
+{
+ int i;
+
+ rcu_read_lock();
+ for (i = 0; i < ARRAY_SIZE(dev->mt76.wcid); i++) {
+ struct mt76_wcid *wcid = mt76_wcid_ptr(dev, i);
+
+ if (!wcid_to_sta(wcid) ||
+ !test_bit(MT_WCID_FLAG_PS, &wcid->flags))
+ continue;
+
+ mt76_sta_ps_transition(&dev->mt76, wcid, false);
+ }
+ rcu_read_unlock();
+}
+
static void
mt7996_mac_reset_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
{
@@ -2718,6 +2736,7 @@ void mt7996_mac_reset_work(struct work_struct *work)
mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_RESET_DONE);
mt7996_wait_reset_state(dev, MT_MCU_CMD_NORMAL_STATE);
+ mt7996_mac_reset_sta_ps(dev);
/* enable DMA Rx/Tx and interrupt */
mt7996_dma_start(dev, false, false);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index 65b5012a0017..e129cd2cd73e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -1385,6 +1385,7 @@ mt7996_mac_sta_init_link(struct mt7996_dev *dev,
msta_link->wcid.link_id = link_id;
msta_link->wcid.link_valid = !!sta->valid_links;
msta_link->wcid.def_wcid = &msta->deflink.wcid;
+ clear_bit(MT_WCID_FLAG_PS, &msta_link->wcid.flags);
if (link_sta->sta->tdls)
set_bit(MT_WCID_FLAG_TDLS_PEER, &msta_link->wcid.flags);
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 14/20] wifi: mt76: mt7996: apply the PS sync bitmap to MLD stations alone
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (11 preceding siblings ...)
2026-11-24 8:43 ` [PATCH mt76-next 13/20] wifi: mt76: mt7996: clear the PS state of stations at a reset Felix Fietkau
@ 2026-11-24 8:43 ` Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 15/20] wifi: mt76: mt7996: keep the TWT state out of the PS flag Felix Fietkau
` (6 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:43 UTC (permalink / raw)
To: linux-wireless
The firmware sends the UNI_PS_MULTI_CLIENT_INFO_BITMAP event after a PS
change of an MLD link. It sets a bit only for a record in an MLD group,
and leaves the bit of every other wcid at 0. mt7996_mcu_rx_ps_sync()
takes each clear bit as a PS leave, so every bitmap event clears
MT_WCID_FLAG_PS of each dozing station that is not an MLD. mt76 then
sends full bursts to a station that the firmware holds in power save.
Apply a bit only to the link wcids of an MLD station. The check uses
sta->mlo, not wcid->link_valid. hostapd adds every station of an AP MLD
on a link, so a station that is not an MLD also has link_valid set.
The bitmap also no longer clears the flag that a UNI_PS_CLIENT_INFO
event sets for the TWT agreement of a station. A TWT station that is
not an MLD thus keeps the flag until the firmware reports a PS leave or
the end of the agreement. It gets one frame per pass until then, with
no frame lost. An AP with no MLD peer already behaves this way.
Fixes: 2d16caccd278 ("wifi: mt76: mt7996: handle UNI PS sync events")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index fc56ce723de5..599bc6735c30 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -983,9 +983,19 @@ mt7996_mcu_rx_ps_sync(struct mt7996_dev *dev, struct sk_buff *skb)
int bitmap_len = tag_len - sizeof(*tlv);
int i;
- for (i = 0; i < bitmap_len * 8; i++)
- mt7996_mcu_ps_transition(dev, i,
- !!(bitmap[i / 8] & BIT(i % 8)));
+ for (i = 0; i < bitmap_len * 8; i++) {
+ struct ieee80211_sta *sta;
+ struct mt76_wcid *wcid;
+ bool ps;
+
+ wcid = mt76_wcid_ptr(dev, i);
+ sta = wcid_to_sta(wcid);
+ if (!sta || !sta->mlo)
+ continue;
+
+ ps = bitmap[i / 8] & BIT(i % 8);
+ mt76_sta_ps_transition(&dev->mt76, wcid, ps);
+ }
break;
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 15/20] wifi: mt76: mt7996: keep the TWT state out of the PS flag
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (12 preceding siblings ...)
2026-11-24 8:43 ` [PATCH mt76-next 14/20] wifi: mt76: mt7996: apply the PS sync bitmap to MLD stations alone Felix Fietkau
@ 2026-11-24 8:43 ` Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 16/20] wifi: mt76: mt7996: read the TSF twice against the firmware's latch Felix Fietkau
` (5 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:43 UTC (permalink / raw)
To: linux-wireless
The UNI_PS_CLIENT_INFO entry of the PS sync event is the TWT agreement
state of a station, not its power save state. The firmware sends it at
the add of the first agreement of a station and at the delete of the
last one. It sends no event per service period.
mt7996_mcu_rx_ps_sync() writes it into MT_WCID_FLAG_PS, so the PS
throttle holds a TWT station to one frame per AC for the whole
agreement.
Do not write the entry into the flag. Only a station that is not an MLD
gets an agreement. The firmware reports no PS change of such a station
in TWT operation. It gates the air time of the station between service
periods itself.
Clear the flag at the first agreement instead. A flag set before it
would otherwise stay set for the whole agreement. Also ignore a PS enter
of a station with an agreement. The firmware can deliver an enter that
it stored before the agreement after the clear. After the last
agreement, the flag stays clear until the firmware reports the next PS
change. The host does not know the PS state of the station at that
point.
Set the flow in the mask of the station before the add command. The
firmware gates the air time from the add on, and an enter can arrive
before the command returns. If the command fails, remove the flow from
the mask again.
The PS sync event reads the flow mask of a station without the mutex
that its writers hold. Mark the accesses.
Fixes: 2d16caccd278 ("wifi: mt76: mt7996: handle UNI PS sync events")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 11 ++++++++---
drivers/net/wireless/mediatek/mt76/mt7996/main.c | 2 +-
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 9 +++++++--
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index 1b133d74c175..6d3061c64e30 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -2604,7 +2604,8 @@ mt7996_mac_full_reset(struct mt7996_dev *dev)
msta_link = container_of(flow, struct mt7996_sta_link,
twt.flow[flow->id]);
- msta_link->twt.flowid_mask &= ~BIT(flow->id);
+ WRITE_ONCE(msta_link->twt.flowid_mask,
+ msta_link->twt.flowid_mask & ~BIT(flow->id));
list_del_init(&flow->list);
}
dev->twt.table_mask = 0;
@@ -3413,15 +3414,18 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
}
flow->tsf = le64_to_cpu(twt_agrt->twt);
+ WRITE_ONCE(msta_link->twt.flowid_mask,
+ msta_link->twt.flowid_mask | BIT(flowid));
if (mt7996_mcu_twt_agrt_update(dev, &msta->vif->deflink, flow,
MCU_TWT_AGRT_ADD)) {
+ WRITE_ONCE(msta_link->twt.flowid_mask,
+ msta_link->twt.flowid_mask & ~BIT(flowid));
list_del(&flow->list);
goto unlock;
}
setup_cmd = TWT_SETUP_CMD_ACCEPT;
dev->twt.table_mask |= BIT(table_id);
- msta_link->twt.flowid_mask |= BIT(flowid);
dev->twt.n_agrt++;
unlock:
@@ -3453,7 +3457,8 @@ void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev,
return;
list_del_init(&flow->list);
- msta_link->twt.flowid_mask &= ~BIT(flowid);
+ WRITE_ONCE(msta_link->twt.flowid_mask,
+ msta_link->twt.flowid_mask & ~BIT(flowid));
dev->twt.table_mask &= ~BIT(flow->table_id);
dev->twt.n_agrt--;
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index e129cd2cd73e..3486781609e3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -2025,7 +2025,7 @@ mt7996_mac_sta_remove(struct mt7996_dev *dev, struct ieee80211_vif *vif,
if (msta_link->twt.flowid_mask & BIT(i))
list_del_init(&msta_link->twt.flow[i].list);
}
- msta_link->twt.flowid_mask = 0;
+ WRITE_ONCE(msta_link->twt.flowid_mask, 0);
for (i = 0; i < ARRAY_SIZE(msta->link); i++)
mt7996_mac_sta_remove_link(dev, sta, i, true);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index 599bc6735c30..91129c1f5a5e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -915,12 +915,17 @@ mt7996_mcu_wed_rro_event(struct mt7996_dev *dev, struct sk_buff *skb)
static void
mt7996_mcu_ps_transition(struct mt7996_dev *dev, u16 wcid_idx, bool ps)
{
+ struct mt7996_sta_link *msta_link;
struct mt76_wcid *wcid;
wcid = mt76_wcid_ptr(dev, wcid_idx);
if (!wcid || !wcid_to_sta(wcid))
return;
+ msta_link = container_of(wcid, struct mt7996_sta_link, wcid);
+ if (ps && READ_ONCE(msta_link->twt.flowid_mask))
+ return;
+
mt76_sta_ps_transition(&dev->mt76, wcid, ps);
}
@@ -951,12 +956,12 @@ mt7996_mcu_rx_ps_sync(struct mt7996_dev *dev, struct sk_buff *skb)
case UNI_PS_CLIENT_INFO: {
struct mt7996_mcu_ps_client_info *info = (void *)tlv;
- if (tag_len < sizeof(*info))
+ if (tag_len < sizeof(*info) || !info->ps_bit)
break;
mt7996_mcu_ps_transition(dev,
le16_to_cpu(info->wlan_idx),
- info->ps_bit);
+ false);
break;
}
case UNI_PS_MULTI_CLIENT_INFO: {
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 16/20] wifi: mt76: mt7996: read the TSF twice against the firmware's latch
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (13 preceding siblings ...)
2026-11-24 8:43 ` [PATCH mt76-next 15/20] wifi: mt76: mt7996: keep the TWT state out of the PS flag Felix Fietkau
@ 2026-11-24 8:43 ` Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 17/20] wifi: mt76: mt7996: check a TSF write " Felix Fietkau
` (4 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:43 UTC (permalink / raw)
To: linux-wireless
__mt7996_get_tsf() latches the timer into the UTTR0/UTTR1 register pair
of the band and reads the pair. The firmware reads the TSF through the
same pair, with no lock. It does so in its pre-TBTT work, for Critical
Update, TTLM and TWT, and for a few commands. A firmware latch between
the latch and the reads of the host gives the host the value of the
firmware. That value can belong to another timer of the band, or be off
by 2^32 us at a low word wrap. Reachable via mt7996_get_tsf(), the TWT
setup and the TTLM and AP Removal Timer code.
Latch and read twice, and take the second value only if it is at most
about 1 ms later. Retry a pair that does not agree a few times, then
warn once and return the last value. This lowers the rate of the race
and does not remove it, since two reads with the same value of the
firmware still agree. The firmware holds no lock or semaphore for the
register pair, so the host cannot exclude it. The GET_TSF command of
the firmware queues behind a deferred beacon template, which breaks the
pairing of the TSF with ktime_get_boottime_ns() that the TTLM and AP
Removal Timer code needs.
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7996/main.c | 39 ++++++++++++++-----
.../wireless/mediatek/mt76/mt7996/mt7996.h | 2 +
2 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index 3486781609e3..b778728bcecc 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -2350,15 +2350,29 @@ mt7996_get_stats(struct ieee80211_hw *hw,
return 0;
}
-u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif_link *link)
+static u64 mt7996_tsf_latch(struct mt7996_dev *dev, u8 band, u16 n)
{
- struct mt7996_phy *phy = mt7996_vif_link_phy(link);
- struct mt7996_dev *dev = mt7996_hw_dev(hw);
union {
u64 t64;
u32 t32[2];
} tsf;
+
+ mt76_rmw(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE,
+ MT_LPON_TCR_SW_READ);
+ tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0(band));
+ tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1(band));
+
+ return tsf.t64;
+}
+
+u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif_link *link)
+{
+ struct mt7996_phy *phy = mt7996_vif_link_phy(link);
+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
+ u64 first = 0, tsf = 0;
+ u8 band;
u16 n;
+ int i;
if (!phy)
return 0;
@@ -2367,13 +2381,20 @@ u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif_link *link)
n = link->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
: link->mt76.omac_idx;
- /* TSF software read */
- mt76_rmw(dev, MT_LPON_TCR(phy->mt76->band_idx, n), MT_LPON_TCR_SW_MODE,
- MT_LPON_TCR_SW_READ);
- tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0(phy->mt76->band_idx));
- tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1(phy->mt76->band_idx));
+ band = phy->mt76->band_idx;
- return tsf.t64;
+ for (i = 0; i < MT7996_TSF_READ_TRIES; i++) {
+ first = mt7996_tsf_latch(dev, band, n);
+ tsf = mt7996_tsf_latch(dev, band, n);
+ if (tsf - first <= MT7996_TSF_READ_SPAN_US)
+ return tsf;
+ }
+
+ dev_warn_once(dev->mt76.dev,
+ "TSF reads of band %u do not agree: %llu, %llu\n",
+ band, first, tsf);
+
+ return tsf;
}
static u64
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
index f5bca533c3e1..65a0ef6b1161 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
@@ -21,6 +21,8 @@
#define MT7996_WATCHDOG_TIME (HZ / 10)
#define MT7996_RESET_TIMEOUT (30 * HZ)
+#define MT7996_TSF_READ_TRIES 3
+#define MT7996_TSF_READ_SPAN_US 1000
#define MT7996_TX_RING_SIZE 2048
#define MT7996_TX_MCU_RING_SIZE 256
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 17/20] wifi: mt76: mt7996: check a TSF write against the firmware's latch
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (14 preceding siblings ...)
2026-11-24 8:43 ` [PATCH mt76-next 16/20] wifi: mt76: mt7996: read the TSF twice against the firmware's latch Felix Fietkau
@ 2026-11-24 8:43 ` Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 18/20] wifi: mt76: mt7915: keep the TWT state out of the PS flag Felix Fietkau
` (3 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:43 UTC (permalink / raw)
To: linux-wireless
mt7996_set_tsf() and mt7996_offset_tsf() write the new value or the
offset to the UTTR0/UTTR1 pair of the band. They then write the write
or adjust mode to the TCR of the timer. The firmware latches its own TSF
reads into the same register pair, with no lock. A firmware read
between the UTTR writes and the mode write replaces the value of the
host. The timer then loads the latched TSF, or adds a whole TSF as the
offset. Reachable via the debugfs tsf file of mac80211 and, for the
offset, the mesh TSF sync.
Write mode 0 after the write or adjust mode, as the TSF write of the
firmware does. The firmware updates other fields of the TCR by
read-modify-write. If the hardware reads the mode back, such a write
would otherwise start the load or the add again. After a write, read
the TSF back. If it is not within about 1 ms after the written value,
write once more. This lowers the rate of the race and does not remove
it.
Do not repeat an adjust, since a check that races itself would add the
offset a second time. The race thus stays for mt7996_offset_tsf(). No
host write order prevents it, and the firmware holds no lock or
semaphore for the register pair.
Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7996/main.c | 42 +++++++++++--------
.../wireless/mediatek/mt76/mt7996/mt7996.h | 1 +
2 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index b778728bcecc..c220376cded6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -2411,6 +2411,20 @@ mt7996_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
return ret;
}
+static void
+mt7996_tsf_load(struct mt7996_dev *dev, u8 band, u16 n, u64 val, u32 mode)
+{
+ union {
+ u64 t64;
+ u32 t32[2];
+ } tsf = { .t64 = val, };
+
+ mt76_wr(dev, MT_LPON_UTTR0(band), tsf.t32[0]);
+ mt76_wr(dev, MT_LPON_UTTR1(band), tsf.t32[1]);
+ mt76_rmw(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE, mode);
+ mt76_clear(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE);
+}
+
static void
mt7996_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
u64 timestamp)
@@ -2419,11 +2433,8 @@ mt7996_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct mt7996_dev *dev = mt7996_hw_dev(hw);
struct mt7996_vif_link *link;
struct mt7996_phy *phy;
- union {
- u64 t64;
- u32 t32[2];
- } tsf = { .t64 = timestamp, };
u16 n;
+ int i;
mutex_lock(&dev->mt76.mutex);
@@ -2437,11 +2448,13 @@ mt7996_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
if (!phy)
goto unlock;
- mt76_wr(dev, MT_LPON_UTTR0(phy->mt76->band_idx), tsf.t32[0]);
- mt76_wr(dev, MT_LPON_UTTR1(phy->mt76->band_idx), tsf.t32[1]);
- /* TSF software overwrite */
- mt76_rmw(dev, MT_LPON_TCR(phy->mt76->band_idx, n), MT_LPON_TCR_SW_MODE,
- MT_LPON_TCR_SW_WRITE);
+ for (i = 0; i < MT7996_TSF_WRITE_TRIES; i++) {
+ mt7996_tsf_load(dev, phy->mt76->band_idx, n, timestamp,
+ MT_LPON_TCR_SW_WRITE);
+ if (__mt7996_get_tsf(hw, link) - timestamp <=
+ MT7996_TSF_READ_SPAN_US)
+ break;
+ }
unlock:
mutex_unlock(&dev->mt76.mutex);
@@ -2455,10 +2468,6 @@ mt7996_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct mt7996_dev *dev = mt7996_hw_dev(hw);
struct mt7996_vif_link *link;
struct mt7996_phy *phy;
- union {
- u64 t64;
- u32 t32[2];
- } tsf = { .t64 = timestamp, };
u16 n;
mutex_lock(&dev->mt76.mutex);
@@ -2473,11 +2482,8 @@ mt7996_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
n = link->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
: link->mt76.omac_idx;
- mt76_wr(dev, MT_LPON_UTTR0(phy->mt76->band_idx), tsf.t32[0]);
- mt76_wr(dev, MT_LPON_UTTR1(phy->mt76->band_idx), tsf.t32[1]);
- /* TSF software adjust*/
- mt76_rmw(dev, MT_LPON_TCR(phy->mt76->band_idx, n), MT_LPON_TCR_SW_MODE,
- MT_LPON_TCR_SW_ADJUST);
+ mt7996_tsf_load(dev, phy->mt76->band_idx, n, timestamp,
+ MT_LPON_TCR_SW_ADJUST);
unlock:
mutex_unlock(&dev->mt76.mutex);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
index 65a0ef6b1161..e6bf1151447f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
@@ -23,6 +23,7 @@
#define MT7996_RESET_TIMEOUT (30 * HZ)
#define MT7996_TSF_READ_TRIES 3
#define MT7996_TSF_READ_SPAN_US 1000
+#define MT7996_TSF_WRITE_TRIES 2
#define MT7996_TX_RING_SIZE 2048
#define MT7996_TX_MCU_RING_SIZE 256
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 18/20] wifi: mt76: mt7915: keep the TWT state out of the PS flag
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (15 preceding siblings ...)
2026-11-24 8:43 ` [PATCH mt76-next 17/20] wifi: mt76: mt7996: check a TSF write " Felix Fietkau
@ 2026-11-24 8:43 ` Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 19/20] wifi: mt76: mt7915: clear the PS flag of a station at a reset Felix Fietkau
` (2 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:43 UTC (permalink / raw)
To: linux-wireless
The firmware also sends the PS sync event from its TWT agreement code.
It sends state 1 when an agreement of a station starts, and state 0
when its last agreement ends. mt7915_mcu_rx_ps_sync() writes that state
into MT_WCID_FLAG_PS.
The host thus holds the TX of a TWT station to the PS limit. That lasts
until the agreement ends or a PS leave clears the flag. The end of the
agreement also clears the flag of a station in power save.
The PS limit is the wrong limit for a station that is not in power
save. The WA firmware of mt7986 and mt7981 applies a frame limit of its
own to the station.
Tell the TWT events from the PS events by their path value. Do not
write the TWT state into the flag.
Clear the flag when an agreement starts. The firmware reports no PS
enter of a TWT station, so a flag set before the agreement could stay
set. This matches what mt7996 does for its TWT state.
Fixes: dc930cf883c8 ("wifi: mt76: mt7915: handle MCU PS sync events")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 10 +++++++++-
drivers/net/wireless/mediatek/mt76/mt7915/mcu.h | 11 ++++++++---
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 981135c23723..59042d043481 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -430,7 +430,7 @@ mt7915_mcu_rx_ps_sync(struct mt7915_dev *dev, struct sk_buff *skb)
struct mt7915_mcu_ps_notify_v2 *p2 = (void *)skb->data;
struct mt7915_mcu_ps_notify *p = (void *)skb->data;
struct mt76_wcid *wcid;
- u16 wcid_idx;
+ u16 wcid_idx, path;
bool v2, ps;
/* the mt7986 and mt7981 firmware send the longer v2 layout */
@@ -443,15 +443,23 @@ mt7915_mcu_rx_ps_sync(struct mt7915_dev *dev, struct sk_buff *skb)
wcid_idx = le16_to_cpu(p2->wtbl_lower) |
(le16_to_cpu(p2->wtbl_higher) << 8);
ps = p2->ps_bit;
+ path = le16_to_cpu(p2->path);
} else {
wcid_idx = p->wtbl_lower | (p->wtbl_higher << 8);
ps = p->ps_bit;
+ path = p->path;
}
wcid = mt76_wcid_ptr(dev, wcid_idx);
if (!wcid || !wcid_to_sta(wcid))
return;
+ if (path == MT7915_PS_SYNC_TWT || path == MT7915_PS_SYNC_TWT_MANY) {
+ if (ps)
+ mt76_sta_ps_transition(&dev->mt76, wcid, false);
+ return;
+ }
+
mt76_sta_ps_transition(&dev->mt76, wcid, ps);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
index 456c452e07c1..175136dfafff 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
@@ -65,7 +65,7 @@ struct mt7915_mcu_ps_notify {
u8 wtbl_lower;
u8 ps_bit;
u8 wtbl_higher;
- u8 rsv;
+ u8 path;
} __packed;
struct mt7915_mcu_ps_notify_v2 {
@@ -73,11 +73,16 @@ struct mt7915_mcu_ps_notify_v2 {
__le16 wtbl_lower;
__le16 wtbl_higher;
- __le16 rsv;
+ __le16 path;
u8 ps_bit;
- u8 rsv2;
+ u8 rsv;
} __packed;
+enum {
+ MT7915_PS_SYNC_TWT_MANY = 0x08,
+ MT7915_PS_SYNC_TWT = 0x80,
+};
+
struct mt7915_mcu_rdd_report {
struct mt76_connac2_mcu_rxd_hdr rxd;
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 19/20] wifi: mt76: mt7915: clear the PS flag of a station at a reset
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (16 preceding siblings ...)
2026-11-24 8:43 ` [PATCH mt76-next 18/20] wifi: mt76: mt7915: keep the TWT state out of the PS flag Felix Fietkau
@ 2026-11-24 8:43 ` Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 20/20] wifi: mt76: mt7996: set the default link again when a link is reused Felix Fietkau
2026-11-24 8:53 ` [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Lorenzo Bianconi
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:43 UTC (permalink / raw)
To: linux-wireless
MT_WCID_FLAG_PS survives a full reset. The replay of a station keeps
wcid->flags. The reloaded firmware holds no PS state and reports no
leave when the station wakes.
The station then gets one frame per AC per TX status until its next
enter and leave. The L1 branch of the reset work writes no flag either.
Clear the flag when a station is added, like mt7996_mac_sta_init_link()
does. Also clear it for every station at the end of an L1 recovery,
like mt7996_mac_reset_sta_ps(). A station that still sleeps gets a new
enter from the firmware.
Fixes: dc930cf883c8 ("wifi: mt76: mt7915: handle MCU PS sync events")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7915/mac.c | 20 +++++++++++++++++++
.../net/wireless/mediatek/mt76/mt7915/main.c | 1 +
2 files changed, 21 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index cc3ef641d1c1..84f75526da58 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -1511,6 +1511,24 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)
ieee80211_restart_hw(ext_phy->hw);
}
+static void
+mt7915_mac_reset_sta_ps(struct mt7915_dev *dev)
+{
+ int i;
+
+ rcu_read_lock();
+ for (i = 0; i < ARRAY_SIZE(dev->mt76.wcid); i++) {
+ struct mt76_wcid *wcid = mt76_wcid_ptr(dev, i);
+
+ if (!wcid_to_sta(wcid) ||
+ !test_bit(MT_WCID_FLAG_PS, &wcid->flags))
+ continue;
+
+ mt76_sta_ps_transition(&dev->mt76, wcid, false);
+ }
+ rcu_read_unlock();
+}
+
static void
mt7915_mac_reset_napi_enable(struct mt7915_dev *dev)
{
@@ -1641,6 +1659,8 @@ void mt7915_mac_reset_work(struct work_struct *work)
if (!mt7915_wait_reset_state(dev, MT_MCU_CMD_NORMAL_STATE))
goto abort;
+ mt7915_mac_reset_sta_ps(dev);
+
/* enable DMA Tx/Rx and interrupt */
mt7915_dma_start(dev, false, false);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
index 47796e0fa506..50e67a209693 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
@@ -759,6 +759,7 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
msta->wcid.idx = idx;
msta->wcid.phy_idx = ext_phy;
msta->jiffies = jiffies;
+ clear_bit(MT_WCID_FLAG_PS, &msta->wcid.flags);
if (sta->tdls)
set_bit(MT_WCID_FLAG_TDLS_PEER, &msta->wcid.flags);
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH mt76-next 20/20] wifi: mt76: mt7996: set the default link again when a link is reused
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (17 preceding siblings ...)
2026-11-24 8:43 ` [PATCH mt76-next 19/20] wifi: mt76: mt7915: clear the PS flag of a station at a reset Felix Fietkau
@ 2026-11-24 8:43 ` Felix Fietkau
2026-11-24 8:53 ` [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Lorenzo Bianconi
19 siblings, 0 replies; 25+ messages in thread
From: Felix Fietkau @ 2026-11-24 8:43 UTC (permalink / raw)
To: linux-wireless
Since commit 08813703ac41 ("wifi: mt76: mt7996: Destroy vif active links
in mt7996_remove_interface()"), a removed vif link stays valid. Its
removal still clears mvif->mt76.deflink_id if it is the default link.
A later add on the same band reuses the link and leaves deflink_id unset
until the interface goes away. A mesh point thus loses its TSF
adjustment after it leaves and joins the mesh, since mt7996_offset_tsf()
finds no link.
Make a reused link the default link if the interface has none. Give its
wcid to the TX queue as well, as the first add of a link does.
Fixes: 08813703ac41 ("wifi: mt76: mt7996: Destroy vif active links in mt7996_remove_interface()")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7996/main.c | 40 ++++++++++++-------
1 file changed, 25 insertions(+), 15 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index c220376cded6..ac4f8b89bd90 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -356,6 +356,20 @@ static void mt7996_vif_link_free(struct mt7996_vif_link *link,
kfree_rcu(mlink, rcu_head);
}
+static void mt7996_vif_deflink_init(struct ieee80211_vif *vif,
+ struct mt7996_vif_link *link)
+{
+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
+ struct mt76_txq *mtxq;
+
+ if (!vif->txq || mvif->mt76.deflink_id != IEEE80211_LINK_UNSPECIFIED)
+ return;
+
+ mtxq = (struct mt76_txq *)vif->txq->drv_priv;
+ mvif->mt76.deflink_id = link->msta_link.wcid.link_id;
+ mtxq->wcid = link->msta_link.wcid.idx;
+}
+
static int mt7996_vif_link_reuse(struct mt7996_phy *phy,
struct ieee80211_vif *vif,
struct ieee80211_bss_conf *link_conf,
@@ -369,10 +383,16 @@ static int mt7996_vif_link_reuse(struct mt7996_phy *phy,
return ret;
if (vif->type == NL80211_IFTYPE_AP && ieee80211_vif_is_mld(vif))
- return mt7996_mcu_mld_link_oper(phy->dev, link_conf, link, true);
+ ret = mt7996_mcu_mld_link_oper(phy->dev, link_conf, link, true);
+ else
+ ret = mt7996_mcu_add_bss_info(phy, vif, link_conf, mlink,
+ &link->msta_link, true);
+ if (ret)
+ return ret;
- return mt7996_mcu_add_bss_info(phy, vif, link_conf, mlink,
- &link->msta_link, true);
+ mt7996_vif_deflink_init(vif, link);
+
+ return 0;
}
int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
@@ -475,14 +495,7 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
ieee80211_iter_keys(mphy->hw, vif, mt7996_key_iter, &it);
if (!mlink->wcid->offchannel) {
- if (vif->txq &&
- mvif->mt76.deflink_id == IEEE80211_LINK_UNSPECIFIED) {
- struct mt76_txq *mtxq;
-
- mtxq = (struct mt76_txq *)vif->txq->drv_priv;
- mvif->mt76.deflink_id = link_conf->link_id;
- mtxq->wcid = idx;
- }
+ mt7996_vif_deflink_init(vif, link);
mvif->mt76.valid_links |= BIT(link_conf->link_id);
}
@@ -564,10 +577,8 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif,
if (vif->txq && mvif->mt76.deflink_id == link_id) {
struct ieee80211_bss_conf *iter;
- struct mt76_txq *mtxq;
mvif->mt76.deflink_id = IEEE80211_LINK_UNSPECIFIED;
- mtxq = (struct mt76_txq *)vif->txq->drv_priv;
/* Primary link will be removed, look for a new one */
for_each_vif_active_link(vif, iter, link_id) {
if (link_id == msta_link->wcid.link_id)
@@ -577,8 +588,7 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif,
if (!link)
continue;
- mtxq->wcid = link->msta_link.wcid.idx;
- mvif->mt76.deflink_id = link_id;
+ mt7996_vif_deflink_init(vif, link);
break;
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
` (18 preceding siblings ...)
2026-11-24 8:43 ` [PATCH mt76-next 20/20] wifi: mt76: mt7996: set the default link again when a link is reused Felix Fietkau
@ 2026-11-24 8:53 ` Lorenzo Bianconi
19 siblings, 0 replies; 25+ messages in thread
From: Lorenzo Bianconi @ 2026-11-24 8:53 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1378 bytes --]
> mt7915_coredump_get_mem_layout() selects the mt7916 regions for chip
> 0x7916, but mt76_chip() returns 0x7906 on mt7916, like is_mt7916()
> expects. 0x7916 is the PCI id of the second interface, which
> mt7915_pci_probe() hands to mt7915_pci_hif2_probe() without a device
> of its own. With the coredump_memdump parameter set, an mt7916
> firmware crash thus gives a dump without firmware memory.
>
> Match the chip id of mt7916.
>
> Fixes: 4dbcb9125cc3 ("wifi: mt76: mt7915: enable coredump support")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/mt7915/coredump.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/coredump.c b/drivers/net/wireless/mediatek/mt76/mt7915/coredump.c
> index db079b274a93..91f02735a882 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/coredump.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/coredump.c
> @@ -96,7 +96,7 @@ mt7915_coredump_get_mem_layout(struct mt7915_dev *dev, u32 *num)
> case 0x7986:
> *num = ARRAY_SIZE(mt798x_mem_regions);
> return &mt798x_mem_regions[0];
> - case 0x7916:
> + case 0x7906:
> *num = ARRAY_SIZE(mt7916_mem_regions);
> return &mt7916_mem_regions[0];
> default:
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH mt76-next 02/20] wifi: mt76: mt7915: set the LED GPIO mux of mt7916
2026-11-24 8:42 ` [PATCH mt76-next 02/20] wifi: mt76: mt7915: set the LED GPIO mux " Felix Fietkau
@ 2026-11-24 8:53 ` Lorenzo Bianconi
0 siblings, 0 replies; 25+ messages in thread
From: Lorenzo Bianconi @ 2026-11-24 8:53 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1945 bytes --]
On Nov 24, Felix Fietkau wrote:
> The three switches of mt7915_init_led_mux() set the mt7916 GPIO mux for
> chip 0x7916. But mt76_chip() returns 0x7906 on mt7916, like is_mt7916()
> expects. 0x7916 is the PCI id of the second interface, which
> mt7915_pci_probe() hands to mt7915_pci_hif2_probe() without a device
> of its own. The GPIO mux of the mt7916 LED pins is thus never set.
>
> Match the chip id of mt7916.
>
> Fixes: 9e81c2c7b9af ("wifi: mt76: mt7915: enable per-phy led support")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/mt7915/init.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
> index 6d09718ec585..1bb2a938c354 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
> @@ -612,7 +612,7 @@ mt7915_init_led_mux(struct mt7915_dev *dev)
> mt76_rmw_field(dev, MT_LED_GPIO_MUX0,
> GENMASK(11, 8), 1);
> break;
> - case 0x7916:
> + case 0x7906:
> mt76_rmw_field(dev, MT_LED_GPIO_MUX1,
> GENMASK(27, 24), 3);
> mt76_rmw_field(dev, MT_LED_GPIO_MUX1,
> @@ -631,7 +631,7 @@ mt7915_init_led_mux(struct mt7915_dev *dev)
> mt76_rmw_field(dev, MT_LED_GPIO_MUX0,
> GENMASK(11, 8), 1);
> break;
> - case 0x7916:
> + case 0x7906:
> mt76_rmw_field(dev, MT_LED_GPIO_MUX1,
> GENMASK(31, 28), 3);
> break;
> @@ -648,7 +648,7 @@ mt7915_init_led_mux(struct mt7915_dev *dev)
> mt76_rmw_field(dev, MT_LED_GPIO_MUX0,
> GENMASK(7, 4), 1);
> break;
> - case 0x7916:
> + case 0x7906:
> mt76_rmw_field(dev, MT_LED_GPIO_MUX1,
> GENMASK(27, 24), 3);
> break;
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH mt76-next 03/20] wifi: mt76: fail an MCU command started during an MCU reset
2026-11-24 8:42 ` [PATCH mt76-next 03/20] wifi: mt76: fail an MCU command started during an MCU reset Felix Fietkau
@ 2026-11-24 8:54 ` Lorenzo Bianconi
0 siblings, 0 replies; 25+ messages in thread
From: Lorenzo Bianconi @ 2026-11-24 8:54 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 2183 bytes --]
On Nov 24, Felix Fietkau wrote:
> While MT76_MCU_RESET is set, mt76_dma_tx_queue_skb_raw() drops a
> command with the error of a full ring or a failed DMA mapping. The SDIO
> path queues the command, reports success and skips it. The USB path
> sends it. The caller thus cannot tell such a command from one whose
> answer the reset cut off.
>
> Do not send a command that starts while the bit is set. Return an error
> that no other step of the send gives. The interrupt path can set the
> bit after this test. Return the same error from the raw TX of the DMA
> path for that case.
>
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/dma.c | 6 ++++--
> drivers/net/wireless/mediatek/mt76/mcu.c | 6 ++++++
> 2 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
> index 8c0403820299..f5203f39e6b1 100644
> --- a/drivers/net/wireless/mediatek/mt76/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/dma.c
> @@ -637,8 +637,10 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q,
> struct mt76_queue_buf buf = {};
> dma_addr_t addr;
>
> - if (test_bit(MT76_MCU_RESET, &dev->phy.state))
> - goto error;
> + if (test_bit(MT76_MCU_RESET, &dev->phy.state)) {
> + dev_kfree_skb(skb);
> + return -ESHUTDOWN;
> + }
>
> if (q->queued + 1 >= q->ndesc - 1)
> goto error;
> diff --git a/drivers/net/wireless/mediatek/mt76/mcu.c b/drivers/net/wireless/mediatek/mt76/mcu.c
> index 7149b2f7aafd..e19fd1bbd911 100644
> --- a/drivers/net/wireless/mediatek/mt76/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mcu.c
> @@ -91,6 +91,12 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
> goto out;
> }
>
> + if (test_bit(MT76_MCU_RESET, &dev->phy.state)) {
> + orig_skb = skb;
> + ret = -ESHUTDOWN;
> + goto out;
> + }
> +
> if (dev->mcu_ops->mcu_skb_prepare_msg) {
> orig_skb = skb;
> ret = dev->mcu_ops->mcu_skb_prepare_msg(dev, skb, cmd, &seq);
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH mt76-next 10/20] wifi: mt76: mt7915: hold the device mutex in the rate control work
2026-11-24 8:42 ` [PATCH mt76-next 10/20] wifi: mt76: mt7915: hold the device mutex in the rate control work Felix Fietkau
@ 2026-11-24 8:56 ` Lorenzo Bianconi
0 siblings, 0 replies; 25+ messages in thread
From: Lorenzo Bianconi @ 2026-11-24 8:56 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1546 bytes --]
On Nov 24, Felix Fietkau wrote:
> mt7915_mac_sta_rc_work() sends its rate control and SMPS updates
> without dev->mt76.mutex. The L1 SER work holds the mutex while
> MT76_MCU_RESET keeps commands from the firmware. The rate control work
> can still run in that window, so its update does not reach the
> firmware.
>
> Hold the mutex across the updates, as mt7996_mac_sta_rc_work() does.
> The work then waits for the end of the L1 SER.
>
> Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> index e9b1704d1289..110d5368a8ee 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> @@ -2008,6 +2008,8 @@ void mt7915_mac_sta_rc_work(struct work_struct *work)
> u32 changed;
> LIST_HEAD(list);
>
> + mutex_lock(&dev->mt76.mutex);
> +
> spin_lock_bh(&dev->mt76.sta_poll_lock);
> list_splice_init(&dev->sta_rc_list, &list);
>
> @@ -2033,6 +2035,8 @@ void mt7915_mac_sta_rc_work(struct work_struct *work)
> }
>
> spin_unlock_bh(&dev->mt76.sta_poll_lock);
> +
> + mutex_unlock(&dev->mt76.mutex);
> }
>
> void mt7915_mac_work(struct work_struct *work)
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH mt76-next 11/20] wifi: mt76: mt7915: hold the device mutex in the station and regd updates
2026-11-24 8:43 ` [PATCH mt76-next 11/20] wifi: mt76: mt7915: hold the device mutex in the station and regd updates Felix Fietkau
@ 2026-11-24 8:58 ` Lorenzo Bianconi
0 siblings, 0 replies; 25+ messages in thread
From: Lorenzo Bianconi @ 2026-11-24 8:58 UTC (permalink / raw)
To: Felix Fietkau; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 3661 bytes --]
On Nov 24, Felix Fietkau wrote:
> The sta_set_4addr and sta_set_decap_offload ops and
> mt7915_regd_notifier() send their MCU commands without dev->mt76.mutex.
> The L1 SER work holds the mutex while MT76_MCU_RESET keeps commands from
> the firmware. An update in that window is thus lost: the header
> translation or the radar detector state.
>
> Hold the mutex across the updates, as mt7996 does in its station ops.
> mt7915_set_radar_background() already holds it for the background
> chain. The callers then wait for the end of the L1 SER.
>
> Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
> Fixes: e151d71e503d ("mt76: mt7915: add encap offload for 4-address mode stations")
> Fixes: 90e3abf07c80 ("mt76: mt7915: add support for rx decapsulation offload")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/wireless/mediatek/mt76/mt7915/init.c | 4 ++++
> drivers/net/wireless/mediatek/mt76/mt7915/main.c | 16 ++++++++++------
> 2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
> index 1bb2a938c354..fb92a0b2e4ab 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
> @@ -383,6 +383,8 @@ mt7915_regd_notifier(struct wiphy *wiphy,
> struct mt76_phy *mphy = hw->priv;
> struct mt7915_phy *phy = mphy->priv;
>
> + mutex_lock(&dev->mt76.mutex);
> +
> memcpy(dev->mt76.alpha2, request->alpha2, sizeof(dev->mt76.alpha2));
> dev->mt76.region = request->dfs_region;
>
> @@ -393,6 +395,8 @@ mt7915_regd_notifier(struct wiphy *wiphy,
>
> mphy->dfs_state = MT_DFS_STATE_UNKNOWN;
> mt7915_dfs_init_radar_detector(phy);
> +
> + mutex_unlock(&dev->mt76.mutex);
> }
>
> static void
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
> index edbb921e63bc..47796e0fa506 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
> @@ -1294,15 +1294,17 @@ static void mt7915_sta_set_4addr(struct ieee80211_hw *hw,
> struct mt7915_dev *dev = mt7915_hw_dev(hw);
> struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
>
> + mutex_lock(&dev->mt76.mutex);
> +
> if (enabled)
> set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
> else
> clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
>
> - if (!msta->wcid.sta)
> - return;
> + if (msta->wcid.sta)
> + mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
>
> - mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
> + mutex_unlock(&dev->mt76.mutex);
> }
>
> static void mt7915_sta_set_decap_offload(struct ieee80211_hw *hw,
> @@ -1313,15 +1315,17 @@ static void mt7915_sta_set_decap_offload(struct ieee80211_hw *hw,
> struct mt7915_dev *dev = mt7915_hw_dev(hw);
> struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
>
> + mutex_lock(&dev->mt76.mutex);
> +
> if (enabled)
> set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
> else
> clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
>
> - if (!msta->wcid.sta)
> - return;
> + if (msta->wcid.sta)
> + mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
>
> - mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
> + mutex_unlock(&dev->mt76.mutex);
> }
>
> static int mt7915_sta_set_txpwr(struct ieee80211_hw *hw,
> --
> 2.47.3
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2026-11-24 8:58 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 8:42 [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 02/20] wifi: mt76: mt7915: set the LED GPIO mux " Felix Fietkau
2026-11-24 8:53 ` Lorenzo Bianconi
2026-11-24 8:42 ` [PATCH mt76-next 03/20] wifi: mt76: fail an MCU command started during an MCU reset Felix Fietkau
2026-11-24 8:54 ` Lorenzo Bianconi
2026-11-24 8:42 ` [PATCH mt76-next 04/20] wifi: mt76: mark an MCU command that only reads Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 05/20] wifi: mt76: retry only an MCU command that reads Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 06/20] wifi: mt76: report an MCU command whose outcome is unknown Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 07/20] wifi: mt76: mt7996: mark the MCU commands that only read Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 08/20] wifi: mt76: mt7996: reset after an MCU reset lost a state command Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 09/20] wifi: mt76: mt7915: mark the MCU commands that only read Felix Fietkau
2026-11-24 8:42 ` [PATCH mt76-next 10/20] wifi: mt76: mt7915: hold the device mutex in the rate control work Felix Fietkau
2026-11-24 8:56 ` Lorenzo Bianconi
2026-11-24 8:43 ` [PATCH mt76-next 11/20] wifi: mt76: mt7915: hold the device mutex in the station and regd updates Felix Fietkau
2026-11-24 8:58 ` Lorenzo Bianconi
2026-11-24 8:43 ` [PATCH mt76-next 12/20] wifi: mt76: mt7915: reset after an MCU reset lost a state command Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 13/20] wifi: mt76: mt7996: clear the PS state of stations at a reset Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 14/20] wifi: mt76: mt7996: apply the PS sync bitmap to MLD stations alone Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 15/20] wifi: mt76: mt7996: keep the TWT state out of the PS flag Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 16/20] wifi: mt76: mt7996: read the TSF twice against the firmware's latch Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 17/20] wifi: mt76: mt7996: check a TSF write " Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 18/20] wifi: mt76: mt7915: keep the TWT state out of the PS flag Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 19/20] wifi: mt76: mt7915: clear the PS flag of a station at a reset Felix Fietkau
2026-11-24 8:43 ` [PATCH mt76-next 20/20] wifi: mt76: mt7996: set the default link again when a link is reused Felix Fietkau
2026-11-24 8:53 ` [PATCH mt76-next 01/20] wifi: mt76: mt7915: dump the firmware memory of mt7916 Lorenzo Bianconi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox