linux-xiaomi-chiron/drivers/net/ethernet/stmicro/stmmac
Junxiao Chang 49725ffc15 net: stmmac: power up/down serdes in stmmac_open/release
This commit fixes DMA engine reset timeout issue in suspend/resume
with ADLink I-Pi SMARC Plus board which dmesg shows:
...
[   54.678271] PM: suspend exit
[   54.754066] intel-eth-pci 0000:00:1d.2 enp0s29f2: PHY [stmmac-3:01] driver [Maxlinear Ethernet GPY215B] (irq=POLL)
[   54.755808] intel-eth-pci 0000:00:1d.2 enp0s29f2: Register MEM_TYPE_PAGE_POOL RxQ-0
...
[   54.780482] intel-eth-pci 0000:00:1d.2 enp0s29f2: Register MEM_TYPE_PAGE_POOL RxQ-7
[   55.784098] intel-eth-pci 0000:00:1d.2: Failed to reset the dma
[   55.784111] intel-eth-pci 0000:00:1d.2 enp0s29f2: stmmac_hw_setup: DMA engine initialization failed
[   55.784115] intel-eth-pci 0000:00:1d.2 enp0s29f2: stmmac_open: Hw setup failed
...

The issue is related with serdes which impacts clock.  There is
serdes in ADLink I-Pi SMARC board ethernet controller. Please refer to
commit b9663b7ca6 ("net: stmmac: Enable SERDES power up/down sequence")
for detial. When issue is reproduced, DMA engine clock is not ready
because serdes is not powered up.

To reproduce DMA engine reset timeout issue with hardware which has
serdes in GBE controller, install Ubuntu. In Ubuntu GUI, click
"Power Off/Log Out" -> "Suspend" menu, it disables network interface,
then goes to sleep mode. When it wakes up, it enables network
interface again. Stmmac driver is called in this way:

1. stmmac_release: Stop network interface. In this function, it
   disables DMA engine and network interface;
2. stmmac_suspend: It is called in kernel suspend flow. But because
   network interface has been disabled(netif_running(ndev) is
   false), it does nothing and returns directly;
3. System goes into S3 or S0ix state. Some time later, system is
   waken up by keyboard or mouse;
4. stmmac_resume: It does nothing because network interface has
   been disabled;
5. stmmac_open: It is called to enable network interace again. DMA
   engine is initialized in this API, but serdes is not power on so
   there will be DMA engine reset timeout issue.

Similarly, serdes powerdown should be added in stmmac_release.
Network interface might be disabled by cmd "ifconfig eth0 down",
DMA engine, phy and mac have been disabled in ndo_stop callback,
serdes should be powered down as well. It doesn't make sense that
serdes is on while other components have been turned off.

If ethernet interface is in enabled state(netif_running(ndev) is true)
before suspend/resume, the issue couldn't be reproduced  because serdes
could be powered up in stmmac_resume.

Because serdes_powerup is added in stmmac_open, it doesn't need to be
called in probe function.

Fixes: b9663b7ca6 ("net: stmmac: Enable SERDES power up/down sequence")
Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
Reviewed-by: Voon Weifeng <weifeng.voon@intel.com>
Tested-by: Jimmy JS Chen <jimmyjs.chen@adlinktech.com>
Tested-by: Looi, Hong Aun <hong.aun.looi@intel.com>
Link: https://lore.kernel.org/r/20220923050448.1220250-1-junxiao.chang@intel.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2022-09-27 10:38:11 +02:00
..
altr_tse_pcs.c net: ethernet: stmmac: fix altr_tse_pcs function when using a fixed-link 2022-04-11 10:41:00 +01:00
altr_tse_pcs.h net: ethernet: stmmac: fix altr_tse_pcs function when using a fixed-link 2022-04-11 10:41:00 +01:00
chain_mode.c net: ethernet: stmicro: stmmac: move dma conf to dedicated struct 2022-07-25 19:38:57 -07:00
common.h
descs.h
descs_com.h
dwmac-anarion.c
dwmac-dwc-qos-eth.c net: stmmac: dwc-qos: Disable split header for Tegra194 2022-07-07 17:05:01 -07:00
dwmac-generic.c
dwmac-imx.c net: stmmac: dwmac-imx: comment spelling fix 2022-04-26 17:28:31 -07:00
dwmac-ingenic.c net: stmmac: fix leaks in probe 2022-07-13 14:21:42 +01:00
dwmac-intel-plat.c
dwmac-intel.c stmmac: intel: Simplify intel_eth_pci_remove() 2022-09-05 14:19:56 +01:00
dwmac-intel.h
dwmac-ipq806x.c net: ethernet: stmmac: reset force speed bit for ipq806x 2022-06-16 10:13:20 +02:00
dwmac-loongson.c stmmac: dwmac-loongson: change loongson_dwmac_driver from global to static 2022-04-04 12:47:54 +01:00
dwmac-lpc18xx.c
dwmac-mediatek.c stmmac: dwmac-mediatek: fix resource leak in probe 2022-07-28 10:43:04 -07:00
dwmac-meson.c
dwmac-meson8b.c
dwmac-oxnas.c
dwmac-qcom-ethqos.c net: stmmac: dwmac-qcom-ethqos: Enable RGMII functional clock on resume 2022-03-24 17:48:02 -07:00
dwmac-rk.c
dwmac-socfpga.c net: ethernet: stmmac: fix write to sgmii_adapter_base 2022-04-22 16:31:56 -07:00
dwmac-sti.c
dwmac-stm32.c
dwmac-sun8i.c net: stmmac: dwmac-sun8i: add missing of_node_put() in sun8i_dwmac_register_mdio_mux() 2022-04-29 19:24:08 -07:00
dwmac-sunxi.c
dwmac-visconti.c
dwmac4.h net: stmmac: switch to use interrupt for hw crosstimestamping 2022-07-18 11:14:35 +01:00
dwmac4_core.c net: stmmac: fix dma queue left shift overflow issue 2022-07-18 11:30:26 +01:00
dwmac4_descs.c net: stmmac: remove unused get_addr() callback 2022-05-18 13:59:15 +01:00
dwmac4_descs.h
dwmac4_dma.c
dwmac4_dma.h
dwmac4_lib.c
dwmac5.c
dwmac5.h
dwmac100.h
dwmac100_core.c
dwmac100_dma.c
dwmac1000.h
dwmac1000_core.c
dwmac1000_dma.c
dwmac_dma.h net: stmmac: dump gmac4 DMA registers correctly 2022-01-31 21:21:10 -08:00
dwmac_lib.c net: stmmac: work around sporadic tx issue on link-up 2022-08-25 12:40:56 -07:00
dwxgmac2.h
dwxgmac2_core.c
dwxgmac2_descs.c net: stmmac: remove unused get_addr() callback 2022-05-18 13:59:15 +01:00
dwxgmac2_dma.c
dwxlgmac2.h
enh_desc.c net: stmmac: remove unused get_addr() callback 2022-05-18 13:59:15 +01:00
hwif.c
hwif.h net: stmmac: remove unused get_addr() callback 2022-05-18 13:59:15 +01:00
Kconfig net: ethernet: stmmac: remove select QCOM_SOCINFO and make it optional 2022-06-19 09:52:47 +01:00
Makefile
mmc.h
mmc_core.c stmicro/stmmac: fix repeated words in comments 2022-07-01 20:13:30 -07:00
norm_desc.c net: stmmac: remove unused get_addr() callback 2022-05-18 13:59:15 +01:00
ring_mode.c net: ethernet: stmicro: stmmac: move dma conf to dedicated struct 2022-07-25 19:38:57 -07:00
stmmac.h net: ethernet: stmicro: stmmac: move dma conf to dedicated struct 2022-07-25 19:38:57 -07:00
stmmac_ethtool.c net: ethernet: stmicro: stmmac: move dma conf to dedicated struct 2022-07-25 19:38:57 -07:00
stmmac_hwtstamp.c net: stmmac: switch to use interrupt for hw crosstimestamping 2022-07-18 11:14:35 +01:00
stmmac_main.c net: stmmac: power up/down serdes in stmmac_open/release 2022-09-27 10:38:11 +02:00
stmmac_mdio.c net: stmmac: make mdio register skips PHY scanning for fixed-link 2022-06-17 10:55:35 +01:00
stmmac_pci.c net: stmmac: fix missing pci_disable_device() on error in stmmac_pci_probe() 2022-05-10 19:12:57 -07:00
stmmac_pcs.h
stmmac_platform.c net: stmmac: fix unbalanced ptp clock issue in suspend/resume flow 2022-07-15 12:06:56 +01:00
stmmac_platform.h
stmmac_ptp.c net: stmmac: switch to use interrupt for hw crosstimestamping 2022-07-18 11:14:35 +01:00
stmmac_ptp.h
stmmac_selftests.c net: ethernet: stmicro: stmmac: move dma conf to dedicated struct 2022-07-25 19:38:57 -07:00
stmmac_tc.c net: ethernet: stmicro: stmmac: move dma conf to dedicated struct 2022-07-25 19:38:57 -07:00
stmmac_xdp.c
stmmac_xdp.h