[PATCH v2 net] net: stmmac: dwmac4: extend timeout for VLAN Tag register busy bit check

Shenwei Wang shenwei.wang at nxp.com
Mon Sep 23 09:18:00 PDT 2024



> -----Original Message-----
> From: Serge Semin <fancer.lancer at gmail.com>
> Sent: Sunday, September 22, 2024 5:18 PM
> To: Shenwei Wang <shenwei.wang at nxp.com>
> Cc: David S. Miller <davem at davemloft.net>; Eric Dumazet
> <edumazet at google.com>; Jakub Kicinski <kuba at kernel.org>; Paolo Abeni
> <pabeni at redhat.com>; Maxime Coquelin <mcoquelin.stm32 at gmail.com>;
> horms at kernel.org; Alexandre Torgue <alexandre.torgue at foss.st.com>; Jose
> Abreu <joabreu at synopsys.com>; Ong Boon Leong <boon.leong.ong at intel.com>;
> Wong Vee Khee <vee.khee.wong at intel.com>; Chuah Kim Tatt
> <kim.tatt.chuah at intel.com>; netdev at vger.kernel.org; linux-stm32 at st-md-
> mailman.stormreply.com; linux-arm-kernel at lists.infradead.org;
> imx at lists.linux.dev; dl-linux-imx <linux-imx at nxp.com>
> Subject: [EXT] Re: [PATCH v2 net] net: stmmac: dwmac4: extend timeout for
> VLAN Tag register busy bit check
> >
> > -     for (i = 0; i < timeout; i++) {
> > -             val = readl(ioaddr + GMAC_VLAN_TAG);
> > -             if (!(val & GMAC_VLAN_TAG_CTRL_OB))
> > -                     return 0;
> > -             udelay(1);
> > -     }
> 
> > +     ret = readl_poll_timeout(ioaddr + GMAC_VLAN_TAG, val,
> > +                              !(val & GMAC_VLAN_TAG_CTRL_OB),
> > +                              1000, timeout);
> > +     if (!ret)
> > +             return 0;
> >
> >       netdev_err(dev, "Timeout accessing MAC_VLAN_Tag_Filter\n");
> 
> 1. Just drop the timeout local variable and use the 500000 literal directly. There is
> no point in such parametrization especially you have already added the delay as
> is.
> 
> 2. A more traditional, readable and maintainable pattern is the error-check
> statement after the call. So seeing you are changing this part of the method
> anyway, let's convert it to:
> 
> +       ret = readl_poll_timeout(ioaddr + GMAC_VLAN_TAG, val,
> +                                !(val & GMAC_VLAN_TAG_CTRL_OB),
> +                                1000, timeout);
> +       if (ret) {
> +               netdev_err(dev, "Timeout accessing MAC_VLAN_Tag_Filter\n");
> +               return ret;
> +       }
> +
> +       return 0;
> 

Hi Serge,

Good suggestions! Will send out a new version.

Thanks,
Shenwei

> -Serge(y)
> 
> >
> > --
> > 2.34.1
> >
> >



More information about the linux-arm-kernel mailing list