From: Jonas Bonn <jonas@southpole.se>
To: netdev@vger.kernel.org
Cc: Jonas Bonn <jonas@southpole.se>
Subject: [PATCH 6/8] ethoc: rework mdio read/write
Date: Thu, 25 Nov 2010 13:30:30 +0100 [thread overview]
Message-ID: <1290688232-25142-7-git-send-email-jonas@southpole.se> (raw)
In-Reply-To: <1290688232-25142-1-git-send-email-jonas@southpole.se>
MDIO read and write were checking whether a timeout had expired to determine
whether to recheck the result of the MDIO operation. Under heavy CPU usage,
however, it was possible for the timeout to expire before the routine got
around to be able to check a second time even, thus erroneousy returning an
-EBUSY.
This patch changes the the MDIO IO routines to try up to five times to complete
the operation before giving up, thus lessening the dependency on CPU load.
This resolves a problem whereby a ping flood would keep the CPU so busy that
the above problem would manifest itself; the MDIO command to check link status
would fail and the interface would erroneously be shut down.
Signed-off-by: Jonas Bonn <jonas@southpole.se>
---
drivers/net/ethoc.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index 43431ff..f3048fa 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -611,13 +611,13 @@ static int ethoc_poll(struct napi_struct *napi, int budget)
static int ethoc_mdio_read(struct mii_bus *bus, int phy, int reg)
{
- unsigned long timeout = jiffies + ETHOC_MII_TIMEOUT;
struct ethoc *priv = bus->priv;
+ int i;
ethoc_write(priv, MIIADDRESS, MIIADDRESS_ADDR(phy, reg));
ethoc_write(priv, MIICOMMAND, MIICOMMAND_READ);
- while (time_before(jiffies, timeout)) {
+ for (i=0; i < 5; i++) {
u32 status = ethoc_read(priv, MIISTATUS);
if (!(status & MIISTATUS_BUSY)) {
u32 data = ethoc_read(priv, MIIRX_DATA);
@@ -625,8 +625,7 @@ static int ethoc_mdio_read(struct mii_bus *bus, int phy, int reg)
ethoc_write(priv, MIICOMMAND, 0);
return data;
}
-
- schedule();
+ usleep_range(100,200);
}
return -EBUSY;
@@ -634,22 +633,21 @@ static int ethoc_mdio_read(struct mii_bus *bus, int phy, int reg)
static int ethoc_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
{
- unsigned long timeout = jiffies + ETHOC_MII_TIMEOUT;
struct ethoc *priv = bus->priv;
+ int i;
ethoc_write(priv, MIIADDRESS, MIIADDRESS_ADDR(phy, reg));
ethoc_write(priv, MIITX_DATA, val);
ethoc_write(priv, MIICOMMAND, MIICOMMAND_WRITE);
- while (time_before(jiffies, timeout)) {
+ for (i=0; i < 5; i++) {
u32 stat = ethoc_read(priv, MIISTATUS);
if (!(stat & MIISTATUS_BUSY)) {
/* reset MII command register */
ethoc_write(priv, MIICOMMAND, 0);
return 0;
}
-
- schedule();
+ usleep_range(100,200);
}
return -EBUSY;
--
1.7.1
next prev parent reply other threads:[~2010-11-25 12:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-25 12:30 ethoc driver changes (version 2) Jonas Bonn
2010-11-25 12:30 ` [PATCH 1/8] ethoc: Add device tree configuration Jonas Bonn
2010-11-25 12:30 ` [PATCH 2/8] ethoc: remove unused spinlock Jonas Bonn
2010-11-25 12:30 ` [PATCH 3/8] ethoc: enable interrupts after napi_complete Jonas Bonn
2010-11-25 12:30 ` [PATCH 4/8] ethoc: Double check pending RX packet Jonas Bonn
2010-11-25 12:30 ` [PATCH 5/8] ethoc: rework interrupt handling Jonas Bonn
2010-11-25 12:30 ` Jonas Bonn [this message]
2010-11-25 12:30 ` [PATCH 7/8] ethoc: fix function return type Jonas Bonn
2010-11-25 12:30 ` [PATCH 8/8] ethoc: remove division from loops Jonas Bonn
2010-11-28 19:17 ` ethoc driver changes (version 2) David Miller
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=1290688232-25142-7-git-send-email-jonas@southpole.se \
--to=jonas@southpole.se \
--cc=netdev@vger.kernel.org \
/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).