Re: [PATCH V1 net-next 0/3] net: stmmac: implement clocks

3 messages, 2 authors, 2021-02-25 · open the first message on its own page

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

RE: [PATCH V1 net-next 0/3] net: stmmac: implement clocks

From: Joakim Zhang <hidden>
Date: 2021-02-25 11:49:20

-----Original Message-----
From: Andrew Lunn <andrew@lunn.ch>
Sent: 2021年2月25日 10:34
To: Joakim Zhang <redacted>
Cc: netdev <redacted>
Subject: Re: [PATCH V1 net-next 0/3] net: stmmac: implement clocks
quoted
Hi Andrew,
quoted
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.
Hi Andrew,

Thanks for you explanation, I still don't quite understand what the use case it is, could you give me more details, thanks a lot!
AFAIK now, there are two connections methods, we can abstract the layer:
	MAC <-> MAC, there is no PHY attached. It seems to know as Fixed link, right?
	MAC+PHY <-> PHY+MAC
From your expression, you should use an external Ethernet switch, if yes, why Ethernet switch needs to use MDIO bus to access another MAC's(STMMAC) PHY?

 
quoted
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.
quoted
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.
Hi Florian,

I am curious about " fixed-link + MDIO sub node for roboswitch ", how does this implement?

Florian, Andrew, I will send a V2, it could still has defects. Welcome to review the patch, I don't expect it to break existing systems. Thanks.

Best Regards,
Joakim Zhang
   Andrew

Re: [PATCH V1 net-next 0/3] net: stmmac: implement clocks

From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-02-25 13:15:18

Hi Andrew,

Thanks for you explanation, I still don't quite understand what the use case it is, could you give me more details, thanks a lot!
AFAIK now, there are two connections methods, we can abstract the layer:
	MAC <-> MAC, there is no PHY attached. It seems to know as Fixed link, right?
Yes, this is the most common way of connecting a switch.
	MAC+PHY <-> PHY+MAC
Switches can be connected like this, but not often. Why pay for two
PHYs which you do not need?
From your expression, you should use an external Ethernet switch, if
yes, why Ethernet switch needs to use MDIO bus to access another
MAC's(STMMAC) PHY?
The switch is on the same board as the MAC. Take a look at:
https://netdevconf.info/2.1/papers/distributed-switch-architecture.pdf

It explains the DSA architecture.

   Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help