diff options
author | Jonas Bonn <jonas@southpole.se> | 2010-11-24 21:30:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-28 14:16:37 -0500 |
commit | 8dac428ae9ae54d8e8540ac157d92925dd7ebed8 (patch) | |
tree | 6d5c53fc4ad5167841ec2e87ed7745c6e4db4a66 /drivers/net/ethoc.c | |
parent | fa98eb0e867c6c16e239545d4deb7ad8f40631b3 (diff) |
ethoc: rework mdio read/write
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethoc.c')
-rw-r--r-- | 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 43431ffcf6c1..f3048faa3c66 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) | |||
611 | 611 | ||
612 | static int ethoc_mdio_read(struct mii_bus *bus, int phy, int reg) | 612 | static int ethoc_mdio_read(struct mii_bus *bus, int phy, int reg) |
613 | { | 613 | { |
614 | unsigned long timeout = jiffies + ETHOC_MII_TIMEOUT; | ||
615 | struct ethoc *priv = bus->priv; | 614 | struct ethoc *priv = bus->priv; |
615 | int i; | ||
616 | 616 | ||
617 | ethoc_write(priv, MIIADDRESS, MIIADDRESS_ADDR(phy, reg)); | 617 | ethoc_write(priv, MIIADDRESS, MIIADDRESS_ADDR(phy, reg)); |
618 | ethoc_write(priv, MIICOMMAND, MIICOMMAND_READ); | 618 | ethoc_write(priv, MIICOMMAND, MIICOMMAND_READ); |
619 | 619 | ||
620 | while (time_before(jiffies, timeout)) { | 620 | for (i=0; i < 5; i++) { |
621 | u32 status = ethoc_read(priv, MIISTATUS); | 621 | u32 status = ethoc_read(priv, MIISTATUS); |
622 | if (!(status & MIISTATUS_BUSY)) { | 622 | if (!(status & MIISTATUS_BUSY)) { |
623 | u32 data = ethoc_read(priv, MIIRX_DATA); | 623 | u32 data = ethoc_read(priv, MIIRX_DATA); |
@@ -625,8 +625,7 @@ static int ethoc_mdio_read(struct mii_bus *bus, int phy, int reg) | |||
625 | ethoc_write(priv, MIICOMMAND, 0); | 625 | ethoc_write(priv, MIICOMMAND, 0); |
626 | return data; | 626 | return data; |
627 | } | 627 | } |
628 | 628 | usleep_range(100,200); | |
629 | schedule(); | ||
630 | } | 629 | } |
631 | 630 | ||
632 | return -EBUSY; | 631 | return -EBUSY; |
@@ -634,22 +633,21 @@ static int ethoc_mdio_read(struct mii_bus *bus, int phy, int reg) | |||
634 | 633 | ||
635 | static int ethoc_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val) | 634 | static int ethoc_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val) |
636 | { | 635 | { |
637 | unsigned long timeout = jiffies + ETHOC_MII_TIMEOUT; | ||
638 | struct ethoc *priv = bus->priv; | 636 | struct ethoc *priv = bus->priv; |
637 | int i; | ||
639 | 638 | ||
640 | ethoc_write(priv, MIIADDRESS, MIIADDRESS_ADDR(phy, reg)); | 639 | ethoc_write(priv, MIIADDRESS, MIIADDRESS_ADDR(phy, reg)); |
641 | ethoc_write(priv, MIITX_DATA, val); | 640 | ethoc_write(priv, MIITX_DATA, val); |
642 | ethoc_write(priv, MIICOMMAND, MIICOMMAND_WRITE); | 641 | ethoc_write(priv, MIICOMMAND, MIICOMMAND_WRITE); |
643 | 642 | ||
644 | while (time_before(jiffies, timeout)) { | 643 | for (i=0; i < 5; i++) { |
645 | u32 stat = ethoc_read(priv, MIISTATUS); | 644 | u32 stat = ethoc_read(priv, MIISTATUS); |
646 | if (!(stat & MIISTATUS_BUSY)) { | 645 | if (!(stat & MIISTATUS_BUSY)) { |
647 | /* reset MII command register */ | 646 | /* reset MII command register */ |
648 | ethoc_write(priv, MIICOMMAND, 0); | 647 | ethoc_write(priv, MIICOMMAND, 0); |
649 | return 0; | 648 | return 0; |
650 | } | 649 | } |
651 | 650 | usleep_range(100,200); | |
652 | schedule(); | ||
653 | } | 651 | } |
654 | 652 | ||
655 | return -EBUSY; | 653 | return -EBUSY; |