summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2010-04-22 14:12:02 +0800
committerRob Herring <r.herring@freescale.com>2010-05-05 17:41:32 -0500
commit16722dcd109ce9a2aed9e9a6e49e196bf6ac924a (patch)
tree7a26fb192a673b93566f7cd7a87ff108c9289c5d /drivers
parent8e716e445a4411cca7274a12320d5e74df13f47b (diff)
UBUNTU: SAUCE: (upstream) netdev/fec: fix performance impact from mdio poll operation
BugLink: http://bugs.launchpad.net/bugs/546649 BugLink: http://bugs.launchpad.net/bugs/457878 After introducing phylib supporting, users experienced performace drop. That is because of the mdio polling operation of phylib. Use msleep to replace the busy waiting cpu_relax() and remove the warning message. Signed-off-by: Bryan Wu <bryan.wu@canonical.com> Acked-by: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andy Whitcroft <apw@canonical.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/fec.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 29adc810fce8..f75bdd479710 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -225,7 +225,7 @@ static void fec_stop(struct net_device *dev);
#define FEC_MMFR_TA (2 << 16)
#define FEC_MMFR_DATA(v) (v & 0xffff)
-#define FEC_MII_TIMEOUT 10000
+#define FEC_MII_TIMEOUT 10
/* Transmitter timeout */
#define TX_TIMEOUT (2 * HZ)
@@ -651,12 +651,28 @@ spin_unlock:
/*
* NOTE: a MII transaction is during around 25 us, so polling it...
*/
+static int fec_enet_mdio_poll(struct fec_enet_private *fep)
+ {
+ int timeout = FEC_MII_TIMEOUT;
+
+ fep->mii_timeout = 0;
+
+ /* wait for end of transfer */
+ while (!(readl(fep->hwp + FEC_IEVENT) & FEC_ENET_MII)) {
+ msleep(1);
+ if (timeout-- < 0) {
+ fep->mii_timeout = 1;
+ break;
+ }
+ }
+
+ return 0;
+}
+
static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
{
struct fec_enet_private *fep = bus->priv;
- int timeout = FEC_MII_TIMEOUT;
- fep->mii_timeout = 0;
/* clear MII end of transfer bit*/
writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
@@ -666,15 +682,7 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) |
FEC_MMFR_TA, fep->hwp + FEC_MII_DATA);
- /* wait for end of transfer */
- while (!(readl(fep->hwp + FEC_IEVENT) & FEC_ENET_MII)) {
- cpu_relax();
- if (timeout-- < 0) {
- fep->mii_timeout = 1;
- printk(KERN_ERR "FEC: MDIO read timeout\n");
- return -ETIMEDOUT;
- }
- }
+ fec_enet_mdio_poll(fep);
/* return value */
return FEC_MMFR_DATA(readl(fep->hwp + FEC_MII_DATA));
@@ -684,9 +692,6 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
u16 value)
{
struct fec_enet_private *fep = bus->priv;
- int timeout = FEC_MII_TIMEOUT;
-
- fep->mii_timeout = 0;
/* clear MII end of transfer bit*/
writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
@@ -697,15 +702,7 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
FEC_MMFR_TA | FEC_MMFR_DATA(value),
fep->hwp + FEC_MII_DATA);
- /* wait for end of transfer */
- while (!(readl(fep->hwp + FEC_IEVENT) & FEC_ENET_MII)) {
- cpu_relax();
- if (timeout-- < 0) {
- fep->mii_timeout = 1;
- printk(KERN_ERR "FEC: MDIO write timeout\n");
- return -ETIMEDOUT;
- }
- }
+ fec_enet_mdio_poll(fep);
return 0;
}