From patchwork Thu Jun 9 15:10:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhuvanchandra DV X-Patchwork-Id: 9167279 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 51C2360467 for ; Thu, 9 Jun 2016 15:14:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4409C28310 for ; Thu, 9 Jun 2016 15:14:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38DB828355; Thu, 9 Jun 2016 15:14:32 +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 BCB3E28310 for ; Thu, 9 Jun 2016 15:14:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bB1dh-0006Jq-5O; Thu, 09 Jun 2016 15:12:57 +0000 Received: from mail-db5eur01on0101.outbound.protection.outlook.com ([104.47.2.101] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bB1cg-0005FN-6l for linux-arm-kernel@lists.infradead.org; Thu, 09 Jun 2016 15:11:56 +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=ZvVB+s64qlmxgpEsuCleM38PdrNuEbz5WM0x9QllgCI=; b=AwE9s9urRtLw2sqOYtBNzpzEHx3REqp2ACQiPorASIf191omvPez+pkvUkiefhIb4re/Ry9CzSiws3I15so6pYmBnlc8QuxE5r7IscBAu4sHYRd3ER1BLRGjJdosAWBSzoR9yK+VxcCNEIS4XorCfZ4WG+OoyZOsBLvZIf0Zzyg= 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 DB4PR05MB270.eurprd05.prod.outlook.com (10.242.158.24) with Microsoft SMTP Server (TLS) id 15.1.511.8; Thu, 9 Jun 2016 15:11:42 +0000 From: Bhuvanchandra DV To: Subject: [PATCH 7/8] tty: serial: fsl-lpuart: Update suspend/resume for DMA mode Date: Thu, 9 Jun 2016 20:40:38 +0530 Message-ID: <20160609151039.20817-8-bhuvanchandra.dv@toradex.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160609151039.20817-1-bhuvanchandra.dv@toradex.com> References: <20160609151039.20817-1-bhuvanchandra.dv@toradex.com> MIME-Version: 1.0 X-Originating-IP: [115.115.243.34] X-ClientProxiedBy: SIXPR04CA0050.apcprd04.prod.outlook.com (10.162.171.40) To DB4PR05MB270.eurprd05.prod.outlook.com (10.242.158.24) X-MS-Office365-Filtering-Correlation-Id: 2e7f9778-c6e4-4c4d-9f8b-08d390786021 X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB270; 2:vc0COb32oH++GPHxpWb+r+3hlCCrkc4xZfnMxmOgs3KhlhoD8H58dxYDjhx0O+2Dr39ngEnhMI3dxb3s1/lFOGamW8HestOTDUwlhLIDFwaMwgIX2aX5P7iw6a/2/WTxyXUk+EMJvbCWKBLs2DRjR15xlMnkbUNIqm1q3oQ1hnuEqssxVYXQx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brd1ZcSFX1bl8jk8s5YSzhckN8o4qHchO+/ve4Q718uf/fX3GIqL36wWBQyWoJZwazlWtQfx669hVnEd/nRfHCmJ4MunB2+dqQ0OpqqtLnLHVVbPp9wt4F+UYsNZGxt2D4b7t5f04PFiwaj7CVPdKPlK5HrVlRwQ/j93rxydWkPECELTb7DALr1aRY2tLu+XIejcuBrEs4J93nIxDS7REcsVf0yY4cayThQQylcweR3sviOD1HeE4ZcUu3yebLVICz8zYiCFWEZrtFTPKdm7G7qVG4aU1JAEPuC60TA+nIPAGq/HG3DyVWT96J/habNKXOw==; 4:jd2JSPdPchbvqj1+S556klZiYZo1Hg7nmc1kUrRa4xBdDZgZkLgrtcRGIwJjIR6w7d1XcXSzj4znLIHp2yfEhYt6tRIMw4ua7JzbKQh6qpKH6vAYkayDtdX16mSfHo/9A0zRqwogzYoOSdV9YNnP8tLNlez8oRlzaAQccfrwQxauK2wi4b/WWli9IJpIBgcIAUaL85iJNet3i6rtBY9XMt0ljGPgFjp2OPmeqd7HC+9xhbOYd8UhKJyq9WB28PJIrLrImQjIxVGUleAU5XSY/6vEj8vcvJbZsGhDpeZbhg8OHkTMMCUolvhaWmolCwjI0p91EUQQ4x0JL1jzHm5eewvDiYhcxxQWpYGe2jqKLBx+JUn7NORzfOCbMrN4a52r X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:DB4PR05MB270; BCL:0; PCL:0; RULEID:; SRVR:DB4PR05MB270; X-Forefront-PRVS: 0968D37274 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(189002)(199003)(36756003)(50466002)(4001430100002)(42186005)(1076002)(86362001)(19580395003)(69596002)(48376002)(5008740100001)(81156014)(19580405001)(97736004)(4326007)(2906002)(77096005)(101416001)(81166006)(50226002)(2950100001)(33646002)(6116002)(68736007)(2351001)(3846002)(5003940100001)(107886002)(105586002)(110136002)(106356001)(53416004)(229853001)(50986999)(8676002)(189998001)(92566002)(5004730100002)(15650500001)(66066001)(586003)(76176999)(47776003); DIR:OUT; SFP:1102; SCL:1; SRVR:DB4PR05MB270; H:tdx-in-nb-0014.toradex.ext; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; DB4PR05MB270; 23:BicKtkgTtpu27So45OGyYMhHSRFDjUfM3kW9Fv2hQ8?= =?us-ascii?Q?7GoC5ojgfd74z7GBXJUrrh8Tt2206FsJ0jAmT/osvdJraA1VXJ/H2jrrsCeJ?= =?us-ascii?Q?1b8ylXmfYzyn5gmF0j0y+et4COo3Mn5BcnRToL7in/RdeC46rBm6w0DgNipk?= =?us-ascii?Q?WI9q0MCAVwbHPQ46ktq9fVPsj+ZVyMz7jrYv47VL0hOTPu7IJTqP6YeX7FnC?= =?us-ascii?Q?Yxf2lfEzIfvm8sMPJ/glKXUWGXYB4u2kckzHed4DMvsipnfgwG86QPnAxTmH?= =?us-ascii?Q?UlgHE8hgZTUBlkhEPexXdbqWLuA/N2AjBsn1oPL9/GQUMNEubkqU7oVmmPL1?= =?us-ascii?Q?micHk8YDEaK9YJDL2439RH8NpylQYb1mJG7DWobOuOn66WlAeMh/IXd+i1NA?= =?us-ascii?Q?7+bf8Y0RjKjx03v+XvpyAvu1KerJO4vqRO5CUVUIYQKf35oJELcaieLLYlsi?= =?us-ascii?Q?jcA1fsrcH/OzpBBFHU/9a7RoK1WpjfU7sJ9KUUTBtNfsJ4CICEqcPoISWc0n?= =?us-ascii?Q?rF3XrmRsjN5uxNMbNMf8pNGq2bCJvdZtJkaEDRkBF9qxdDOSQnWYeD06BHYZ?= =?us-ascii?Q?QlqLvLvIUvE3XzsXYFIjUIEXh/SCGG2Fx2fHpxhSAmbS9GNECPsTGvDUQU1l?= =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dustvY5rzELydmLabSTIj7mh3EqXo4CDXAMTG1BHvpSbOhmLVRNPX0stuvLiVPpCjR2UNnH8QOoVijT76b0fP5+Sk7wDGJOU8jvv3w6tngBLhL2wnBv9QrlT9sSmnaqOT8hMg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: toradex.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2016 15:11:42.3600 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR05MB270 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160609_081154_588151_7BF02495 X-CRM114-Status: GOOD ( 11.18 ) 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;