Skip to content

Commit

Permalink
r8169: prevent excessive busy-waiting
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Francois Romieu committed Jan 28, 2006
1 parent 3ee68c4 commit 2371408
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions drivers/net/r8169.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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;
}
Expand Down

0 comments on commit 2371408

Please sign in to comment.