Skip to content

Commit

Permalink
TTY: serial, move locking in uart_close
Browse files Browse the repository at this point in the history
So now, when we handle CLOSING flag, there is no point to hold
port->mutex over the start of uart_close.

Yes, there are still several things to reason about:
* port->count etc is and always was protected by a spinlock
* ->stop_rx is protected by a spinlock. Otherwise it would
  race with interrupts.
* uart_wait_until_sent -- that one is already called without
  port->mutex from set_termios and tty_set_ldisc. Should anything
  be protected there, it would be tx_empty. And by a spinlock.
  8250 does this internally...

This step is needed to fix system stalls. To not create an AB-BA lock
dependency (see next patches).

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 426929f commit bafb0bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/tty/serial/serial_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,6 @@ static void uart_close(struct tty_struct *tty, struct file *filp)

pr_debug("uart_close(%d) called\n", uport->line);

mutex_lock(&port->mutex);
spin_lock_irqsave(&port->lock, flags);

if (tty_hung_up_p(filp)) {
Expand Down Expand Up @@ -1312,6 +1311,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
uart_wait_until_sent(tty, uport->timeout);
}

mutex_lock(&port->mutex);
uart_shutdown(tty, state);
uart_flush_buffer(tty);

Expand Down

0 comments on commit bafb0bd

Please sign in to comment.