From patchwork Tue Dec 13 16:27:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 9472661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4E91B60760 for ; Tue, 13 Dec 2016 16:31:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38EB128652 for ; Tue, 13 Dec 2016 16:31:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B5CC28655; Tue, 13 Dec 2016 16:31:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B2C2428652 for ; Tue, 13 Dec 2016 16:31:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cGpwr-0005W2-2J; Tue, 13 Dec 2016 16:29:01 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cGpwn-0005TB-4r for linux-arm-kernel@lists.infradead.org; Tue, 13 Dec 2016 16:28:57 +0000 Received: by mail-wm0-x242.google.com with SMTP id m203so19219699wma.3 for ; Tue, 13 Dec 2016 08:28:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=PT+AwGl2I/wiVN+4eD4H5moD0T5BnJ8S5xXZZwACGOU=; b=ks2BQnSAKNjsbEg0nTqaR4ucWYZs7lIssOb1ssr2oPd50wgsZ85oVfjCk6l0twTziM 9rJMG+DfDyz0/nsmYghcUg0m8yOkCcpy+KQd0aFd6fiJHXiFHVrdxVz6UfkaXAvQSd7R S28Qx/bXGfAi+VT08SqotZqd/Fsbwigqpj+3uw2sYLUTT9z6vdFyDptlL3C7znOGkQXU Ws0dddys2HDr9i7lRhTPfJKtGZCkxwENCLhV7BmXbSQS2DdFxGQQnoGQLqDjlR8wgYax CXB9PO8wriUV+hOL7VKQYFdvQahiKdafsbe/5rsCUsaTKMWxKy6TAO2xZ0K4hYKMj/hS gH2g== 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=PT+AwGl2I/wiVN+4eD4H5moD0T5BnJ8S5xXZZwACGOU=; b=Bel573lGb4Hu9nD8RiqWcR5Jui4BFERcJqS002/3dI3T1m/1QmVuac4n+xAGJ00qJ1 Tt8EQort7fqhVpJWp1rZU14CHs4KYPU1Qmz8kW1qwjbs7yXnNhb9aa4O3JZi0zGxvtkd fKgvBkVAZIYfWNTA43mb2i9BR2TnS2rBQD0u6lksaSZpYPKbfFIZFWIWzxWgDMcUv7zH +E2woOD5C8z2WazYaYcRzYFPejuDJ2RiXT5u+eZU9M4tFPYvTYQtDYWXJTz3LKNL1wqd uAMONVAWN5SR1IUzk+bpm5olL/XeAZTlLp5EtS1O9tjsl5hLoQTpOhI+b84S8+xE680r cQvQ== X-Gm-Message-State: AKaTC01KM1I8fOqJKek1Rg1n+4Fqjbneuq5aAk/PQfNWGoZtfeLdkN0p/fSLv1swT+LSiw== X-Received: by 10.28.109.2 with SMTP id i2mr3344469wmc.41.1481646514126; Tue, 13 Dec 2016 08:28:34 -0800 (PST) Received: from localhost ([46.227.18.67]) by smtp.gmail.com with ESMTPSA id bj1sm63017608wjc.17.2016.12.13.08.28.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Dec 2016 08:28:33 -0800 (PST) From: Richard Genoud To: Nicolas Ferre , Alexandre Belloni , Greg Kroah-Hartman , Cyrille Pitchen Subject: [PATCH] tty/serial: atmel_serial: BUG: stop DMA from transmitting in stop_tx Date: Tue, 13 Dec 2016 17:27:56 +0100 Message-Id: <20161213162756.16139-1-richard.genoud@gmail.com> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161213_082857_422216_1C34319F X-CRM114-Status: GOOD ( 12.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Richard Genoud , "beware, this won't apply before 4.3" , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If we don't disable the transmitter in atmel_stop_tx, the DMA buffer continues to send data until it is emptied. This cause problems with the flow control (CTS is asserted and data are still sent). So, disabling the transmitter in atmel_stop_tx is a sane thing to do. Tested on at91sam9g35-cm(DMA) Tested for regressions on sama5d2-xplained(Fifo) and at91sam9g20ek(PDC) Cc: (beware, this won't apply before 4.3) Signed-off-by: Richard Genoud Acked-by: Nicolas Ferre --- drivers/tty/serial/atmel_serial.c | 11 +++++++++++ 1 file changed, 11 insertions(+) NB: this is not for the 4.10 merge window, I'm just sending it now to have some comments if someone is againts it. diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 168b10cad47b..f9d42de5ab2d 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -481,6 +481,14 @@ static void atmel_stop_tx(struct uart_port *port) /* disable PDC transmit */ atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); } + + /* + * Disable the transmitter. + * This is mandatory when DMA is used, otherwise the DMA buffer + * is fully transmitted. + */ + atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS); + /* Disable interrupts */ atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); @@ -513,6 +521,9 @@ static void atmel_start_tx(struct uart_port *port) /* Enable interrupts */ atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); + + /* re-enable the transmitter */ + atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); } /*