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: 6333771 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AE109BEEE1 for ; Tue, 5 May 2015 03:17:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99041202F8 for ; Tue, 5 May 2015 03:17:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6346C202F2 for ; Tue, 5 May 2015 03:17:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YpTJt-0008QL-Uj; Tue, 05 May 2015 03:14:53 +0000 Received: from mail-pd0-f179.google.com ([209.85.192.179]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YpTJr-0008N7-3N for linux-arm-kernel@lists.infradead.org; Tue, 05 May 2015 03:14:51 +0000 Received: by pdea3 with SMTP id a3so181103871pde.3 for ; Mon, 04 May 2015 20:14:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RZj/hRL1u77LmnT/Fyy8pVYLFolYnvB12sNSZEmBS+o=; b=J6xFRHV/+4Q/2LnohaJ2ozC2bXAOxuOwVX6xkFt7NTNj93eQHVq32crUnRcERONjX2 bRkagg9IJiPsp6toU6dDSZEgiuPqT2bCJ3PwnkaHa0XWVBZMa2YIw8VpW/Vn8UKkTzIf 5v+6i5tFIIwONLsjp8tRv4HZZYVMSlaQ3YOKDmRxhREffnBBqbnLLBf6pgk3f5+GqIhM XkQ/o0ylbNe3DoDydoWnRHd68SchCO5robnWWrM/aOXNrbT19ysj3VlfgbZ/YcEd4IpN WIbVWSX0rVo0HhTSSPL1X23yza5UfQjAJ/3tdR2FbqR6p8ML+J/lIKRJAItCjbFaCfmp j21A== X-Gm-Message-State: ALoCoQlO7af0ConviYnLmCpmS2x7tbMbc2D0r5NzLMfKT7bOlklSZlrTpVQ84+ZNgatFO0ac4g88 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150504_201451_209216_EDAF31A0 X-CRM114-Status: GOOD ( 16.29 ) X-Spam-Score: -0.7 (/) Cc: Leo Yan X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);