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: 6333751 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D0E419F373 for ; Tue, 5 May 2015 03:03:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F03D8202F8 for ; Tue, 5 May 2015 03:03:55 +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 08985202E6 for ; Tue, 5 May 2015 03:03:55 +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 1YpT6g-000366-BB; Tue, 05 May 2015 03:01:14 +0000 Received: from mail-pa0-f43.google.com ([209.85.220.43]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YpT6d-00030q-UB for linux-arm-kernel@lists.infradead.org; Tue, 05 May 2015 03:01:12 +0000 Received: by pabsx10 with SMTP id sx10so178124874pab.3 for ; Mon, 04 May 2015 20:00:50 -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=JxAATOM4o24yVf/0EdEK+s1Ds6tvFlao0v5FfrhysuI=; b=dLENdBQ8KbKSSL+WTqcYQYez7sScgBuNvqZjucxT+NddD32pIvC1gN5RQDT2GA0BSv eXSnGv9YdKiN2GM3CeieVvYInpzvF9GRp8clmsHY9d7Qa+LeaFpUM5A+WcYGrw5HQzP7 qAYzuVPLd9WZndc/79qG1OHkGQKn9PixyRS+NIz8Sy1UAEhjD2NDoh6Q3DFM2GNVvlz1 fsRfP43pV9f+0RZE2lDG0oiM75Gxaa9POJG1R+cWlQrkTAU6IuPU68HiRkWVpbgJLx7X TdaAdPQJbppQFRQGahbZzPTxJEwOENvqfcEtBNRKdLCg0sCPYcwbWsM0H3d6qYc2IePJ rQXA== X-Gm-Message-State: ALoCoQluHlYaR6ec5ke+rxfek5lKbvPh/gQB+H+SFhNMDWAtayKbjN04nRDhvLtv2bLJ6aUm1F7+ 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150504_200112_016581_7B34B457 X-CRM114-Status: GOOD ( 16.37 ) 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 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);