From: Neil Armstrong <neil.armstrong@linaro.org>
To: John Ogness <john.ogness@linutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Jiri Slaby" <jirislaby@kernel.org>,
linux-serial@vger.kernel.org, "Petr Mladek" <pmladek@suse.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
linux-kernel@vger.kernel.org,
"Kevin Hilman" <khilman@baylibre.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Dmitry Rokosov" <ddrokosov@sberdevices.ru>,
"Lucas Tanure" <tanure@linux.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org
Subject: Re: [PATCH tty v1 37/74] serial: meson: Use port lock wrappers
Date: Fri, 15 Sep 2023 08:56:49 +0200 [thread overview]
Message-ID: <5cd2ed15-949d-40b4-93fd-b1480f557b14@linaro.org> (raw)
In-Reply-To: <20230914183831.587273-38-john.ogness@linutronix.de>
On 14/09/2023 20:37, John Ogness wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
>
> 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>
> ---
> drivers/tty/serial/meson_uart.c | 30 +++++++++++++++---------------
> 1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
> index 790d910dafa5..45cc23e9e399 100644
> --- a/drivers/tty/serial/meson_uart.c
> +++ b/drivers/tty/serial/meson_uart.c
> @@ -129,14 +129,14 @@ static void meson_uart_shutdown(struct uart_port *port)
>
> free_irq(port->irq, port);
>
> - spin_lock_irqsave(&port->lock, flags);
> + uart_port_lock_irqsave(port, &flags);
>
> val = readl(port->membase + AML_UART_CONTROL);
> val &= ~AML_UART_RX_EN;
> val &= ~(AML_UART_RX_INT_EN | AML_UART_TX_INT_EN);
> writel(val, port->membase + AML_UART_CONTROL);
>
> - spin_unlock_irqrestore(&port->lock, flags);
> + uart_port_unlock_irqrestore(port, flags);
> }
>
> static void meson_uart_start_tx(struct uart_port *port)
> @@ -238,7 +238,7 @@ static irqreturn_t meson_uart_interrupt(int irq, void *dev_id)
> {
> struct uart_port *port = (struct uart_port *)dev_id;
>
> - spin_lock(&port->lock);
> + uart_port_lock(port);
>
> if (!(readl(port->membase + AML_UART_STATUS) & AML_UART_RX_EMPTY))
> meson_receive_chars(port);
> @@ -248,7 +248,7 @@ static irqreturn_t meson_uart_interrupt(int irq, void *dev_id)
> meson_uart_start_tx(port);
> }
>
> - spin_unlock(&port->lock);
> + uart_port_unlock(port);
>
> return IRQ_HANDLED;
> }
> @@ -284,7 +284,7 @@ static int meson_uart_startup(struct uart_port *port)
> u32 val;
> int ret = 0;
>
> - spin_lock_irqsave(&port->lock, flags);
> + uart_port_lock_irqsave(port, &flags);
>
> val = readl(port->membase + AML_UART_CONTROL);
> val |= AML_UART_CLEAR_ERR;
> @@ -301,7 +301,7 @@ static int meson_uart_startup(struct uart_port *port)
> val = (AML_UART_RECV_IRQ(1) | AML_UART_XMIT_IRQ(port->fifosize / 2));
> writel(val, port->membase + AML_UART_MISC);
>
> - spin_unlock_irqrestore(&port->lock, flags);
> + uart_port_unlock_irqrestore(port, flags);
>
> ret = request_irq(port->irq, meson_uart_interrupt, 0,
> port->name, port);
> @@ -341,7 +341,7 @@ static void meson_uart_set_termios(struct uart_port *port,
> unsigned long flags;
> u32 val;
>
> - spin_lock_irqsave(&port->lock, flags);
> + uart_port_lock_irqsave(port, &flags);
>
> cflags = termios->c_cflag;
> iflags = termios->c_iflag;
> @@ -401,7 +401,7 @@ static void meson_uart_set_termios(struct uart_port *port,
> AML_UART_FRAME_ERR;
>
> uart_update_timeout(port, termios->c_cflag, baud);
> - spin_unlock_irqrestore(&port->lock, flags);
> + uart_port_unlock_irqrestore(port, flags);
> }
>
> static int meson_uart_verify_port(struct uart_port *port,
> @@ -460,14 +460,14 @@ static int meson_uart_poll_get_char(struct uart_port *port)
> u32 c;
> unsigned long flags;
>
> - spin_lock_irqsave(&port->lock, flags);
> + uart_port_lock_irqsave(port, &flags);
>
> if (readl(port->membase + AML_UART_STATUS) & AML_UART_RX_EMPTY)
> c = NO_POLL_CHAR;
> else
> c = readl(port->membase + AML_UART_RFIFO);
>
> - spin_unlock_irqrestore(&port->lock, flags);
> + uart_port_unlock_irqrestore(port, flags);
>
> return c;
> }
> @@ -478,7 +478,7 @@ static void meson_uart_poll_put_char(struct uart_port *port, unsigned char c)
> u32 reg;
> int ret;
>
> - spin_lock_irqsave(&port->lock, flags);
> + uart_port_lock_irqsave(port, &flags);
>
> /* Wait until FIFO is empty or timeout */
> ret = readl_poll_timeout_atomic(port->membase + AML_UART_STATUS, reg,
> @@ -502,7 +502,7 @@ static void meson_uart_poll_put_char(struct uart_port *port, unsigned char c)
> dev_err(port->dev, "Timeout waiting for UART TX EMPTY\n");
>
> out:
> - spin_unlock_irqrestore(&port->lock, flags);
> + uart_port_unlock_irqrestore(port, flags);
> }
>
> #endif /* CONFIG_CONSOLE_POLL */
> @@ -559,9 +559,9 @@ static void meson_serial_port_write(struct uart_port *port, const char *s,
> if (port->sysrq) {
> locked = 0;
> } else if (oops_in_progress) {
> - locked = spin_trylock(&port->lock);
> + locked = uart_port_trylock(port);
> } else {
> - spin_lock(&port->lock);
> + uart_port_lock(port);
> locked = 1;
> }
>
> @@ -573,7 +573,7 @@ static void meson_serial_port_write(struct uart_port *port, const char *s,
> writel(val, port->membase + AML_UART_CONTROL);
>
> if (locked)
> - spin_unlock(&port->lock);
> + uart_port_unlock(port);
> local_irq_restore(flags);
> }
>
Acked-by: Neil Armstrong <neil.armstrong@linaro.org>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-09-15 6:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230914183831.587273-1-john.ogness@linutronix.de>
2023-09-14 18:37 ` [PATCH tty v1 04/74] serial: 8250_aspeed_vuart: Use port lock wrappers John Ogness
2023-09-14 18:37 ` [PATCH tty v1 11/74] serial: 8250_mtk: " John Ogness
2023-09-15 4:07 ` Chen-Yu Tsai
2023-09-14 18:37 ` [PATCH tty v1 21/74] serial: atmel: " John Ogness
2023-09-14 18:37 ` [PATCH tty v1 24/74] serial: digicolor: " John Ogness
2023-09-18 6:13 ` Baruch Siach
2023-09-14 18:37 ` [PATCH tty v1 29/74] serial: imx: " John Ogness
2023-09-15 20:21 ` Uwe Kleine-König
2023-09-16 19:45 ` John Ogness
2023-09-17 12:11 ` Uwe Kleine-König
2023-09-14 18:37 ` [PATCH tty v1 33/74] serial: lpc32xx_hs: " John Ogness
2023-09-14 18:37 ` [PATCH tty v1 34/74] serial: ma35d1: " John Ogness
2023-09-14 18:37 ` [PATCH tty v1 37/74] serial: meson: " John Ogness
2023-09-15 6:56 ` Neil Armstrong [this message]
2023-09-14 18:37 ` [PATCH tty v1 38/74] serial: milbeaut_usio: " John Ogness
2023-09-14 18:37 ` [PATCH tty v1 40/74] serial: mps2-uart: " John Ogness
2023-09-14 18:38 ` [PATCH tty v1 44/74] serial: owl: " John Ogness
2023-09-14 18:38 ` [PATCH tty v1 50/74] serial: rda: " John Ogness
2023-09-14 18:38 ` [PATCH tty v1 53/74] serial: samsung_tty: " John Ogness
2023-09-14 18:38 ` [PATCH tty v1 63/74] serial: st-asc: " John Ogness
2023-09-14 18:38 ` [PATCH tty v1 64/74] serial: stm32: " John Ogness
2023-09-14 18:38 ` [PATCH tty v1 73/74] serial: vt8500: " John Ogness
2023-09-14 18:38 ` [PATCH tty v1 74/74] serial: xilinx_uartps: " John Ogness
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5cd2ed15-949d-40b4-93fd-b1480f557b14@linaro.org \
--to=neil.armstrong@linaro.org \
--cc=ddrokosov@sberdevices.ru \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jbrunet@baylibre.com \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=pmladek@suse.com \
--cc=tanure@linux.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox