Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

serial: 8250_dw: Fix deadlock in LCR workaround

Trying to write console output from within the serial console driver
while the port->lock is held causes recursive deadlock:

CPU 0
spin_lock_irqsave(&port->lock)
printk()
console_unlock()
call_console_drivers()
serial8250_console_write()
spin_lock_irqsave(&port->lock)
** DEADLOCK **

The 8250_dw i/o accessors try to write a console error message if the
LCR workaround was unsuccessful. When the port->lock is already held
(eg., when called from serial8250_set_termios()), this deadlocks.

Make the error message a FIXME until a general solution is devised.

Cc: Tim Kryger <tim.kryger@gmail.com>
Reported-by: Zhang Zhen <zhenzhang.zhang@huawei.com>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Peter Hurley and committed by
Greg Kroah-Hartman
7fd6f640 9eccca08

+12 -3
+12 -3
drivers/tty/serial/8250/8250_dw.c
··· 119 119 dw8250_force_idle(p); 120 120 writeb(value, p->membase + (UART_LCR << p->regshift)); 121 121 } 122 - dev_err(p->dev, "Couldn't set LCR to %d\n", value); 122 + /* 123 + * FIXME: this deadlocks if port->lock is already held 124 + * dev_err(p->dev, "Couldn't set LCR to %d\n", value); 125 + */ 123 126 } 124 127 } 125 128 ··· 166 163 __raw_writeq(value & 0xff, 167 164 p->membase + (UART_LCR << p->regshift)); 168 165 } 169 - dev_err(p->dev, "Couldn't set LCR to %d\n", value); 166 + /* 167 + * FIXME: this deadlocks if port->lock is already held 168 + * dev_err(p->dev, "Couldn't set LCR to %d\n", value); 169 + */ 170 170 } 171 171 } 172 172 #endif /* CONFIG_64BIT */ ··· 193 187 dw8250_force_idle(p); 194 188 writel(value, p->membase + (UART_LCR << p->regshift)); 195 189 } 196 - dev_err(p->dev, "Couldn't set LCR to %d\n", value); 190 + /* 191 + * FIXME: this deadlocks if port->lock is already held 192 + * dev_err(p->dev, "Couldn't set LCR to %d\n", value); 193 + */ 197 194 } 198 195 } 199 196