Skip to content

Commit

Permalink
TTY: define tty_wait_until_sent_from_close
Browse files Browse the repository at this point in the history
We need this helper to fix system stalls. The issue is that the rest
of the system TTYs wait for us to finish waiting. This wasn't an issue
with BKL. BKL used to unlock implicitly.

This is based on the Arnd suggestion.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jiri Slaby authored and Greg Kroah-Hartman committed Aug 25, 2011
1 parent bafb0bd commit a57a7bf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions include/linux/tty.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,24 @@ extern long vt_compat_ioctl(struct tty_struct *tty,
extern void __lockfunc tty_lock(void) __acquires(tty_lock);
extern void __lockfunc tty_unlock(void) __releases(tty_lock);

/*
* this shall be called only from where BTM is held (like close)
*
* We need this to ensure nobody waits for us to finish while we are waiting.
* Without this we were encountering system stalls.
*
* This should be indeed removed with BTM removal later.
*
* Locking: BTM required. Nobody is allowed to hold port->mutex.
*/
static inline void tty_wait_until_sent_from_close(struct tty_struct *tty,
long timeout)
{
tty_unlock(); /* tty->ops->close holds the BTM, drop it while waiting */
tty_wait_until_sent(tty, timeout);
tty_lock();
}

/*
* wait_event_interruptible_tty -- wait for a condition with the tty lock held
*
Expand Down

0 comments on commit a57a7bf

Please sign in to comment.