linux/include
Imre Deak 1a2d35126f wait: fix false timeouts when using wait_event_timeout()
commit 4c663cfc52 upstream.

Many callers of the wait_event_timeout() and
wait_event_interruptible_timeout() expect that the return value will be
positive if the specified condition becomes true before the timeout
elapses.  However, at the moment this isn't guaranteed.  If the wake-up
handler is delayed enough, the time remaining until timeout will be
calculated as 0 - and passed back as a return value - even if the
condition became true before the timeout has passed.

Fix this by returning at least 1 if the condition becomes true.  This
semantic is in line with what wait_for_condition_timeout() does; see
commit bb10ed09 ("sched: fix wait_for_completion_timeout() spurious
failure under heavy load").

Daniel said "We have 3 instances of this bug in drm/i915.  One case even
where we switch between the interruptible and not interruptible
wait_event_timeout variants, foolishly presuming they have the same
semantics.  I very much like this."

One such bug is reported at
  https://bugs.freedesktop.org/show_bug.cgi?id=64133

Signed-off-by: Imre Deak <imre.deak@intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: David Howells <dhowells@redhat.com>
Acked-by: Jens Axboe <axboe@kernel.dk>
Cc: "Paul E.  McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Dave Jones <davej@redhat.com>
Cc: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-07-19 11:04:30 +08:00
..
acpi ACPI: Store SRAT table revision 2012-01-25 17:24:57 -08:00
asm-generic Merge remote-tracking branch 'stable/linux-3.0.y' into develop-3.0 2013-01-15 12:45:19 +08:00
crypto
drm drm/radeon/kms: add new BTC PCI ids 2012-06-10 00:33:04 +09:00
keys Revert "Merge remote-tracking branch 'linux-2.6.32.y/master' into develop" 2011-07-30 16:09:59 +08:00
linux wait: fix false timeouts when using wait_event_timeout() 2013-07-19 11:04:30 +08:00
math-emu Revert "Merge remote branch 'linux-2.6.32.y/master' into develop" 2011-07-30 16:24:52 +08:00
media camera(v0.4.1): cif:v0.4.1 generic_sensor:v0.1.0 rk_camera:v0.1.0 2013-04-10 16:27:20 +08:00
mtd
net Merge remote-tracking branch 'stable/linux-3.0.y' into develop-3.0 2013-01-21 17:21:19 +08:00
pcmcia
rdma
rxrpc
scsi Revert "Merge commit 'v2.6.32.9' into android-2.6.32" 2011-07-30 22:24:29 +08:00
sound Merge remote-tracking branch 'stable/linux-3.0.y' into develop-3.0 2012-12-01 12:07:55 +08:00
target target: Set additional sense length field in sense data 2012-01-25 17:25:00 -08:00
trace sync: add tracepoint support 2013-02-22 17:47:18 +08:00
video OMAPDSS: HDMI: PHY burnout fix 2012-03-12 10:32:59 -07:00
xen xen/xenbus: Reject replies with payload > XENSTORE_PAYLOAD_MAX. 2012-01-25 17:24:41 -08:00
Kbuild