[PATCH 3/5] serial: imx: avoid spinlock recursion deadlock
Huang Shijie
b32955 at freescale.com
Sun May 11 20:12:15 PDT 2014
于 2014年05月09日 23:19, dean_jenkins at mentor.com 写道:
> From: Andy Lowe<andy_lowe at mentor.com>
>
> The following deadlock has been observed:
>
> imx_int() {
> imx_txint() {
> spin_lock_irqsave(&sport->port.lock,flags);
> /* ^^^uart_port spinlock taken in imx_txint */
> imx_transmit_buffer() {
> uart_write_wakeup(&sport->port) {
> tty_wakeup() {
> hci_uart_tty_wakeup() {
> hci_uart_tx_wakeup() {
> uart_write() {
> spin_lock_irqsave(&port->lock, flags);
> /* ^^^deadlock here when spinlock is taken again */
> .
> .
> .
> spin_unlock_irqrestore(&port->lock, flags);
> }
> }
> }
> }
> }
> }
> spin_unlock_irqrestore(&sport->port.lock,flags);
> }
> }
>
> To correct this call uart_write_wakeup() at the end of imx_txint() after
> the uart_port spinlock is unlocked.
>
> Signed-off-by: Andy Lowe<andy_lowe at mentor.com>
> Signed-off-by: Dirk Behme<dirk.behme at de.bosch.com>
> ---
> drivers/tty/serial/imx.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index abe31ad..cc79706 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -636,8 +636,13 @@ static irqreturn_t imx_txint(int irq, void *dev_id)
>
> imx_transmit_buffer(sport);
>
> - if (uart_circ_chars_pending(xmit)< WAKEUP_CHARS)
> + if (uart_circ_chars_pending(xmit)< WAKEUP_CHARS) {
> + spin_unlock_irqrestore(&sport->port.lock, flags);
> uart_write_wakeup(&sport->port);
> + } else
> + spin_unlock_irqrestore(&sport->port.lock, flags);
> +
> + return IRQ_HANDLED;
>
> out:
> spin_unlock_irqrestore(&sport->port.lock, flags);
I think this patch :
https://lkml.org/lkml/2014/3/20/623
has fixed this deadlock.
We can ignore this patch now.
thanks
Huang Shijie
More information about the linux-arm-kernel
mailing list