summaryrefslogtreecommitdiffstats
path: root/debian/patches-rt/0061-serial-sifive-Use-port-lock-wrappers.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches-rt/0061-serial-sifive-Use-port-lock-wrappers.patch')
-rw-r--r--debian/patches-rt/0061-serial-sifive-Use-port-lock-wrappers.patch102
1 files changed, 102 insertions, 0 deletions
diff --git a/debian/patches-rt/0061-serial-sifive-Use-port-lock-wrappers.patch b/debian/patches-rt/0061-serial-sifive-Use-port-lock-wrappers.patch
new file mode 100644
index 000000000..a2babdbea
--- /dev/null
+++ b/debian/patches-rt/0061-serial-sifive-Use-port-lock-wrappers.patch
@@ -0,0 +1,102 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Thu, 14 Sep 2023 20:44:18 +0206
+Subject: [PATCH 061/134] serial: sifive: Use port lock wrappers
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.6/older/patches-6.6.7-rt18.tar.xz
+
+When a serial port is used for kernel console output, then all
+modifications to the UART registers which are done from other contexts,
+e.g. getty, termios, are interference points for the kernel console.
+
+So far this has been ignored and the printk output is based on the
+principle of hope. The rework of the console infrastructure which aims to
+support threaded and atomic consoles, requires to mark sections which
+modify the UART registers as unsafe. This allows the atomic write function
+to make informed decisions and eventually to restore operational state. It
+also allows to prevent the regular UART code from modifying UART registers
+while printk output is in progress.
+
+All modifications of UART registers are guarded by the UART port lock,
+which provides an obvious synchronization point with the console
+infrastructure.
+
+To avoid adding this functionality to all UART drivers, wrap the
+spin_[un]lock*() invocations for uart_port::lock into helper functions
+which just contain the spin_[un]lock*() invocations for now. In a
+subsequent step these helpers will gain the console synchronization
+mechanisms.
+
+Converted with coccinelle. No functional change.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: John Ogness <john.ogness@linutronix.de>
+Link: https://lore.kernel.org/r/20230914183831.587273-62-john.ogness@linutronix.de
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ drivers/tty/serial/sifive.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+--- a/drivers/tty/serial/sifive.c
++++ b/drivers/tty/serial/sifive.c
+@@ -521,11 +521,11 @@ static irqreturn_t sifive_serial_irq(int
+ struct sifive_serial_port *ssp = dev_id;
+ u32 ip;
+
+- spin_lock(&ssp->port.lock);
++ uart_port_lock(&ssp->port);
+
+ ip = __ssp_readl(ssp, SIFIVE_SERIAL_IP_OFFS);
+ if (!ip) {
+- spin_unlock(&ssp->port.lock);
++ uart_port_unlock(&ssp->port);
+ return IRQ_NONE;
+ }
+
+@@ -534,7 +534,7 @@ static irqreturn_t sifive_serial_irq(int
+ if (ip & SIFIVE_SERIAL_IP_TXWM_MASK)
+ __ssp_transmit_chars(ssp);
+
+- spin_unlock(&ssp->port.lock);
++ uart_port_unlock(&ssp->port);
+
+ return IRQ_HANDLED;
+ }
+@@ -653,7 +653,7 @@ static void sifive_serial_set_termios(st
+ ssp->port.uartclk / 16);
+ __ssp_update_baud_rate(ssp, rate);
+
+- spin_lock_irqsave(&ssp->port.lock, flags);
++ uart_port_lock_irqsave(&ssp->port, &flags);
+
+ /* Update the per-port timeout */
+ uart_update_timeout(port, termios->c_cflag, rate);
+@@ -670,7 +670,7 @@ static void sifive_serial_set_termios(st
+ if (v != old_v)
+ __ssp_writel(v, SIFIVE_SERIAL_RXCTRL_OFFS, ssp);
+
+- spin_unlock_irqrestore(&ssp->port.lock, flags);
++ uart_port_unlock_irqrestore(&ssp->port, flags);
+ }
+
+ static void sifive_serial_release_port(struct uart_port *port)
+@@ -795,9 +795,9 @@ static void sifive_serial_console_write(
+ if (ssp->port.sysrq)
+ locked = 0;
+ else if (oops_in_progress)
+- locked = spin_trylock(&ssp->port.lock);
++ locked = uart_port_trylock(&ssp->port);
+ else
+- spin_lock(&ssp->port.lock);
++ uart_port_lock(&ssp->port);
+
+ ier = __ssp_readl(ssp, SIFIVE_SERIAL_IE_OFFS);
+ __ssp_writel(0, SIFIVE_SERIAL_IE_OFFS, ssp);
+@@ -807,7 +807,7 @@ static void sifive_serial_console_write(
+ __ssp_writel(ier, SIFIVE_SERIAL_IE_OFFS, ssp);
+
+ if (locked)
+- spin_unlock(&ssp->port.lock);
++ uart_port_unlock(&ssp->port);
+ local_irq_restore(flags);
+ }
+