Skip to content

Commit

Permalink
pch_uart: add sysrq support
Browse files Browse the repository at this point in the history
When send break to the uart port, we always get 'frame error', but we
can not just reset receive fifo in such case, otherwise the sysrq cmd
will not be received correctly.

When we handle sysrq output via pch_console_write, the priv lock has
already been taken so no need to take the lock in pch_console_write.

Signed-off-by: Liang Li <liang.li@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Liang Li authored and Greg Kroah-Hartman committed Jan 21, 2013
1 parent 384e301 commit 1f9db09
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions drivers/tty/serial/pch_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@
*along with this program; if not, write to the Free Software
*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#if defined(CONFIG_SERIAL_PCH_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
#define SUPPORT_SYSRQ
#endif
#include <linux/kernel.h>
#include <linux/serial_reg.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/console.h>
#include <linux/serial_core.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/dmi.h>
#include <linux/console.h>
#include <linux/nmi.h>
#include <linux/delay.h>

Expand Down Expand Up @@ -553,12 +556,24 @@ static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf,
{
int i;
u8 rbr, lsr;
struct uart_port *port = &priv->port;

lsr = ioread8(priv->membase + UART_LSR);
for (i = 0, lsr = ioread8(priv->membase + UART_LSR);
i < rx_size && lsr & UART_LSR_DR;
i < rx_size && lsr & (UART_LSR_DR | UART_LSR_BI);
lsr = ioread8(priv->membase + UART_LSR)) {
rbr = ioread8(priv->membase + PCH_UART_RBR);

if (lsr & UART_LSR_BI) {
port->icount.brk++;
if (uart_handle_break(port))
continue;
}
if (port->sysrq) {
if (uart_handle_sysrq_char(port, rbr))
continue;
}

buf[i++] = rbr;
}
return i;
Expand Down Expand Up @@ -1023,16 +1038,11 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv)

static void pch_uart_err_ir(struct eg20t_port *priv, unsigned int lsr)
{
u8 fcr = ioread8(priv->membase + UART_FCR);
struct uart_port *port = &priv->port;
struct tty_struct *tty = tty_port_tty_get(&port->state->port);
char *error_msg[5] = {};
int i = 0;

/* Reset FIFO */
fcr |= UART_FCR_CLEAR_RCVR;
iowrite8(fcr, priv->membase + UART_FCR);

if (lsr & PCH_UART_LSR_ERR)
error_msg[i++] = "Error data in FIFO\n";

Expand Down Expand Up @@ -1565,7 +1575,8 @@ pch_console_write(struct console *co, const char *s, unsigned int count)

local_irq_save(flags);
if (priv->port.sysrq) {
spin_lock(&priv->lock);
/* call to uart_handle_sysrq_char already took the priv lock */
priv_locked = 0;
/* serial8250_handle_port() already took the port lock */
port_locked = 0;
} else if (oops_in_progress) {
Expand Down

0 comments on commit 1f9db09

Please sign in to comment.