linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: gregkh@linuxfoundation.org, jslaby@suse.cz
Cc: linaro-kernel@lists.linaro.org, patches@linaro.org,
	linux-serial@vger.kernel.org,
	Viresh Kumar <viresh.kumar@linaro.org>
Subject: [PATCH 15/25] tty: serial: mpsc: drop uart_port->lock before calling tty_flip_buffer_push()
Date: Fri, 16 Aug 2013 17:13:16 +0530	[thread overview]
Message-ID: <bcdda9a01d8bea7ba4ad78e6e14b9ad7f86a3ee4.1376651114.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1376651114.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1376651114.git.viresh.kumar@linaro.org>

The -rt patch triggers a lockdep warning for serial drivers if
tty_flip_buffer_push() is called with uart_port->lock locked. This never shows
up on UP kernels.

Release the port lock before calling tty_flip_buffer_push() and reacquire it
after the call.

Similar stuff was already done for few other drivers in the past, like:

commit 2389b272168ceec056ca1d8a870a97fa9c26e11a
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Tue May 29 21:53:50 2007 +0100

    [ARM] 4417/1: Serial: Fix AMBA drivers locking

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/tty/serial/mpsc.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c
index bc24f49..556ff04 100644
--- a/drivers/tty/serial/mpsc.c
+++ b/drivers/tty/serial/mpsc.c
@@ -934,7 +934,7 @@ static int serial_polled;
  ******************************************************************************
  */
 
-static int mpsc_rx_intr(struct mpsc_port_info *pi)
+static int mpsc_rx_intr(struct mpsc_port_info *pi, unsigned long *flags)
 {
 	struct mpsc_rx_desc *rxre;
 	struct tty_port *port = &pi->port.state->port;
@@ -969,8 +969,11 @@ static int mpsc_rx_intr(struct mpsc_port_info *pi)
 #endif
 		/* Following use of tty struct directly is deprecated */
 		if (tty_buffer_request_room(port, bytes_in) < bytes_in) {
-			if (port->low_latency)
+			if (port->low_latency) {
+				spin_unlock_irqrestore(&pi->port.lock, *flags);
 				tty_flip_buffer_push(port);
+				spin_lock_irqsave(&pi->port.lock, *flags);
+			}
 			/*
 			 * If this failed then we will throw away the bytes
 			 * but must do so to clear interrupts.
@@ -1080,7 +1083,9 @@ next_frame:
 	if ((readl(pi->sdma_base + SDMA_SDCM) & SDMA_SDCM_ERD) == 0)
 		mpsc_start_rx(pi);
 
+	spin_unlock_irqrestore(&pi->port.lock, *flags);
 	tty_flip_buffer_push(port);
+	spin_lock_irqsave(&pi->port.lock, *flags);
 	return rc;
 }
 
@@ -1222,7 +1227,7 @@ static irqreturn_t mpsc_sdma_intr(int irq, void *dev_id)
 
 	spin_lock_irqsave(&pi->port.lock, iflags);
 	mpsc_sdma_intr_ack(pi);
-	if (mpsc_rx_intr(pi))
+	if (mpsc_rx_intr(pi, &iflags))
 		rc = IRQ_HANDLED;
 	if (mpsc_tx_intr(pi))
 		rc = IRQ_HANDLED;
-- 
1.7.12.rc2.18.g61b472e


  parent reply	other threads:[~2013-08-16 11:45 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-16 11:43 [PATCH 00/25] tty: serial: drop uart_port->lock before calling Viresh Kumar
2013-08-16 11:43 ` [PATCH 01/25] tty: serial: altera_jtag: drop uart_port->lock before calling tty_flip_buffer_push() Viresh Kumar
2013-08-16 11:43 ` [PATCH 02/25] tty: serial: altera: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 03/25] tty: serial: apbuart: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 04/25] tty: serial: ar933x: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 05/25] tty: serial: arc: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 06/25] tty: serial: bcm63xx: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 07/25] tty: serial: bfin_sport: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 08/25] tty: serial: efm32: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 09/25] tty: serial: icom: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 10/25] tty: serial: lpc32xx_hs: don't call tty_flip_buffer_push() twice Viresh Kumar
2013-08-16 11:43 ` [PATCH 11/25] tty: serial: lpc32xx_hs: drop uart_port->lock before calling tty_flip_buffer_push() Viresh Kumar
2013-08-16 11:43 ` [PATCH 12/25] tty: serial: m32r_sio: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 13/25] tty: serial: mcf: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 14/25] tty: serial: mfd: " Viresh Kumar
2013-08-16 11:43 ` Viresh Kumar [this message]
2013-08-16 11:43 ` [PATCH 16/25] tty: serial: msm: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 17/25] tty: serial: netx: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 18/25] tty: serial: nwpserial: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 19/25] tty: serial: pnx8xxx: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 20/25] tty: serial: rp2: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 21/25] tty: serial: sa1100: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 22/25] tty: serial: samsung: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 23/25] tty: serial: tegra: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 24/25] tty: serial: sirfsoc: " Viresh Kumar
2013-08-16 11:43 ` [PATCH 25/25] tty: serial: vt8500: " Viresh Kumar
2013-08-16 12:06 ` [PATCH 00/25] tty: serial: drop uart_port->lock before calling Peter Hurley
2013-08-16 16:59   ` Viresh Kumar
2013-08-16 12:27 ` Greg KH
2013-08-16 17:44   ` Viresh Kumar
2013-08-19 10:43     ` Viresh Kumar
2013-08-19 13:15       ` Peter Hurley
2013-08-19 14:37         ` Viresh Kumar

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=bcdda9a01d8bea7ba4ad78e6e14b9ad7f86a3ee4.1376651114.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=patches@linaro.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;
as well as URLs for NNTP newsgroup(s).