Subject: Re: [PATCH RFC 03/18] net: marvell: mvneta: Simplify EEE configuration

From: Andrew Lunn <[email-masked]>
Date: Fri, 17 Feb 2023 14:45:26 +0100

On Fri, Feb 17, 2023 at 11:59:39AM +0000, Russell King (Oracle) wrote:
> On Fri, Feb 17, 2023 at 04:42:15AM +0100, Andrew Lunn wrote:
> > @@ -4221,10 +4218,8 @@ static void mvneta_mac_link_up(struct phylink_config *config,
> >  
> >  	mvneta_port_up(pp);
> >  
> > -	if (phy && pp->eee_enabled) {
> > -		pp->eee_active = phy_init_eee(phy, false) >= 0;
> > -		mvneta_set_eee(pp, pp->eee_active && pp->tx_lpi_enabled);
> > -	}
> > +	if (phy)
> > +		mvneta_set_eee(pp, phy->eee_active && pp->tx_lpi_enabled);
> 
> Thinking about this a bit more, I'm not convinced this is properly safe.
> What protects phy->eee_active from changing here? The phydev mutex won't
> be held at this point.

That is one of the differences between phylib and phylink. For phylib,
the adjust_link callback is performed while holding phydev lock. So it
is guaranteed to be consistent.

> It's way more invasive, as it requires the mac_link_up() method
> signature to change, but I think it would be a cleaner approach
> overall.

Yes, i think it has to happen. But i also think it will have a
beneficial side effect. Very few MAC drivers implement EEE. Having
this parameters will make it much more visible, which could lead to
more MAC drivers adding EEE support.

     Andrew