From patchwork Thu Sep 13 15:03:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 11396 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 DF6BC23EB4 for ; Thu, 13 Sep 2012 15:06:41 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id DA934A2677A for ; Thu, 13 Sep 2012 15:06:40 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id k11so4928223iea.11 for ; Thu, 13 Sep 2012 08:06:40 -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=o37h0E+W69H6VcEA50s2JWaTJdPjXJ8rURQHmSZeTrU=; b=AHtH5wEEdplO1Ze4OQtrFxzTSekk55f+HSZ7MzxIxP7ws0/KlXjOAk8N3fZDMIRlwp On6vAPr1/x+i9zCdOKCWAk7gSSMWtjIVu9vQY79cJZuBMa6iX53WB8+H4ibtdZ3tXlmV OVE016NzOY2OTHLqlWBn/MEPhdV2tDio1lmst+PgHb5lO2ns71D09FbJ2deOAvu6ppzj JNby+dyzKQakAEL14TXsF5S3EKwOSHNEqH90okINzwDH6W1NXhuhCiRpZZO+3lSuu8hL CkIgP04IxQHY+QU8OEw7IJlqsWQSEnEBlYgxGWfRb5DDMMdkL1KXl3ecpMzxSjB56ick 45WA== Received: by 10.50.207.106 with SMTP id lv10mr91614igc.0.1347548800672; Thu, 13 Sep 2012 08:06:40 -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 ex8csp137341igc; Thu, 13 Sep 2012 08:06:40 -0700 (PDT) Received: by 10.68.232.106 with SMTP id tn10mr67307pbc.26.1347548799879; Thu, 13 Sep 2012 08:06:39 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id ip5si34517161pbc.318.2012.09.13.08.06.39 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Sep 2012 08:06:39 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.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-pz0-f50.google.com with SMTP id e7so2138480dad.37 for ; Thu, 13 Sep 2012 08:06:39 -0700 (PDT) Received: by 10.66.89.6 with SMTP id bk6mr3560598pab.81.1347548799646; Thu, 13 Sep 2012 08:06:39 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id qw6sm13214781pbc.26.2012.09.13.08.06.38 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Sep 2012 08:06:39 -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: Thu, 13 Sep 2012 08:03:30 -0700 Message-Id: <1347548615-18227-6-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <20120913150133.GA16238@lizard> References: <20120913150133.GA16238@lizard> X-Gm-Message-State: ALoCoQnb5iOgrOo9PIP9hnpAFcDqqRtKQFRdAd8sBUV7kJ/G0zxKWNWVL9szXTLpWwavD0iSOVd8 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 --- 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;