Commit d47dd323 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Greg Kroah-Hartman

serial: pch: Use uart_prepare_sysrq_char().

The port lock is a spinlock_t which is becomes a sleeping lock on PREEMPT_RT.
The driver splits the locking function into two parts: local_irq_save() and
uart_port_lock() and this breaks PREEMPT_RT.

Delay handling sysrq until port lock is dropped.
Remove the special case in the console write routine an always use the
complete locking function.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20240301215246.891055-19-bigeasy@linutronix.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 06d28ca0
...@@ -564,7 +564,7 @@ static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf, ...@@ -564,7 +564,7 @@ static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf,
if (uart_handle_break(port)) if (uart_handle_break(port))
continue; continue;
} }
if (uart_handle_sysrq_char(port, rbr)) if (uart_prepare_sysrq_char(port, rbr))
continue; continue;
buf[i++] = rbr; buf[i++] = rbr;
...@@ -1070,7 +1070,7 @@ static irqreturn_t pch_uart_interrupt(int irq, void *dev_id) ...@@ -1070,7 +1070,7 @@ static irqreturn_t pch_uart_interrupt(int irq, void *dev_id)
handled |= (unsigned int)ret; handled |= (unsigned int)ret;
} }
uart_port_unlock(&priv->port); uart_unlock_and_check_sysrq(&priv->port);
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
...@@ -1550,22 +1550,17 @@ pch_console_write(struct console *co, const char *s, unsigned int count) ...@@ -1550,22 +1550,17 @@ pch_console_write(struct console *co, const char *s, unsigned int count)
{ {
struct eg20t_port *priv; struct eg20t_port *priv;
unsigned long flags; unsigned long flags;
int port_locked = 1; int locked = 1;
u8 ier; u8 ier;
priv = pch_uart_ports[co->index]; priv = pch_uart_ports[co->index];
touch_nmi_watchdog(); touch_nmi_watchdog();
local_irq_save(flags); if (oops_in_progress)
if (priv->port.sysrq) { locked = uart_port_trylock_irqsave(&priv->port, &flags);
/* serial8250_handle_port() already took the port lock */ else
port_locked = 0; uart_port_lock_irqsave(&priv->port, &flags);
} else if (oops_in_progress) {
port_locked = uart_port_trylock(&priv->port);
} else {
uart_port_lock(&priv->port);
}
/* /*
* First save the IER then disable the interrupts * First save the IER then disable the interrupts
...@@ -1583,9 +1578,8 @@ pch_console_write(struct console *co, const char *s, unsigned int count) ...@@ -1583,9 +1578,8 @@ pch_console_write(struct console *co, const char *s, unsigned int count)
wait_for_xmitr(priv, UART_LSR_BOTH_EMPTY); wait_for_xmitr(priv, UART_LSR_BOTH_EMPTY);
iowrite8(ier, priv->membase + UART_IER); iowrite8(ier, priv->membase + UART_IER);
if (port_locked) if (locked)
uart_port_unlock(&priv->port); uart_port_unlock_irqrestore(&priv->port, flags);
local_irq_restore(flags);
} }
static int __init pch_console_setup(struct console *co, char *options) static int __init pch_console_setup(struct console *co, char *options)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment