Re: [PATCH net v3 2/2] net: fec: Suspend the PHY on probe

From: Maxime Chevallier
Date: Wed Mar 06 2024 - 13:12:21 EST


Hello John,

I'm adding Andrew and Russell to the thread as PHY maintainers and
reviewers.

On Wed, 6 Mar 2024 13:37:45 +0000
John Ernberg <john.ernberg@xxxxxxxx> wrote:

> Since the power management is now performed by the FEC instead of generic
> pm the PHY will not suspend until the link has been up.
>
> Therefor suspend it on probe. It will be resumed by {of_,}phy_connect()
> when the link is brought up.
>
> Since {of_,}phy_connect() and phy_disconnect() will resume and suspend the
> PHY when the link is brought up and down respectively, and phy_stop() and
> phy_start() will resume and suspend the PHY in the suspend-resume paths
> there is no need for any additional calls anywhere.
>
> Signed-off-by: John Ernberg <john.ernberg@xxxxxxxx>

[...]

> @@ -2539,8 +2539,10 @@ static int fec_enet_mii_init(struct platform_device *pdev)
> /* find all the PHY devices on the bus and set mac_managed_pm to true */
> for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
> phydev = mdiobus_get_phy(fep->mii_bus, addr);
> - if (phydev)
> + if (phydev) {
> phydev->mac_managed_pm = true;
> + phy_suspend(phydev);
> + }

I don't think that's correct. here phy_suspend() is being called before
the PHY got attached, so the PHY wasn't initialized at all at that
point (which I guess is your issue as the PHY is still in the state it
was configured into by the bootloader)

Following the code paths, it looks like this works for you because the
PHY you're using has a .suspend callback populated, but for any PHY
that uses the genphy driver, this will do nothing at all (the PHY isn't
yet attached to the genphy ops, therefore genphy_suspend won't be
called).

Best regards,

Maxime