mbox series

[net-next,0/7] net: Korina improvements

Message ID 20210413204818.23350-1-tsbogend@alpha.franken.de
Headers show
Series net: Korina improvements | expand

Message

Thomas Bogendoerfer April 13, 2021, 8:48 p.m. UTC
While converting Mikrotik RB532 support to use device tree I stumbled
over the korina ethernet driver, which used way too many MIPS specific
hacks. This series cleans this all up.

Thomas Bogendoerfer (7):
  net: korina: Fix MDIO functions
  net: korina: Use devres functions
  net: korina: Remove not needed cache flushes
  net: korina: Remove nested helpers
  net: korina: Use DMA API
  net: korina: Only pass mac address via platform data
  net: korina: Make driver COMPILE_TESTable

 arch/mips/rb532/devices.c     |   5 +-
 drivers/net/ethernet/Kconfig  |   2 +-
 drivers/net/ethernet/korina.c | 542 ++++++++++++++++++++++++----------
 3 files changed, 386 insertions(+), 163 deletions(-)

Comments

Andrew Lunn April 14, 2021, 7:36 p.m. UTC | #1
> +static int korina_mdio_wait(struct korina_private *lp)

> +{

> +	int timeout = 1000;

> +

> +	while ((readl(&lp->eth_regs->miimind) & 1) && timeout-- > 0)

> +		udelay(1);

> +

> +	if (timeout <= 0)

> +		return -1;

> +

> +	return 0;


Using readl_poll_timeout_atomic() would be better.


> +}

> +

> +static int korina_mdio_read(struct net_device *dev, int phy, int reg)

>  {

>  	struct korina_private *lp = netdev_priv(dev);

>  	int ret;

>  

> -	mii_id = ((lp->rx_irq == 0x2c ? 1 : 0) << 8);

> +	if (korina_mdio_wait(lp))

> +		return -1;


This should really be -ETIMEDOUT

>  	dev->watchdog_timeo = TX_TIMEOUT;

>  	netif_napi_add(dev, &lp->napi, korina_poll, NAPI_POLL_WEIGHT);

>  

> -	lp->phy_addr = (((lp->rx_irq == 0x2c? 1:0) << 8) | 0x05);

>  	lp->mii_if.dev = dev;

> -	lp->mii_if.mdio_read = mdio_read;

> -	lp->mii_if.mdio_write = mdio_write;

> -	lp->mii_if.phy_id = lp->phy_addr;

> +	lp->mii_if.mdio_read = korina_mdio_read;

> +	lp->mii_if.mdio_write = korina_mdio_write;

> +	lp->mii_if.phy_id = 1;

>  	lp->mii_if.phy_id_mask = 0x1f;

>  	lp->mii_if.reg_num_mask = 0x1f;


You could also replace all the mii code with phylib.

    Andrew
Thomas Bogendoerfer April 14, 2021, 8:36 p.m. UTC | #2
On Wed, Apr 14, 2021 at 09:36:04PM +0200, Andrew Lunn wrote:
> > +static int korina_mdio_wait(struct korina_private *lp)

> > +{

> > +	int timeout = 1000;

> > +

> > +	while ((readl(&lp->eth_regs->miimind) & 1) && timeout-- > 0)

> > +		udelay(1);

> > +

> > +	if (timeout <= 0)

> > +		return -1;

> > +

> > +	return 0;

> 

> Using readl_poll_timeout_atomic() would be better.


I'll have a look

> 

> 

> > +}

> > +

> > +static int korina_mdio_read(struct net_device *dev, int phy, int reg)

> >  {

> >  	struct korina_private *lp = netdev_priv(dev);

> >  	int ret;

> >  

> > -	mii_id = ((lp->rx_irq == 0x2c ? 1 : 0) << 8);

> > +	if (korina_mdio_wait(lp))

> > +		return -1;

> 

> This should really be -ETIMEDOUT


ok.

> >  	dev->watchdog_timeo = TX_TIMEOUT;

> >  	netif_napi_add(dev, &lp->napi, korina_poll, NAPI_POLL_WEIGHT);

> >  

> > -	lp->phy_addr = (((lp->rx_irq == 0x2c? 1:0) << 8) | 0x05);

> >  	lp->mii_if.dev = dev;

> > -	lp->mii_if.mdio_read = mdio_read;

> > -	lp->mii_if.mdio_write = mdio_write;

> > -	lp->mii_if.phy_id = lp->phy_addr;

> > +	lp->mii_if.mdio_read = korina_mdio_read;

> > +	lp->mii_if.mdio_write = korina_mdio_write;

> > +	lp->mii_if.phy_id = 1;

> >  	lp->mii_if.phy_id_mask = 0x1f;

> >  	lp->mii_if.reg_num_mask = 0x1f;

> 

> You could also replace all the mii code with phylib.


that's on my todo.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]