Re: [PATCH V1 net-next 0/3] net: stmmac: implement clocks
From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-02-25 02:34:24
Hi Andrew,
I don't have experience with Ethernet switch, according to your points, you mean we can connect STMMAC to an Ethernet switch, and then Ethernet switch managed STMMAC by the MDIO bus but without checking whether STMMAC interface is opened or not, so STMMAC needs clocks for MDIO even interface is closed, right?
Correct. The MDIO bus has a different life cycle to the MAC. If any of stmmac_xgmac2_mdio_read(), stmmac_xgmac2_mdio_write(), stmmac_mdio_read(), and stmmac_mdio_write() need clocks ticking, you need to ensure the clock is ticking, because these functions can be called while the interface is not opened.
quoted
You said you copied the FEC driver. Take a look at that, it was initially broken in this way, and i needed to extend it when i got a board with an Ethernet switch attached to the FEC.
Could you point me how to implement clocks management to cover above Ethernet switch case? Or can we upstream this first and then fix it later for such case?
I actually got is wrong on the first attempt. So you need to look at:
42ea4457ae net: fec: normalize return value of pm_runtime_get_sync() in MDIO write
14d2b7c1a9 net: fec: fix initial runtime PM refcount
8fff755e9f net: fec: Ensure clocks are enabled while using mdio bus
And no, you cannot fix it later, because your patches potentially
break existing systems using an Ethernet switch. See:
ommit da29f2d84bd10234df570b7f07cbd0166e738230
Author: Jose Abreu [off-list ref]
Date: Tue Jan 7 13:35:42 2020 +0100
net: stmmac: Fixed link does not need MDIO Bus
When using fixed link we don't need the MDIO bus support.
...
Tested-by: Florian Fainelli <f.fainelli@gmail> # Lamobo R1 (fixed-link + MDIO sub node for roboswitch).
So there are boards which make use of a switch and MDIO. Florian might
however be able to run tests for you, if you ask him.
Andrew