All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: designware: improve ethernet DMA reset
@ 2021-07-21  6:19 Artem Lapkin
  2021-07-26  7:38 ` Neil Armstrong
  0 siblings, 1 reply; 2+ messages in thread
From: Artem Lapkin @ 2021-07-21  6:19 UTC (permalink / raw)
  To: narmstrong, joe.hershberger, rfried.dev
  Cc: u-boot, u-boot-amlogic, khilman, christianshewitt,
	martin.blumenstingl, art, nick, gouwa

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@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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: designware: improve ethernet DMA reset
  2021-07-21  6:19 [PATCH] net: designware: improve ethernet DMA reset Artem Lapkin
@ 2021-07-26  7:38 ` Neil Armstrong
  0 siblings, 0 replies; 2+ messages in thread
From: Neil Armstrong @ 2021-07-26  7:38 UTC (permalink / raw)
  To: Artem Lapkin, joe.hershberger, rfried.dev
  Cc: u-boot, u-boot-amlogic, khilman, christianshewitt,
	martin.blumenstingl, art, nick, gouwa

Hi,

On 21/07/2021 08:19, Artem Lapkin wrote:
> 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.

Interesting, maybe add this phy_reset() call only if the GPIO reset is not available ?

Neil

> 
> Signed-off-by: Artem Lapkin <art@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);
>  	};
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-26  7:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21  6:19 [PATCH] net: designware: improve ethernet DMA reset Artem Lapkin
2021-07-26  7:38 ` Neil Armstrong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.