mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Ogness <john.ogness@linutronix.de>
To: Sascha Hauer <kernel@pengutronix.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] serial: fix possible imx deadlock
Date: Mon, 15 Mar 2010 10:08:58 +0100	[thread overview]
Message-ID: <80k4tehryt.fsf@merkur.tec.linutronix.de> (raw)

This patch fixes a possible deadlock situation with the port and timer
locks. The calling paths for the deadlock situation are:

1. imx_set_termios() -> LOCK(port.lock)
      -> del_timer_sync() -> LOCK(timer.base.lock)

2. run_timer_softirq() -> LOCK(timer.base.lock)
      -> imx_timeout() -> LOCK(port.lock)

This patch is against 2.6.34-rc1.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 drivers/serial/imx.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff -Naurp a/drivers/serial/imx.c b/drivers/serial/imx.c
--- a/drivers/serial/imx.c	2010-03-08 19:45:44.000000000 +0100
+++ b/drivers/serial/imx.c	2010-03-15 09:52:39.855261060 +0100
@@ -836,6 +836,12 @@ imx_set_termios(struct uart_port *port, 
 	baud = uart_get_baud_rate(port, termios, old, 50, port->uartclk / 16);
 	quot = uart_get_divisor(port, baud);
 
+	/*
+	 * Stop our timer. This is done with the port unlocked
+	 * to avoid possible deadlock against the timer function.
+	 */
+	del_timer_sync(&sport->timer);
+
 	spin_lock_irqsave(&sport->port.lock, flags);
 
 	sport->port.read_status_mask = 0;
@@ -860,8 +866,6 @@ imx_set_termios(struct uart_port *port, 
 			sport->port.ignore_status_mask |= URXD_OVRRUN;
 	}
 
-	del_timer_sync(&sport->timer);
-
 	/*
 	 * Update the per-port timeout.
 	 */

             reply	other threads:[~2010-03-15  9:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-15  9:08 John Ogness [this message]
2010-03-15 13:45 ` Sascha Hauer
2010-03-19 21:57   ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80k4tehryt.fsf@merkur.tec.linutronix.de \
    --to=john.ogness@linutronix.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®