net:ethernet: mtk_wed: setup WDMA_RING_TX(0) for non-DBDC MT7986
Subsystems (4)
PATCH 1/1 net:ethernet: mtk_wed: setup WDMA_RING_TX(0) for non-DBDC MT7986
WDMA_RING_TX(0) is required to set MTK_WED_WDMA_RING_TX for WED RX but on a non-DBDC MT7986 it is never setup because idx is 1.
Setting MTK_WED_WDMA_RING_TX with WDMA_RING_TX(1) is not feasible because WED still tries to send through WDMA_RING_TX(0). This is verified with register dump.
Fix this by calling mtk_wed_wdma_tx_ring_setup if WDMA_RING_TX(0) is not setup and guard it with mtk_wed_is_v2.
--- drivers/net/ethernet/mediatek/mtk_wed.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mediatek/mtk_wed.c +4 -0
@@ -2334,6 +2334,10 @@ mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask)if (!dev->rx_wdma[i].desc)mtk_wed_wdma_rx_ring_setup (dev, i,16 , false); +if (mtk_wed_is_v2 (dev->hw)) +if (!dev->tx_wdma[0 ].desc) +mtk_wed_wdma_tx_ring_setup (dev,0 ,MTK_WED_WDMA_RING_SIZE , false); +if (dev->wlan.hw_rro) {for (i =0 ; i <MTK_WED_RX_PAGE_QUEUES ; i++) { u32 addr = MTK_WED_RRO_MSDU_PG_CTRL0(i) +
Signature · 1 line
2.47.3
Paolo Abeni
maintainerFrom: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev/
---
net:ethernet: mtk_wed: setup WDMA_RING_TX(0) for non-DBDC MT7986
This commit updates mtk_wed_start() to configure WDMA_RING_TX(0) on non-DBDC MT7986 devices. It adds a call to mtk_wed_wdma_tx_ring_setup() for v2 hardware if the descriptor is not yet set up.
drivers/net/ethernet/mediatek/mtk_wed.c mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask) · line 2335
Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_wed.c +0
-0@@ -2334,6 +2334,10 @@ mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask)if (!dev->rx_wdma[i].desc)mtk_wed_wdma_rx_ring_setup (dev, i,16 , false);
[Severity: High]
This isn't a bug introduced by this patch, but does this loop need to check the return value of mtk_wed_wdma_rx_ring_setup()?
If mtk_wed_wdma_rx_ring_setup() returns -ENOMEM, the hardware registers are not programmed, but mtk_wed_start() continues execution and enables DMA.
Could this lead to hardware DMA using an uninitialized ring base address?
drivers/net/ethernet/mediatek/mtk_wed.c mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask) · line 2339
Quoted 4 lines
drivers/net/ethernet/mediatek/mtk_wed.c +3
-0+if (mtk_wed_is_v2 (dev->hw)) +if (!dev->tx_wdma[0 ].desc) +mtk_wed_wdma_tx_ring_setup (dev,0 ,MTK_WED_WDMA_RING_SIZE , false);
[Severity: High]
Are there similar error handling concerns with this new call to mtk_wed_wdma_tx_ring_setup()?
Like the RX path, if dma_alloc_coherent() fails inside this setup function, it returns -ENOMEM without programming the hardware registers.
Since mtk_wed_start() doesn't check this return value, it will proceed to enable hardware DMA, which might attempt to use an uninitialized DMA address.
[Severity: High]
Does the check for !dev->tx_wdma[0].desc prevent necessary hardware initialization after a warm reset?
When the WLAN driver triggers a hardware reset, the WED hardware registers are cleared, and mtk_wed_start() is called again.
Because dev->tx_wdma[0].desc was allocated during the initial start, the guard will evaluate to false, skipping the hardware register reprogramming for tx_wdma[0].
Will the hardware DMA end up using a zeroed ring base address after a reset?
Quoted 4 lines
drivers/net/ethernet/mediatek/mtk_wed.c +1
-0+if (dev->wlan.hw_rro) {for (i =0 ; i <MTK_WED_RX_PAGE_QUEUES ; i++) { u32 addr = MTK_WED_RRO_MSDU_PG_CTRL0(i) +
Signature · 1 line
This is an AI-generated review.
Quoted 25 lines · Paolo Abeni
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev/
---
net:ethernet:mtk_wed: setupWDMA_RING_TX(0)for non-DBDC MT7986This commit updates
mtk_wed_start()to configureWDMA_RING_TX(0)on non-DBDC MT7986 devices. It adds a call tomtk_wed_wdma_tx_ring_setup()for v2 hardware if the descriptor is not yet set up.drivers/net/ethernet/mediatek/mtk_wed.c mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask) · line 2335
Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_wed.c +0
-0@@ -2334,6 +2334,10 @@ mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask)if (!dev->rx_wdma[i].desc)mtk_wed_wdma_rx_ring_setup (dev, i,16 , false);[Severity: High]
This isn't a bug introduced by this patch, but does this loop need to check the return value ofmtk_wed_wdma_rx_ring_setup()?
Quoted 4 lines
If
mtk_wed_wdma_rx_ring_setup()returns-ENOMEM, the hardware registers are not programmed, butmtk_wed_start()continues execution and enables DMA.Could this lead to hardware DMA using an uninitialized ring base address?
Hi,
I am not sure how to proceed with this one. mtk_wed_start is a void function and both mt7915 and mt7996's dma function that calls it don't have return value handling either.
Quoted 20 lines
drivers/net/ethernet/mediatek/mtk_wed.c mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask) · line 2339
Quoted 5 lines
drivers/net/ethernet/mediatek/mtk_wed.c +3
-0+if (mtk_wed_is_v2 (dev->hw)) +if (!dev->tx_wdma[0 ].desc) +mtk_wed_wdma_tx_ring_setup (dev,0 ,MTK_WED_WDMA_RING_SIZE , false);[Severity: High]
Are there similar error handling concerns with this new call tomtk_wed_wdma_tx_ring_setup()?Like the RX path, if
dma_alloc_coherent()fails inside this setup function, it returns-ENOMEMwithout programming the hardware registers.Since
mtk_wed_start()doesn't check this return value, it will proceed to enable hardware DMA, which might attempt to use an uninitialized DMA address.[Severity: High]
Does the check for !dev->tx_wdma[0].desc prevent necessary hardware initialization after a warm reset?
Quoted 8 lines
When the WLAN driver triggers a hardware reset, the WED hardware registers are cleared, and
mtk_wed_start()is called again.Because dev->tx_wdma[0].desc was allocated during the initial start, the guard will evaluate to false, skipping the hardware register reprogramming for tx_wdma[0].
Will the hardware DMA end up using a zeroed ring base address after a reset?
During warm reset, MTK_WDMA_RING_TX(i) + MTK_WED_RING_OFS_CPU_IDX is set to 0. Other parts are left untouched.
After the warm reset, mtk_wed_rx_ring_setup will be called with reset=true, which also callsmtk_wed_wdma_tx_ring_setup with reset=true.
reset=true will skip ring allocation and call an extra mtk_wed_ring_reset but for non-DBDC mt7986, this path won't happen for the tx_wdma[0].
Usually rx_ring and tx_wdma are paired together but this is a special case that rx_ring[1] and
tx_wdma[1] are allocated but tx_wdma[0] is still required. Maybe something like this would work?
Runs only if wed is v2 and rx ring 0 is not allocated, reset only when tx_wdma[0] was already allocated.
if (mtk_wed_is_v2 && !dev->rx_ring[0].desc)
mtk_wed_wdma_tx_ring_setup(dev, 0, MTK_WED_WDMA_RING_SIZE,
!!dev->tx_wdma[0].desc);
Best regards,
Zhi-Jun
Quoted 8 lines
drivers/net/ethernet/mediatek/mtk_wed.c mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask) · line 2343
Quoted 5 lines
drivers/net/ethernet/mediatek/mtk_wed.c +1
-0+if (dev->wlan.hw_rro) {for (i =0 ; i <MTK_WED_RX_PAGE_QUEUES ; i++) { u32 addr = MTK_WED_RRO_MSDU_PG_CTRL0(i) +--
This is an AI-generated review.