From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
To: Deepak Sikri <deepak.sikri@st.com>
Cc: spear-devel@list.st.com, netdev@vger.kernel.org
Subject: Re: [PATCH 6/6] stmmac: Replace infinite loops by timeouts in mdio r/w
Date: Tue, 06 Mar 2012 08:55:18 +0100 [thread overview]
Message-ID: <4F55C2E6.8040204@st.com> (raw)
In-Reply-To: <1330692928-30330-7-git-send-email-deepak.sikri@st.com>
On 3/2/2012 1:55 PM, Deepak Sikri wrote:
> This patch removes the infinite waits from the mdio read and
> write interfaces. These infinite waits have been replaced by
> the timeout handling. In case if a time out occurs, an error is
> returned.
>
> Signed-off-by: Deepak Sikri <deepak.sikri@st.com>
Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 30 ++++++++++++++++-----
> 1 files changed, 23 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> index 7319532..b6a6fb2 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> @@ -34,6 +34,20 @@
> #define MII_BUSY 0x00000001
> #define MII_WRITE 0x00000002
>
> +static int stmmac_mdio_busy_wait(unsigned long ioaddr, unsigned int mii_addr)
> +{
> + unsigned long finish = jiffies + 3 * HZ;
> +
> + do {
> + if (readl(ioaddr + mii_addr) & MII_BUSY)
> + cpu_relax();
> + else
> + return 0;
> + } while (!time_after_eq(jiffies, finish));
> +
> + return -EBUSY;
> +}
> +
> /**
> * stmmac_mdio_read
> * @bus: points to the mii_bus structure
> @@ -56,9 +70,13 @@ static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg)
> ((phyreg << 6) & (0x000007C0)));
> regValue |= MII_BUSY | ((priv->plat->clk_csr & 7) << 2);
>
> - do {} while (((readl(priv->ioaddr + mii_address)) & MII_BUSY) == 1);
> + if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address))
> + return -EBUSY;
> +
> writel(regValue, priv->ioaddr + mii_address);
> - do {} while (((readl(priv->ioaddr + mii_address)) & MII_BUSY) == 1);
> +
> + if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address))
> + return -EBUSY;
>
> /* Read the data from the MII data register */
> data = (int)readl(priv->ioaddr + mii_data);
> @@ -88,18 +106,16 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
>
> value |= MII_BUSY | ((priv->plat->clk_csr & 7) << 2);
>
> -
> /* Wait until any existing MII operation is complete */
> - do {} while (((readl(priv->ioaddr + mii_address)) & MII_BUSY) == 1);
> + if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address))
> + return -EBUSY;
>
> /* Set the MII address register to write */
> writel(phydata, priv->ioaddr + mii_data);
> writel(value, priv->ioaddr + mii_address);
>
> /* Wait until any existing MII operation is complete */
> - do {} while (((readl(priv->ioaddr + mii_address)) & MII_BUSY) == 1);
> -
> - return 0;
> + return stmmac_mdio_busy_wait(priv->ioaddr, mii_address);
> }
>
> /**
next prev parent reply other threads:[~2012-03-06 7:56 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-02 12:55 [PATCH 0/6] stmmac: Driver Updates Deepak Sikri
2012-03-02 12:55 ` [PATCH 1/6] stmmac: Define CSUM offload engine Types Deepak Sikri
2012-03-02 12:55 ` [PATCH 2/6] stmmac: Define MDC clock selection macros Deepak Sikri
2012-03-02 12:55 ` [PATCH 3/6] stmmac: Add support for CPU freq notifiers Deepak Sikri
2012-03-02 12:55 ` [PATCH 4/6] stmmac: Update stmmac descriptor checks for stmmac core prior to Rev-3.5 Deepak Sikri
2012-03-02 12:55 ` [PATCH 5/6] stmmac: configure burst related GMAC DMA parameters Deepak Sikri
2012-03-02 12:55 ` [PATCH 6/6] stmmac: Replace infinite loops by timeouts in mdio r/w Deepak Sikri
2012-03-06 7:55 ` Giuseppe CAVALLARO [this message]
2012-03-05 1:52 ` [PATCH 5/6] stmmac: configure burst related GMAC DMA parameters David Miller
2012-03-07 5:39 ` deepaksi
2012-03-06 7:43 ` Giuseppe CAVALLARO
2012-03-07 6:18 ` deepaksi
2012-03-05 1:51 ` [PATCH 4/6] stmmac: Update stmmac descriptor checks for stmmac core prior to Rev-3.5 David Miller
2012-03-05 4:01 ` Shiraz Hashim
2012-03-05 4:59 ` David Miller
2012-03-07 8:26 ` deepaksi
2012-03-06 7:10 ` Giuseppe CAVALLARO
2012-03-07 8:25 ` deepaksi
2012-03-07 8:45 ` Giuseppe CAVALLARO
2012-03-05 1:50 ` [PATCH 3/6] stmmac: Add support for CPU freq notifiers David Miller
2012-03-07 7:18 ` deepaksi
2012-03-05 15:05 ` Giuseppe CAVALLARO
2012-03-06 8:04 ` Giuseppe CAVALLARO
2012-03-07 8:28 ` deepaksi
2012-03-07 7:17 ` deepaksi
2012-03-05 14:34 ` [PATCH 2/6] stmmac: Define MDC clock selection macros Giuseppe CAVALLARO
2012-03-07 6:55 ` deepaksi
2012-03-07 7:19 ` Giuseppe CAVALLARO
2012-03-07 8:30 ` deepaksi
2012-03-05 14:13 ` [PATCH 1/6] stmmac: Define CSUM offload engine Types Giuseppe CAVALLARO
2012-03-07 6:50 ` deepaksi
2012-03-05 15:31 ` [PATCH 0/6] stmmac: Driver Updates Giuseppe CAVALLARO
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=4F55C2E6.8040204@st.com \
--to=peppe.cavallaro@st.com \
--cc=deepak.sikri@st.com \
--cc=netdev@vger.kernel.org \
--cc=spear-devel@list.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.