Commit 3689a0ec60bc8f56cc372c1dfa0d89dab48f7c9c

Authored by George G. Davis
Committed by Linus Torvalds
1 parent 9b22271d4b

[PATCH] serial: make sure UART is powered up when dumping MCTRL status

Since serial devices are powered down when not in use and some of those
devices cannot be accessed when powered down, we need to enable power
around calls to get_mcrtl() when dumping port state via uart_line_info().
This resolves hangs observed on some machines while reading serial device
registers when a port is powered off.

Signed-off-by: George G. Davis <gdavis@mvista.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 11 additions and 0 deletions Side-by-side Diff

drivers/serial/serial_core.c
... ... @@ -1660,6 +1660,7 @@
1660 1660 static int uart_line_info(char *buf, struct uart_driver *drv, int i)
1661 1661 {
1662 1662 struct uart_state *state = drv->state + i;
  1663 + int pm_state;
1663 1664 struct uart_port *port = state->port;
1664 1665 char stat_buf[32];
1665 1666 unsigned int status;
1666 1667  
... ... @@ -1682,9 +1683,16 @@
1682 1683  
1683 1684 if(capable(CAP_SYS_ADMIN))
1684 1685 {
  1686 + mutex_lock(&state->mutex);
  1687 + pm_state = state->pm_state;
  1688 + if (pm_state)
  1689 + uart_change_pm(state, 0);
1685 1690 spin_lock_irq(&port->lock);
1686 1691 status = port->ops->get_mctrl(port);
1687 1692 spin_unlock_irq(&port->lock);
  1693 + if (pm_state)
  1694 + uart_change_pm(state, pm_state);
  1695 + mutex_unlock(&state->mutex);
1688 1696  
1689 1697 ret += sprintf(buf + ret, " tx:%d rx:%d",
1690 1698 port->icount.tx, port->icount.rx);
... ... @@ -2099,6 +2107,9 @@
2099 2107 unsigned long flags;
2100 2108  
2101 2109 uart_report_port(drv, port);
  2110 +
  2111 + /* Power up port for set_mctrl() */
  2112 + uart_change_pm(state, 0);
2102 2113  
2103 2114 /*
2104 2115 * Ensure that the modem control lines are de-activated.