From 795e5a2ca9df55db46323646301ca2d74c38391b Mon Sep 17 00:00:00 2001 From: "Chia-Lin Kao (AceLan)" Date: Tue, 22 Aug 2023 11:57:40 +0800 Subject: [PATCH] UBUNTU: SAUCE: platform/x86: dell-uart-backlight: replace chars_in_buffer() with flush_chars() BugLink: https://bugs.launchpad.net/bugs/2032174 After v6.5, calls tty->driver->ops->chars_in_buffer() may lead to a deadlock and got soft lockup error. Try using tty->driver->ops->flush_chars() to archive to same scenario. There is no functional change, even if uart_flush_chars() doesn't do what we expected, the driver should be able to keep working, as the backlight commands is only 3 or 4 bytes short and has little chance to stay in the queue partially. Signed-off-by: Chia-Lin Kao (AceLan) Signed-off-by: Andrea Righi --- drivers/platform/x86/dell/dell-uart-backlight.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/dell/dell-uart-backlight.c b/drivers/platform/x86/dell/dell-uart-backlight.c index 3f8ea639d557..120701e5b8b1 100644 --- a/drivers/platform/x86/dell/dell-uart-backlight.c +++ b/drivers/platform/x86/dell/dell-uart-backlight.c @@ -39,7 +39,8 @@ static struct file *ftty; unsigned int (*io_serial_in)(struct uart_port *p, int offset); int (*uart_write)(struct tty_struct *tty, const unsigned char *buf, int count); -unsigned int (*uart_chars_in_buffer)(struct tty_struct *tty); +void (*uart_flush_chars)(struct tty_struct *tty); + static bool force; module_param(force, bool, 0444); @@ -160,8 +161,7 @@ static int dell_uart_write(struct uart_8250_port *up, __u8 *buf, int len) tty_port_tty_wakeup(&port->state->port); tty = tty_port_tty_get(&port->state->port); actual = uart_write(tty, buf, len); - while (uart_chars_in_buffer(tty)) - udelay(10); + uart_flush_chars(tty); return actual; } @@ -401,7 +401,7 @@ static int dell_uart_startup(struct dell_uart_backlight *dell_pdata) tty = port->state->port.tty; io_serial_in = port->serial_in; uart_write = tty->driver->ops->write; - uart_chars_in_buffer = tty->driver->ops->chars_in_buffer; + uart_flush_chars = tty->driver->ops->flush_chars; return 0; }