Skip to contentSkip to conversation

wifi: mt76: do not mask negative MCU command ids

PATCH New Oleh Shcherba 1 participant 1 message Nov 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: mt76: do not mask negative MCU command ids

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")
---
 drivers/net/wireless/mediatek/mt76/mcu.c  | 6 +++---
 drivers/net/wireless/mediatek/mt76/mt76.h | 6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mcu.c +3 -3
index 4f3471b..4dc287e 100644
@@ -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;
drivers/net/wireless/mediatek/mt76/mt76.h +6 -0
index d635df2..237057c 100644
@@ -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;
Signature · 1 line
2.43.0