From patchwork Tue May 5 03:00:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 48016 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B21BD2121F for ; Tue, 5 May 2015 03:01:19 +0000 (UTC) Received: by wgin8 with SMTP id n8sf49067471wgi.0 for ; Mon, 04 May 2015 20:01:18 -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=HzY7ClAg57rBPgktdKH73ywA0/Xy0GO52ahVpXZHBgY=; b=NoNnCrWPSVXlCeyeOtIUb8xfl3JtaV9RpgXPbFBsab3rhq2j+8UKwbWC/f5ZTO4heT 2lhLVA3ZROY8jm+/EuDh0kJDyjQJh/TApUo9dTINX3GdrAg1xtN1QNCsKsemoTvbLKLq AEbzZmdvXcAWyzGiOr3MMf66raSw5hrnZb8pJmTU32rwy8MH+kMP3oLSLuVAGJz+tvmB 30/0xwqnJ74Wg540nFVGQHGu9cPqlWwBjPjnFSC9tTOSS3IFVx/DagyLUA8liUe2i0Vc 00LFHVF4xHuZYXnG5jTmFxeFMSeqJUERWR0+SEF50Q6eC49Gv8nDGX35yXsKHew8mp35 d+Gw== X-Gm-Message-State: ALoCoQnkByxViI3S67pyB4AKWBeLSFQvARpS1hjKLOSgs3xFgQEpzNpyeGedjsDgbWpDXAsHa18o X-Received: by 10.112.151.146 with SMTP id uq18mr20611717lbb.20.1430794878887; Mon, 04 May 2015 20:01:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.197 with SMTP id o5ls768037laf.66.gmail; Mon, 04 May 2015 20:01:18 -0700 (PDT) X-Received: by 10.112.160.41 with SMTP id xh9mr21504626lbb.96.1430794878640; Mon, 04 May 2015 20:01:18 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id ur11si11318103lac.39.2015.05.04.20.01.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2015 20:01:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbqq2 with SMTP id qq2so118280854lbb.3 for ; Mon, 04 May 2015 20:01:18 -0700 (PDT) X-Received: by 10.112.222.133 with SMTP id qm5mr22032128lbc.86.1430794878505; Mon, 04 May 2015 20:01:18 -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 l1csp1991124lbt; Mon, 4 May 2015 20:01:17 -0700 (PDT) X-Received: by 10.66.240.37 with SMTP id vx5mr14029570pac.16.1430794876440; Mon, 04 May 2015 20:01:16 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hy9si22267551pac.82.2015.05.04.20.01.13; Mon, 04 May 2015 20:01:16 -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 S1755155AbbEEDBG (ORCPT + 29 others); Mon, 4 May 2015 23:01:06 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:35071 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755073AbbEEDAu (ORCPT ); Mon, 4 May 2015 23:00:50 -0400 Received: by pabtp1 with SMTP id tp1so178184657pab.2 for ; Mon, 04 May 2015 20:00:50 -0700 (PDT) X-Received: by 10.68.69.2 with SMTP id a2mr2006499pbu.35.1430794850335; Mon, 04 May 2015 20:00:50 -0700 (PDT) Received: from localhost.localdomain ([180.150.148.224]) by mx.google.com with ESMTPSA id bz11sm14186425pdb.34.2015.05.04.20.00.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 May 2015 20:00:49 -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] serial/amba-pl011: fix minor bugs for pio mode Date: Tue, 5 May 2015 11:00:25 +0800 Message-Id: <1430794825-14367-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.217.175 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 2240197 "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 Tested-by: Leo Yan Tested-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);