MIPS: __raw_spin_lock() may spin forever on ticket wrap.
authorDavid Daney <ddaney@caviumnetworks.com>
Fri, 27 Mar 2009 17:07:02 +0000 (10:07 -0700)
committerRalf Baechle <ralf@linux-mips.org>
Mon, 30 Mar 2009 12:49:39 +0000 (14:49 +0200)
commit0e6826c73c9aa785ec58b52613df7699fb31af9a
treea85de8026984bbe94bf8ebc49873fcf0367782d9
parentf5fd02a33e9a53480c7c489d3210b144d24da24e
MIPS: __raw_spin_lock() may spin forever on ticket wrap.

If the lock is not acquired and has to spin *and* the second attempt
to acquire the lock fails, the delay time is not masked by the ticket
range mask.  If the ticket number wraps around to zero, the result is
that the lock sampling delay is essentially infinite (due to casting
-1 to an unsigned int).

The fix: Always mask the difference between my_ticket and the current
ticket value before calculating the delay.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/spinlock.h