Subject: Re: [PATCH net 2/3] net: mediatek: sgmii: autonegotiation is required

From: "Russell King (Oracle)" <[email-masked]>
Date: Thu, 19 Jan 2023 17:21:57 +0000

On Thu, Jan 19, 2023 at 06:12:47PM +0100, Bjørn Mork wrote:
> sgmii mode fails if autonegotiation is disabled.
> 
> Signed-off-by: Bjørn Mork <[email-masked]>
> ---
>  drivers/net/ethernet/mediatek/mtk_sgmii.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c
> index 481f2f1e39f5..d1f2bcb21242 100644
> --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c
> +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c
> @@ -62,14 +62,9 @@ static int mtk_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
>  	 * other words, 1000Mbps or 2500Mbps).
>  	 */
>  	if (interface == PHY_INTERFACE_MODE_SGMII) {
> -		sgm_mode = SGMII_IF_MODE_SGMII;
> -		if (phylink_autoneg_inband(mode)) {
> -			sgm_mode |= SGMII_REMOTE_FAULT_DIS |
> -				    SGMII_SPEED_DUPLEX_AN;
> -			use_an = true;
> -		} else {
> -			use_an = false;
> -		}
> +		sgm_mode = SGMII_IF_MODE_SGMII | SGMII_REMOTE_FAULT_DIS |
> +			   SGMII_SPEED_DUPLEX_AN;
> +		use_an = true;

I wasn't actually suggesting in our discussion that this is something
which should be changed.

The reference implementation for the expected behaviour is
phylink_mii_c22_pcs_config(), and it only enables in-band if "mode"
says so. If we have a PHY which has in-band disabled (yes, they do
exist) then having SGMII in-band unconditionally enabled breaks them,
and yes, those PHYs appear on SFP modules.

The proper answer is to use 'managed = "in-band-status";' in your DT
to have in-band used with SGMII.

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