mirror of
https://github.com/OpenVoiceOS/OpenVoiceOS
synced 2025-06-05 22:19:21 +02:00
187 lines
6.8 KiB
Diff
187 lines
6.8 KiB
Diff
From dbc779923fac8271f6e0d47a7648c333c97727e3 Mon Sep 17 00:00:00 2001
|
|
From: Thomas Gleixner <tglx@linutronix.de>
|
|
Date: Thu, 14 Sep 2023 20:44:12 +0206
|
|
Subject: [PATCH 082/195] serial: sc16is7xx: Use port lock wrappers
|
|
|
|
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-56-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/sc16is7xx.c | 40 +++++++++++++++++-----------------
|
|
1 file changed, 20 insertions(+), 20 deletions(-)
|
|
|
|
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
|
|
index 6aeb821d9b1d..a99c58cd5706 100644
|
|
--- a/drivers/tty/serial/sc16is7xx.c
|
|
+++ b/drivers/tty/serial/sc16is7xx.c
|
|
@@ -668,9 +668,9 @@ static void sc16is7xx_handle_tx(struct uart_port *port)
|
|
}
|
|
|
|
if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
|
|
- spin_lock_irqsave(&port->lock, flags);
|
|
+ uart_port_lock_irqsave(port, &flags);
|
|
sc16is7xx_stop_tx(port);
|
|
- spin_unlock_irqrestore(&port->lock, flags);
|
|
+ uart_port_unlock_irqrestore(port, flags);
|
|
return;
|
|
}
|
|
|
|
@@ -696,13 +696,13 @@ static void sc16is7xx_handle_tx(struct uart_port *port)
|
|
sc16is7xx_fifo_write(port, to_send);
|
|
}
|
|
|
|
- spin_lock_irqsave(&port->lock, flags);
|
|
+ uart_port_lock_irqsave(port, &flags);
|
|
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
|
|
uart_write_wakeup(port);
|
|
|
|
if (uart_circ_empty(xmit))
|
|
sc16is7xx_stop_tx(port);
|
|
- spin_unlock_irqrestore(&port->lock, flags);
|
|
+ uart_port_unlock_irqrestore(port, flags);
|
|
}
|
|
|
|
static unsigned int sc16is7xx_get_hwmctrl(struct uart_port *port)
|
|
@@ -734,7 +734,7 @@ static void sc16is7xx_update_mlines(struct sc16is7xx_one *one)
|
|
|
|
one->old_mctrl = status;
|
|
|
|
- spin_lock_irqsave(&port->lock, flags);
|
|
+ uart_port_lock_irqsave(port, &flags);
|
|
if ((changed & TIOCM_RNG) && (status & TIOCM_RNG))
|
|
port->icount.rng++;
|
|
if (changed & TIOCM_DSR)
|
|
@@ -745,7 +745,7 @@ static void sc16is7xx_update_mlines(struct sc16is7xx_one *one)
|
|
uart_handle_cts_change(port, status & TIOCM_CTS);
|
|
|
|
wake_up_interruptible(&port->state->port.delta_msr_wait);
|
|
- spin_unlock_irqrestore(&port->lock, flags);
|
|
+ uart_port_unlock_irqrestore(port, flags);
|
|
}
|
|
|
|
static bool sc16is7xx_port_irq(struct sc16is7xx_port *s, int portno)
|
|
@@ -836,9 +836,9 @@ static void sc16is7xx_tx_proc(struct kthread_work *ws)
|
|
sc16is7xx_handle_tx(port);
|
|
mutex_unlock(&s->efr_lock);
|
|
|
|
- spin_lock_irqsave(&port->lock, flags);
|
|
+ uart_port_lock_irqsave(port, &flags);
|
|
sc16is7xx_ier_set(port, SC16IS7XX_IER_THRI_BIT);
|
|
- spin_unlock_irqrestore(&port->lock, flags);
|
|
+ uart_port_unlock_irqrestore(port, flags);
|
|
}
|
|
|
|
static void sc16is7xx_reconf_rs485(struct uart_port *port)
|
|
@@ -849,14 +849,14 @@ static void sc16is7xx_reconf_rs485(struct uart_port *port)
|
|
struct serial_rs485 *rs485 = &port->rs485;
|
|
unsigned long irqflags;
|
|
|
|
- spin_lock_irqsave(&port->lock, irqflags);
|
|
+ uart_port_lock_irqsave(port, &irqflags);
|
|
if (rs485->flags & SER_RS485_ENABLED) {
|
|
efcr |= SC16IS7XX_EFCR_AUTO_RS485_BIT;
|
|
|
|
if (rs485->flags & SER_RS485_RTS_AFTER_SEND)
|
|
efcr |= SC16IS7XX_EFCR_RTS_INVERT_BIT;
|
|
}
|
|
- spin_unlock_irqrestore(&port->lock, irqflags);
|
|
+ uart_port_unlock_irqrestore(port, irqflags);
|
|
|
|
sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG, mask, efcr);
|
|
}
|
|
@@ -867,10 +867,10 @@ static void sc16is7xx_reg_proc(struct kthread_work *ws)
|
|
struct sc16is7xx_one_config config;
|
|
unsigned long irqflags;
|
|
|
|
- spin_lock_irqsave(&one->port.lock, irqflags);
|
|
+ uart_port_lock_irqsave(&one->port, &irqflags);
|
|
config = one->config;
|
|
memset(&one->config, 0, sizeof(one->config));
|
|
- spin_unlock_irqrestore(&one->port.lock, irqflags);
|
|
+ uart_port_unlock_irqrestore(&one->port, irqflags);
|
|
|
|
if (config.flags & SC16IS7XX_RECONF_MD) {
|
|
u8 mcr = 0;
|
|
@@ -976,18 +976,18 @@ static void sc16is7xx_throttle(struct uart_port *port)
|
|
* value set in MCR register. Stop reading data from RX FIFO so the
|
|
* AutoRTS feature will de-activate RTS output.
|
|
*/
|
|
- spin_lock_irqsave(&port->lock, flags);
|
|
+ uart_port_lock_irqsave(port, &flags);
|
|
sc16is7xx_ier_clear(port, SC16IS7XX_IER_RDI_BIT);
|
|
- spin_unlock_irqrestore(&port->lock, flags);
|
|
+ uart_port_unlock_irqrestore(port, flags);
|
|
}
|
|
|
|
static void sc16is7xx_unthrottle(struct uart_port *port)
|
|
{
|
|
unsigned long flags;
|
|
|
|
- spin_lock_irqsave(&port->lock, flags);
|
|
+ uart_port_lock_irqsave(port, &flags);
|
|
sc16is7xx_ier_set(port, SC16IS7XX_IER_RDI_BIT);
|
|
- spin_unlock_irqrestore(&port->lock, flags);
|
|
+ uart_port_unlock_irqrestore(port, flags);
|
|
}
|
|
|
|
static unsigned int sc16is7xx_tx_empty(struct uart_port *port)
|
|
@@ -1126,7 +1126,7 @@ static void sc16is7xx_set_termios(struct uart_port *port,
|
|
/* Setup baudrate generator */
|
|
baud = sc16is7xx_set_baud(port, baud);
|
|
|
|
- spin_lock_irqsave(&port->lock, flags);
|
|
+ uart_port_lock_irqsave(port, &flags);
|
|
|
|
/* Update timeout according to new baud rate */
|
|
uart_update_timeout(port, termios->c_cflag, baud);
|
|
@@ -1134,7 +1134,7 @@ static void sc16is7xx_set_termios(struct uart_port *port,
|
|
if (UART_ENABLE_MS(port, termios->c_cflag))
|
|
sc16is7xx_enable_ms(port);
|
|
|
|
- spin_unlock_irqrestore(&port->lock, flags);
|
|
+ uart_port_unlock_irqrestore(port, flags);
|
|
}
|
|
|
|
static int sc16is7xx_config_rs485(struct uart_port *port, struct ktermios *termios,
|
|
@@ -1221,9 +1221,9 @@ static int sc16is7xx_startup(struct uart_port *port)
|
|
sc16is7xx_port_write(port, SC16IS7XX_IER_REG, val);
|
|
|
|
/* Enable modem status polling */
|
|
- spin_lock_irqsave(&port->lock, flags);
|
|
+ uart_port_lock_irqsave(port, &flags);
|
|
sc16is7xx_enable_ms(port);
|
|
- spin_unlock_irqrestore(&port->lock, flags);
|
|
+ uart_port_unlock_irqrestore(port, flags);
|
|
|
|
return 0;
|
|
}
|
|
--
|
|
2.43.0
|
|
|