From patchwork Wed Sep 19 23:41:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 11516 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 0E1FF23E41 for ; Wed, 19 Sep 2012 23:47:39 +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 8F1ADA19152 for ; Wed, 19 Sep 2012 23:47:38 +0000 (UTC) Received: by iafj25 with SMTP id j25so1205786iaf.11 for ; Wed, 19 Sep 2012 16:47:37 -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:in-reply-to:references :x-gm-message-state; bh=7X9QkjjKkn9jFzTKZyK+wpezbout8hphY1zd5SAv7tc=; b=cC6ZcQfWWv46racAOxER5WSO9eRSPDer+pFmJO5pEEUkff1Jo5iHJtG84YHMCc1kPl VLxj6oFPmug6v92j5P6K1E+Qob5VqcS/WLmBYwBNuftU4XC2HCo9KnsuVL3cnMtNHOlK A7IlpGy/ItJqLa4wC/ILpsxBZFGnHDTYHs8PWWBm+KAuKOljYMK0Jwmvy2PWehcgCzEr KN+lEdgqlrC8TzQVNO/YMLGT4tr+Cn/J1U2SjtWeSMVPGj+knUjHftqVqg8XvImjWVcp 3UnVMu8BkuG/pJ6559XNRPUJR06Z66w2Oq5IrYDfIFKN9NubhgIg4IZXucHe+6CZkHKh dnAw== Received: by 10.50.184.129 with SMTP id eu1mr162466igc.0.1348098457896; Wed, 19 Sep 2012 16:47:37 -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.50.184.232 with SMTP id ex8csp49733igc; Wed, 19 Sep 2012 16:47:37 -0700 (PDT) Received: by 10.66.77.229 with SMTP id v5mr899343paw.60.1348098457137; Wed, 19 Sep 2012 16:47:37 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id h9si2141159paw.221.2012.09.19.16.47.36 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Sep 2012 16:47:37 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by mail-pb0-f50.google.com with SMTP id md12so3888024pbc.37 for ; Wed, 19 Sep 2012 16:47:36 -0700 (PDT) Received: by 10.68.200.162 with SMTP id jt2mr2013473pbc.54.1348098456910; Wed, 19 Sep 2012 16:47:36 -0700 (PDT) Received: from localhost (ip-64-134-220-225.public.wayport.net. [64.134.220.225]) by mx.google.com with ESMTPS id py9sm2547343pbb.20.2012.09.19.16.47.29 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Sep 2012 16:47:36 -0700 (PDT) From: Anton Vorontsov To: Andrew Morton , Russell King , Jason Wessel , Greg Kroah-Hartman , Alan Cox Cc: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Colin Cross , Brian Swetland , John Stultz , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com, kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH 06/11] tty/serial/amba-pl011: Quiesce interrupts in poll_get_char Date: Wed, 19 Sep 2012 16:41:57 -0700 Message-Id: <1348098122-11041-6-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <20120919234003.GA24143@lizard> References: <20120919234003.GA24143@lizard> X-Gm-Message-State: ALoCoQlcOKqT7VeYt+fERJ5ydbEAsKTWZwAmmZaRC5NqfpI9dUnhJjYKnynEtmXFP3rjGlzK9Bo9 We need to quiesce interrupts in the poll_get_char routine, otherwise, if used with KGDB NMI debugger, we'll keep reentering the NMI. Quiescing interrupts is pretty straightforward, except for TXIM interrupt. The interrupt has "ready to transmit" meaning, so it's almost always raised, and the only way to silence it is to mask it. But that's OK, ops->start_tx will unmask it. Signed-off-by: Anton Vorontsov Acked-by: Alan Cox --- drivers/tty/serial/amba-pl011.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 45137e4..459f8ba 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -1284,11 +1284,40 @@ static void pl011_break_ctl(struct uart_port *port, int break_state) } #ifdef CONFIG_CONSOLE_POLL + +static void pl011_quiesce_irqs(struct uart_port *port) +{ + struct uart_amba_port *uap = (struct uart_amba_port *)port; + unsigned char __iomem *regs = uap->port.membase; + + writew(readw(regs + UART011_MIS), regs + UART011_ICR); + /* + * There is no way to clear TXIM as this is "ready to transmit IRQ", so + * we simply mask it. start_tx() will unmask it. + * + * Note we can race with start_tx(), and if the race happens, the + * polling user might get another interrupt just after we clear it. + * But it should be OK and can happen even w/o the race, e.g. + * controller immediately got some new data and raised the IRQ. + * + * And whoever uses polling routines assumes that it manages the device + * (including tx queue), so we're also fine with start_tx()'s caller + * side. + */ + writew(readw(regs + UART011_IMSC) & ~UART011_TXIM, regs + UART011_IMSC); +} + static int pl011_get_poll_char(struct uart_port *port) { struct uart_amba_port *uap = (struct uart_amba_port *)port; unsigned int status; + /* + * The caller might need IRQs lowered, e.g. if used with KDB NMI + * debugger. + */ + pl011_quiesce_irqs(port); + status = readw(uap->port.membase + UART01x_FR); if (status & UART01x_FR_RXFE) return NO_POLL_CHAR;