Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7fd6f640 authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman
Browse files

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: default avatarZhang Zhen <zhenzhang.zhang@huawei.com>
Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9eccca08
Loading
Loading
Loading
Loading
+12 −3
Original line number Original line Diff line number Diff line
@@ -119,7 +119,10 @@ static void dw8250_serial_out(struct uart_port *p, int offset, int value)
			dw8250_force_idle(p);
			dw8250_force_idle(p);
			writeb(value, p->membase + (UART_LCR << p->regshift));
			writeb(value, p->membase + (UART_LCR << p->regshift));
		}
		}
		dev_err(p->dev, "Couldn't set LCR to %d\n", value);
		/*
		 * FIXME: this deadlocks if port->lock is already held
		 * dev_err(p->dev, "Couldn't set LCR to %d\n", value);
		 */
	}
	}
}
}


@@ -163,7 +166,10 @@ static void dw8250_serial_outq(struct uart_port *p, int offset, int value)
			__raw_writeq(value & 0xff,
			__raw_writeq(value & 0xff,
				     p->membase + (UART_LCR << p->regshift));
				     p->membase + (UART_LCR << p->regshift));
		}
		}
		dev_err(p->dev, "Couldn't set LCR to %d\n", value);
		/*
		 * FIXME: this deadlocks if port->lock is already held
		 * dev_err(p->dev, "Couldn't set LCR to %d\n", value);
		 */
	}
	}
}
}
#endif /* CONFIG_64BIT */
#endif /* CONFIG_64BIT */
@@ -187,7 +193,10 @@ static void dw8250_serial_out32(struct uart_port *p, int offset, int value)
			dw8250_force_idle(p);
			dw8250_force_idle(p);
			writel(value, p->membase + (UART_LCR << p->regshift));
			writel(value, p->membase + (UART_LCR << p->regshift));
		}
		}
		dev_err(p->dev, "Couldn't set LCR to %d\n", value);
		/*
		 * FIXME: this deadlocks if port->lock is already held
		 * dev_err(p->dev, "Couldn't set LCR to %d\n", value);
		 */
	}
	}
}
}