Thread (18 messages) read the whole thread 18 messages, 5 authors, 2014-05-29
STALE4446d

Revision v1 of 3 in this series.

Revisions (3)
  1. v1 [diff vs current]
  2. v1 current
  3. v1 [diff vs current]

[PATCH 3/5] serial: imx: avoid spinlock recursion deadlock

From: Huang Shijie <hidden>
Date: 2014-05-12 03:12:15
Also in: linux-serial

? 2014?05?09? 23:19, dean_jenkins at mentor.com ??:
quoted hunk ↗ jump to hunk
From: Andy Lowe<redacted>

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<redacted>
Signed-off-by: Dirk Behme<redacted>
---
  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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help