From patchwork Mon Aug 18 14:28:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 35511 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8A32A20523 for ; Mon, 18 Aug 2014 14:28:34 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id va2sf21284202obc.7 for ; Mon, 18 Aug 2014 07:28:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=oLvsXWzoe4PmRmUNCGfBuXUjC9qA3rFcX28UcsORK0Q=; b=IjDbpR7J8xKIXlwo6D9OCFe58XCfDiZO9rHDfiqkE0xhpkQKFLFZDb9Udr15zme0g+ pt2xRytb1/Nw4RwzWogf1ckReif9xTYTNKtkeZ01qxexWWuh7f0WsIh42iWik8r4kccQ V/lQCTcKWj6vOOwro+jiXQ42qUqrd5P9MwaEyK7qNqQO1rbRnlYSSjf3Rd2wImLk//fo sgtJHsA79DtzrG5aAyI2DgnKu4ubjjJH9vt/7ZAsi4GBNZWAwWp/9FTbyQL+WZ+CPwqj JdRpXB8a2QQrVKkKGaW251zKL48mrM2f0s91LsT26YK3F7o2GFT0LNbyTrELCUVt6GEd wLKw== X-Gm-Message-State: ALoCoQmN/7464YqVCCVWkHq+Bap5iWNBMjcqPkr1LEsIYMeUpMQ1hT2pAmpW9fUPp8B7ZOicPU09 X-Received: by 10.182.199.4 with SMTP id jg4mr452655obc.43.1408372114216; Mon, 18 Aug 2014 07:28:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.87 with SMTP id f81ls2510075qge.65.gmail; Mon, 18 Aug 2014 07:28:34 -0700 (PDT) X-Received: by 10.220.247.3 with SMTP id ma3mr22661557vcb.29.1408372114032; Mon, 18 Aug 2014 07:28:34 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id ss10si7167123vcb.92.2014.08.18.07.28.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Aug 2014 07:28:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id lf12so5715264vcb.26 for ; Mon, 18 Aug 2014 07:28:33 -0700 (PDT) X-Received: by 10.220.182.1 with SMTP id ca1mr25215348vcb.21.1408372113950; Mon, 18 Aug 2014 07:28:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp156836vcb; Mon, 18 Aug 2014 07:28:33 -0700 (PDT) X-Received: by 10.194.243.230 with SMTP id xb6mr9307719wjc.100.1408372112960; Mon, 18 Aug 2014 07:28:32 -0700 (PDT) Received: from mail-we0-f174.google.com (mail-we0-f174.google.com [74.125.82.174]) by mx.google.com with ESMTPS id wa9si14117477wjc.159.2014.08.18.07.28.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Aug 2014 07:28:32 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.174 as permitted sender) client-ip=74.125.82.174; Received: by mail-we0-f174.google.com with SMTP id x48so5106990wes.19 for ; Mon, 18 Aug 2014 07:28:32 -0700 (PDT) X-Received: by 10.194.206.67 with SMTP id lm3mr43393551wjc.70.1408372112518; Mon, 18 Aug 2014 07:28:32 -0700 (PDT) Received: from sundance.lan (cpc4-aztw19-0-0-cust157.18-1.cable.virginm.net. [82.33.25.158]) by mx.google.com with ESMTPSA id pe6sm42668080wjb.38.2014.08.18.07.28.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Aug 2014 07:28:31 -0700 (PDT) From: Daniel Thompson To: Russell King Cc: Dirk Behme , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, patches@linaro.org, linaro-kernel@lists.linaro.org, John Stultz , Anton Vorontsov , Colin Cross , kernel-team@android.com, Rob Herring , Linus Walleij , Ben Dooks , Catalin Marinas , Dave Martin , Fabio Estevam , Frederic Weisbecker , Nicolas Pitre , Daniel Thompson , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org Subject: [PATCH v9 15/16] serial: imx: clean up imx_poll_get_char() Date: Mon, 18 Aug 2014 15:28:10 +0100 Message-Id: <1408372091-12689-16-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1404979427-12943-1-git-send-email-daniel.thompson@linaro.org> References: <1404979427-12943-1-git-send-email-daniel.thompson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Dirk Behme Looking at the get_poll_char() function of the 8250.c serial driver, we learn: * poll_get_char() doesn't have to save/disable/restore the interrupt registers. No interrupt handling is needed in this function at all. Remove it. * Don't block in case there is no data available. So instead blocking in the do {} while loop, just return with NO_POLL_CHAR, immediately . Additionally, while the i.MX6 register URXD[7-0] contain the RX_DATA, the upper bits of this register (URXD[15-10]) might contain some control flags. To ensure that these are not returned with the data read, just mask out URXD[7-0]. These changes fix the 'hang' working with kdb: $ echo ttymxc3 > /sys/module/kgdboc/parameters/kgdboc $ echo g >/proc/sysrq-trigger [0]kdb> help ... Signed-off-by: Dirk Behme Signed-off-by: Daniel Thompson Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: linux-serial@vger.kernel.org --- drivers/tty/serial/imx.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 044e86d..983668a 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -80,6 +80,7 @@ #define URXD_FRMERR (1<<12) #define URXD_BRK (1<<11) #define URXD_PRERR (1<<10) +#define URXD_RX_DATA (0xFF<<0) #define UCR1_ADEN (1<<15) /* Auto detect interrupt */ #define UCR1_ADBR (1<<14) /* Auto detect baud rate */ #define UCR1_TRDYEN (1<<13) /* Transmitter ready interrupt enable */ @@ -1506,32 +1507,10 @@ imx_verify_port(struct uart_port *port, struct serial_struct *ser) #if defined(CONFIG_CONSOLE_POLL) static int imx_poll_get_char(struct uart_port *port) { - struct imx_port_ucrs old_ucr; - unsigned int status; - unsigned char c; - - /* save control registers */ - imx_port_ucrs_save(port, &old_ucr); - - /* disable interrupts */ - writel(UCR1_UARTEN, port->membase + UCR1); - writel(old_ucr.ucr2 & ~(UCR2_ATEN | UCR2_RTSEN | UCR2_ESCI), - port->membase + UCR2); - writel(old_ucr.ucr3 & ~(UCR3_DCD | UCR3_RI | UCR3_DTREN), - port->membase + UCR3); - - /* poll */ - do { - status = readl(port->membase + USR2); - } while (~status & USR2_RDR); - - /* read */ - c = readl(port->membase + URXD0); - - /* restore control registers */ - imx_port_ucrs_restore(port, &old_ucr); + if (!(readl(port->membase + USR2) & USR2_RDR)) + return NO_POLL_CHAR; - return c; + return readl(port->membase + URXD0) & URXD_RX_DATA; } static void imx_poll_put_char(struct uart_port *port, unsigned char c)