From: sean.wang@kernel.org
To: nbd@nbd.name, lorenzo.bianconi@redhat.com
Cc: linux-wireless@vger.kernel.org,
linux-mediatek@lists.infradead.org,
Sean Wang <sean.wang@mediatek.com>,
Xiong Huang <xiong.huang@mediatek.com>
Subject: [PATCH 04/11] wifi: mt76: mt7921: add MT7902e DMA layout support
Date: Wed, 18 Feb 2026 18:40:00 -0600 [thread overview]
Message-ID: <20260219004007.19733-4-sean.wang@kernel.org> (raw)
In-Reply-To: <20260219004007.19733-1-sean.wang@kernel.org>
From: Sean Wang <sean.wang@mediatek.com>
Add MT7902 PCIe specific DMA layout overrides for MCU TXQ index, RX ring
size, and MCU_WA usage. Common layout remains the default for other chips.
This is a prerequisite patch before enabling MT7902 PCIe support.
Co-developed-by: Xiong Huang <xiong.huang@mediatek.com>
Signed-off-by: Xiong Huang <xiong.huang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
.../wireless/mediatek/mt76/mt7921/mt7921.h | 14 +++++++
.../net/wireless/mediatek/mt76/mt7921/pci.c | 41 +++++++++++++++----
2 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
index ad92af98e314..64f60c4fc60c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
@@ -17,6 +17,9 @@
#define MT7921_RX_MCU_RING_SIZE 8
#define MT7921_RX_MCU_WA_RING_SIZE 512
+/* MT7902 Rx Ring0 is for both Rx Event and Tx Done Event */
+#define MT7902_RX_MCU_RING_SIZE 512
+
#define MT7921_EEPROM_SIZE 3584
#define MT7921_TOKEN_SIZE 8192
@@ -119,6 +122,17 @@ enum mt7921_rxq_id {
MT7921_RXQ_MCU_WM = 0,
};
+/* MT7902 assigns its MCU-WM TXQ at index 15 */
+enum mt7902_txq_id {
+ MT7902_TXQ_MCU_WM = 15,
+};
+
+struct mt7921_dma_layout {
+ u8 mcu_wm_txq;
+ u16 mcu_rxdone_ring_size;
+ bool has_mcu_wa;
+};
+
enum {
MT7921_CLC_POWER,
MT7921_CLC_CHAN,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
index 5f857a21f362..6bb3c6a1cf6a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
@@ -167,8 +167,29 @@ static u32 mt7921_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val)
static int mt7921_dma_init(struct mt792x_dev *dev)
{
+ struct mt7921_dma_layout layout = {
+ /* General case: MT7921 / MT7922 /MT7920 */
+ .mcu_wm_txq = MT7921_TXQ_MCU_WM,
+ .mcu_rxdone_ring_size = MT7921_RX_MCU_RING_SIZE,
+ .has_mcu_wa = true,
+ };
+ bool is_mt7902;
int ret;
+ is_mt7902 = mt7921_l1_rr(dev, MT_HW_CHIPID) == 0x7902;
+
+ /*
+ * MT7902 special case:
+ * - MCU-WM TXQ uses index 15
+ * - RX Ring0 is larger and shared for event/TX-done
+ * - MT7902 does not use the MCU_WA ring
+ */
+ if (is_mt7902) {
+ layout.mcu_wm_txq = MT7902_TXQ_MCU_WM;
+ layout.mcu_rxdone_ring_size = MT7902_RX_MCU_RING_SIZE;
+ layout.has_mcu_wa = false;
+ }
+
mt76_dma_attach(&dev->mt76);
ret = mt792x_dma_disable(dev, true);
@@ -185,7 +206,7 @@ static int mt7921_dma_init(struct mt792x_dev *dev)
mt76_wr(dev, MT_WFDMA0_TX_RING0_EXT_CTRL, 0x4);
/* command to WM */
- ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_WM, MT7921_TXQ_MCU_WM,
+ ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_WM, layout.mcu_wm_txq,
MT7921_TX_MCU_RING_SIZE, MT_TX_RING_BASE);
if (ret)
return ret;
@@ -199,18 +220,20 @@ static int mt7921_dma_init(struct mt792x_dev *dev)
/* event from WM before firmware download */
ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MCU],
MT7921_RXQ_MCU_WM,
- MT7921_RX_MCU_RING_SIZE,
+ layout.mcu_rxdone_ring_size,
MT_RX_BUF_SIZE, MT_RX_EVENT_RING_BASE);
if (ret)
return ret;
- /* Change mcu queue after firmware download */
- ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MCU_WA],
- MT7921_RXQ_MCU_WM,
- MT7921_RX_MCU_WA_RING_SIZE,
- MT_RX_BUF_SIZE, MT_WFDMA0(0x540));
- if (ret)
- return ret;
+ if (layout.has_mcu_wa) {
+ /* Change mcu queue after firmware download */
+ ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MCU_WA],
+ MT7921_RXQ_MCU_WM,
+ MT7921_RX_MCU_WA_RING_SIZE,
+ MT_RX_BUF_SIZE, MT_WFDMA0(0x540));
+ if (ret)
+ return ret;
+ }
/* rx data */
ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MAIN],
--
2.43.0
next prev parent reply other threads:[~2026-02-19 0:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 0:39 [PATCH 01/11] wifi: mt76: connac: use is_connac2() to replace is_mt7921() checks sean.wang
2026-02-19 0:39 ` [PATCH 02/11] wifi: mt76: mt7921: use mt76_for_each_q_rx() in reset path sean.wang
2026-02-19 0:39 ` [PATCH 03/11] wifi: mt76: mt7921: handle MT7902 irq_map quirk with mutable copy sean.wang
2026-02-20 10:09 ` Philip Müller
2026-02-20 18:39 ` Sean Wang
2026-02-19 0:40 ` sean.wang [this message]
2026-02-19 0:40 ` [PATCH 05/11] wifi: mt76: connac: mark MT7902 as hw txp devices sean.wang
2026-02-19 0:40 ` [PATCH 06/11] wifi: mt76: mt792x: add PSE handling barrier for the large MCU cmd sean.wang
2026-02-19 0:40 ` [PATCH 07/11] wifi: mt76: mt792x: ensure MCU ready before ROM patch download sean.wang
2026-02-19 0:40 ` [PATCH 08/11] wifi: mt76: mt7921: add MT7902 MCU support sean.wang
2026-02-19 0:40 ` [PATCH 09/11] wifi: mt76: mt792x: add MT7902 WFDMA prefetch configuration sean.wang
2026-02-19 0:40 ` [PATCH 10/11] wifi: mt76: mt7921: add MT7902 PCIe device support sean.wang
2026-02-19 0:40 ` [PATCH 11/11] wifi: mt76: mt7921: add MT7902 SDIO " sean.wang
2026-02-20 20:41 ` [PATCH 01/11] wifi: mt76: connac: use is_connac2() to replace is_mt7921() checks Philip Müller
2026-02-21 20:19 ` Sean Wang
2026-03-22 8:04 ` Philip Müller
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=20260219004007.19733-4-sean.wang@kernel.org \
--to=sean.wang@kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=nbd@nbd.name \
--cc=sean.wang@mediatek.com \
--cc=xiong.huang@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