linux/drivers/net/ethernet/stmicro/stmmac
Joakim Zhang 90702dcd19 net: stmmac: fix MAC not working when system resume back with WoL active
We can reproduce this issue with below steps:
1) enable WoL on the host
2) host system suspended
3) remote client send out wakeup packets
We can see that host system resume back, but can't work, such as ping failed.

After a bit digging, this issue is introduced by the commit 46f69ded98
("net: stmmac: Use resolved link config in mac_link_up()"), which use
the finalised link parameters in mac_link_up() rather than the
parameters in mac_config().

There are two scenarios for MAC suspend/resume in STMMAC driver:

1) MAC suspend with WoL inactive, stmmac_suspend() call
phylink_mac_change() to notify phylink machine that a change in MAC
state, then .mac_link_down callback would be invoked. Further, it will
call phylink_stop() to stop the phylink instance. When MAC resume back,
firstly phylink_start() is called to start the phylink instance, then
call phylink_mac_change() which will finally trigger phylink machine to
invoke .mac_config and .mac_link_up callback. All is fine since
configuration in these two callbacks will be initialized, that means MAC
can restore the state.

2) MAC suspend with WoL active, phylink_mac_change() will put link
down, but there is no phylink_stop() to stop the phylink instance, so it
will link up again, that means .mac_config and .mac_link_up would be
invoked before system suspended. After system resume back, it will do
DMA initialization and SW reset which let MAC lost the hardware setting
(i.e MAC_Configuration register(offset 0x0) is reset). Since link is up
before system suspended, so .mac_link_up would not be invoked after
system resume back, lead to there is no chance to initialize the
configuration in .mac_link_up callback, as a result, MAC can't work any
longer.

After discussed with Russell King [1], we confirm that phylink framework
have not take WoL into consideration yet. This patch calls
phylink_suspend()/phylink_resume() functions which is newly introduced
by Russell King to fix this issue.

[1] https://lore.kernel.org/netdev/20210901090228.11308-1-qiangqing.zhang@nxp.com/

Fixes: 46f69ded98 ("net: stmmac: Use resolved link config in mac_link_up()")
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-09-07 14:04:59 +01:00
..
altr_tse_pcs.c
altr_tse_pcs.h
chain_mode.c
common.h net: stmmac: add ethtool per-queue irq statistic support 2021-08-16 11:36:04 +01:00
descs_com.h
descs.h
dwmac4_core.c net: stmmac: add est_irq_status callback function for GMAC 4.10 and 5.10 2021-07-26 12:29:44 +01:00
dwmac4_descs.c
dwmac4_descs.h
dwmac4_dma.c net: stmmac: Do not enable RX FIFO overflow interrupts 2021-05-07 15:53:57 -07:00
dwmac4_dma.h net: stmmac: Add HW descriptor prefetch setting for DWMAC Core 5.20 onwards 2021-04-22 15:02:40 -07:00
dwmac4_lib.c net: stmmac: add ethtool per-queue irq statistic support 2021-08-16 11:36:04 +01:00
dwmac4.h
dwmac5.c net: stmmac: enable platform specific safety features 2021-06-01 16:59:50 -07:00
dwmac5.h net: stmmac: enable platform specific safety features 2021-06-01 16:59:50 -07:00
dwmac100_core.c
dwmac100_dma.c
dwmac100.h
dwmac1000_core.c
dwmac1000_dma.c
dwmac1000.h net: stmmac: dwmac1000: Fix extended MAC address registers definition 2021-06-11 13:05:55 -07:00
dwmac_dma.h
dwmac_lib.c
dwmac-anarion.c
dwmac-dwc-qos-eth.c
dwmac-generic.c
dwmac-imx.c
dwmac-ingenic.c net: stmmac: Fix error return code in ingenic_mac_probe() 2021-06-16 12:02:38 -07:00
dwmac-intel-plat.c
dwmac-intel.c stmmac: intel: set PCI_D3hot in suspend 2021-06-29 11:34:48 -07:00
dwmac-intel.h stmmac: intel: move definitions to dwmac-intel header file 2021-06-12 13:10:52 -07:00
dwmac-ipq806x.c net: ethernet: stmmac: Do not use unreachable() in ipq806x_gmac_probe() 2021-08-07 09:45:46 +01:00
dwmac-loongson.c stmmac: dwmac-loongson:Fix missing return value 2021-09-06 12:52:52 +01:00
dwmac-lpc18xx.c
dwmac-mediatek.c
dwmac-meson8b.c
dwmac-meson.c
dwmac-oxnas.c
dwmac-qcom-ethqos.c net: stmmac: Use devm_platform_ioremap_resource_byname() 2021-06-09 15:24:43 -07:00
dwmac-rk.c net: stmmac: dwmac-rk: fix unbalanced pm_runtime_enable warnings 2021-08-25 10:37:17 +01:00
dwmac-socfpga.c
dwmac-sti.c
dwmac-stm32.c
dwmac-sun8i.c
dwmac-sunxi.c net: stmicro: handle clk_prepare() failure during init 2021-05-13 17:33:18 +02:00
dwmac-visconti.c
dwxgmac2_core.c net: stmmac: enable platform specific safety features 2021-06-01 16:59:50 -07:00
dwxgmac2_descs.c
dwxgmac2_dma.c
dwxgmac2.h
dwxlgmac2.h
enh_desc.c
hwif.c
hwif.h net: pcs: xpcs: convert to phylink_pcs_ops 2021-06-03 13:30:43 -07:00
Kconfig ethernet: fix PTP_1588_CLOCK dependencies 2021-08-13 17:49:05 -07:00
Makefile stmmac: pci: Add dwmac support for Loongson 2021-06-18 11:48:34 -07:00
mmc_core.c
mmc.h
norm_desc.c
ring_mode.c
stmmac_ethtool.c ethtool: extend coalesce setting uAPI with CQE mode 2021-08-24 07:38:29 -07:00
stmmac_hwtstamp.c net: stmmac: Add support for external trigger timestamping 2021-04-14 12:57:45 -07:00
stmmac_main.c net: stmmac: fix MAC not working when system resume back with WoL active 2021-09-07 14:04:59 +01:00
stmmac_mdio.c net: stmmac: reverse Christmas tree notation in stmmac_xpcs_setup 2021-06-11 13:43:55 -07:00
stmmac_pci.c net: stmmac: enable platform specific safety features 2021-06-01 16:59:50 -07:00
stmmac_pcs.h
stmmac_platform.c stmmac: platform: Fix signedness bug in stmmac_probe_config_dt() 2021-07-07 13:43:50 -07:00
stmmac_platform.h
stmmac_ptp.c net: stmmac: ptp: update tas basetime after ptp adjust 2021-07-05 10:16:17 -07:00
stmmac_ptp.h net: stmmac: Add support for external trigger timestamping 2021-04-14 12:57:45 -07:00
stmmac_selftests.c
stmmac_tc.c net: stmmac: fix kernel panic due to NULL pointer dereference of plat->est 2021-08-23 11:49:34 +01:00
stmmac_xdp.c net: stmmac: fix kernel panic due to NULL pointer dereference of xsk_pool 2021-08-25 10:59:39 +01:00
stmmac_xdp.h net: stmmac: Enable RX via AF_XDP zero-copy 2021-04-13 15:06:51 -07:00
stmmac.h stmmac: Revert "stmmac: align RX buffers" 2021-08-20 14:44:49 -07:00