From: Corentin Labbe <clabbe.montjoie@gmail.com>
To: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
Cc: alexandre.torgue@st.com, netdev@vger.kernel.org,
davem@davemloft.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 07/17] net: stmmac: replace stmmac_mdio_busy_wait by readl_poll_timeout
Date: Tue, 31 Jan 2017 11:39:01 +0100 [thread overview]
Message-ID: <20170131103901.GA15482@Red> (raw)
In-Reply-To: <299b8e9a-00fe-173e-a125-5e7e27f123d1@st.com>
On Tue, Jan 31, 2017 at 11:13:49AM +0100, Giuseppe CAVALLARO wrote:
> On 1/31/2017 10:11 AM, Corentin Labbe wrote:
> > The stmmac_mdio_busy_wait() function do the same job than
> > readl_poll_timeout().
> > So is is better to replace it.
> >
> > Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
>
> I just wonder if you also tested it, this impacts all the platforms
> where SMA block is used
I have tested all patch in this series on my cubieboard2 (dwmac-sunxi) and my opipc/pine64/bpim2+ (dwmac-sun8i)
(Yes I could have said that in cover letter).
So this code was tested on two different stmmac glue driver.
>
> if yes, pls consider my:
>
> Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
>
> > ---
> > drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 33 ++++++++---------------
> > 1 file changed, 11 insertions(+), 22 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> > index c24bef2..d9893cf 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> > @@ -21,6 +21,7 @@
> > *******************************************************************************/
> >
> > #include <linux/io.h>
> > +#include <linux/iopoll.h>
> > #include <linux/mii.h>
> > #include <linux/of.h>
> > #include <linux/of_gpio.h>
> > @@ -38,22 +39,6 @@
> > #define MII_GMAC4_WRITE (1 << MII_GMAC4_GOC_SHIFT)
> > #define MII_GMAC4_READ (3 << MII_GMAC4_GOC_SHIFT)
> >
> > -static int stmmac_mdio_busy_wait(void __iomem *ioaddr, unsigned int mii_addr)
> > -{
> > - unsigned long curr;
> > - unsigned long finish = jiffies + 3 * HZ;
> > -
> > - do {
> > - curr = jiffies;
> > - if (readl(ioaddr + mii_addr) & MII_BUSY)
> > - cpu_relax();
> > - else
> > - return 0;
> > - } while (!time_after_eq(curr, finish));
> > -
> > - return -EBUSY;
> > -}
> > -
> > /**
> > * stmmac_mdio_read
> > * @bus: points to the mii_bus structure
> > @@ -70,7 +55,7 @@ static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg)
> > struct stmmac_priv *priv = netdev_priv(ndev);
> > unsigned int mii_address = priv->hw->mii.addr;
> > unsigned int mii_data = priv->hw->mii.data;
> > -
> > + u32 v;
> > int data;
> > u32 value = MII_BUSY;
> >
> > @@ -82,12 +67,14 @@ static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg)
> > if (priv->plat->has_gmac4)
> > value |= MII_GMAC4_READ;
> >
> > - if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address))
> > + if (readl_poll_timeout(priv->ioaddr + mii_address, v, !(v & MII_BUSY),
> > + 100, 10000))
> > return -EBUSY;
> >
> > writel(value, priv->ioaddr + mii_address);
> >
> > - if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address))
> > + if (readl_poll_timeout(priv->ioaddr + mii_address, v, !(v & MII_BUSY),
> > + 100, 10000))
> > return -EBUSY;
> >
> > /* Read the data from the MII data register */
> > @@ -111,7 +98,7 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
> > struct stmmac_priv *priv = netdev_priv(ndev);
> > unsigned int mii_address = priv->hw->mii.addr;
> > unsigned int mii_data = priv->hw->mii.data;
> > -
> > + u32 v;
> > u32 value = MII_BUSY;
> >
> > value |= (phyaddr << priv->hw->mii.addr_shift)
> > @@ -126,7 +113,8 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
> > value |= MII_WRITE;
> >
> > /* Wait until any existing MII operation is complete */
> > - if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address))
> > + if (readl_poll_timeout(priv->ioaddr + mii_address, v, !(v & MII_BUSY),
> > + 100, 10000))
> > return -EBUSY;
> >
> > /* Set the MII address register to write */
> > @@ -134,7 +122,8 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
> > writel(value, priv->ioaddr + mii_address);
> >
> > /* Wait until any existing MII operation is complete */
> > - return stmmac_mdio_busy_wait(priv->ioaddr, mii_address);
> > + return readl_poll_timeout(priv->ioaddr + mii_address, v, !(v & MII_BUSY),
> > + 100, 10000);
> > }
> >
> > /**
> >
>
next prev parent reply other threads:[~2017-01-31 10:39 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-31 9:11 [PATCH 00/17] net: stmmac: misc fix Corentin Labbe
2017-01-31 9:11 ` [PATCH 01/17] net: stmmac: fix the typo on MAC_RNABLE_RX Corentin Labbe
2017-01-31 10:03 ` Giuseppe CAVALLARO
2017-01-31 9:11 ` [PATCH 02/17] net: stmmac: Remove the bus_setup function pointer Corentin Labbe
2017-01-31 10:02 ` Giuseppe CAVALLARO
2017-01-31 9:11 ` [PATCH 03/17] net: stmmac: fix some typos in comments Corentin Labbe
2017-01-31 10:03 ` Giuseppe CAVALLARO
2017-01-31 9:11 ` [PATCH 04/17] net: stmmac: remove freesoftware address Corentin Labbe
2017-01-31 9:11 ` [PATCH 05/17] net: stmmac: remplace asm/io.h by linux/io.h Corentin Labbe
2017-01-31 9:11 ` [PATCH 06/17] net: stmmac: fix some code style problem Corentin Labbe
2017-01-31 10:05 ` Giuseppe CAVALLARO
2017-01-31 9:11 ` [PATCH 07/17] net: stmmac: replace stmmac_mdio_busy_wait by readl_poll_timeout Corentin Labbe
2017-01-31 10:13 ` Giuseppe CAVALLARO
2017-01-31 10:39 ` Corentin Labbe [this message]
2017-01-31 10:44 ` Giuseppe CAVALLARO
2017-01-31 9:11 ` [PATCH 08/17] net: stmmac: Use readl_poll_timeout Corentin Labbe
2017-01-31 9:11 ` [PATCH 09/17] net: stmmac: replace ENOSYS by EINVAL Corentin Labbe
2017-01-31 10:06 ` Giuseppe CAVALLARO
2017-01-31 9:11 ` [PATCH 10/17] net: stmmac: Correct the error message about invalid speed Corentin Labbe
2017-01-31 10:07 ` Giuseppe CAVALLARO
2017-01-31 9:11 ` [PATCH 11/17] net: stmmac: Rewrite two test against NULL value Corentin Labbe
2017-01-31 10:07 ` Giuseppe CAVALLARO
2017-01-31 9:11 ` [PATCH 12/17] net: stmmac: rename rx_crc to rx_crc_errors Corentin Labbe
2017-01-31 10:08 ` Giuseppe CAVALLARO
2017-01-31 9:11 ` [PATCH 13/17] net: stmmac: Implement NAPI for TX Corentin Labbe
2017-01-31 10:28 ` Giuseppe CAVALLARO
2017-01-31 13:38 ` Corentin Labbe
2017-02-01 4:12 ` David Miller
2017-02-03 13:41 ` Corentin Labbe
2017-02-03 15:15 ` David Miller
2017-02-03 15:58 ` Corentin Labbe
2017-01-31 9:11 ` [PATCH 14/17] net: stmmac: print phy information Corentin Labbe
2017-01-31 10:10 ` Giuseppe CAVALLARO
2017-02-03 13:16 ` Corentin Labbe
2017-01-31 9:11 ` [PATCH 15/17] net: stmmac: remove dead code in stmmac_tx_clean Corentin Labbe
2017-01-31 10:21 ` Giuseppe CAVALLARO
2017-01-31 9:11 ` [PATCH 16/17] net: stmmac: remove unused variable in sysfs_display_ring Corentin Labbe
2017-01-31 10:11 ` Giuseppe CAVALLARO
2017-01-31 9:11 ` [PATCH 17/17] net: stmmac: replace unsigned by u32 Corentin Labbe
2017-01-31 10:12 ` Giuseppe CAVALLARO
2017-01-31 10:00 ` [PATCH 00/17] net: stmmac: misc fix Giuseppe CAVALLARO
2017-01-31 10:23 ` Joao Pinto
2017-01-31 10:33 ` Giuseppe CAVALLARO
2017-01-31 10:37 ` Joao Pinto
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=20170131103901.GA15482@Red \
--to=clabbe.montjoie@gmail.com \
--cc=alexandre.torgue@st.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.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).