Re: patch "TTY: remove tty_locked" added to tty tree

Arnd Bergmann
2011-08-23T18:47:16Z

On Tuesday 23 August 2011 20:33:38 Jiri Slaby wrote:

> It looks like I need tty_locked to fix system stalls in
> tty_wait_until_sent in the end. Like with the patch attached. But if
> someone finds another way to fix this in short-term, it would be great.
>
>
> @@ -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);
>
>

According to http://kernelnewbies.org/BigKernelLock, I concluded back then
that tty_wait_until_sent would always be called without BTM held. Has that
changed recently, or did I miss a caller that holds the BTM?

The only caller that used to call it with BKL was tty_set_ldisc, and that
got changed to release the BTM before calling it. If there is another
caller, can it do the same?

Arnd