From patchwork Tue May 5 03:14:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 48017 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4A3A82121F for ; Tue, 5 May 2015 03:14:54 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf46921398lbc.1 for ; Mon, 04 May 2015 20:14:52 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=uN3jY/NC3POqvVGeQ72WXioavXCb+/Cw9Fm28RMa5uU=; b=UB3WlKfQAvmfXWkFh7ECYWQbIHbcj0HCxcK6UQxMp0QIq9bbKybKtUIqt+CGokGPAw QdjZEs8MjvdMXX2nOQ333+L5my56KludFci51D/wdmoSnbdEeRqSm7Y0lgj8bpf7pPNJ Lw7k4CaWBgh1czV+WVuPnQfHCEaAzxyhd3TAA+HXse6EeYfQL5yAYM6bgM8j5io8KmHp ds/uWIIkVDyA+0hS6cHZFa2a+f4DiukXcom4DFaysqZN3PVFE8cnGUHfahkJtewBewc7 NxLAiQj4xhZuMsHaoYIJHriD95WvMwqnXQUdaZ83dLChc7UNzFod8K8RqATjhPVIA2+F uLnA== X-Gm-Message-State: ALoCoQlzKV3bpMEwNxZuQ6o8Hfzo38z/CGPfyT2pr4tDafUSq+tXRkbIAgnm+huIXN9v/Aabuh8h X-Received: by 10.112.51.68 with SMTP id i4mr20784256lbo.13.1430795692702; Mon, 04 May 2015 20:14:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.5.42 with SMTP id cj10ls823753lad.51.gmail; Mon, 04 May 2015 20:14:52 -0700 (PDT) X-Received: by 10.112.16.227 with SMTP id j3mr21847935lbd.43.1430795692534; Mon, 04 May 2015 20:14:52 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id y10si11314792lal.107.2015.05.04.20.14.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2015 20:14:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by laat2 with SMTP id t2so117665259laa.1 for ; Mon, 04 May 2015 20:14:52 -0700 (PDT) X-Received: by 10.152.9.66 with SMTP id x2mr21949592laa.36.1430795692389; Mon, 04 May 2015 20:14:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1995298lbt; Mon, 4 May 2015 20:14:51 -0700 (PDT) X-Received: by 10.70.88.170 with SMTP id bh10mr47806426pdb.62.1430795690536; Mon, 04 May 2015 20:14:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dv4si22302968pdb.70.2015.05.04.20.14.49; Mon, 04 May 2015 20:14:50 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755260AbbEEDOm (ORCPT + 29 others); Mon, 4 May 2015 23:14:42 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:36699 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751403AbbEEDOa (ORCPT ); Mon, 4 May 2015 23:14:30 -0400 Received: by pabsx10 with SMTP id sx10so178395977pab.3 for ; Mon, 04 May 2015 20:14:29 -0700 (PDT) X-Received: by 10.66.185.168 with SMTP id fd8mr47511865pac.27.1430795669862; Mon, 04 May 2015 20:14:29 -0700 (PDT) Received: from localhost.localdomain ([180.150.148.224]) by mx.google.com with ESMTPSA id ea4sm14112185pbb.94.2015.05.04.20.14.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 May 2015 20:14:29 -0700 (PDT) From: Leo Yan To: Andrew Jackson , Dave Martin , linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH RESEND] serial/amba-pl011: fix minor bugs for pio mode Date: Tue, 5 May 2015 11:14:15 +0800 Message-Id: <1430795655-22428-1-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: leo.yan@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.215.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When use pio mode, there have two issues can be observed: - In the commit f2ee6df "serial/amba-pl011: Leave the TX IRQ alone when the UART is not open", it will skip clearing the TX IRQ across pl011_shutdown() and pl011_startup(); So at the next time after the uart port has been opened, there have chance for the function pl011_tx_chars() will not be executed if the TX IRQ will not be triggered; finally the console cannot output anymore. This is caused by the uart FIFO still keep data rather than the threshold. So revert this patch to make sure every time open the uart port, it will force to call function pl011_tx_chars(). - Sometimes will output the duplicate chars. Function pl011_tx_char() will firstly send char and check if FIFO is full, and if the FIFO is full it will return false; Caller function will consider the char has _NOT_ been send out and resend it again, finally will send the duplicate chars. So change to check FIFO is full or not, if full then return false, otherwise send out char and return true. Signed-off-by: Leo Yan --- drivers/tty/serial/amba-pl011.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 5a4e9d5..9d9ac76 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -1249,20 +1249,19 @@ __acquires(&uap->port.lock) /* * Transmit a character - * There must be at least one free entry in the TX FIFO to accept the char. * - * Returns true if the FIFO might have space in it afterwards; - * returns false if the FIFO definitely became full. + * Before send character, need check FIFO is full or not; + * If FIFO is full, will not send char and return false, + * otherwise send out character and return ture. */ static bool pl011_tx_char(struct uart_amba_port *uap, unsigned char c) { + if (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF) + return false; + writew(c, uap->port.membase + UART01x_DR); uap->port.icount.tx++; - - if (likely(uap->tx_irq_seen > 1)) - return true; - - return !(readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF); + return true; } static bool pl011_tx_chars(struct uart_amba_port *uap) @@ -1639,6 +1638,9 @@ static int pl011_startup(struct uart_port *port) writew(uap->vendor->ifls, uap->port.membase + UART011_IFLS); + /* Assume that TX IRQ doesn't work until we see one: */ + uap->tx_irq_seen = 0; + spin_lock_irq(&uap->port.lock); /* restore RTS and DTR */ @@ -1702,7 +1704,7 @@ static void pl011_shutdown(struct uart_port *port) spin_lock_irq(&uap->port.lock); uap->im = 0; writew(uap->im, uap->port.membase + UART011_IMSC); - writew(0xffff & ~UART011_TXIS, uap->port.membase + UART011_ICR); + writew(0xffff, uap->port.membase + UART011_ICR); spin_unlock_irq(&uap->port.lock); pl011_dma_shutdown(uap);