From patchwork Wed May 14 14:55:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 30166 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3BD0B2055D for ; Wed, 14 May 2014 14:55:59 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id c1sf5202029igq.6 for ; Wed, 14 May 2014 07:55:58 -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=ZtZyv0fb8z5zPC4PCcHDjyH8HuO8EVziK8GH6xzXN5Q=; b=YcKuBh30o7SPbUxKjmZO/RAqYwg2zKuPfONnoyzQ6EHmBamNY6KrnefI4lSQAOv44K UYZLff0gOiJE9doagOFd2pVpqEYXz0AqVgKfpIEc2Br6e9JVtPian00b49ekdRR1WeFX BL3yYVkHo2MHMH58l4DAFEcnh2y/qYG34+P76CEcNgkBfa7q9Rj1/mLD4syduUbAg75K 1YOFC3RcwLKr7pyAPdCk4R5CGFJMRaRxgqroPLSnwK7n3P1SbEty2IkDA1D2uiuvZCmJ 4XTnqyDcFM2pLDsA3AUwRfqnM/87urkOTXlRqzDsj6a5Yv2YoKNTc0/twAPVJuqx3MPn GMCw== X-Gm-Message-State: ALoCoQkyCicwusqlYVIaA5Y4jcqiFoVU8g+zB42NCErnjttvwvbu3IzqsAQBMjpEi+JOt9pCVJLq X-Received: by 10.43.94.71 with SMTP id bx7mr1657771icc.2.1400079358778; Wed, 14 May 2014 07:55:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.72 with SMTP id k66ls2325543qgd.96.gmail; Wed, 14 May 2014 07:55:58 -0700 (PDT) X-Received: by 10.52.93.201 with SMTP id cw9mr169457vdb.80.1400079358654; Wed, 14 May 2014 07:55:58 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id sg6si368475vdc.63.2014.05.14.07.55.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 May 2014 07:55:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id hr9so2621723vcb.3 for ; Wed, 14 May 2014 07:55:58 -0700 (PDT) X-Received: by 10.58.198.107 with SMTP id jb11mr3558966vec.10.1400079358553; Wed, 14 May 2014 07:55:58 -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.220.221.72 with SMTP id ib8csp246934vcb; Wed, 14 May 2014 07:55:58 -0700 (PDT) X-Received: by 10.180.91.114 with SMTP id cd18mr3981540wib.28.1400079357659; Wed, 14 May 2014 07:55:57 -0700 (PDT) Received: from mail-we0-f169.google.com (mail-we0-f169.google.com [74.125.82.169]) by mx.google.com with ESMTPS id ch9si5131407wib.109.2014.05.14.07.55.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 May 2014 07:55:57 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.169 as permitted sender) client-ip=74.125.82.169; Received: by mail-we0-f169.google.com with SMTP id u56so2102793wes.0 for ; Wed, 14 May 2014 07:55:57 -0700 (PDT) X-Received: by 10.180.39.178 with SMTP id q18mr3918850wik.56.1400079356966; Wed, 14 May 2014 07:55:56 -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 ho2sm4412630wib.15.2014.05.14.07.55.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 May 2014 07:55:55 -0700 (PDT) From: Daniel Thompson To: Greg Kroah-Hartman , linux-serial@vger.kernel.org Cc: patches@linaro.org, linaro-kernel@lists.linaro.org, Daniel Thompson , linux-kernel@vger.kernel.org, John Stultz , Anton Vorontsov , Colin Cross , kernel-team@android.com, Jason Wessel , kgdb-bugreport@lists.sourceforge.net, Jiri Slaby , Kumar Gala , Pantelis Antoniou , Heikki Krogerus , Joe Schultz , Loic Poulain , Kyle McMartin , Stephen Warren , Ingo Molnar , Paul Gortmaker , Grant Likely , Rob Herring , Jingoo Han , Christophe Leroy Subject: [PATCH 1/4] serial: core: Consistent LF handling for poll_put_char Date: Wed, 14 May 2014 15:55:32 +0100 Message-Id: <1400079335-32125-2-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1400079335-32125-1-git-send-email-daniel.thompson@linaro.org> References: <1400079335-32125-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.172 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: , The behaviour of the UART poll_put_char infrastructure is inconsistent with respect to linefeed conversions. This in turn leads to difficulty using kdb on serial ports that are not also consoles (e.g. console=ttyAMA0,115200 kgdboc=ttyAMA1,115200). The following drivers automatically convert '\n' to '\r\n' inside their own poll functions but the remaining seventeen do not: serial8250, cpm, pch_uart, serial_pxa, serial_txx9, This can be made fully consistent but performing the conversion in uart_poll_put_char(). A similar conversion is already made inside uart_console_write() but it is optional for drivers to use this function. Fortunately we can be confident the translation is safe because the (very common) 8250 already does this translation. Signed-off-by: Daniel Thompson Cc: Kumar Gala Cc: Pantelis Antoniou Cc: Heikki Krogerus Cc: Joe Schultz Cc: Loic Poulain Cc: Kyle McMartin Cc: Stephen Warren Cc: Ingo Molnar Cc: Paul Gortmaker Cc: Grant Likely Cc: Rob Herring Cc: Jingoo Han Cc: Christophe Leroy --- drivers/tty/serial/8250/8250_core.c | 5 ----- drivers/tty/serial/cpm_uart/cpm_uart_core.c | 8 ++++---- drivers/tty/serial/pch_uart.c | 5 ----- drivers/tty/serial/pxa.c | 5 ----- drivers/tty/serial/serial_core.c | 2 ++ drivers/tty/serial/serial_txx9.c | 5 ----- 6 files changed, 6 insertions(+), 24 deletions(-) diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index 2d4bd39..053c200 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -1926,13 +1926,8 @@ static void serial8250_put_poll_char(struct uart_port *port, wait_for_xmitr(up, BOTH_EMPTY); /* * Send the character out. - * If a LF, also do CR... */ serial_port_out(port, UART_TX, c); - if (c == 10) { - wait_for_xmitr(up, BOTH_EMPTY); - serial_port_out(port, UART_TX, 13); - } /* * Finally, wait for transmitter to become empty diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c index 7d76214..aa60e6d 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c @@ -971,7 +971,7 @@ static void cpm_uart_config_port(struct uart_port *port, int flags) * Note that this is called with interrupts already disabled */ static void cpm_uart_early_write(struct uart_cpm_port *pinfo, - const char *string, u_int count) + const char *string, u_int count, bool handle_linefeed) { unsigned int i; cbd_t __iomem *bdp, *bdbase; @@ -1013,7 +1013,7 @@ static void cpm_uart_early_write(struct uart_cpm_port *pinfo, bdp++; /* if a LF, also do CR... */ - if (*string == 10) { + if (handle_linefeed && *string == 10) { while ((in_be16(&bdp->cbd_sc) & BD_SC_READY) != 0) ; @@ -1111,7 +1111,7 @@ static void cpm_put_poll_char(struct uart_port *port, static char ch[2]; ch[0] = (char)c; - cpm_uart_early_write(pinfo, ch, 1); + cpm_uart_early_write(pinfo, ch, 1, false); } #endif /* CONFIG_CONSOLE_POLL */ @@ -1275,7 +1275,7 @@ static void cpm_uart_console_write(struct console *co, const char *s, spin_lock_irqsave(&pinfo->port.lock, flags); } - cpm_uart_early_write(pinfo, s, count); + cpm_uart_early_write(pinfo, s, count, true); if (unlikely(nolock)) { local_irq_restore(flags); diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 0931b3f..11e631d 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c @@ -1588,13 +1588,8 @@ static void pch_uart_put_poll_char(struct uart_port *port, wait_for_xmitr(priv, UART_LSR_THRE); /* * Send the character out. - * If a LF, also do CR... */ iowrite8(c, priv->membase + PCH_UART_THR); - if (c == 10) { - wait_for_xmitr(priv, UART_LSR_THRE); - iowrite8(13, priv->membase + PCH_UART_THR); - } /* * Finally, wait for transmitter to become empty diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c index f9f20f3..9e7ee39 100644 --- a/drivers/tty/serial/pxa.c +++ b/drivers/tty/serial/pxa.c @@ -711,13 +711,8 @@ static void serial_pxa_put_poll_char(struct uart_port *port, wait_for_xmitr(up); /* * Send the character out. - * If a LF, also do CR... */ serial_out(up, UART_TX, c); - if (c == 10) { - wait_for_xmitr(up); - serial_out(up, UART_TX, 13); - } /* * Finally, wait for transmitter to become empty diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index b68550d..50167bf 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2239,6 +2239,8 @@ static void uart_poll_put_char(struct tty_driver *driver, int line, char ch) return; port = state->uart_port; + if (ch == '\n') + port->ops->poll_put_char(port, '\r'); port->ops->poll_put_char(port, ch); } #endif diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c index 90a080b..60f49b9 100644 --- a/drivers/tty/serial/serial_txx9.c +++ b/drivers/tty/serial/serial_txx9.c @@ -535,13 +535,8 @@ static void serial_txx9_put_poll_char(struct uart_port *port, unsigned char c) wait_for_xmitr(up); /* * Send the character out. - * If a LF, also do CR... */ sio_out(up, TXX9_SITFIFO, c); - if (c == 10) { - wait_for_xmitr(up); - sio_out(up, TXX9_SITFIFO, 13); - } /* * Finally, wait for transmitter to become empty