Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752383AbdF3MFc (ORCPT ); Fri, 30 Jun 2017 08:05:32 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:37579 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751978AbdF3MFS (ORCPT ); Fri, 30 Jun 2017 08:05:18 -0400 From: Romain Perier To: Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nandor Han , Romain Perier Subject: [PATCH 5/7] serial: imx: umap sg buffers when DMA channel is released Date: Fri, 30 Jun 2017 14:04:44 +0200 Message-Id: <20170630120446.13994-6-romain.perier@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630120446.13994-1-romain.perier@collabora.com> References: <20170630120446.13994-1-romain.perier@collabora.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1258 Lines: 42 From: Nandor Han This commits unmaps sg buffers when the DMA channel is released Signed-off-by: Nandor Han Signed-off-by: Romain Perier --- drivers/tty/serial/imx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index e8cf7cf..58d6b1c 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1215,6 +1215,12 @@ static void imx_stop_tx_dma(struct imx_port *sport) temp = readl(sport->port.membase + UCR1); temp &= ~UCR1_TDMAEN; writel(temp, sport->port.membase + UCR1); + + if (sport->dma_is_txing) { + dma_unmap_sg(sport->port.dev, &sport->tx_sgl[0], + sport->dma_tx_nents, DMA_TO_DEVICE); + sport->dma_is_txing = 0; + } } static void imx_stop_rx_dma(struct imx_port *sport) @@ -1224,6 +1230,12 @@ static void imx_stop_rx_dma(struct imx_port *sport) temp = readl(sport->port.membase + UCR1); temp &= ~(UCR1_RDMAEN | UCR1_ATDMAEN); writel(temp, sport->port.membase + UCR1); + + if (sport->dma_is_rxing) { + dma_unmap_sg(sport->port.dev, &sport->rx_sgl, 1, + DMA_FROM_DEVICE); + sport->dma_is_rxing = 0; + } } static void imx_enable_dma(struct imx_port *sport) -- 1.8.3.1