diff mbox series

LF-2678 net: ethernet: stmmac: delete the eee_ctrl_timer after napi disabled

Message ID 20201202085949.3279-2-qiangqing.zhang@nxp.com
State New
Headers show
Series LF-2678 net: ethernet: stmmac: delete the eee_ctrl_timer after napi disabled | expand

Commit Message

Joakim Zhang Dec. 2, 2020, 8:59 a.m. UTC
From: Fugang Duan <fugang.duan@nxp.com>

There have chance to re-enable the eee_ctrl_timer and fire the timer
in napi callback after delete the timer in .stmmac_release(), which
introduces to access eee registers in the timer function after clocks
are disabled then causes system hang.

It is safe to delete the timer after napi disabled and disable lpi mode.

Tested-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Reviewed-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Joakim Zhang Dec. 2, 2020, 9:12 a.m. UTC | #1
Hi,

Please ignore this patch due to wrongly send out. Sorry.

Best Regards,
Joakim Zhang

> -----Original Message-----

> From: Joakim Zhang <qiangqing.zhang@nxp.com>

> Sent: 2020年12月2日 17:00

> To: peppe.cavallaro@st.com; alexandre.torgue@st.com;

> joabreu@synopsys.com

> Cc: davem@davemloft.net; kuba@kernel.org; netdev@vger.kernel.org;

> dl-linux-imx <linux-imx@nxp.com>

> Subject: [PATCH] LF-2678 net: ethernet: stmmac: delete the eee_ctrl_timer

> after napi disabled

> 

> From: Fugang Duan <fugang.duan@nxp.com>

> 

> There have chance to re-enable the eee_ctrl_timer and fire the timer in napi

> callback after delete the timer in .stmmac_release(), which introduces to

> access eee registers in the timer function after clocks are disabled then causes

> system hang.

> 

> It is safe to delete the timer after napi disabled and disable lpi mode.

> 

> Tested-by: Joakim Zhang <qiangqing.zhang@nxp.com>

> Reviewed-by: Joakim Zhang <qiangqing.zhang@nxp.com>

> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>

> ---

>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++++++---

>  1 file changed, 10 insertions(+), 3 deletions(-)

> 

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

> b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

> index cc1f17b170f0..7e655fa34589 100644

> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

> @@ -2933,9 +2933,6 @@ static int stmmac_release(struct net_device *dev)

>  	struct platform_device *pdev = to_platform_device(priv->device);

>  	u32 chan;

> 

> -	if (priv->eee_enabled)

> -		del_timer_sync(&priv->eee_ctrl_timer);

> -

>  	if (device_may_wakeup(priv->device))

>  		phylink_speed_down(priv->phylink, false);

>  	/* Stop and disconnect the PHY */

> @@ -2954,6 +2951,11 @@ static int stmmac_release(struct net_device *dev)

>  	if (priv->lpi_irq > 0)

>  		free_irq(priv->lpi_irq, dev);

> 

> +	if (priv->eee_enabled) {

> +		priv->tx_path_in_lpi_mode = false;

> +		del_timer_sync(&priv->eee_ctrl_timer);

> +	}

> +

>  	/* Stop TX/RX DMA and clear the descriptors */

>  	stmmac_stop_all_dma(priv);

> 

> @@ -5224,6 +5226,11 @@ int stmmac_suspend(struct device *dev)

>  	for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)

>  		del_timer_sync(&priv->tx_queue[chan].txtimer);

> 

> +	if (priv->eee_enabled) {

> +		priv->tx_path_in_lpi_mode = false;

> +		del_timer_sync(&priv->eee_ctrl_timer);

> +	}

> +

>  	/* Stop TX/RX DMA */

>  	stmmac_stop_all_dma(priv);

> 

> --

> 2.17.1
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index cc1f17b170f0..7e655fa34589 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2933,9 +2933,6 @@  static int stmmac_release(struct net_device *dev)
 	struct platform_device *pdev = to_platform_device(priv->device);
 	u32 chan;
 
-	if (priv->eee_enabled)
-		del_timer_sync(&priv->eee_ctrl_timer);
-
 	if (device_may_wakeup(priv->device))
 		phylink_speed_down(priv->phylink, false);
 	/* Stop and disconnect the PHY */
@@ -2954,6 +2951,11 @@  static int stmmac_release(struct net_device *dev)
 	if (priv->lpi_irq > 0)
 		free_irq(priv->lpi_irq, dev);
 
+	if (priv->eee_enabled) {
+		priv->tx_path_in_lpi_mode = false;
+		del_timer_sync(&priv->eee_ctrl_timer);
+	}
+
 	/* Stop TX/RX DMA and clear the descriptors */
 	stmmac_stop_all_dma(priv);
 
@@ -5224,6 +5226,11 @@  int stmmac_suspend(struct device *dev)
 	for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
 		del_timer_sync(&priv->tx_queue[chan].txtimer);
 
+	if (priv->eee_enabled) {
+		priv->tx_path_in_lpi_mode = false;
+		del_timer_sync(&priv->eee_ctrl_timer);
+	}
+
 	/* Stop TX/RX DMA */
 	stmmac_stop_all_dma(priv);