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: 4737091 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 67DD09F344 for ; Mon, 18 Aug 2014 14:33:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2ECD82010B for ; Mon, 18 Aug 2014 14:33:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80E6B200F2 for ; Mon, 18 Aug 2014 14:33:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJNw8-0005pI-5W; Mon, 18 Aug 2014 14:29:28 +0000 Received: from mail-wi0-f174.google.com ([209.85.212.174]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJNvb-00052K-GZ for linux-arm-kernel@lists.infradead.org; Mon, 18 Aug 2014 14:28:56 +0000 Received: by mail-wi0-f174.google.com with SMTP id d1so3814389wiv.13 for ; Mon, 18 Aug 2014 07:28:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oLvsXWzoe4PmRmUNCGfBuXUjC9qA3rFcX28UcsORK0Q=; b=j5QF87aRUM5uAUdWCzSb/MlUNSiS6hy1cmKT3XGWV+JYI7vOLVhM4488OyXVgjinoF WI0sFX795fBODICYLtAorc6AhbjKGzSJLINqPzthTa5irVVIlreiqrjsAuppzIrKsXCH 6GhVk27hDA2Du8LyKi8WTAW3CgpMfzZRvzyNfoOizZnkBVXl6zlGI2jS0brc05xpvt32 7pMJB7nxFYxUDTbsIewxqE8jTXlCxd4KFpUztQAB6PNDzGXPi28ZHUGO6GgH8zSZHGYk O0v3GkmK0J8S2OjDi1/onsxb2UKsMiU/kX0+fGfnTMcTKk/1EXm+o2yN/LNrpLgA9Z1K rW+w== X-Gm-Message-State: ALoCoQksQ8IwJD4i/fvunE3FgFhFd9VeCKhQ6WTCz2nLkVxmId46Ci+Mpg0eY7wr8O7bE53S4sSU 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140818_072855_720286_C46590B2 X-CRM114-Status: GOOD ( 16.35 ) X-Spam-Score: -0.7 (/) Cc: Catalin Marinas , Linus Walleij , Fabio Estevam , Daniel Thompson , Dirk Behme , Nicolas Pitre , Jiri Slaby , Anton Vorontsov , Ben Dooks , linux-serial@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, kernel-team@android.com, Dave Martin , linaro-kernel@lists.linaro.org, patches@linaro.org, John Stultz , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Colin Cross , Frederic Weisbecker X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)