Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756033AbcJFWWD (ORCPT ); Thu, 6 Oct 2016 18:22:03 -0400 Received: from p3plsmtpa08-10.prod.phx3.secureserver.net ([173.201.193.111]:34420 "EHLO p3plsmtpa08-10.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752906AbcJFWV4 (ORCPT ); Thu, 6 Oct 2016 18:21:56 -0400 X-Greylist: delayed 488 seconds by postgrey-1.27 at vger.kernel.org; Thu, 06 Oct 2016 18:21:56 EDT From: Aaron Brice To: gregkh@linuxfoundation.org, jslaby@suse.com, bhuvanchandra.dv@toradex.com, stefan@agner.ch Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] tty: serial: fsl_lpuart: Fix Tx DMA edge case Date: Thu, 6 Oct 2016 15:13:04 -0700 Message-Id: <1475791984-17705-1-git-send-email-aaron.brice@datasoft.com> X-Mailer: git-send-email 2.7.4 X-CMAE-Envelope: MS4wfK6AVzKzjztex6G9+F+ulm/AxqB/C0z/0nNGPM1Aer0tzIQ/jPVNl6/bpT/X1gAwovcTBJ7PI41a8nfh68V/dDgPjJ/cenhlMhvWl7VdWFEqH/0nSGRx QK2UEpHCqeF+XSzBYU1yGMwoVFV/fLDrQgWJ3OdxcrozMXvwhc/6Fbg7Sd4/hd4jG2tmuZiJcf9SmIbfEodkgbz150+SZZHzGBndQKYh0OnERT03wrvzBagK r4iaqUop2kPLB6rEBq6Vcb7alRaiJicLzVwDoG5TcARZGvEDQHJnxMltkgoTYiNBdeml3zJA9uMWxZfpJ/ojB/ZRkhs/J79AYDejKDU9oJK6SLaBHNODo6X3 qG8vGZ/Ec1j3N6YLmLgSe8jACIzjBm4Zb+Oj3GXwiByOANbHyOeHQG8+11mG5x3AdGdKDRlUyp0Tku0X9gqqRzRLzDX18A== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1125 Lines: 32 In the case where head == 0 on the circular buffer, there should be one DMA buffer, not two. The second zero-length buffer would break the lpuart driver, transfer would never complete. Signed-off-by: Aaron Brice --- drivers/tty/serial/fsl_lpuart.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index de9d510..76103f2 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -328,7 +328,7 @@ static void lpuart_dma_tx(struct lpuart_port *sport) sport->dma_tx_bytes = uart_circ_chars_pending(xmit); - if (xmit->tail < xmit->head) { + if (xmit->tail < xmit->head || xmit->head == 0) { sport->dma_tx_nents = 1; sg_init_one(sgl, xmit->buf + xmit->tail, sport->dma_tx_bytes); } else { @@ -359,7 +359,6 @@ static void lpuart_dma_tx(struct lpuart_port *sport) sport->dma_tx_in_progress = true; sport->dma_tx_cookie = dmaengine_submit(sport->dma_tx_desc); dma_async_issue_pending(sport->dma_tx_chan); - } static void lpuart_dma_tx_complete(void *arg) -- 2.7.4