Skip to content

Commit

Permalink
powerpc: Fix spin_event_timeout() to be robust over context switches
Browse files Browse the repository at this point in the history
Current implementation of spin_event_timeout can be interrupted by an
IRQ or context switch after testing the condition, but before checking
the timeout.  This can cause the loop to report a timeout when the
condition actually became true in the middle.

This patch adds one final check of the condition upon exit of the loop
if the last test of the condition was still false.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Grant Likely authored and Benjamin Herrenschmidt committed Jul 8, 2009
1 parent 30c5af4 commit ad9064d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/powerpc/include/asm/delay.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ extern void udelay(unsigned long usecs);
udelay(delay); \
else \
cpu_relax(); \
if (!__ret) \
__ret = (condition); \
__ret; \
})

Expand Down

0 comments on commit ad9064d

Please sign in to comment.