Subject: Re: Strange tg3 regression with UMP fw. link reporting

From: Arnd Bergmann <[email-masked]>
Date: Fri, 8 Aug 2008 11:21:30 +0200

On Friday 08 August 2008, Segher Boessenkool wrote:
> > I don't know yet for sure what happens, but a quick look at the commit
> > seems to show that the driver synchronously spin-waits for up to 2.5ms
>=20
> That's what the comment says, but the code says 2.5 _seconds_:
>=20
> + =A0 =A0 =A0 /* Wait for up to 2.5 milliseconds */
> + =A0 =A0 =A0 for (i =3D 0; i < 250000; i++) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!(tr32(GRC_RX_CPU_EVENT) & GRC_RX_CPU_D=
RIVER_EVENT))
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 udelay(10);
> + =A0 =A0 =A0 }
>=20
> (not that milliseconds wouldn't be bad already...)

It can potentially be even much longer, because each udelay will wait
for *more* than 10 microseconds, and tr32() is an mmio read that takes
additional time, possibly in the order of microseconds as well.

The correct way to implement a timeout like this would be to use
time_before() in the condition, aside from better not doing a busy-loop
in the first place.

	Arnd <><