From: Francesco Palmarini via B4 Relay <devnull+palmarini.unive.it@kernel.org>
To: Felix Fietkau <nbd@nbd.name>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Ryder Lee <ryder.lee@mediatek.com>
Cc: Shayne Chen <shayne.chen@mediatek.com>,
Sean Wang <sean.wang@mediatek.com>,
linux-wireless@vger.kernel.org,
linux-mediatek@lists.infradead.org,
Francesco Palmarini <palmarini@unive.it>
Subject: [PATCH 1/2] wifi: mt76: mt7615: fix lost first mcu event on mt7622
Date: Sun, 25 Oct 2026 12:32:31 +0000 [thread overview]
Message-ID: <20261025-mt7622-patch-sem-v1-1-e16e31c1face@unive.it> (raw)
In-Reply-To: <20261025-mt7622-patch-sem-v1-0-e16e31c1face@unive.it>
From: Francesco Palmarini <palmarini@unive.it>
On MT7622 the 2.4 GHz wmac fails to initialize on most boots:
mt7622-wmac 18000000.wmac: Message 00000010 (seq 1) timeout
mt7622-wmac 18000000.wmac: Failed to get patch semaphore
The rom actually replies to the first PATCH_SEM_CONTROL command and
grants the semaphore, but the event shows up on the data ring with an
extra zero dword in front of it:
00000000 e000001c 00000000 00000000
00000000 e000000c 00000104 00000002
Since RXD0 is zero, mt7615_rx_check() handles it as tx status and the
event is dropped. The command times out and all the retries in
mt7615_pci_init_work() fail because the semaphore is already taken.
Detect the shifted event while the mcu is not running yet and strip the
extra dword.
Tested on Xiaomi AX3200 (same hw as Redmi AX6S).
Signed-off-by: Francesco Palmarini <palmarini@unive.it>
---
drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
index aad232c5a..54c70a427 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
@@ -1590,6 +1590,21 @@ static void mt7615_mac_tx_free(struct mt7615_dev *dev, void *data, int len)
mt76_worker_schedule(&dev->mt76.tx_worker);
}
+static bool
+mt7615_mac_rx_shifted_event(struct mt7615_dev *dev, __le32 *rxd, int len)
+{
+ /* mt7622 rom can report the first mcu event on the data ring,
+ * with an extra dword in front of it
+ */
+ if (!is_mt7622(&dev->mt76) ||
+ test_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state))
+ return false;
+
+ return len >= 8 && !rxd[0] &&
+ le32_get_bits(rxd[1], MT_RXD0_PKT_TYPE) == PKT_TYPE_RX_EVENT &&
+ le32_get_bits(rxd[1], MT_RXD0_LENGTH) == len - 4;
+}
+
bool mt7615_rx_check(struct mt76_dev *mdev, void *data, int len)
{
struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
@@ -1597,6 +1612,9 @@ bool mt7615_rx_check(struct mt76_dev *mdev, void *data, int len)
__le32 *end = (__le32 *)&rxd[len / 4];
enum rx_pkt_type type;
+ if (mt7615_mac_rx_shifted_event(dev, rxd, len))
+ return true;
+
type = le32_get_bits(rxd[0], MT_RXD0_PKT_TYPE);
switch (type) {
@@ -1624,6 +1642,11 @@ void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
enum rx_pkt_type type;
u16 flag;
+ if (mt7615_mac_rx_shifted_event(dev, rxd, skb->len)) {
+ skb_pull(skb, 4);
+ rxd = (__le32 *)skb->data;
+ }
+
type = le32_get_bits(rxd[0], MT_RXD0_PKT_TYPE);
flag = le32_get_bits(rxd[0], MT_RXD0_PKT_FLAG);
if (type == PKT_TYPE_RX_EVENT && flag == 0x1)
--
2.39.5
next prev parent reply other threads:[~2026-10-25 12:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 12:32 [PATCH 0/2] wifi: mt76: mt7615: fix mt7622 wmac init Francesco Palmarini via B4 Relay
2026-10-25 12:32 ` Francesco Palmarini via B4 Relay [this message]
2026-10-25 12:32 ` [PATCH 2/2] wifi: mt76: mt7615: release patch semaphore on timeout Francesco Palmarini via B4 Relay
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=20261025-mt7622-patch-sem-v1-1-e16e31c1face@unive.it \
--to=devnull+palmarini.unive.it@kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=nbd@nbd.name \
--cc=palmarini@unive.it \
--cc=ryder.lee@mediatek.com \
--cc=sean.wang@mediatek.com \
--cc=shayne.chen@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