From patchwork Wed Sep 3 11:33:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 36588 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3DA5B202E4 for ; Wed, 3 Sep 2014 11:34:11 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wn1sf44682415obc.6 for ; Wed, 03 Sep 2014 04:34:10 -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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=oLvsXWzoe4PmRmUNCGfBuXUjC9qA3rFcX28UcsORK0Q=; b=ZYpTG0T+u4WNWnj/I/SgnZDbkXO7y/SNjgesw5HqFXVbqhORNaru3jhU9xAK4USm+F p+hI+360IXg+XN3BCJs8dNHjh6MD2/MaD0n8vryVzHMUZrtn6JMbhWYOyXs+DjbNDgy8 49LZz1E6G7nOCNDhSdjrImBT2twfjk4TWlLZ1P0Vmp9IvJ67M8pLTB4cwDOAFQeeKRBz vTeoYe8g27o02dLlPVS8tWxBtaAWUWk/U1/uSt+mDz3K7YJfHmrwSnI0NjqHUZ3yZb3/ 9UZuVQUT8iPBnWQ3olb36+A7N6GYrfW9OqUUSVpdXicrnJ7uJjkuDg5u5Cz/Xm1ip4dO 9TIw== X-Gm-Message-State: ALoCoQn1eXPUlRv24GwWYstIiaG6nrUk0bLS1pSzIwRYNBoPwCe7yd/ptEtGTSJ21t8nHKttyS9t X-Received: by 10.182.43.164 with SMTP id x4mr23298897obl.5.1409744050698; Wed, 03 Sep 2014 04:34:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.170 with SMTP id u39ls2708859qga.21.gmail; Wed, 03 Sep 2014 04:34:10 -0700 (PDT) X-Received: by 10.221.44.69 with SMTP id uf5mr34800918vcb.4.1409744050545; Wed, 03 Sep 2014 04:34:10 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id sq9si713309vdb.90.2014.09.03.04.34.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Sep 2014 04:34:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id id10so8554934vcb.2 for ; Wed, 03 Sep 2014 04:34:10 -0700 (PDT) X-Received: by 10.220.190.134 with SMTP id di6mr319456vcb.43.1409744050468; Wed, 03 Sep 2014 04:34:10 -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 uj3csp665864vcb; Wed, 3 Sep 2014 04:34:09 -0700 (PDT) X-Received: by 10.180.35.133 with SMTP id h5mr34493338wij.74.1409744049217; Wed, 03 Sep 2014 04:34:09 -0700 (PDT) Received: from mail-we0-f179.google.com (mail-we0-f179.google.com [74.125.82.179]) by mx.google.com with ESMTPS id sf4si2512080wic.1.2014.09.03.04.34.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Sep 2014 04:34:09 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.179 as permitted sender) client-ip=74.125.82.179; Received: by mail-we0-f179.google.com with SMTP id t60so8325619wes.24 for ; Wed, 03 Sep 2014 04:34:08 -0700 (PDT) X-Received: by 10.180.106.232 with SMTP id gx8mr34255634wib.2.1409744048687; Wed, 03 Sep 2014 04:34:08 -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 o10sm2123316wia.0.2014.09.03.04.34.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Sep 2014 04:34:07 -0700 (PDT) From: Daniel Thompson To: Greg Kroah-Hartman Cc: Dirk Behme , linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, Daniel Thompson , Jiri Slaby , linux-serial@vger.kernel.org Subject: [PATCH 3.17-rc3] serial: imx: clean up imx_poll_get_char() Date: Wed, 3 Sep 2014 12:33:53 +0100 Message-Id: <1409744033-32741-1-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.3 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.171 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(-) -- 1.9.3 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)