[PATCH] net: designware: improve ethernet DMA reset

Artem Lapkin email2tema at gmail.com
Wed Jul 21 08:19:10 CEST 2021


Problem: uboot ethernet always have "DMA reset timeout" after
linux usage, detected on VIM2 VIM3 VIM3L amlogic devices,
mainline uboot and mainline linux > 5.1? .

How-to reproduce:

1) Poweron device => ethernet uboot work fine.
2) Linux start and ethernet interface up and same works.
3) Reboot to uboot again and we cant use ethernet anymore.
uboot always have "DMA reset timeout" inside designware_eth_init()
only poweroff/poweron cycle can solve this problem.

Solution: add phy_reset() into waiting DMA reset cycle,
this insertion doesn't break normal behaviour (maybe).

Note: same need explore real problem why its happens! because this 
patch may be just hack.

Signed-off-by: Artem Lapkin <art at khadas.com>
---
 drivers/net/designware.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 5d92257e..6485c46d 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -371,6 +371,7 @@ int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
 	struct eth_dma_regs *dma_p = priv->dma_regs_p;
 	unsigned int start;
 	int ret;
+	int phy_reset_force = 0;
 
 	writel(readl(&dma_p->busmode) | DMAMAC_SRST, &dma_p->busmode);
 
@@ -389,6 +390,9 @@ int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
 			printf("DMA reset timeout\n");
 			return -ETIMEDOUT;
 		}
+		// forced phy reset after 0.2s can help with DMAMAC_SRST
+		if (phy_reset_force++ == 2)
+			phy_reset(priv->phydev);
 
 		mdelay(100);
 	};
-- 
2.25.1



More information about the U-Boot mailing list