Commit c37bc682 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

TTY: fix tty_wait_until_sent maximum timeout

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: default avatarJohan Hovold <johan@kernel.org>
Reviewed-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 79fbf4a5
...@@ -218,10 +218,10 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout) ...@@ -218,10 +218,10 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout)
if (!timeout) if (!timeout)
timeout = MAX_SCHEDULE_TIMEOUT; timeout = MAX_SCHEDULE_TIMEOUT;
if (wait_event_interruptible_timeout(tty->write_wait, timeout = wait_event_interruptible_timeout(tty->write_wait,
!tty_chars_in_buffer(tty), timeout) < 0) { !tty_chars_in_buffer(tty), timeout);
if (timeout <= 0)
return; return;
}
if (timeout == MAX_SCHEDULE_TIMEOUT) if (timeout == MAX_SCHEDULE_TIMEOUT)
timeout = 0; timeout = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment