From patchwork Thu Sep 21 16:18:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martyn Welch X-Patchwork-Id: 9964251 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 257316020C for ; Thu, 21 Sep 2017 16:20:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1292129574 for ; Thu, 21 Sep 2017 16:20:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0696429582; Thu, 21 Sep 2017 16:20:39 +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.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, 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 8CD782957A for ; Thu, 21 Sep 2017 16:20:38 +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=mu8QKOKVW+WkNd9YRtY1OS1sc0AGSfqPa4Nz6Etvsec=; b=om3CLxUGnFgqoACt7by+WXr6D0 gtS0tGskbjrbW8YEwWctl/hOa4NZPgIg8dobTu1LomW8lLgDxqKorCk6Yv+K4KYx/hK2IcQ8f1CCI cJVM2nP4i19V1OFAKUjT8ZFuiVyovtawmRUmfTwcGTYoIwjdqsvc4VjRNco8YIwk9OSKNqLWLFDXD 43RiNc5sJsXLFQ13Hup6VNAp+limj95s5TXCE4P8w9eqCtIvBQIVjLqo/g5B91J4jYQ7z//QcFOSG liAbZx2JsXgCNcUH3e8pAjJg6+9XYrvbvl/C3+J80ALZVDSwfrrfz4+nPUZ/UUUjf6ZiRNzjFs9pF Kq8MXNyA==; 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 1dv4DJ-0005Gp-Cb; Thu, 21 Sep 2017 16:20:33 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dv4Bl-0002QB-VE for linux-arm-kernel@lists.infradead.org; Thu, 21 Sep 2017 16:19:01 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: martyn) with ESMTPSA id 92A77268781 Received: by kratos.localdomain (Postfix, from userid 1000) id DB150204D84BC; Thu, 21 Sep 2017 17:18:22 +0100 (BST) From: Martyn Welch To: Greg Kroah-Hartman Subject: [PATCH v3 4/6] serial: imx: unmap sg buffers when DMA channel is released Date: Thu, 21 Sep 2017 17:18:15 +0100 Message-Id: <1506010697-22114-5-git-send-email-martyn.welch@collabora.co.uk> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506010697-22114-1-git-send-email-martyn.welch@collabora.co.uk> References: <1506010697-22114-1-git-send-email-martyn.welch@collabora.co.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170921_091858_281535_FCAB9EB1 X-CRM114-Status: UNSURE ( 8.85 ) 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: Martyn Welch , Nandor Han , linux-kernel@vger.kernel.org, Fabio Estevam , linux-serial@vger.kernel.org, u.kleine-koenig@pengutronix.de, Romain Perier , linux-arm-kernel@lists.infradead.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 Signed-off-by: Martyn Welch --- 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 2fb3210..ed02783 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -357,6 +357,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) @@ -366,6 +372,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; + } } /*