]> git.baikalelectronics.ru Git - kernel.git/commit
net: stmmac: fix system hang caused by eee_ctrl_timer during suspend/resume
authorJoakim Zhang <qiangqing.zhang@nxp.com>
Wed, 8 Sep 2021 07:43:35 +0000 (15:43 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 Sep 2021 11:28:26 +0000 (12:28 +0100)
commita62e35e9df3fe36baea34cdf0e98c70e2d3e38ec
tree6437de2b5fe3d352a9679db4c91075cc61206a3e
parentdb0f1ab5d4f9e4d090f0bfb0b95d81403301363f
net: stmmac: fix system hang caused by eee_ctrl_timer during suspend/resume

commit cfdaddd672ad ("net: stmmac: delete the eee_ctrl_timer after
napi disabled"), this patch tries to fix system hang caused by eee_ctrl_timer,
unfortunately, it only can resolve it for system reboot stress test. System
hang also can be reproduced easily during system suspend/resume stess test
when mount NFS on i.MX8MP EVK board.

In stmmac driver, eee feature is combined to phylink framework. When do
system suspend, phylink_stop() would queue delayed work, it invokes
stmmac_mac_link_down(), where to deactivate eee_ctrl_timer synchronizly.
In above commit, try to fix issue by deactivating eee_ctrl_timer obviously,
but it is not enough. Looking into eee_ctrl_timer expire callback
stmmac_eee_ctrl_timer(), it could enable hareware eee mode again. What is
unexpected is that LPI interrupt (MAC_Interrupt_Enable.LPIEN bit) is always
asserted. This interrupt has chance to be issued when LPI state entry/exit
from the MAC, and at that time, clock could have been already disabled.
The result is that system hang when driver try to touch register from
interrupt handler.

The reason why above commit can fix system hang issue in stmmac_release()
is that, deactivate eee_ctrl_timer not just after napi disabled, further
after irq freed.

In conclusion, hardware would generate LPI interrupt when clock has been
disabled during suspend or resume, since hardware is in eee mode and LPI
interrupt enabled.

Interrupts from MAC, MTL and DMA level are enabled and never been disabled
when system suspend, so postpone clocks management from suspend stage to
noirq suspend stage should be more safe.

Fixes: cfdaddd672ad ("net: stmmac: delete the eee_ctrl_timer after napi disabled")
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c