Subject: Re: [PATCH 1/2] net: phylink: add helper to initialize phylink's phydev

From: "Russell King (Oracle)" <[email-masked]>
Date: Mon, 5 Dec 2022 15:57:53 +0000

On Mon, Dec 05, 2022 at 05:33:27PM +0200, Claudiu Beznea wrote:
> Add helper to initialize phydev embedded in a phylink object.
> 
> Signed-off-by: Claudiu Beznea <[email-masked]>
> ---
>  drivers/net/phy/phylink.c | 10 ++++++++++
>  include/linux/phylink.h   |  1 +
>  2 files changed, 11 insertions(+)
> 
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 09cc65c0da93..1e2478b8cd5f 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -2541,6 +2541,16 @@ int phylink_ethtool_set_eee(struct phylink *pl, struct ethtool_eee *eee)
>  }
>  EXPORT_SYMBOL_GPL(phylink_ethtool_set_eee);
>  
> +/**
> + * phylink_init_phydev() - initialize phydev associated to phylink
> + * @pl: a pointer to a &struct phylink returned from phylink_create()
> + */
> +int phylink_init_phydev(struct phylink *pl)
> +{
> +	return phy_init_hw(pl->phydev);
> +}
> +EXPORT_SYMBOL_GPL(phylink_init_phydev);

I'd guess this is something that many MAC drivers will need to do when
resuming if the PHY has lost power.

Maybe a better solution would be to integrate it into phylink_resume(),
when we know that the PHY has lost power - maybe the MAC driver can
tell phylink that detail, and be updated to use phylink_suspend() and
phylink_resume() ?

macb_set_wol() sets bp->wol's MACB_WOL_ENABLED flag depending on
whether WAKE_MAGIC is set in wolopts. No other wolopts are supported.
Generic code sets netdev->wol_enabled if set_wol() was successful and
wolopts is nonzero, indicating that WoL is enabled, and thus
phylink_stop() won't be called if WoL is enabled (similar to what
macb_suspend() is doing.)

Given that the macb MAC seems to be implementing WoL, it should call
phylink_suspend() with mac_wol=true.

Please can you look into this, thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!