serial: amba-pl011: use port lock to guard control register access
authorJon Medhurst <tixy@linaro.org>
Tue, 10 Dec 2013 10:18:58 +0000 (10:18 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Dec 2013 17:35:37 +0000 (09:35 -0800)
commitfe43390702a1b5741fdf217063b05c7612b38303
tree6bd4b42a7ba001a36a3f9a901dd6eeb19f96682a
parent8f898bfd048f65856d8911a89b1616ad3e677c6c
serial: amba-pl011: use port lock to guard control register access

When the pl011 is being used for a console, pl011_console_write forces
the control register (CR) to enable the UART for transmission and then
restores this to the original value afterwards. It does this while
holding the port lock.

Unfortunately, when the uart is started or shutdown - say in response to
userland using the serial device for a terminal - then this updates the
control register without any locking.

This means we can have

  pl011_console_write   Save CR
  pl011_startup         Initialise CR, e.g. enable receive
  pl011_console_write   Restore old CR with receive not enabled

this result is a serial port which doesn't respond to any input.

A similar race in reverse could happen when the device is shutdown.

We can fix these problems by taking the port lock when updating CR.

Signed-off-by: Jon Medhurst <tixy@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/amba-pl011.c