From: Francesco Dolcini <hidden> Date: 2021-12-15 11:02:01
On Wed, Dec 15, 2021 at 10:36:52AM +0100, Andrew Lunn wrote:
On Tue, Dec 14, 2021 at 11:35:48PM +0100, Francesco Dolcini wrote:
quoted
Hello Andrew,
On Tue, Dec 14, 2021 at 07:54:54PM +0100, Andrew Lunn wrote:
quoted
What i don't particularly like about this is that the MAC driver is
doing it. Meaning if this PHY is used with any other MAC, the same
code needs adding there.
This is exactly the same case as phy_reset_after_clk_enable() [1][2], to
me it does not look that bad.
quoted
So maybe in the phy driver, add a suspend handler, which asserts the
reset. This call here will take it out of reset, so applying the reset
you need?
Asserting the reset in the phylib in suspend path is a bad idea, in the
general case in which the PHY is powered in suspend the
power-consumption is likely to be higher if the device is in reset
compared to software power-down using the BMCR register (at least for
the PHY datasheet I checked).
Maybe i don't understand your hardware.
You have a regulator providing power of the PHY.
You have a reset, i guess a GPIO, connected to the reset pin of the
PHY.
What you could do is:
PHY driver suspend handler does a phy_device_reset(ndev->phydev, 1)
to put the PHY into reset.
MAC driver disables the regulator.
Power consumption should now be 0, since it does not have any power.
On resume, the MAC enables the regulator. At this point, the PHY gets
power, but is still held in reset. It is now consuming power, but not
doing anything. The MAC calls phy_hw_init(), which calls
phy_device_reset(ndev->phydev, 0), taking the PHY out of reset.
Hopefully, this release from reset is enough to make the PHY work.
This is all correct and will solve the issue, however ...
The problem I see is that nor the phylib nor the PHY driver is aware
that the PHY was powered down, if we unconditionally assert the reset in
the suspend callback in the PHY driver/lib this will affect in a bad
case the most common use case in which we keep the PHY powered in
suspend.
We would have to move the regulator in the PHY driver (phy/micrel.c) to
do it properly.
The reason is that the power consumption in reset is higher in reset
compared to the normal PHY software power down.
This will create a power consumption regression for lot of users.
Doing this into the FEC driver would not have this issue, since we know
if we have a regulator (I guess you saw my one line patch for it).
On Wed, Dec 15, 2021 at 10:29:07AM +0000, Russell King (Oracle) wrote:
Here's another question which no one seems to have considered. If the
PHY power source can be controlled, why doesn't the firmware describe
the power supply for the PHY, and why doesn't the PHY driver control
the PHY power source? Why is that in the SoC network driver?
Legacy/historical reasons ...
In the first RFC patch for this issue this was mentioned by Philippe,
but than the discussion went into another direction.
As I wrote above if we handle both reset/regulator in the PHY driver it
should work, just a little bit tricky because phy/micrel.c handle a
whole family of phys.
On Wed, Dec 15, 2021 at 10:25:14AM +0000, Joakim Zhang wrote:
As I mentioned before, both mac and phylib have not taken PHY reset
into consideration during system suspend/resume scenario. As Andrew
suggested, you could move this into phy driver suspend function, this
is a corner case. One point I don't understand, why do you reject to
assert reset signal during system suspended?
See my answer to Andrew above, in short asserting the reset without
disabling the regulator will create a regression on the power
consumption.
Any agreement on how to move forward?
1. add phy_reset_after_power_on() and call it from FEC driver (current
patchset)
2. assert phy reset in FEC driver suspend (one line patch from me in
this thread)
3. move regulator to phy/micrel.c and assert reset in the phy driver resume
callback
4. ?
?
Francesco
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-12-15 19:34:14
This is all correct and will solve the issue, however ...
The problem I see is that nor the phylib nor the PHY driver is aware
that the PHY was powered down, if we unconditionally assert the reset in
the suspend callback in the PHY driver/lib this will affect in a bad
case the most common use case in which we keep the PHY powered in
suspend.
We know if the PHY should be left up because of WoL. So that is not an
issue. We can also put the PHY into lower power mode, before making
the call to put the PHY into reset. If the reset is not implemented,
the PHY stays in low power mode. If it is implemented, it is both in
lower power mode and held in reset. And if the regulator is provided,
the power will go off.
The reason is that the power consumption in reset is higher in reset
compared to the normal PHY software power down.
Does the datasheet have numbers for in lower power mode and held in
reset? We only have an issue if held in reset when in low power mode
consumes more power than simply in low power mode.
Andrew
From: Francesco Dolcini <hidden> Date: 2021-12-15 19:49:18
On Wed, Dec 15, 2021 at 08:34:00PM +0100, Andrew Lunn wrote:
quoted
The reason is that the power consumption in reset is higher in reset
compared to the normal PHY software power down.
Does the datasheet have numbers for in lower power mode and held in
reset? We only have an issue if held in reset when in low power mode
consumes more power than simply in low power mode.
The numbers for KSZ9131, Table 6-3: Power Consumption from datasheet [0]
61.2mW in reset, 24.4mW in software power down (3.3VDD)
40.9mW in reset, 12.5mW in software power down (2.5VDD)
Francesco
[0] https://ww1.microchip.com/downloads/en/DeviceDoc/00002841B.pdf
-----Original Message-----
From: Francesco Dolcini <redacted>
Sent: 2021年12月15日 19:02
To: Andrew Lunn <andrew@lunn.ch>; Russell King (Oracle)
[off-list ref]; Joakim Zhang [off-list ref]
Cc: Russell King (Oracle) <linux@armlinux.org.uk>; Francesco Dolcini
[off-list ref]; Philippe Schenker
[off-list ref]; netdev@vger.kernel.org; Joakim Zhang
[off-list ref]; David S . Miller [off-list ref];
Heiner Kallweit [off-list ref]; Jakub Kicinski [off-list ref];
Fabio Estevam [off-list ref]; linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 3/3] net: fec: reset phy on resume after
power-up
[...]
On Wed, Dec 15, 2021 at 10:25:14AM +0000, Joakim Zhang wrote:
quoted
As I mentioned before, both mac and phylib have not taken PHY reset
into consideration during system suspend/resume scenario. As Andrew
suggested, you could move this into phy driver suspend function, this
is a corner case. One point I don't understand, why do you reject to
assert reset signal during system suspended?
See my answer to Andrew above, in short asserting the reset without
disabling the regulator will create a regression on the power consumption.
As I can see, when system suspended, PHY is totally powered down, since you disable the
regulator. At this situation, if you assert reset signal, you mean it will increase the power
consumption? PHY is totally powered down, why assert reset signal still affect PHY?
Best Regards,
Joakim Zhang
From: Francesco Dolcini <hidden> Date: 2021-12-16 07:52:21
On Thu, Dec 16, 2021 at 04:52:39AM +0000, Joakim Zhang wrote:
As I can see, when system suspended, PHY is totally powered down,
since you disable the regulator. At this situation, if you
assert reset signal, you mean it will increase the power
consumption? PHY is totally powered down, why assert reset
signal still affect PHY?
In general there are *other* use cases in which the PHY is powered in
suspend. We should not create a regression there.
Francesco
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-12-16 10:24:39
On Thu, Dec 16, 2021 at 08:52:16AM +0100, Francesco Dolcini wrote:
On Thu, Dec 16, 2021 at 04:52:39AM +0000, Joakim Zhang wrote:
quoted
As I can see, when system suspended, PHY is totally powered down,
since you disable the regulator. At this situation, if you
assert reset signal, you mean it will increase the power
consumption? PHY is totally powered down, why assert reset
signal still affect PHY?
In general there are *other* use cases in which the PHY is powered in
suspend. We should not create a regression there.
Yes, this is the sticking point. We can do what you want, but
potentially, the change affects others.
I think you need to move the regulator into phylib, so the PHY driver
can do the right thing. It is really the only entity which knows what
is the correct thing to do.
Andrew
From: Francesco Dolcini <hidden> Date: 2021-12-16 11:24:38
On Thu, Dec 16, 2021 at 11:24:24AM +0100, Andrew Lunn wrote:
I think you need to move the regulator into phylib, so the PHY driver
can do the right thing. It is really the only entity which knows what
is the correct thing to do.
Do you believe that the right place is the phylib and not the phy driver?
Is this generic enough?
Francesco
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-12-16 11:28:31
On Thu, Dec 16, 2021 at 12:24:33PM +0100, Francesco Dolcini wrote:
On Thu, Dec 16, 2021 at 11:24:24AM +0100, Andrew Lunn wrote:
quoted
I think you need to move the regulator into phylib, so the PHY driver
can do the right thing. It is really the only entity which knows what
is the correct thing to do.
Do you believe that the right place is the phylib and not the phy driver?
Is this generic enough?
It is split. phylib can do the lookup in DT, get the regulator and
provide a helper to enable/disable it. So very similar to the reset.
The phy driver would then use the helpers. It probably needs to look
into the phydev structure to see what is actually available, is there
a reset, a regulator etc, and then decide what is best to do given the
available resources.
Andrew
From: Francesco Dolcini <hidden> Date: 2021-12-16 11:31:10
On Thu, Dec 16, 2021 at 12:28:19PM +0100, Andrew Lunn wrote:
On Thu, Dec 16, 2021 at 12:24:33PM +0100, Francesco Dolcini wrote:
quoted
On Thu, Dec 16, 2021 at 11:24:24AM +0100, Andrew Lunn wrote:
quoted
I think you need to move the regulator into phylib, so the PHY driver
can do the right thing. It is really the only entity which knows what
is the correct thing to do.
quoted
Do you believe that the right place is the phylib and not the phy driver?
Is this generic enough?
It is split. phylib can do the lookup in DT, get the regulator and
provide a helper to enable/disable it. So very similar to the reset.
Sounds good.
Can we safely assume that we do have at most one regulator for the phy?
Francesco