From patchwork Tue Jul 19 07:43:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhuvanchandra DV X-Patchwork-Id: 9236249 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 3DF696075D for ; Tue, 19 Jul 2016 07:49:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F512205AA for ; Tue, 19 Jul 2016 07:49:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 201052074F; Tue, 19 Jul 2016 07:49:08 +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=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, 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 ACD202015F for ; Tue, 19 Jul 2016 07:49:07 +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 1bPPkV-0000QE-V7; Tue, 19 Jul 2016 07:47:28 +0000 Received: from mail-ve1eur01on0138.outbound.protection.outlook.com ([104.47.1.138] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bPPiJ-0006IE-FW for linux-arm-kernel@lists.infradead.org; Tue, 19 Jul 2016 07:45:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toradex.onmicrosoft.com; s=selector1-toradex-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=TjdXS7Z1UhydlzYbQlmvqNcv5qNCIH5ucCbLcFhZm1s=; b=jIF8nC2iQU0mrm6+xmX89wA7KudXTWaWJ+kcAOBNSsiftiGUECg/YPatnnUaoG730mfeCgb7SKMF+ykOUBomFB9lMsXjaF17cPCZ+wrY/3R2gd0jP7pY+XSiGAaQ7y5iZUgQ9NoAQjXrA6ZPSWvxDAKrKRLUx2xW4jN/u9v5XV8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=bhuvanchandra.dv@toradex.com; Received: from tdx-in-nb-0014.toradex.ext (115.115.243.34) by DB6PR0501MB2087.eurprd05.prod.outlook.com (10.168.9.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.544.10; Tue, 19 Jul 2016 07:44:54 +0000 From: Bhuvanchandra DV To: Subject: [PATCH RESEND v2 7/8] tty: serial: fsl_lpuart: Update suspend/resume for DMA mode Date: Tue, 19 Jul 2016 13:13:09 +0530 Message-ID: <20160719074310.16872-8-bhuvanchandra.dv@toradex.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160719074310.16872-1-bhuvanchandra.dv@toradex.com> References: <20160719074310.16872-1-bhuvanchandra.dv@toradex.com> MIME-Version: 1.0 X-Originating-IP: [115.115.243.34] X-ClientProxiedBy: MA1PR01CA0045.INDPRD01.PROD.OUTLOOK.COM (10.164.116.145) To DB6PR0501MB2087.eurprd05.prod.outlook.com (10.168.9.139) X-MS-Office365-Filtering-Correlation-Id: cb181b40-d304-40da-4252-08d3afa89448 X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2087; 2:RC+IrPm6GT8im8QADChUC6PBgvpy033Bm9gMIHXiRLOsMwHIetCfeGG5Y+RiYsRCEgl+8/J5o1ZHPCAiEbWDjw7WDnQNwA/As6LIMlj11Q4QTZ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Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:DB6PR0501MB2087; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0501MB2087; X-Forefront-PRVS: 000800954F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(77096005)(36756003)(42186005)(69596002)(4001430100002)(19580395003)(86362001)(7736002)(19580405001)(47776003)(5003940100001)(2950100001)(92566002)(50466002)(66066001)(76176999)(50986999)(50226002)(4326007)(48376002)(6116002)(3846002)(1076002)(586003)(97736004)(305945005)(68736007)(189998001)(105586002)(8676002)(110136002)(15650500001)(107886002)(53416004)(101416001)(2906002)(2351001)(81156014)(81166006)(229853001)(106356001)(7846002)(33646002)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0501MB2087; H:tdx-in-nb-0014.toradex.ext; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: toradex.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0501MB2087; 23:KK8QRZVk/WCTSqTdPA66bFjH0O2psmOSjlDyp5T?= =?us-ascii?Q?PYmXRH5P4OahugSrWaoKiXlBrqVHbWEA7mdWLNjSFLE/7kWl0D21ySqsFlu2?= =?us-ascii?Q?t/PrU/q0mFxgOyED0nvBxdhZZuVAOn9IO9mafc4zh6yCSiDRvIzcQdUHOEPk?= =?us-ascii?Q?gfdHMUd5ibs2LKxVdu65n1PJDHVY2Angf3goK87WLIun7E4Z8BFSzy1nOiZY?= =?us-ascii?Q?yuAp4sH/4pJTtoSrHNQDcABJmPlJAeQ3nQN19IXdGFm3vElooWxoMQCCJFEj?= =?us-ascii?Q?ZHFc2yM/zrfXcQ61tdgDZNtLNa+G/lKstoh/tZU7bb9elFnCqzLZUWXwJ1nw?= =?us-ascii?Q?g4IRXV7+Y0XoryCdVJ9tZSAHPq4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microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2087; 6:7l4OwVIaRtBP+2OxCY3E0UsQbYKu48jNGAAjz1OBZkAiR4kAd/zKf1txr1aFer8EwnqDlQ8P9jJLVw+FLYprwBCFmDLMSW+5XxQpEfluG16A42v2GMzpPL/VK7fNPFbIty86WLtuXJHKBTpE7oB4matlur+bMfttNRPYUhRAbfSjGxi7VMG3uB0tsxvnx6bMvCEH+57IEjSl/biWVhiATAoNNoXMYG8iOn7OyJaJMF9LgnYrf1AnpkqPakZW/H9P2HkognUk3FPjEY7DlhKIPAkYFO9AWFmNxkG08AJxOrk=; 5:qO/z7hdpfcQLeAAJt4isuq6Xx/9qccPuIuoOn1ceHuPru6xvLcqLOpR/j+Zio6sLeQ/Bv3OhDK/zFzRFITu6lOjZHfPGDp3JVTq6s/xpJ4LcsqT/N45fgzFatR80PP+yZSLHybPimHKpluN2uKmqHg==; 24:pQvtQ5KIkcYqR6Sif63Z7ezKc/q+3z6FwVShZu2DgOoMQoRYStq4TM+R6FMYa9I1bsrLoa2z7cR7X3aSAgmWuSbQMitqsexlR2mxS093nUM=; 7:XYv68+Yk5eWm4bIf4rDT+7EiHfDI6s9vne8vvi4XbN+DWWagg/gkE6zUJrzLuRNJQPfiyF/cKBFN3owp01Bn9d6r6nacm7DUwWb/ddiXWa3Q8PxEGYujmcVDu33lRNvz1H2UF0lir3dbGT45qhsHwFH5+rT/zI9zkGkJ5Fh9Ck8RSZABUtQaFomMJOG7bLHw6fV4dW8lWqgYl+AnryAV9DQNEbOlqjEK10ofqRP3FC8HLifO0FBUtVgg7o5CLRfB SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: toradex.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2016 07:44:54.4293 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2087 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160719_004511_855040_DCFD8589 X-CRM114-Status: GOOD ( 10.96 ) 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-serial@vger.kernel.org, mturquette@baylibre.com, sboyd@codeaurora.org, linux-kernel@vger.kernel.org, stefan@agner.ch, kernel@pengutronix.de, jslaby@suse.com, shawnguo@kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bhuvanchandra DV 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 When DMA mode is enabled one need to make sure the DMA channels are idle before entering suspend mode especially when UART ports which are set as wakeup source and console port with no_console_suspend is set. This patch takes care of gracefully releasing DMA channels for the above two cases and start the DMA at resume. Signed-off-by: Bhuvanchandra DV --- drivers/tty/serial/fsl_lpuart.c | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 27687d5..134090a 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1943,6 +1943,30 @@ static int lpuart_suspend(struct device *dev) } uart_suspend_port(&lpuart_reg, &sport->port); + + if (sport->lpuart_dma_rx_use) { + /* + * EDMA driver during suspend will forcefully release any + * non-idle DMA channels. If port wakeup is enabled or if port + * is console port or 'no_console_suspend' is set the Rx DMA + * cannot resume as as expected, hence gracefully release the + * Rx DMA path before suspend and start Rx DMA path on resume. + */ + if (sport->port.irq_wake) { + del_timer_sync(&sport->lpuart_timer); + lpuart_dma_rx_free(&sport->port); + } + + /* Disable Rx DMA to use UART port as wakeup source */ + writeb(readb(sport->port.membase + UARTCR5) & ~UARTCR5_RDMAS, + sport->port.membase + UARTCR5); + } + + if (sport->lpuart_dma_tx_use) { + sport->dma_tx_in_progress = false; + dmaengine_terminate_all(sport->dma_tx_chan); + } + if (sport->port.suspended && !sport->port.irq_wake) clk_disable_unprepare(sport->clk); @@ -1970,6 +1994,26 @@ static int lpuart_resume(struct device *dev) writeb(temp, sport->port.membase + UARTCR2); } + if (sport->lpuart_dma_rx_use) { + if (sport->port.irq_wake) { + if (!lpuart_start_rx_dma(sport)) { + sport->lpuart_dma_rx_use = true; + rx_dma_timer_init(sport); + } else { + sport->lpuart_dma_rx_use = false; + } + } + } + + if (sport->dma_tx_chan && !lpuart_dma_tx_request(&sport->port)) { + init_waitqueue_head(&sport->dma_wait); + sport->lpuart_dma_tx_use = true; + writeb(readb(sport->port.membase + UARTCR5) | + UARTCR5_TDMAS, sport->port.membase + UARTCR5); + } else { + sport->lpuart_dma_tx_use = false; + } + uart_resume_port(&lpuart_reg, &sport->port); return 0;