* [PATCH] wifi: mt76: do not mask negative MCU command ids
@ 2026-11-28 12:25 Oleh Shcherba
0 siblings, 0 replies; only message in thread
From: Oleh Shcherba @ 2026-11-28 12:25 UTC (permalink / raw)
To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee
Cc: Shayne Chen, Sean Wang, Matthias Brugger,
AngeloGioacchino Del Regno, linux-wireless, linux-kernel,
linux-arm-kernel, linux-mediatek, Oleh Shcherba
Commit 1ffc90633ad6 ("wifi: mt76: mark an MCU command that only reads")
clears BIT(30) of every command id before it reaches the driver. mt7603
sends its legacy commands as negative ids, and a small negative int has
bit 30 set by its sign. Clearing it turns -MCU_CMD_FW_SCATTER (0xffffff12)
into 0xbfffff12, so mt7603_mcu_skb_send_msg() no longer matches it and
queues the firmware image to MCU_PORT_QUEUE instead of MCU_PORT_QUEUE_FW.
The firmware never starts and probe fails:
mt76_wmac 10300000.wmac: Timeout waiting for firmware to initialize
mt76_wmac 10300000.wmac: probe with driver mt76_wmac failed with error -5
Only handle the READ flag of non-negative command ids.
Fixes: 1ffc90633ad6 ("wifi: mt76: mark an MCU command that only reads")
Signed-off-by: Oleh Shcherba <scherbaoleg4@gmail.com>
---
drivers/net/wireless/mediatek/mt76/mcu.c | 6 +++---
drivers/net/wireless/mediatek/mt76/mt76.h | 6 ++++++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mcu.c b/drivers/net/wireless/mediatek/mt76/mcu.c
index 4f3471b..4dc287e 100644
--- a/drivers/net/wireless/mediatek/mt76/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mcu.c
@@ -59,7 +59,7 @@ 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 & ~MT76_MCU_CMD_READ,
+ return dev->mcu_ops->mcu_send_msg(dev, mt76_mcu_cmd_strip(cmd),
data, len, wait_resp);
skb = mt76_mcu_msg_alloc(dev, data, len);
@@ -74,14 +74,14 @@ 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;
+ bool read = cmd >= 0 && (cmd & MT76_MCU_CMD_READ);
unsigned int retry = 0;
struct sk_buff *orig_skb = NULL;
unsigned long expires;
bool lost = false;
int ret, seq;
- cmd &= ~MT76_MCU_CMD_READ;
+ cmd = mt76_mcu_cmd_strip(cmd);
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 d635df2..237057c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -272,6 +272,12 @@ struct mt76_queue {
*/
#define MT76_MCU_CMD_READ BIT(30)
+/* mt7603 uses negative command ids, do not mask them */
+static inline int mt76_mcu_cmd_strip(int cmd)
+{
+ return cmd < 0 ? cmd : cmd & ~MT76_MCU_CMD_READ;
+}
+
struct mt76_mcu_ops {
unsigned int max_retry;
u32 headroom;
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-28 12:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 12:25 [PATCH] wifi: mt76: do not mask negative MCU command ids Oleh Shcherba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox