]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
r8169: prevent excessive busy-waiting
authorFrancois Romieu <romieu@fr.zoreil.com>
Sat, 28 Jan 2006 23:49:09 +0000 (00:49 +0100)
committerFrancois Romieu <romieu@fr.zoreil.com>
Sat, 28 Jan 2006 23:49:09 +0000 (00:49 +0100)
The MII registers read/write function blindly busy waits for an
amount of 1000 us (1 ms), then up to 200 ms. These functions are
called from irq disabled context. Depending on the clock management,
it triggers lost ticks events. Since the value is way above the
standard delay required for mii register access, it strangely looks
like a bandaid against posted writes.

Fixes http://bugzilla.kernel.org/show_bug.cgi?id=5947

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
drivers/net/r8169.c

index 2e1bed153c39c00827e2ef986bca3db3129c807d..a81338b501fbed3759832ddd19dd224e08be7d17 100644 (file)
@@ -484,13 +484,12 @@ static void mdio_write(void __iomem *ioaddr, int RegAddr, int value)
        int i;
 
        RTL_W32(PHYAR, 0x80000000 | (RegAddr & 0xFF) << 16 | value);
-       udelay(1000);
 
-       for (i = 2000; i > 0; i--) {
+       for (i = 20; i > 0; i--) {
                /* Check if the RTL8169 has completed writing to the specified MII register */
                if (!(RTL_R32(PHYAR) & 0x80000000)) 
                        break;
-               udelay(100);
+               udelay(25);
        }
 }
 
@@ -499,15 +498,14 @@ static int mdio_read(void __iomem *ioaddr, int RegAddr)
        int i, value = -1;
 
        RTL_W32(PHYAR, 0x0 | (RegAddr & 0xFF) << 16);
-       udelay(1000);
 
-       for (i = 2000; i > 0; i--) {
+       for (i = 20; i > 0; i--) {
                /* Check if the RTL8169 has completed retrieving data from the specified MII register */
                if (RTL_R32(PHYAR) & 0x80000000) {
                        value = (int) (RTL_R32(PHYAR) & 0xFFFF);
                        break;
                }
-               udelay(100);
+               udelay(25);
        }
        return value;
 }