From patchwork Tue May 13 16:08:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 30094 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B5D2C20446 for ; Tue, 13 May 2014 16:09:16 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id pa12sf1634710veb.7 for ; Tue, 13 May 2014 09:09:16 -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=OHfpDj3s+1rPEwwoD+PZRE/JKCXimKL8UOAA1Vjn9eA=; b=QTPHZiQ3J0+RDKCwuQ8ASnJ3Chf/WHvsyZ1/ddC3lJYUOAA9VZe7s2uveAVe0kW5KQ QiLpcNZ8V0y8VE6gTxlQmRfshajTCUq9jBRSreKSD8I2DQfQ8f9yBRnTo5cm+xYrPFXP sb29S8CcSjcJwgDC4wz9s5VkxdjCMGQe/VsULWITmAfw1lMpOlLo50QmKz3X9HYQz8Bg 5a3lBhfmOLMncTIcrtkwalNQcGbvoN7ArL8JilAKZa02XXR+OQ7W2XfkRI3G5TuUdMSO S3FgfboYArciZuk8k+HTDBNxc90bdy6dfiJs2PRLQKgt/cXHS25aj9mZZrLDcEiqmPjH pMEw== X-Gm-Message-State: ALoCoQkgMUsVcdbbuyijESWZWSdi7wFay+wgREZhV/sMy8Msha3ycHhDKCC9LcayodLXqrcE1LKF X-Received: by 10.58.18.200 with SMTP id y8mr17109998ved.20.1399997356526; Tue, 13 May 2014 09:09:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.9 with SMTP id 9ls1882963qgg.75.gmail; Tue, 13 May 2014 09:09:16 -0700 (PDT) X-Received: by 10.52.164.175 with SMTP id yr15mr833253vdb.59.1399997356433; Tue, 13 May 2014 09:09:16 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id dn5si509774vcb.196.2014.05.13.09.09.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 09:09:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id lh14so743498vcb.5 for ; Tue, 13 May 2014 09:09:16 -0700 (PDT) X-Received: by 10.52.2.229 with SMTP id 5mr24672058vdx.24.1399997356346; Tue, 13 May 2014 09:09:16 -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 ib8csp163465vcb; Tue, 13 May 2014 09:09:15 -0700 (PDT) X-Received: by 10.180.11.178 with SMTP id r18mr21897030wib.41.1399997354705; Tue, 13 May 2014 09:09:14 -0700 (PDT) Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) by mx.google.com with ESMTPS id l5si4008791wif.93.2014.05.13.09.09.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 09:09:14 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.45 as permitted sender) client-ip=74.125.82.45; Received: by mail-wg0-f45.google.com with SMTP id m15so601069wgh.28 for ; Tue, 13 May 2014 09:09:14 -0700 (PDT) X-Received: by 10.194.63.196 with SMTP id i4mr8560887wjs.50.1399997354184; Tue, 13 May 2014 09:09:14 -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 dk4sm12553212wib.14.2014.05.13.09.09.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 May 2014 09:09:12 -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, Srinivas Kandagatla , Maxime Coquelin , Patrice Chotard , Jiri Slaby , linux-arm-kernel@lists.infradead.org, kernel@stlinux.com Subject: [PATCH] serial: st-asc: Fix data corruption during long console bursts Date: Tue, 13 May 2014 17:08:57 +0100 Message-Id: <1399997337-27950-1-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.0 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.174 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: , On my test platform (B2020/STiH416) the serial port issues bad characters during the initial message avalanche as the console comes up. The problem also occurs when dense(ish) I/O is done using the polled I/O interface. The problem is fixed for me by using the FIFO half-empty bit rather than FIFO full bit. Note that using the half-empty bit causes the FIFO to be managed in a similar way to interrupt based I/O (i.e. where the hardware gets best test coverage). Running the FIFO half full will have no impact (good or bad) on console performance. The UART will still remain fully saturated and the busy-wait until the FIFO is empty in asc_console_write() will complete at the same time. Signed-off-by: Daniel Thompson Acked-by: Maxime Coquelin Acked-by: Srinivas Kandagatla --- drivers/tty/serial/st-asc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c index dd3a96e..c7f61ac 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -194,9 +194,9 @@ static inline u32 asc_txfifo_is_empty(struct uart_port *port) return asc_in(port, ASC_STA) & ASC_STA_TE; } -static inline int asc_txfifo_is_full(struct uart_port *port) +static inline u32 asc_txfifo_is_half_empty(struct uart_port *port) { - return asc_in(port, ASC_STA) & ASC_STA_TF; + return asc_in(port, ASC_STA) & ASC_STA_THE; } static inline const char *asc_port_name(struct uart_port *port) @@ -628,7 +628,7 @@ static int asc_get_poll_char(struct uart_port *port) static void asc_put_poll_char(struct uart_port *port, unsigned char c) { - while (asc_txfifo_is_full(port)) + while (!asc_txfifo_is_half_empty(port)) cpu_relax(); asc_out(port, ASC_TXBUF, c); } @@ -783,7 +783,7 @@ static void asc_console_putchar(struct uart_port *port, int ch) unsigned int timeout = 1000000; /* Wait for upto 1 second in case flow control is stopping us. */ - while (--timeout && asc_txfifo_is_full(port)) + while (--timeout && !asc_txfifo_is_half_empty(port)) udelay(1); asc_out(port, ASC_TXBUF, ch);