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: 11689 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 E970423E41 for ; Mon, 24 Sep 2012 21:32:25 +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 B0BBBA18AC2 for ; Mon, 24 Sep 2012 21:32:25 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so11249367iej.11 for ; Mon, 24 Sep 2012 14:32: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:in-reply-to:references :x-gm-message-state; bh=lmLqlYbeeOyhcbq6bZrRyNpHtaAyHVzeXzrnXFmBkeE=; b=Eha4xaYCGSCDSg4zRBWnHQC5JTh9EBcG42sOg5hW0kmsMWhE4QC8dBt2+rQB0alzSh N1j5KOqQAAUe+Vh17A3X8gY/BIodIkScNvQb87VQg5g8uT5Rh8D4sts9RqN0/P+0MDQC CIVZDvs65qaZ3TFcqrRn5gO0tkEtNMJh3uuHclzbMyg7Hqjp2/EkeuKmWdC6yrfE41VS K96xrjVD+LLSjwhP25Tvsh2EEGjauewkyG3rnFFpw9HwNgdLEAu14LblIz/fWuEAW5v1 KTj134kw7Jd/CA2bCL9FZm7EfvfdRtR6RIEYCjJkPqaBvCmAMkvhLAomcprP2pKrnmGy n4Pw== Received: by 10.50.242.3 with SMTP id wm3mr6542894igc.0.1348522345500; Mon, 24 Sep 2012 14:32: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.50.184.232 with SMTP id ex8csp263628igc; Mon, 24 Sep 2012 14:32:25 -0700 (PDT) Received: by 10.68.237.3 with SMTP id uy3mr40060891pbc.30.1348522344781; Mon, 24 Sep 2012 14:32:24 -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 j9si6686665paw.67.2012.09.24.14.32.24 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 14:32:24 -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 md12so13998041pbc.37 for ; Mon, 24 Sep 2012 14:32:24 -0700 (PDT) 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 Cc: Alan Cox , Jason Wessel , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Colin Cross , Brian Swetland , John Stultz , 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: 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: ALoCoQm0LHs23PadBbatb4jZ5ezYTdsqIyU3fMTCcqRDRtTsD/1JuTH+79ue8flchYZutR5dYSqy 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;