port->lock is unlocked in each branch in altera_jtaguart_console_putc(),
so do it before the "if". "status" needs not be under the lock, as the
register was already read.
Cc: Tobias Klauser <[email protected]>
Signed-off-by: Jiri Slaby <[email protected]>
---
drivers/tty/serial/altera_jtaguart.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
index ac8ce418de36..c2d154d78e54 100644
--- a/drivers/tty/serial/altera_jtaguart.c
+++ b/drivers/tty/serial/altera_jtaguart.c
@@ -310,11 +310,12 @@ static void altera_jtaguart_console_putc(struct uart_port *port, unsigned char c
spin_lock_irqsave(&port->lock, flags);
while (!altera_jtaguart_tx_space(port, &status)) {
+ spin_unlock_irqrestore(&port->lock, flags);
+
if ((status & ALTERA_JTAGUART_CONTROL_AC_MSK) == 0) {
- spin_unlock_irqrestore(&port->lock, flags);
return; /* no connection activity */
}
- spin_unlock_irqrestore(&port->lock, flags);
+
cpu_relax();
spin_lock_irqsave(&port->lock, flags);
}
--
2.37.3
On 2022-09-27 at 13:18:19 +0200, Jiri Slaby <[email protected]> wrote:
> port->lock is unlocked in each branch in altera_jtaguart_console_putc(),
> so do it before the "if". "status" needs not be under the lock, as the
> register was already read.
>
> Cc: Tobias Klauser <[email protected]>
> Signed-off-by: Jiri Slaby <[email protected]>
Acked-by: Tobias Klauser <[email protected]>
Thanks
On Tue, 27 Sep 2022, Jiri Slaby wrote:
> port->lock is unlocked in each branch in altera_jtaguart_console_putc(),
> so do it before the "if". "status" needs not be under the lock, as the
> register was already read.
>
> Cc: Tobias Klauser <[email protected]>
> Signed-off-by: Jiri Slaby <[email protected]>
> ---
> drivers/tty/serial/altera_jtaguart.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
> index ac8ce418de36..c2d154d78e54 100644
> --- a/drivers/tty/serial/altera_jtaguart.c
> +++ b/drivers/tty/serial/altera_jtaguart.c
> @@ -310,11 +310,12 @@ static void altera_jtaguart_console_putc(struct uart_port *port, unsigned char c
>
> spin_lock_irqsave(&port->lock, flags);
> while (!altera_jtaguart_tx_space(port, &status)) {
> + spin_unlock_irqrestore(&port->lock, flags);
> +
> if ((status & ALTERA_JTAGUART_CONTROL_AC_MSK) == 0) {
> - spin_unlock_irqrestore(&port->lock, flags);
> return; /* no connection activity */
> }
There braces are now unnecessary.
Reviewed-by: Ilpo J?rvinen <[email protected]>
--
i.
> - spin_unlock_irqrestore(&port->lock, flags);
> +
> cpu_relax();
> spin_lock_irqsave(&port->lock, flags);
> }
>