All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Florian Fainelli <f.fainelli@gmail.com>, netdev@vger.kernel.org
Cc: andrew@lunn.ch, kuba@kernel.org, davem@davemloft.net
Subject: Re: [PATCH net 2/3] net: phy: broadcom: Only set BMCR.PDOWN to suspend
Date: Wed, 10 Mar 2021 22:43:41 +0100	[thread overview]
Message-ID: <c8c68a18-334b-373d-f24c-2e646b121881@gmail.com> (raw)
In-Reply-To: <f7f0e6d2-447d-4b12-94f6-5e483e02ca87@gmail.com>

On 10.03.2021 22:15, Florian Fainelli wrote:
> On 3/10/21 1:07 PM, Heiner Kallweit wrote:
>> On 10.03.2021 21:41, Florian Fainelli wrote:
>>> B50212E PHYs have been observed to get into an incorrect state with the
>>> visible effect of having both activity and link LEDs flashing
>>> alternatively instead of being turned off as intended when
>>> genphy_suspend() was issued. The BCM54810 is a similar design and
>>> equally suffers from that issue.
>>>
>>> The datasheet is not particularly clear whether a read/modify/write
>>> sequence is acceptable and only indicates that BMCR.PDOWN=1 should be
>>> utilized to enter the power down mode. When this was done the PHYs were
>>> always measured to have power levels that match the expectations and
>>> LEDs powered off.
>>>
>>> Fixes: fe26821fa614 ("net: phy: broadcom: Wire suspend/resume for BCM54810")
>>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>>> ---
>>>  drivers/net/phy/broadcom.c | 17 ++++++++++++++++-
>>>  1 file changed, 16 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
>>> index b8eb736fb456..b33ffd44f799 100644
>>> --- a/drivers/net/phy/broadcom.c
>>> +++ b/drivers/net/phy/broadcom.c
>>> @@ -388,6 +388,21 @@ static int bcm54xx_config_init(struct phy_device *phydev)
>>>  	return 0;
>>>  }
>>>  
>>> +static int bcm54xx_suspend(struct phy_device *phydev)
>>> +{
>>> +	/* We cannot perform a read/modify/write like what genphy_suspend()
>>> +	 * does because depending on the time we can observe the PHY having
>>> +	 * both of its LEDs flashing indicating that it is in an incorrect
>>> +	 * state and not powered down as expected.
>>> +	 *
>>> +	 * There is not a clear indication in the datasheet whether a
>>> +	 * read/modify/write would be acceptable, but a blind write to the
>>> +	 * register has been proven to be functional unlike the
>>> +	 * Read/Modify/Write.
>>> +	 */
>>> +	return phy_write(phydev, MII_BMCR, BMCR_PDOWN);
>>
>> This clears all other bits in MII_BMCR, incl. ANENABLE and the ones used in
>> forced mode. So you have to rely on somebody calling genphy_config_aneg()
>> to sync the register bits with the values cached in struct phy_device
>> on resume. Typically the phylib state machine takes care, but do we have
>> to consider use cases where this is not the case?
> 
> Good point, how about if we had forced the link before suspending, does
> PHYLIB take care of re-applying the same parameters? It arguably should
> do that in all cases given that power to the PHY can be cut depending on
> the suspend mode.
> 

When entering power-down mode the link is lost and we go to HALTED state.
On resume, phy_start() sets UP state and state machine calls
phy_start_aneg(), which takes care of syncing the BMCR forced mode bits.
A potential issue arises if we have a driver that doesn't use the
phylib state machine and prefers to do it on its own.
IIRC I once stumbled across this when I also relied on the phylib state
machine running in a change.
I'm not sure whether we can run into a problem, but it's worth spending
a thought before somebody complains after applying the change.

  reply	other threads:[~2021-03-10 21:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 20:41 [PATCH net 0/3] net: phy: broadcom: Suspend fixes Florian Fainelli
2021-03-10 20:41 ` [PATCH net 1/3] net: phy: broadcom: Add power down exit reset state delay Florian Fainelli
2021-03-10 22:36   ` kernel test robot
2021-03-10 22:36     ` kernel test robot
2021-03-10 23:20   ` kernel test robot
2021-03-10 23:20     ` kernel test robot
2021-03-10 20:41 ` [PATCH net 2/3] net: phy: broadcom: Only set BMCR.PDOWN to suspend Florian Fainelli
2021-03-10 21:07   ` Heiner Kallweit
2021-03-10 21:15     ` Florian Fainelli
2021-03-10 21:43       ` Heiner Kallweit [this message]
2021-03-10 22:56         ` Florian Fainelli
2021-03-11  3:31           ` Florian Fainelli
2021-03-10 20:41 ` [PATCH net 3/3] net: phy: broadcom: Use corrected suspend for BCM54811 Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c8c68a18-334b-373d-f24c-2e646b121881@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.