All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Clear previous interrupts after fifo is disabled
@ 2012-02-27  9:30 Chanho Min
  2012-02-27 10:45   ` Linus Walleij
                   ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Chanho Min @ 2012-02-27  9:30 UTC (permalink / raw)
  To: Russell King, Alan Cox, Greg Kroah-Hartman, Linus Walleij,
	Shreshtha Kumar Sahu, Kim, Jong-Sung
  Cc: linux-kernel, linux-serial

This is another workaroud of  'https://lkml.org/lkml/2012/1/17/104'
with additional analysis.Bootloader can transfer control to kernel and
there are some pending interrupts. In this case, RXFE of the flag
register is set by clearing FEN(LCRH) even if rx data remains in the
fifo. It seems that the fifo's status is initiailized. Interrupt
handler can not get any data from data register because of the below
break condtion.

pl011_fifo_to_tty
 while (max_count--) {
   if (status & UART01x_FR_RXFE)
	break;

Then, Rx interrupt is never cleared. cpu is looping in ISR. System is
hang. If we don't guarantee that no interrupt is pended until fifo is
disabled by calling 'writew(0, uap->port.membase + uap->lcrh_rx)',
this misbehave of the interrupt handelr can be occurred. So, All
pending interrupts should be cleared just after fifo is disabled under
the protection from interrupt. Also,'clear error interrupts' routine
can be removed becuase all interrupts are cleared before.

Signed-off-by: Chanho Min <chanho.min@lge.com>
---
 drivers/tty/serial/amba-pl011.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 6800f5f..8b5a824 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1397,7 +1397,11 @@ static int pl011_startup(struct uart_port *port)
 	writew(cr, uap->port.membase + UART011_CR);
 	writew(0, uap->port.membase + UART011_FBRD);
 	writew(1, uap->port.membase + UART011_IBRD);
+	spin_lock_irq(&uap->port.lock);
 	writew(0, uap->port.membase + uap->lcrh_rx);
+	/* Clear all pending interrupts. */
+	writew(0xffff, uap->port.membase + UART011_ICR);
+	spin_unlock_irq(&uap->port.lock);
 	if (uap->lcrh_tx != uap->lcrh_rx) {
 		int i;
 		/*
@@ -1417,10 +1421,6 @@ static int pl011_startup(struct uart_port *port)
 	cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE;
 	writew(cr, uap->port.membase + UART011_CR);

-	/* Clear pending error interrupts */
-	writew(UART011_OEIS | UART011_BEIS | UART011_PEIS | UART011_FEIS,
-	       uap->port.membase + UART011_ICR);
-
 	/*
 	 * initialise the old status of the modem signals
 	 */
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2012-03-12  8:29 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-27  9:30 [PATCH] Clear previous interrupts after fifo is disabled Chanho Min
2012-02-27 10:45 ` Linus Walleij
2012-02-27 10:45   ` Linus Walleij
2012-02-27 10:48 ` Russell King - ARM Linux
2012-02-27 11:02   ` Russell King - ARM Linux
2012-02-27 13:54     ` Linus Walleij
2012-02-28  1:35     ` Chanho Min
2012-02-28  8:35       ` Russell King - ARM Linux
2012-02-28  8:35         ` Russell King - ARM Linux
2012-02-28  9:16         ` Chanho Min
2012-02-28  9:16           ` Chanho Min
2012-02-28  9:21           ` Russell King - ARM Linux
2012-02-28  9:46             ` Chanho Min
2012-02-28 10:23               ` Russell King - ARM Linux
2012-02-29  2:47                 ` Chanho Min
2012-02-29  2:47                   ` Chanho Min
2012-03-08  9:02 ` Kim, Jong-Sung
2012-03-08  9:02   ` Kim, Jong-Sung
2012-03-08 18:49 ` Greg Kroah-Hartman
2012-03-09 16:34   ` Linus Walleij
2012-03-09 16:34     ` Linus Walleij
2012-03-09 16:37     ` Greg Kroah-Hartman
2012-03-09 16:37       ` Greg Kroah-Hartman
2012-03-10  2:14       ` Chanho Min
2012-03-12  1:24         ` Kim, Jong-Sung
2012-03-12  1:24           ` Kim, Jong-Sung
2012-03-12  8:29   ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.