From patchwork Mon Sep 24 21:27:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 1500351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 97121DF280 for ; Mon, 24 Sep 2012 21:36:23 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TGGHx-0003D0-Vy; Mon, 24 Sep 2012 21:34:03 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TGGGO-00023J-R5 for linux-arm-kernel@lists.infradead.org; Mon, 24 Sep 2012 21:32:25 +0000 Received: by mail-pb0-f49.google.com with SMTP id rq8so13811871pbb.36 for ; Mon, 24 Sep 2012 14:32:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=lmLqlYbeeOyhcbq6bZrRyNpHtaAyHVzeXzrnXFmBkeE=; b=jAnB1/SIjiYA9uhoMLBC2H5WIHPvTfWMF8sFcFqmH7FDrCWgrQCPp3p6H1SanZOQSW 8fOCsqXKMNIpspxZkFGXMfcjf2wG5nghyDwwUjLge2dLqksByH/u2I6Bsxz7Uv1hptMP 94y12kCVxMblM07PwAJNnUOgUqGAEuthk1Y8lBf0PYp6msstMZzsp049rWpYfVxqfKyk fb6LpiN/+4TJDVeTs+/HSYlNwNkMCNt35/9Ae5iBsDLiLpqF7ZGq+6rl8idxAT6QE0Jg +yM5NN7E95nkcsTRC8K5DiNdfVKXrRLkKAbZOnyA2hO+ViUQkGdKSHWaPMrct6dwa+JQ 1TtA== Received: by 10.66.83.9 with SMTP id m9mr35611016pay.22.1348522344536; Mon, 24 Sep 2012 14:32:24 -0700 (PDT) Received: from localhost (ip-64-134-232-154.public.wayport.net. [64.134.232.154]) by mx.google.com with ESMTPS id g1sm9304699paz.18.2012.09.24.14.32.23 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 14:32:23 -0700 (PDT) From: Anton Vorontsov To: Greg Kroah-Hartman , Russell King Subject: [PATCH 06/11] tty/serial/amba-pl011: Quiesce interrupts in poll_get_char Date: Mon, 24 Sep 2012 14:27:55 -0700 Message-Id: <1348522080-32629-6-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.12 In-Reply-To: <20120924212648.GA27605@lizard> References: <20120924212648.GA27605@lizard> X-Gm-Message-State: ALoCoQnF5fA9qEvdqYfaNS7SVZEii+SnRVZS+hN0YkYedb49/Xci5aU2MgdCbwFbXvAKxIpdKzVZ X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, Brian Swetland , Jason Wessel , linux-kernel@vger.kernel.org, =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , John Stultz , linux-serial@vger.kernel.org, Colin Cross , kgdb-bugreport@lists.sourceforge.net, kernel-team@android.com, linux-arm-kernel@lists.infradead.org, Alan Cox X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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;