From patchwork Mon Mar 12 08:25:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 7225 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 184AE23E0E for ; Mon, 12 Mar 2012 08:27:26 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id B034FA18310 for ; Mon, 12 Mar 2012 08:27:25 +0000 (UTC) Received: by iage36 with SMTP id e36so8447414iag.11 for ; Mon, 12 Mar 2012 01:27:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=Db/Y48capugApbcG7Q5vYHtyFeZPx+WLc10C1QYC2ZU=; b=BGNfZgwowWsWzps8oi8kGkRZx1wLX2QADHJcfKcqqg5bebwxxyMh608mT1j7/aR7qX ooaJ305dOqQ2x6WtJSoQOCChc6FPXxWDLpaicfOdD5SFweGZXddrmiZFnogvxIHAV7ke rrYwQP4Rkm+N1laGJNGRW66XMpvQLIz9t42Lt5An55lVCDmWCUtDNu9eK28xQqBEm0/0 mFKEvG9b1ED3V4bzVFvpy9VWk8D7w4K4Q78VHtCZV/i9x+qEpKwdFpr+uJdURA8rWrc/ 67bkrl9jeqKZvhrPJl1wNP+BhlYctDrp8ni0nB/v5A1ogxt+KvqgbciGjve5yDRp9hvn sbSg== Received: by 10.42.145.72 with SMTP id e8mr14373111icv.0.1331540845118; Mon, 12 Mar 2012 01:27:25 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.53.18 with SMTP id k18csp35089ibg; Mon, 12 Mar 2012 01:27:24 -0700 (PDT) Received: by 10.14.127.5 with SMTP id c5mr1730149eei.17.1331540843414; Mon, 12 Mar 2012 01:27:23 -0700 (PDT) Received: from eu1sys200aog117.obsmtp.com (eu1sys200aog117.obsmtp.com. [207.126.144.143]) by mx.google.com with SMTP id p4si5809180eef.87.2012.03.12.01.27.08 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Mar 2012 01:27:23 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.143 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.143; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.143 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob117.postini.com ([207.126.147.11]) with SMTP ID DSNKT12zUpoNU24S7yadPo7FIvLhGxbq8nyc@postini.com; Mon, 12 Mar 2012 08:27:22 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id ACC1690; Mon, 12 Mar 2012 08:25:54 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 92C5AC3; Mon, 12 Mar 2012 06:49:19 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id C666424C2F3; Mon, 12 Mar 2012 09:26:00 +0100 (CET) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 12 Mar 2012 09:26:04 +0100 From: Linus Walleij To: Greg Kroah-Hartman , , Chanho Min Cc: , Russell King , Jong-Sung Kim , Linus Walleij , , Shreshtha Kumar Sahu Subject: [PATCH] serial: PL011: clear pending interrupts Date: Mon, 12 Mar 2012 09:25:50 +0100 Message-ID: <1331540750-25697-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.8 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmGNwtdHv1muvbMeHmyPMNT1Ou1WevjgRkhkeylia/D40XRq6YhQXwH3qIjOQiU4pKcqNJn From: Linus Walleij Chanho Min reported that when the boot loader transfers control to the kernel, there may be pending interrupts causing the UART to lock up in an eternal loop trying to pick tokens from the FIFO (since the RX interrupt flag indicates there are tokens) while in practice there are no tokens - in fact there is only a pending IRQ flag. This patch address the issue with a combination of a patch from Russell King that clears and mask all interrupts at probe() and clears any pending error and RX interrupts at port startup time, and a patch from Jong-Sung Kim that clears any RX interrupts (including timeouts) even if if there are zero tokens in the FIFO. This way these pending interrupts should be addressed in two ways and solidify the driver in both probe() and IRQ paths. Cc: stable@kernel.org Cc: Shreshtha Kumar Sahu Reported-by: Chanho Min Suggested-by: Russell King Suggested-by: Jong-Sung Kim Signed-off-by: Linus Walleij --- OK Greg requested that we send out this combined approach, can addressees (Chanho especially) please confirm that the patch solves the problem? Tested on U300 and U8500. --- drivers/tty/serial/amba-pl011.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 6800f5f..ff3fed0 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -224,6 +224,11 @@ static int pl011_fifo_to_tty(struct uart_amba_port *uap) uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag); } + /* RXIS but RXFE? Just clear the interrupt */ + if(unlikely(fifotaken == 0)) + writew(UART011_RTIS | UART011_RXIS, + uap->port.membase + UART011_ICR); + return fifotaken; } @@ -1381,6 +1386,10 @@ static int pl011_startup(struct uart_port *port) uap->port.uartclk = clk_get_rate(uap->clk); + /* Clear pending error and receive interrupts */ + writew(UART011_OEIS | UART011_BEIS | UART011_PEIS | UART011_FEIS | + UART011_RTIS | UART011_RXIS, uap->port.membase + UART011_ICR); + /* * Allocate the IRQ */ @@ -1417,10 +1426,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 */ @@ -1927,6 +1932,10 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) goto unmap; } + /* Ensure interrupts from this UART are masked and cleared */ + writew(0, uap->port.membase + UART011_IMSC); + writew(0xffff, uap->port.membase + UART011_ICR); + uap->vendor = vendor; uap->lcrh_rx = vendor->lcrh_rx; uap->lcrh_tx = vendor->lcrh_tx;