[PATCH] TTY: fix stalls on BTM when waiting until sent

From: Jiri Slaby
Date: Fri Aug 19 2011 - 16:16:51 EST


Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
Cc: Andreas Bombe <aeb@xxxxxxxxxx>
---
drivers/tty/tty_ioctl.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index 53f2442..3837175 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -146,6 +146,7 @@ EXPORT_SYMBOL(tty_unthrottle);

void tty_wait_until_sent(struct tty_struct *tty, long timeout)
{
+ int retval;
#ifdef TTY_DEBUG_WAIT_UNTIL_SENT
char buf[64];

@@ -153,8 +154,14 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout)
#endif
if (!timeout)
timeout = MAX_SCHEDULE_TIMEOUT;
- if (wait_event_interruptible_timeout(tty->write_wait,
- !tty_chars_in_buffer(tty), timeout) >= 0) {
+
+ if (tty_locked()) /* e.g. uart (holds) vs. tty_ioctl (does not) */
+ retval = wait_event_interruptible_timeout_tty(tty->write_wait,
+ !tty_chars_in_buffer(tty), timeout);
+ else
+ retval = wait_event_interruptible_timeout(tty->write_wait,
+ !tty_chars_in_buffer(tty), timeout);
+ if (retval >= 0) {
if (tty->ops->wait_until_sent)
tty->ops->wait_until_sent(tty, timeout);
}
--
1.7.6


--------------040006090207050306080407--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/