mirror of
https://github.com/OpenVoiceOS/OpenVoiceOS
synced 2025-06-05 22:19:21 +02:00
[All] {WIP} The big bump to buildroot 2024.02.x
This commit is contained in:
@ -0,0 +1,281 @@
|
||||
From 3d50225857afa57a9507e16afe8a901b8fcaac87 Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Gleixner <tglx@linutronix.de>
|
||||
Date: Thu, 14 Sep 2023 20:44:31 +0206
|
||||
Subject: [PATCH 100/196] serial: xilinx_uartps: 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-75-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/xilinx_uartps.c | 56 +++++++++++++++---------------
|
||||
1 file changed, 28 insertions(+), 28 deletions(-)
|
||||
|
||||
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
|
||||
index 2e5e86a00a77..9c13dac1d4d1 100644
|
||||
--- a/drivers/tty/serial/xilinx_uartps.c
|
||||
+++ b/drivers/tty/serial/xilinx_uartps.c
|
||||
@@ -346,7 +346,7 @@ static irqreturn_t cdns_uart_isr(int irq, void *dev_id)
|
||||
struct uart_port *port = (struct uart_port *)dev_id;
|
||||
unsigned int isrstatus;
|
||||
|
||||
- spin_lock(&port->lock);
|
||||
+ uart_port_lock(port);
|
||||
|
||||
/* Read the interrupt status register to determine which
|
||||
* interrupt(s) is/are active and clear them.
|
||||
@@ -369,7 +369,7 @@ static irqreturn_t cdns_uart_isr(int irq, void *dev_id)
|
||||
!(readl(port->membase + CDNS_UART_CR) & CDNS_UART_CR_RX_DIS))
|
||||
cdns_uart_handle_rx(dev_id, isrstatus);
|
||||
|
||||
- spin_unlock(&port->lock);
|
||||
+ uart_port_unlock(port);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
@@ -506,14 +506,14 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb,
|
||||
return NOTIFY_BAD;
|
||||
}
|
||||
|
||||
- spin_lock_irqsave(&cdns_uart->port->lock, flags);
|
||||
+ uart_port_lock_irqsave(cdns_uart->port, &flags);
|
||||
|
||||
/* Disable the TX and RX to set baud rate */
|
||||
ctrl_reg = readl(port->membase + CDNS_UART_CR);
|
||||
ctrl_reg |= CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS;
|
||||
writel(ctrl_reg, port->membase + CDNS_UART_CR);
|
||||
|
||||
- spin_unlock_irqrestore(&cdns_uart->port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(cdns_uart->port, flags);
|
||||
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
@@ -523,7 +523,7 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb,
|
||||
* frequency.
|
||||
*/
|
||||
|
||||
- spin_lock_irqsave(&cdns_uart->port->lock, flags);
|
||||
+ uart_port_lock_irqsave(cdns_uart->port, &flags);
|
||||
|
||||
locked = 1;
|
||||
port->uartclk = ndata->new_rate;
|
||||
@@ -533,7 +533,7 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb,
|
||||
fallthrough;
|
||||
case ABORT_RATE_CHANGE:
|
||||
if (!locked)
|
||||
- spin_lock_irqsave(&cdns_uart->port->lock, flags);
|
||||
+ uart_port_lock_irqsave(cdns_uart->port, &flags);
|
||||
|
||||
/* Set TX/RX Reset */
|
||||
ctrl_reg = readl(port->membase + CDNS_UART_CR);
|
||||
@@ -555,7 +555,7 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb,
|
||||
ctrl_reg |= CDNS_UART_CR_TX_EN | CDNS_UART_CR_RX_EN;
|
||||
writel(ctrl_reg, port->membase + CDNS_UART_CR);
|
||||
|
||||
- spin_unlock_irqrestore(&cdns_uart->port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(cdns_uart->port, flags);
|
||||
|
||||
return NOTIFY_OK;
|
||||
default:
|
||||
@@ -652,7 +652,7 @@ static void cdns_uart_break_ctl(struct uart_port *port, int ctl)
|
||||
unsigned int status;
|
||||
unsigned long flags;
|
||||
|
||||
- spin_lock_irqsave(&port->lock, flags);
|
||||
+ uart_port_lock_irqsave(port, &flags);
|
||||
|
||||
status = readl(port->membase + CDNS_UART_CR);
|
||||
|
||||
@@ -664,7 +664,7 @@ static void cdns_uart_break_ctl(struct uart_port *port, int ctl)
|
||||
writel(CDNS_UART_CR_STOPBRK | status,
|
||||
port->membase + CDNS_UART_CR);
|
||||
}
|
||||
- spin_unlock_irqrestore(&port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(port, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -683,7 +683,7 @@ static void cdns_uart_set_termios(struct uart_port *port,
|
||||
unsigned long flags;
|
||||
unsigned int ctrl_reg, mode_reg;
|
||||
|
||||
- spin_lock_irqsave(&port->lock, flags);
|
||||
+ uart_port_lock_irqsave(port, &flags);
|
||||
|
||||
/* Disable the TX and RX to set baud rate */
|
||||
ctrl_reg = readl(port->membase + CDNS_UART_CR);
|
||||
@@ -794,7 +794,7 @@ static void cdns_uart_set_termios(struct uart_port *port,
|
||||
cval &= ~CDNS_UART_MODEMCR_FCM;
|
||||
writel(cval, port->membase + CDNS_UART_MODEMCR);
|
||||
|
||||
- spin_unlock_irqrestore(&port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(port, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -813,7 +813,7 @@ static int cdns_uart_startup(struct uart_port *port)
|
||||
|
||||
is_brk_support = cdns_uart->quirks & CDNS_UART_RXBS_SUPPORT;
|
||||
|
||||
- spin_lock_irqsave(&port->lock, flags);
|
||||
+ uart_port_lock_irqsave(port, &flags);
|
||||
|
||||
/* Disable the TX and RX */
|
||||
writel(CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS,
|
||||
@@ -861,7 +861,7 @@ static int cdns_uart_startup(struct uart_port *port)
|
||||
writel(readl(port->membase + CDNS_UART_ISR),
|
||||
port->membase + CDNS_UART_ISR);
|
||||
|
||||
- spin_unlock_irqrestore(&port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(port, flags);
|
||||
|
||||
ret = request_irq(port->irq, cdns_uart_isr, 0, CDNS_UART_NAME, port);
|
||||
if (ret) {
|
||||
@@ -889,7 +889,7 @@ static void cdns_uart_shutdown(struct uart_port *port)
|
||||
int status;
|
||||
unsigned long flags;
|
||||
|
||||
- spin_lock_irqsave(&port->lock, flags);
|
||||
+ uart_port_lock_irqsave(port, &flags);
|
||||
|
||||
/* Disable interrupts */
|
||||
status = readl(port->membase + CDNS_UART_IMR);
|
||||
@@ -900,7 +900,7 @@ static void cdns_uart_shutdown(struct uart_port *port)
|
||||
writel(CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS,
|
||||
port->membase + CDNS_UART_CR);
|
||||
|
||||
- spin_unlock_irqrestore(&port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(port, flags);
|
||||
|
||||
free_irq(port->irq, port);
|
||||
}
|
||||
@@ -1050,7 +1050,7 @@ static int cdns_uart_poll_get_char(struct uart_port *port)
|
||||
int c;
|
||||
unsigned long flags;
|
||||
|
||||
- spin_lock_irqsave(&port->lock, flags);
|
||||
+ uart_port_lock_irqsave(port, &flags);
|
||||
|
||||
/* Check if FIFO is empty */
|
||||
if (readl(port->membase + CDNS_UART_SR) & CDNS_UART_SR_RXEMPTY)
|
||||
@@ -1058,7 +1058,7 @@ static int cdns_uart_poll_get_char(struct uart_port *port)
|
||||
else /* Read a character */
|
||||
c = (unsigned char) readl(port->membase + CDNS_UART_FIFO);
|
||||
|
||||
- spin_unlock_irqrestore(&port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(port, flags);
|
||||
|
||||
return c;
|
||||
}
|
||||
@@ -1067,7 +1067,7 @@ static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
- spin_lock_irqsave(&port->lock, flags);
|
||||
+ uart_port_lock_irqsave(port, &flags);
|
||||
|
||||
/* Wait until FIFO is empty */
|
||||
while (!(readl(port->membase + CDNS_UART_SR) & CDNS_UART_SR_TXEMPTY))
|
||||
@@ -1080,7 +1080,7 @@ static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c)
|
||||
while (!(readl(port->membase + CDNS_UART_SR) & CDNS_UART_SR_TXEMPTY))
|
||||
cpu_relax();
|
||||
|
||||
- spin_unlock_irqrestore(&port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(port, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1232,9 +1232,9 @@ static void cdns_uart_console_write(struct console *co, const char *s,
|
||||
if (port->sysrq)
|
||||
locked = 0;
|
||||
else if (oops_in_progress)
|
||||
- locked = spin_trylock_irqsave(&port->lock, flags);
|
||||
+ locked = uart_port_trylock_irqsave(port, &flags);
|
||||
else
|
||||
- spin_lock_irqsave(&port->lock, flags);
|
||||
+ uart_port_lock_irqsave(port, &flags);
|
||||
|
||||
/* save and disable interrupt */
|
||||
imr = readl(port->membase + CDNS_UART_IMR);
|
||||
@@ -1257,7 +1257,7 @@ static void cdns_uart_console_write(struct console *co, const char *s,
|
||||
writel(imr, port->membase + CDNS_UART_IER);
|
||||
|
||||
if (locked)
|
||||
- spin_unlock_irqrestore(&port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(port, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1325,7 +1325,7 @@ static int cdns_uart_suspend(struct device *device)
|
||||
if (console_suspend_enabled && uart_console(port) && may_wake) {
|
||||
unsigned long flags;
|
||||
|
||||
- spin_lock_irqsave(&port->lock, flags);
|
||||
+ uart_port_lock_irqsave(port, &flags);
|
||||
/* Empty the receive FIFO 1st before making changes */
|
||||
while (!(readl(port->membase + CDNS_UART_SR) &
|
||||
CDNS_UART_SR_RXEMPTY))
|
||||
@@ -1334,7 +1334,7 @@ static int cdns_uart_suspend(struct device *device)
|
||||
writel(1, port->membase + CDNS_UART_RXWM);
|
||||
/* disable RX timeout interrups */
|
||||
writel(CDNS_UART_IXR_TOUT, port->membase + CDNS_UART_IDR);
|
||||
- spin_unlock_irqrestore(&port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(port, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1372,7 +1372,7 @@ static int cdns_uart_resume(struct device *device)
|
||||
return ret;
|
||||
}
|
||||
|
||||
- spin_lock_irqsave(&port->lock, flags);
|
||||
+ uart_port_lock_irqsave(port, &flags);
|
||||
|
||||
/* Set TX/RX Reset */
|
||||
ctrl_reg = readl(port->membase + CDNS_UART_CR);
|
||||
@@ -1392,14 +1392,14 @@ static int cdns_uart_resume(struct device *device)
|
||||
|
||||
clk_disable(cdns_uart->uartclk);
|
||||
clk_disable(cdns_uart->pclk);
|
||||
- spin_unlock_irqrestore(&port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(port, flags);
|
||||
} else {
|
||||
- spin_lock_irqsave(&port->lock, flags);
|
||||
+ uart_port_lock_irqsave(port, &flags);
|
||||
/* restore original rx trigger level */
|
||||
writel(rx_trigger_level, port->membase + CDNS_UART_RXWM);
|
||||
/* enable RX timeout interrupt */
|
||||
writel(CDNS_UART_IXR_TOUT, port->membase + CDNS_UART_IER);
|
||||
- spin_unlock_irqrestore(&port->lock, flags);
|
||||
+ uart_port_unlock_irqrestore(port, flags);
|
||||
}
|
||||
|
||||
return uart_resume_port(cdns_uart->cdns_uart_driver, port);
|
||||
--
|
||||
2.43.2
|
||||
|
Reference in New Issue
Block a user