From patchwork Fri Aug 20 18:45:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 62304 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 775A4B72F6 for ; Sat, 21 Aug 2010 04:46:14 +1000 (EST) Received: by ozlabs.org (Postfix) id AABBAB70E1; Sat, 21 Aug 2010 04:46:02 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from DB3EHSOBE006.bigfish.com (db3ehsobe006.messaging.microsoft.com [213.199.154.144]) by ozlabs.org (Postfix) with ESMTP id EA3F8B70E0 for ; Sat, 21 Aug 2010 04:46:01 +1000 (EST) Received: from mail12-db3-R.bigfish.com (10.3.81.248) by DB3EHSOBE006.bigfish.com (10.3.84.26) with Microsoft SMTP Server id 8.1.436.0; Fri, 20 Aug 2010 18:45:57 +0000 Received: from mail12-db3 (localhost.localdomain [127.0.0.1]) by mail12-db3-R.bigfish.com (Postfix) with ESMTP id AB3BF1A70414; Fri, 20 Aug 2010 18:53:13 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bh8275dhz2dh2a8h62h) X-Spam-TCS-SCL: 1:0 X-FB-SS: 0, Received: from mail12-db3 (localhost.localdomain [127.0.0.1]) by mail12-db3 (MessageSwitch) id 128233038497893_21720; Fri, 20 Aug 2010 18:53:04 +0000 (UTC) Received: from DB3EHSMHS005.bigfish.com (unknown [10.3.81.245]) by mail12-db3.bigfish.com (Postfix) with ESMTP id 137AA111804F; Fri, 20 Aug 2010 18:53:04 +0000 (UTC) Received: from az33egw02.freescale.net (192.88.158.103) by DB3EHSMHS005.bigfish.com (10.3.87.105) with Microsoft SMTP Server (TLS) id 14.0.482.44; Fri, 20 Aug 2010 18:45:44 +0000 Received: from az33smr01.freescale.net (az33smr01.freescale.net [10.64.34.199]) by az33egw02.freescale.net (8.14.3/8.14.3) with ESMTP id o7KIjMpI024647; Fri, 20 Aug 2010 11:45:22 -0700 (MST) Received: from localhost.localdomain (efes.am.freescale.net [10.82.123.3]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id o7KIvB2w005407; Fri, 20 Aug 2010 13:57:11 -0500 (CDT) From: Timur Tabi To: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org, benh@kernel.crashing.org, kumar.gala@freescale.com, amit.shah@redhat.com Subject: [PATCH] hvc_console: fix dropping of characters when output byte channel is full Date: Fri, 20 Aug 2010 13:45:21 -0500 Message-ID: <1282329921-24394-1-git-send-email-timur@freescale.com> X-Mailer: git-send-email 1.7.0.1 MIME-Version: 1.0 X-Reverse-DNS: az33egw02.freescale.net X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org hvc_console_print() calls the HVC client driver's put_chars() callback to write some characters to the console. If the callback returns 0, that indicates that no characters were written (perhaps the output buffer is full), but hvc_console_print() treats that as an error and discards the rest of the buffer. So change hvc_console_print() to just loop and call put_chars() again if it returns a 0 return code. This change makes hvc_console_print() behave more like hvc_push(), which does check for a 0 return code and re-schedules itself. Signed-off-by: Timur Tabi --- drivers/char/hvc_console.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index fa27d16..b4deffd 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c @@ -3,6 +3,7 @@ * Copyright (C) 2001 Paul Mackerras , IBM * Copyright (C) 2004 Benjamin Herrenschmidt , IBM Corp. * Copyright (C) 2004 IBM Corporation + * Copyright 2009 Freescale Semiconductor, Inc. * * Additional Author(s): * Ryan S. Arnold @@ -141,6 +142,7 @@ static void hvc_console_print(struct console *co, const char *b, char c[N_OUTBUF] __ALIGNED__; unsigned i = 0, n = 0; int r, donecr = 0, index = co->index; + unsigned int timeout = 1000000; /* Keep trying for up to one second */ /* Console access attempt outside of acceptable console range. */ if (index >= MAX_NR_HVC_CONSOLES) @@ -152,6 +154,10 @@ static void hvc_console_print(struct console *co, const char *b, while (count > 0 || i > 0) { if (count > 0 && i < sizeof(c)) { + /* If the local buffer (c) is not full, then copy some + * bytes from the input buffer to it. We stop when the + * local buffer is full. \n is converted to \r\n. + */ if (b[n] == '\n' && !donecr) { c[i++] = '\r'; donecr = 1; @@ -162,14 +168,25 @@ static void hvc_console_print(struct console *co, const char *b, } } else { r = cons_ops[index]->put_chars(vtermnos[index], c, i); - if (r <= 0) { + if (r < 0) { /* throw away chars on error */ i = 0; } else if (r > 0) { i -= r; if (i > 0) memmove(c, c+r, i); + } else { + /* If r == 0, then the client driver didn't do + * anything, so wait 1us and try again. If we + * time out, then just exit. + */ + if (!--timeout) + return; + udelay(1); + continue; } + /* Reset the timeout */ + timeout = 1000000; } } }