netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org,
	Nicolas Ferre <nicolas.ferre@microchip.com>
Subject: Re: [CFT 6/8] net: macb: use resolved link config in mac_link_up()
Date: Thu, 20 Feb 2020 10:18:28 +0000	[thread overview]
Message-ID: <20200220101828.GV25745@shell.armlinux.org.uk> (raw)
In-Reply-To: <20200219143036.GB3390@piout.net>

On Wed, Feb 19, 2020 at 03:30:36PM +0100, Alexandre Belloni wrote:
> Hi,
> 
> On 17/02/2020 17:24:21+0000, Russell King wrote:
> > Convert the macb ethernet driver to use the finalised link
> > parameters in mac_link_up() rather than the parameters in mac_config().
> > 
> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> > ---
> >  drivers/net/ethernet/cadence/macb.h      |  1 -
> >  drivers/net/ethernet/cadence/macb_main.c | 46 ++++++++++++++----------
> >  2 files changed, 27 insertions(+), 20 deletions(-)
> > 
> 
> I did test the series after rebasing on top of the at91rm9200 fix.
> 
> Here is what I tested:
> 
> diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
> index a3f0f27fc79a..ab827fb4b6b9 100644
> --- a/drivers/net/ethernet/cadence/macb.h
> +++ b/drivers/net/ethernet/cadence/macb.h
> @@ -1200,7 +1200,6 @@ struct macb {
>  	unsigned int		dma_burst_length;
>  
>  	phy_interface_t		phy_interface;
> -	int			speed;
>  
>  	/* AT91RM9200 transmit */
>  	struct sk_buff *skb;			/* holds skb until xmit interrupt completes */
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 7ab0bef5e1bd..3a7c26b08607 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -571,37 +571,20 @@ static void macb_mac_config(struct phylink_config *config, unsigned int mode,
>  
>  	old_ctrl = ctrl = macb_or_gem_readl(bp, NCFGR);
>  
> -	/* Clear all the bits we might set later */
> -	ctrl &= ~(MACB_BIT(SPD) | MACB_BIT(FD) | MACB_BIT(PAE));
> -
>  	if (bp->caps & MACB_CAPS_MACB_IS_EMAC) {
>  		if (state->interface == PHY_INTERFACE_MODE_RMII)
>  			ctrl |= MACB_BIT(RM9200_RMII);
>  	} else {
> -		ctrl &= ~(GEM_BIT(GBE) | GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL));
> -
> -		/* We do not support MLO_PAUSE_RX yet */
> -		if (state->pause & MLO_PAUSE_TX)
> -			ctrl |= MACB_BIT(PAE);
> +		ctrl &= ~(GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL));
>  
>  		if (state->interface == PHY_INTERFACE_MODE_SGMII)
>  			ctrl |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL);
>  	}
>  
> -	if (state->speed == SPEED_1000)
> -		ctrl |= GEM_BIT(GBE);
> -	else if (state->speed == SPEED_100)
> -		ctrl |= MACB_BIT(SPD);
> -
> -	if (state->duplex)
> -		ctrl |= MACB_BIT(FD);
> -
>  	/* Apply the new configuration, if any */
>  	if (old_ctrl ^ ctrl)
>  		macb_or_gem_writel(bp, NCFGR, ctrl);
>  
> -	bp->speed = state->speed;
> -
>  	spin_unlock_irqrestore(&bp->lock, flags);
>  }
>  
> @@ -635,10 +618,33 @@ static void macb_mac_link_up(struct phylink_config *config,
>  	struct net_device *ndev = to_net_dev(config->dev);
>  	struct macb *bp = netdev_priv(ndev);
>  	struct macb_queue *queue;
> +	unsigned long flags;
>  	unsigned int q;
> +	u32 ctrl;
> +
> +	spin_lock_irqsave(&bp->lock, flags);
> +
> +	ctrl = macb_or_gem_readl(bp, NCFGR);
> +
> +	ctrl &= ~(MACB_BIT(SPD) | MACB_BIT(FD));
> +
> +	if (speed == SPEED_100)
> +		ctrl |= MACB_BIT(SPD);
> +
> +	if (duplex)
> +		ctrl |= MACB_BIT(FD);
>  
>  	if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC)) {
> -		macb_set_tx_clk(bp->tx_clk, bp->speed, ndev);
> +		ctrl &= ~(GEM_BIT(GBE) | MACB_BIT(PAE));
> +
> +		if (speed == SPEED_1000)
> +			ctrl |= GEM_BIT(GBE);
> +
> +		/* We do not support MLO_PAUSE_RX yet */
> +		if (tx_pause)
> +			ctrl |= MACB_BIT(PAE);
> +
> +		macb_set_tx_clk(bp->tx_clk, speed, ndev);
>  
>  		/* Initialize rings & buffers as clearing MACB_BIT(TE) in link down
>  		 * cleared the pipeline and control registers.
> @@ -651,6 +657,10 @@ static void macb_mac_link_up(struct phylink_config *config,
>  				     bp->rx_intr_mask | MACB_TX_INT_FLAGS | MACB_BIT(HRESP));
>  	}
>  
> +	macb_or_gem_writel(bp, NCFGR, ctrl);
> +
> +	spin_unlock_irqrestore(&bp->lock, flags);
> +
>  	/* Enable Rx and Tx */
>  	macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(RE) | MACB_BIT(TE));
>  
> @@ -4432,8 +4442,6 @@ static int macb_probe(struct platform_device *pdev)
>  	else
>  		bp->phy_interface = interface;
>  
> -	bp->speed = SPEED_UNKNOWN;
> -
>  	/* IP specific init */
>  	err = init(pdev);
>  	if (err)
> 
> 

Thanks, that looks reasonable to me. I'll replace my patch with this
one if it's appropriate for net-next when I send this series for
merging.  However, I see most affected network driver maintainers
haven't responded yet, which is rather disappointing.  So, thanks
for taking the time to look at this.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

  reply	other threads:[~2020-02-20 10:18 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 17:22 [CFT 0/8] rework phylink interface for split MAC/PCS support Russell King - ARM Linux admin
2020-02-17 17:23 ` [CFT 1/8] net: phylink: propagate resolved link config via mac_link_up() Russell King
2020-02-17 18:03   ` Matthew Wilcox
2020-02-17 18:48     ` Russell King - ARM Linux admin
2020-02-17 21:54   ` Florian Fainelli
2020-02-18  1:53     ` Russell King - ARM Linux admin
2020-02-17 17:23 ` [CFT 2/8] net: dsa: " Russell King
2020-02-17 17:24 ` [CFT 3/8] net: mv88e6xxx: use resolved link config in mac_link_up() Russell King
2020-02-17 17:24 ` [CFT 4/8] net: axienet: " Russell King
2020-02-20 10:29   ` Russell King - ARM Linux admin
2020-02-24 12:24   ` Andre Przywara
2020-02-24 13:01     ` Russell King - ARM Linux admin
2020-02-17 17:24 ` [CFT 5/8] net: dpaa2-mac: " Russell King
2020-02-18 10:34   ` Russell King - ARM Linux admin
2020-02-18 10:42     ` Ioana Ciornei
2020-02-20 10:20       ` Russell King - ARM Linux admin
2020-02-17 17:24 ` [CFT 6/8] net: macb: " Russell King
2020-02-19 14:30   ` Alexandre Belloni
2020-02-20 10:18     ` Russell King - ARM Linux admin [this message]
2020-02-20 12:38       ` Andrew Lunn
2020-02-20 12:44         ` Russell King - ARM Linux admin
2020-02-21 20:25         ` Russell King - ARM Linux admin
2020-02-24 13:15       ` Russell King - ARM Linux admin
2020-02-24 14:37         ` Alexandre Belloni
2020-02-17 17:24 ` [CFT 7/8] net: mvneta: " Russell King
2020-02-17 17:24 ` [CFT 8/8] net: mvpp2: " Russell King
2020-02-17 17:33 ` [CFT 0/8] rework phylink interface for split MAC/PCS support Andrew Lunn
2020-02-17 18:51   ` Russell King - ARM Linux admin
2020-02-18 10:29     ` Russell King - ARM Linux admin
2020-06-21 14:33 ` Russell King - ARM Linux admin
2020-06-21 19:37   ` Vladimir Oltean
2020-06-21 20:02     ` Russell King - ARM Linux admin
2020-06-21 21:17       ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200220101828.GV25745@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).