From patchwork Wed Jul 5 13:07:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Perier X-Patchwork-Id: 9826491 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 C781560237 for ; Wed, 5 Jul 2017 13:09:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C94AF228C9 for ; Wed, 5 Jul 2017 13:09:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD66E283F2; Wed, 5 Jul 2017 13:09:11 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 512D5228C9 for ; Wed, 5 Jul 2017 13:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=r1b03bPtyBnEpOC7ZVDczrgZQ6wGVA+Pv167T+bn3D4=; b=hB0+XWrn50tTPOtkBqhTOs+R2n ev56zpJVM36EjauH50XmdR86Jg0Q7TGs/YUDfWWUY7TGRtvkxoe+7zMb2Mijftv32GNqrQgYRi5Wl Hs367LgBW5ROe8lS2BOBCOXJEuie/dd2kXl8EEiHyFsRkMIiSXZ6mLw89OqrgOfy21avGj5hWAdzx 9gL6VvHs/Zef+hu4l/RRqeFM7VUUpHVxE1B8f7zxAK6/OpxIyVxF6sxvJjNyXT84vcS1DasFOIecO wMlLjUmn+hV+XKS8LBjhoZZZI07A0L0h0h9roTYblHHfw+LELJiDgK9kM8AbR289cO6tIoFxHHLgK ILIW6CmA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dSk3H-0005JD-Lk; Wed, 05 Jul 2017 13:09:07 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dSk2H-0004FK-Gm for linux-arm-kernel@lists.infradead.org; Wed, 05 Jul 2017 13:08:13 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: rperier) with ESMTPSA id 90BDC26BFEB From: Romain Perier To: Greg Kroah-Hartman Subject: [PATCH v2 4/6] serial: imx: unmap sg buffers when DMA channel is released Date: Wed, 5 Jul 2017 15:07:04 +0200 Message-Id: <20170705130706.10388-5-romain.perier@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170705130706.10388-1-romain.perier@collabora.com> References: <20170705130706.10388-1-romain.perier@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170705_060806_138810_E86CD9A8 X-CRM114-Status: UNSURE ( 7.71 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Romain Perier , Nandor Han , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, linux-kernel@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 From: Nandor Han This commits unmaps sg buffers when the DMA channel is released. It also sets to zero `dma_is_rxing` and `dma_is_txing` to state that the corresponding channels cannot transmit/receive data, as these are disabled. 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 dd3ebb4..3112d88 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -367,6 +367,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) @@ -376,6 +382,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; + } } /*