Subject: Re: [PATCH net-next v10 6/6] net: stmmac: dwmac-loongson: Add Loongson GNET support

From: "Russell King (Oracle)" <[email-masked]>
Date: Wed, 10 Apr 2024 14:07:36 +0100

On Tue, Apr 09, 2024 at 10:04:34PM +0800, Yanteng Si wrote:
> +	/* The GMAC device with PCI ID 7a03 does not support any pause mode.
> +	 * The GNET device (only LS7A2000) does not support half-duplex.
> +	 */
> +	if (pdev->device == PCI_DEVICE_ID_LOONGSON_GMAC) {
> +		priv->hw->link.caps = MAC_10FD | MAC_100FD |
> +			MAC_1000FD;
> +	} else {

I'm sorry, but what follows looks totally broken to me.

> +		priv->hw->link.caps = (MAC_ASYM_PAUSE |
> +			MAC_SYM_PAUSE | MAC_10FD | MAC_100FD | MAC_1000FD);

Parens not required.

This sets 10Mbps full duplex, 100Mbps full duplex, 1000Mbps full duplex.
It does *not* set 10Mbps half duplex, 100Mbps half duplex, nor 1000Mbps
half duplex.

> +
> +		if (loongson_gmac == DWMAC_CORE_3_70) {
> +			priv->hw->link.caps &= ~(MAC_10HD |
> +				MAC_100HD | MAC_1000HD);
> +		}

Braces not required.

This clears 10Mbps half duplex, 100Mbps half duplex, 1000Mbps half
duplex, all of which were _NOT_ set. Therefore this code as written
can be entirely deleted.

Alternatively, this code is completely untested and is functionally
incorrect.

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