net: stmmac: Set dma ring length before enabling the DMA
PATCH 1/1 net: stmmac: Set dma ring length before enabling the DMA
This was fixed in upstream by commit 7d9e6c5afab6 ("net: stmmac: Integrate XGMAC into main driver flow") that is a new feature commit.
We found a race condition in the DMA init sequence that hits if the PHY already has link up during stmmac_hw_setup. Since the ring length was programmed after enabling the RX path, we might receive a packet before the correct ring length is programmed. When that happened we could not get reliable interrupts for DMA RX and the MTL complained about RX FIFO overrun.
The correct init sequence according to the data book for DWC Ethernet QoS 4.10 is:
1. Write Ring length
2. Write Descriptor list base address
3. Start the DMA.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +9 -8
@@ -1618,6 +1618,15 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)return ret; } +/* set TX ring length */ +if (priv->hw->dma->set_tx_ring_len) + priv->hw->dma->set_tx_ring_len (priv->ioaddr, + (DMA_TX_SIZE -1 )); +/* set RX ring length */ +if (priv->hw->dma->set_rx_ring_len) + priv->hw->dma->set_rx_ring_len (priv->ioaddr, + (DMA_RX_SIZE -1 )); + priv->hw->dma->init (priv->ioaddr, pbl, fixed_burst, mixed_burst, aal, priv->dma_tx_phy, priv->dma_rx_phy, atds);
@@ -1767,14 +1776,6 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)if (priv->hw->pcs && priv->hw->mac->pcs_ctrl_ane) priv->hw->mac->pcs_ctrl_ane (priv->hw,1 , priv->hw->ps,0 ); -/* set TX ring length */ -if (priv->hw->dma->set_tx_ring_len) - priv->hw->dma->set_tx_ring_len (priv->ioaddr, - (DMA_TX_SIZE -1 )); -/* set RX ring length */ -if (priv->hw->dma->set_rx_ring_len) - priv->hw->dma->set_rx_ring_len (priv->ioaddr, - (DMA_RX_SIZE -1 ));/* Enable TSO */ if (priv->tso) priv->hw->dma->enable_tso (priv->ioaddr,1 ,STMMAC_CHAN0 );
Signature · 1 line
2.11.0
A message that is not in the archive (sent off-list or not yet received): 20190412141654.GQ11568@sasha-vm
Quoted 17 lines · Sasha Levin
Quoted 16 lines · Lars Persson
This was fixed in upstream by commit
7d9e6c5afab6("net: stmmac: Integrate XGMAC into main driver flow") that is a new feature commit.We found a race condition in the DMA init sequence that hits if the PHY already has link up during
stmmac_hw_setup. Since the ring length was programmed after enabling the RX path, we might receive a packet before the correct ring length is programmed. When that happened we could not get reliable interrupts for DMA RX and the MTL complained about RX FIFO overrun.The correct init sequence according to the data book for DWC Ethernet QoS 4.10 is:
1. Write Ring length
2. Write Descriptor list base address
3. Start the DMA.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Lars Persson <[email protected]>Cc [email protected] # 4.9.xCc Giuseppe Cavallaro <[email protected]>Cc Alexandre Torgue <[email protected]>Cc Jose Abreu <[email protected]>What about 4.14?
7d9e6c5afab6isn't in it either.
I will send a separate patch for 4.14 in some days.
-Lars
Sasha Levin
maintainerQuoted 26 lines · Lars Persson
Quoted 23 lines · Sasha Levin
Quoted 21 lines · Lars Persson
This was fixed in upstream by commit
7d9e6c5afab6("net: stmmac: Integrate XGMAC into main driver flow") that is a new feature commit.We found a race condition in the DMA init sequence that hits if the PHY already has link up during
stmmac_hw_setup. Since the ring length was programmed after enabling the RX path, we might receive a packet before the correct ring length is programmed. When that happened we could not get reliable interrupts for DMA RX and the MTL complained about RX FIFO overrun.The correct init sequence according to the data book for DWC Ethernet QoS 4.10 is:
1. Write Ring length
2. Write Descriptor list base address
3. Start the DMA.Signed-off-by Lars Persson <[email protected]>Cc [email protected] # 4.9.xCc Giuseppe Cavallaro <[email protected]>Cc Alexandre Torgue <[email protected]>Cc Jose Abreu <[email protected]>
Quoted 4 lines
Quoted 2 lines
What about 4.14?
7d9e6c5afab6isn't in it either.I will send a separate patch for 4.14 in some days.
Okay. I can't merge this one until we have the 4.14 as well (otherwise, people who upgrade from 4.9 to 4.14 will see a regression), so when it's posted I can do both.
--
Thanks,
Sasha