net: stmmac: fix unbalanced ptp clock issue in suspend/resume flow
authorBiao Huang <biao.huang@mediatek.com>
Thu, 14 Jul 2022 06:00:14 +0000 (14:00 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Jul 2022 11:06:56 +0000 (12:06 +0100)
commitf4c7d8948e866918d61493264dbbd67e45ef2bda
tree0c2d8b2e1ea8a6e6aa5763bd0526613e5782641b
parent0d9a15913b871e03fdd3b3d90a2e665fb22f9bcf
net: stmmac: fix unbalanced ptp clock issue in suspend/resume flow

Current stmmac driver will prepare/enable ptp_ref clock in
stmmac_init_tstamp_counter().

The stmmac_pltfr_noirq_suspend will disable it once in suspend flow.

But in resume flow,
stmmac_pltfr_noirq_resume --> stmmac_init_tstamp_counter
stmmac_resume --> stmmac_hw_setup --> stmmac_init_ptp --> stmmac_init_tstamp_counter
ptp_ref clock reference counter increases twice, which leads to unbalance
ptp clock when resume back.

Move ptp_ref clock prepare/enable out of stmmac_init_tstamp_counter to fix it.

Fixes: 0735e639f129d ("net: stmmac: skip only stmmac_ptp_register when resume from suspend")
Signed-off-by: Biao Huang <biao.huang@mediatek.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