mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
wifi: mt76: mt7996: do not leave state behind after a failed WED attach
mt7996_mmio_wed_init() set dev->mt76.hwrro_mode and rx_token_size while
building the WED configuration, before knowing whether the WED attach
can succeed. A failed attach left the enlarged rx_token_size behind and
reset hwrro_mode to MT76_HWRRO_OFF, clobbering the values that another
RX datapath owner may have configured earlier in probe: on Airoha
platforms with the wed_enable module parameter set, this broke the NPU
offload configuration set up by mt76_npu_init() (NPU offload requires
HW-RRO and a larger rx token space, and the attach always fails there
since no SoC has both an Airoha NPU and MTK WED).
Move both assignments after a successful attach, next to the existing
success-only dma_dev/irq assignments. This is safe for the regular WED
attach case: the first consumer of either field runs after probe
continues (mtk_wed_device_attach() only invokes the init_buf callback;
rx buffers are allocated via init_rx_buf from mtk_wed_start(), long
after mt7996_mmio_wed_init() has returned).
Within the WED configuration the HW-RRO checks were constant: the mode
was assigned unconditionally right before them, and the hif2 path is
only reachable after a successful main attach has set it. Resolve them
to their constant values and drop the dead branches.
Fixes: 377aa17d2aed ("wifi: mt76: mt7996: Add NPU offload support to MT7996 driver")
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
+20
-33
@@ -464,9 +464,6 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
|
|||||||
if (!wed_enable)
|
if (!wed_enable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dev->mt76.hwrro_mode = is_mt7996(&dev->mt76) ? MT76_HWRRO_V3
|
|
||||||
: MT76_HWRRO_V3_1;
|
|
||||||
|
|
||||||
hif1_ofs = dev->hif2 ? MT_WFDMA0_PCIE1(0) - MT_WFDMA0(0) : 0;
|
hif1_ofs = dev->hif2 ? MT_WFDMA0_PCIE1(0) - MT_WFDMA0(0) : 0;
|
||||||
|
|
||||||
if (hif2)
|
if (hif2)
|
||||||
@@ -491,23 +488,16 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
|
|||||||
wed->wlan.wpdma_tx = wed->wlan.phy_base + hif1_ofs +
|
wed->wlan.wpdma_tx = wed->wlan.phy_base + hif1_ofs +
|
||||||
MT_TXQ_RING_BASE(0) +
|
MT_TXQ_RING_BASE(0) +
|
||||||
MT7996_TXQ_BAND2 * MT_RING_SIZE;
|
MT7996_TXQ_BAND2 * MT_RING_SIZE;
|
||||||
if (mt7996_has_hwrro(dev)) {
|
if (is_mt7996(&dev->mt76)) {
|
||||||
if (is_mt7996(&dev->mt76)) {
|
wed->wlan.txfree_tbit = ffs(MT_INT_RX_TXFREE_EXT) - 1;
|
||||||
wed->wlan.txfree_tbit = ffs(MT_INT_RX_TXFREE_EXT) - 1;
|
|
||||||
wed->wlan.wpdma_txfree = wed->wlan.phy_base + hif1_ofs +
|
|
||||||
MT_RXQ_RING_BASE(0) +
|
|
||||||
MT7996_RXQ_TXFREE2 * MT_RING_SIZE;
|
|
||||||
} else {
|
|
||||||
wed->wlan.txfree_tbit = ffs(MT_INT_RX_TXFREE_BAND1_EXT) - 1;
|
|
||||||
wed->wlan.wpdma_txfree = wed->wlan.phy_base + hif1_ofs +
|
|
||||||
MT_RXQ_RING_BASE(0) +
|
|
||||||
MT7996_RXQ_MCU_WA_EXT * MT_RING_SIZE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
wed->wlan.wpdma_txfree = wed->wlan.phy_base + hif1_ofs +
|
wed->wlan.wpdma_txfree = wed->wlan.phy_base + hif1_ofs +
|
||||||
MT_RXQ_RING_BASE(0) +
|
MT_RXQ_RING_BASE(0) +
|
||||||
MT7996_RXQ_MCU_WA_TRI * MT_RING_SIZE;
|
MT7996_RXQ_TXFREE2 * MT_RING_SIZE;
|
||||||
wed->wlan.txfree_tbit = ffs(MT_INT_RX_DONE_WA_TRI) - 1;
|
} else {
|
||||||
|
wed->wlan.txfree_tbit = ffs(MT_INT_RX_TXFREE_BAND1_EXT) - 1;
|
||||||
|
wed->wlan.wpdma_txfree = wed->wlan.phy_base + hif1_ofs +
|
||||||
|
MT_RXQ_RING_BASE(0) +
|
||||||
|
MT7996_RXQ_MCU_WA_EXT * MT_RING_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wed->wlan.wpdma_rx_glo = wed->wlan.phy_base + hif1_ofs + MT_WFDMA0_GLO_CFG;
|
wed->wlan.wpdma_rx_glo = wed->wlan.phy_base + hif1_ofs + MT_WFDMA0_GLO_CFG;
|
||||||
@@ -518,7 +508,7 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
|
|||||||
wed->wlan.id = MT7996_DEVICE_ID_2;
|
wed->wlan.id = MT7996_DEVICE_ID_2;
|
||||||
wed->wlan.tx_tbit[0] = ffs(MT_INT_TX_DONE_BAND2) - 1;
|
wed->wlan.tx_tbit[0] = ffs(MT_INT_TX_DONE_BAND2) - 1;
|
||||||
} else {
|
} else {
|
||||||
wed->wlan.hw_rro = mt7996_has_hwrro(dev);
|
wed->wlan.hw_rro = true;
|
||||||
wed->wlan.wpdma_int = wed->wlan.phy_base + MT_INT_SOURCE_CSR;
|
wed->wlan.wpdma_int = wed->wlan.phy_base + MT_INT_SOURCE_CSR;
|
||||||
wed->wlan.wpdma_mask = wed->wlan.phy_base + MT_INT_MASK_CSR;
|
wed->wlan.wpdma_mask = wed->wlan.phy_base + MT_INT_MASK_CSR;
|
||||||
wed->wlan.wpdma_tx = wed->wlan.phy_base + MT_TXQ_RING_BASE(0) +
|
wed->wlan.wpdma_tx = wed->wlan.phy_base + MT_TXQ_RING_BASE(0) +
|
||||||
@@ -571,23 +561,15 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
|
|||||||
wed->wlan.tx_tbit[0] = ffs(MT_INT_TX_DONE_BAND0) - 1;
|
wed->wlan.tx_tbit[0] = ffs(MT_INT_TX_DONE_BAND0) - 1;
|
||||||
wed->wlan.tx_tbit[1] = ffs(MT_INT_TX_DONE_BAND1) - 1;
|
wed->wlan.tx_tbit[1] = ffs(MT_INT_TX_DONE_BAND1) - 1;
|
||||||
if (is_mt7996(&dev->mt76)) {
|
if (is_mt7996(&dev->mt76)) {
|
||||||
if (mt7996_has_hwrro(dev)) {
|
wed->wlan.wpdma_txfree = wed->wlan.phy_base +
|
||||||
wed->wlan.wpdma_txfree = wed->wlan.phy_base +
|
MT_RXQ_RING_BASE(0) +
|
||||||
MT_RXQ_RING_BASE(0) +
|
MT7996_RXQ_TXFREE0 * MT_RING_SIZE;
|
||||||
MT7996_RXQ_TXFREE0 * MT_RING_SIZE;
|
wed->wlan.txfree_tbit = ffs(MT_INT_RX_TXFREE_MAIN) - 1;
|
||||||
wed->wlan.txfree_tbit = ffs(MT_INT_RX_TXFREE_MAIN) - 1;
|
|
||||||
} else {
|
|
||||||
wed->wlan.wpdma_txfree = wed->wlan.phy_base +
|
|
||||||
MT_RXQ_RING_BASE(0) +
|
|
||||||
MT7996_RXQ_MCU_WA_MAIN * MT_RING_SIZE;
|
|
||||||
wed->wlan.txfree_tbit = ffs(MT_INT_RX_DONE_WA_MAIN) - 1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
wed->wlan.txfree_tbit = ffs(MT_INT_RX_DONE_WA_MAIN) - 1;
|
wed->wlan.txfree_tbit = ffs(MT_INT_RX_DONE_WA_MAIN) - 1;
|
||||||
wed->wlan.wpdma_txfree = wed->wlan.phy_base + MT_RXQ_RING_BASE(0) +
|
wed->wlan.wpdma_txfree = wed->wlan.phy_base + MT_RXQ_RING_BASE(0) +
|
||||||
MT7996_RXQ_MCU_WA_MAIN * MT_RING_SIZE;
|
MT7996_RXQ_MCU_WA_MAIN * MT_RING_SIZE;
|
||||||
}
|
}
|
||||||
dev->mt76.rx_token_size = MT7996_TOKEN_SIZE + wed->wlan.rx_npkt;
|
|
||||||
|
|
||||||
if (dev->hif2 && is_mt7992(&dev->mt76))
|
if (dev->hif2 && is_mt7992(&dev->mt76))
|
||||||
wed->wlan.id = 0x7992;
|
wed->wlan.id = 0x7992;
|
||||||
@@ -610,9 +592,14 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr,
|
|||||||
wed->wlan.reset_complete = mt76_wed_reset_complete;
|
wed->wlan.reset_complete = mt76_wed_reset_complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mtk_wed_device_attach(wed)) {
|
if (mtk_wed_device_attach(wed))
|
||||||
dev->mt76.hwrro_mode = MT76_HWRRO_OFF;
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (!hif2) {
|
||||||
|
dev->mt76.hwrro_mode = is_mt7996(&dev->mt76) ? MT76_HWRRO_V3
|
||||||
|
: MT76_HWRRO_V3_1;
|
||||||
|
dev->mt76.rx_token_size = MT7996_TOKEN_SIZE +
|
||||||
|
wed->wlan.rx_npkt;
|
||||||
}
|
}
|
||||||
|
|
||||||
*irq = wed->irq;
|
*irq = wed->irq;
|
||||||
|
|||||||
Reference in New Issue
Block a user