Subject: Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

From: "Russell King (Oracle)" <[email-masked]>
Date: Thu, 21 Mar 2024 15:19:58 +0000

On Thu, Mar 21, 2024 at 04:02:54PM +0100, Andrew Lunn wrote:
> On Thu, Mar 21, 2024 at 05:29:55PM +0800, Yanteng Si wrote:
> > 
> > 在 2024/3/20 01:02, Serge Semin 写道:
> > > > > Due to a bug in the chip's internal PHY, the network is still not working after
> > > > > the first self-negotiation, and it needs to be self-negotiated again.
> > > Then please describe the bug in more details then.
> > > 
> > > Getting back to the code you implemented here. In the in-situ comment
> > > you say: "We need to use the PS bit to check if the controller's
> > > status is correct and reset PHY if necessary." By calling
> > > phy_restart_aneg() you don't reset the PHY.
> > > 
> > > Moreover if "PS" flag is set, then the MAC has been pre-configured to
> > > work in the 10/100Mbps mode. Since 1000Mbps speed is requested, the
> > > MAC_CTRL_REG.PS flag will be cleared later in the
> > > stmmac_mac_link_up() method and then phylink_start() shall cause the
> > > link speed re-auto-negotiation. Why do you need the auto-negotiation
> > > started for the default MAC config which will be changed just in a
> > > moment later? All of that seems weird.
> > 
> > When switching speeds (from 100M to 1000M), the phy cannot output clocks,
> > 
> > resulting in the unavailability of the network card.  At this time, a reset
> > of the
> > 
> > phy is required.
> 
> reset, or restart of autoneg?
> 
> > BTW, This bug has been fixed in gnet of 2k2000 (0x10, 7a13).
> > 
> > > 
> > > Most importantly I have doubts the networking subsystem maintainers
> > > will permit you calling the phy_restart_aneg() method from the MAC
> > > driver code.
> 
> That is O.K. It should have a comment explaining that it is working
> around a hardware bug. And you need to take care of locking. But a MAC
> driver can call this, e.g. if it implements ethtool nway_reset, it
> needs to do exactly this. See phy_ethtool_nway_reset().

However, because stmmac uses phylink, we should be adding phylink
interfaces that forward to phylib to avoid the layering violation.

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