diff options
author | 2022-04-07 16:16:19 +0900 | |
---|---|---|
committer | 2022-04-15 08:42:46 +0200 | |
commit | e73b5c7f3d34c159447de0d24110f1df6d1b6615 (patch) | |
tree | 7a9df5b19f9f9e0558b987d8de7c27143952f2bf /drivers/tty/serial/samsung_tty.c | |
parent | tty: Fix a possible resource leak in icom_probe (diff) | |
download | linux-e73b5c7f3d34c159447de0d24110f1df6d1b6615.tar.gz linux-e73b5c7f3d34c159447de0d24110f1df6d1b6615.tar.bz2 linux-e73b5c7f3d34c159447de0d24110f1df6d1b6615.zip |
tty: serial: samsung: add spin_lock for interrupt and console_write
The console_write and IRQ handler can run concurrently.
Problems may occurs console_write is continuously executed while
the IRQ handler is running.
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
Link: https://lore.kernel.org/r/20220407071619.102249-2-jaewon02.kim@samsung.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/samsung_tty.c')
-rw-r--r-- | drivers/tty/serial/samsung_tty.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index e1585fbae909..8af5aceb9f4e 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -2480,12 +2480,24 @@ s3c24xx_serial_console_write(struct console *co, const char *s, unsigned int count) { unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON); + unsigned long flags; + bool locked = true; /* not possible to xmit on unconfigured port */ if (!s3c24xx_port_configured(ucon)) return; + if (cons_uart->sysrq) + locked = false; + else if (oops_in_progress) + locked = spin_trylock_irqsave(&cons_uart->lock, flags); + else + spin_lock_irqsave(&cons_uart->lock, flags); + uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar); + + if (locked) + spin_unlock_irqrestore(&cons_uart->lock, flags); } /* Shouldn't be __init, as it can be instantiated from other module */ |