Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: JB Tsai <jb.tsai@mediatek.com>
To: <nbd@nbd.name>, <lorenzo@kernel.org>
Cc: <linux-wireless@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>, <Sean.Wang@mediatek.com>,
	<Quan.Zhou@mediatek.com>, <Ryder.Lee@mediatek.com>,
	<litien.chang@mediatek.com>, <vick.cheng@mediatek.com>,
	<jb.tsai@mediatek.com>
Subject: [PATCH] wifi: mt76: mt7925: fix REG_ACCESS command size for register type
Date: Wed, 5 Aug 2026 10:16:06 +0800	[thread overview]
Message-ID: <20260805021606.1253882-1-jb.tsai@mediatek.com> (raw)

From: Vick Cheng <vick.cheng@mediatek.com>

mt7925_mcu_regval() always sent sizeof(req) - the full union - regardless of which member (basic reg or RF reg) was active. The two members differ in size, so the firmware received trailing zero bytes which it parsed as extra TLV entries, causing a dead loop.

Pass the size of the active member instead of the union size.

Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Signed-off-by: Vick Cheng <vick.cheng@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index 5532e1722d17..64bba015f5f8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -90,6 +90,7 @@ int mt7925_mcu_regval(struct mt792x_dev *dev, u32 regidx, u32 *val, bool set)
 		};
 	} __packed * res, req;
 	struct sk_buff *skb;
+	int cmd_len;
 	int ret;
 
 	if (u32_get_bits(regidx, MT_RF_REG_HDR) == RF_REG_PREFIX) {
@@ -98,20 +99,22 @@ int mt7925_mcu_regval(struct mt792x_dev *dev, u32 regidx, u32 *val, bool set)
 		req.rf_reg.ant = cpu_to_le16(u32_get_bits(regidx, MT_RF_REG_ANT));
 		req.rf_reg.idx = cpu_to_le32(regidx);
 		req.rf_reg.data = set ? cpu_to_le32(*val) : 0;
+		cmd_len = sizeof(req.__rsv) + sizeof(req.rf_reg);
 	} else {
 		req.reg.tag = cpu_to_le16(UNI_CMD_ACCESS_REG_BASIC);
 		req.reg.len = cpu_to_le16(sizeof(req.reg));
 		req.reg.idx = cpu_to_le32(regidx);
 		req.reg.data = set ? cpu_to_le32(*val) : 0;
+		cmd_len = sizeof(req.__rsv) + sizeof(req.reg);
 	}
 
 	if (set)
 		return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(REG_ACCESS),
-					 &req, sizeof(req), true);
+					 &req, cmd_len, true);
 
 	ret = mt76_mcu_send_and_get_msg(&dev->mt76,
 					MCU_WM_UNI_CMD_QUERY(REG_ACCESS),
-					&req, sizeof(req), true, &skb);
+					&req, cmd_len, true, &skb);
 	if (ret)
 		return ret;
 
-- 
2.45.2



                 reply	other threads:[~2026-08-05  2:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260805021606.1253882-1-jb.tsai@mediatek.com \
    --to=jb.tsai@mediatek.com \
    --cc=Quan.Zhou@mediatek.com \
    --cc=Ryder.Lee@mediatek.com \
    --cc=Sean.Wang@mediatek.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=litien.chang@mediatek.com \
    --cc=lorenzo@kernel.org \
    --cc=nbd@nbd.name \
    --cc=vick.cheng@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox