From patchwork Tue Sep 2 13:00:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 36484 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f200.google.com (mail-yk0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 305B4203BE for ; Tue, 2 Sep 2014 13:07:36 +0000 (UTC) Received: by mail-yk0-f200.google.com with SMTP id 9sf22861799ykp.3 for ; Tue, 02 Sep 2014 06:07:36 -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=B9g7kyiCUnFt+MP7eFj6lAyVMjruE/dG872yFiu7OTIuX/uruopG8QXWH9uozUkpRc UN4Y8FYMXtNvrDwmcHAROTilCoW5SVW1n1maMVqN5c8DXHE1h4BmCzhDNRjrFDT9ONtu mdQPE6agu0BxQZ4XSnF/E2GHbNU73Vh7KI9TkC3+D7EbDQwmF0dzXj5GurxjoEjbdlzA tYoSRLnA8hN11SEz9sULKHD0h4RgglZ9cpAbZidFlWaP54N25bGX0IbDHmoMaOln0dqy Lvt9imS+9+SqJXq5Mu98CWETblFec72+CCPjMrmaVa7xhPmyA1zl9JkZ9at8N+4V1NxL NK0w== X-Gm-Message-State: ALoCoQk34gF4XFZyE+M2B16xnSqN2YskOf6O1TVwUgJJMghNIF+Rke6e7tSk1Vg37TraZ4c32rZ1 X-Received: by 10.236.108.172 with SMTP id q32mr19240004yhg.0.1409663256010; Tue, 02 Sep 2014 06:07:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.50 with SMTP id 47ls2452018qgk.6.gmail; Tue, 02 Sep 2014 06:07:35 -0700 (PDT) X-Received: by 10.220.251.200 with SMTP id mt8mr30187093vcb.24.1409663255912; Tue, 02 Sep 2014 06:07:35 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id jq10si2217446vdb.75.2014.09.02.06.07.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Sep 2014 06:07:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id la4so7041153vcb.1 for ; Tue, 02 Sep 2014 06:07:35 -0700 (PDT) X-Received: by 10.52.83.227 with SMTP id t3mr25418802vdy.20.1409663255841; Tue, 02 Sep 2014 06:07:35 -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.45.67 with SMTP id uj3csp524825vcb; Tue, 2 Sep 2014 06:07:35 -0700 (PDT) X-Received: by 10.180.93.8 with SMTP id cq8mr28112360wib.17.1409663254860; Tue, 02 Sep 2014 06:07:34 -0700 (PDT) Received: from mail-we0-f171.google.com (mail-we0-f171.google.com [74.125.82.171]) by mx.google.com with ESMTPS id gh6si5794083wjd.165.2014.09.02.06.07.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Sep 2014 06:07:34 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.171 as permitted sender) client-ip=74.125.82.171; Received: by mail-we0-f171.google.com with SMTP id u56so6969107wes.2 for ; Tue, 02 Sep 2014 06:07:34 -0700 (PDT) X-Received: by 10.180.188.205 with SMTP id gc13mr28651517wic.66.1409663254256; Tue, 02 Sep 2014 06:07:34 -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 ec2sm34928892wib.19.2014.09.02.06.07.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Sep 2014 06:07:33 -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 v11 18/19] serial: imx: clean up imx_poll_get_char() Date: Tue, 2 Sep 2014 14:00:52 +0100 Message-Id: <1409662853-29313-19-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1409662853-29313-1-git-send-email-daniel.thompson@linaro.org> References: <1408466769-20004-1-git-send-email-daniel.thompson@linaro.org> <1409662853-29313-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.170 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)