TTY: fix tty_wait_until_sent maximum timeout
authorJohan Hovold <johan@kernel.org>
Wed, 4 Mar 2015 09:39:07 +0000 (10:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Mar 2015 02:44:15 +0000 (03:44 +0100)
Currently tty_wait_until_sent may take up to twice as long as the
requested timeout while waiting for driver and hardware buffers to
drain.

Fix this by taking the remaining number of jiffies after waiting for
driver buffers to drain into account so that the timeout actually
becomes a maximum timeout as it is documented to be.

Note that this specifically implies tighter timings when closing a port
as a consequence of actually honouring the port closing-wait setting
for drivers relying on tty_wait_until_sent_from_close (e.g. via
tty_port_close_start).

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/tty_ioctl.c

index 89ae23ac9ae61c6c1651d89f1a70f443507b017b..632fc815206169281af9aa13f6ca345eb846eabe 100644 (file)
@@ -218,10 +218,10 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout)
        if (!timeout)
                timeout = MAX_SCHEDULE_TIMEOUT;
 
-       if (wait_event_interruptible_timeout(tty->write_wait,
-                       !tty_chars_in_buffer(tty), timeout) < 0) {
+       timeout = wait_event_interruptible_timeout(tty->write_wait,
+                       !tty_chars_in_buffer(tty), timeout);
+       if (timeout <= 0)
                return;
-       }
 
        if (timeout == MAX_SCHEDULE_TIMEOUT)
                timeout = 0;
This page took 0.024908 seconds and 5 git commands to generate.