From patchwork Tue Jun 28 05:32:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhuvanchandra DV X-Patchwork-Id: 9201869 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 B7C776075F for ; Tue, 28 Jun 2016 05:35:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A75F8285E6 for ; Tue, 28 Jun 2016 05:35:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BFB7285EA; Tue, 28 Jun 2016 05:35:31 +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 50984285E6 for ; Tue, 28 Jun 2016 05:35:31 +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 1bHlez-0007r3-LM; Tue, 28 Jun 2016 05:34:09 +0000 Received: from mail-db5eur01on0105.outbound.protection.outlook.com ([104.47.2.105] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bHleZ-0007cL-RF for linux-arm-kernel@lists.infradead.org; Tue, 28 Jun 2016 05:33:45 +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=qwxrJ6nbxanWkljL767SHIHA/Fki31GzbGy+HJrKSG4=; b=nvvsLCuFjo+c3lEp1s1FzSbjH/6xXqZA+rwamoCE1MtVWcXC5R2zIi6gPLqFvYtBA6W6DPCaCD0tRVi+exqMH6nY5iBCGVS/qrOffA15Umsrv7FP75F3PDcRjOgE66KxF4sqqDOlY3FUGm5XrKiSGqRnSdnduH3M9bvxb8+A/vM= 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 HE1PR0501MB2089.eurprd05.prod.outlook.com (10.167.246.9) with Microsoft SMTP Server (TLS) id 15.1.523.12; Tue, 28 Jun 2016 05:33:21 +0000 From: Bhuvanchandra DV To: Subject: [PATCH v2 4/9] tty: serial: fsl_lpuart: fix clearing of receive flag Date: Tue, 28 Jun 2016 11:02:30 +0530 Message-ID: <20160628053235.5114-5-bhuvanchandra.dv@toradex.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160628053235.5114-1-bhuvanchandra.dv@toradex.com> References: <20160628053235.5114-1-bhuvanchandra.dv@toradex.com> MIME-Version: 1.0 X-Originating-IP: [115.115.243.34] X-ClientProxiedBy: BM1PR01CA0056.INDPRD01.PROD.OUTLOOK.COM (10.163.199.28) To HE1PR0501MB2089.eurprd05.prod.outlook.com (10.167.246.9) X-MS-Office365-Filtering-Correlation-Id: b24067fe-ef12-479a-f72f-08d39f15b94b X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2089; 2:sD+d4pI+osnnkeD9HKcwd7HYmGjNoOUL1NcAqLvrLFTdH9rpWoRCTT2RtKn9CdlE84QgdNX2+9kO0aK4xehRadsCfn5Qm73ZchSZfFNEf9ehpCeUJOxq55OAp5d0k/vbkjus6F9BoDEka7iy99/XPTEThHaU4uWzp6S8C6CRkSQBZ0u1RDDtWZNvCpoA6kEc; 3:3/C5PqZbaZIuaXL7GgS7Vm0RoJ2u4MLo6mQoFU4/JeHbCSmHMhorZm76RaxOQs/Z3dPRW2Bptn2adiB4c+PUlnvBFh/vliNaIcKIax057CxxjBOfvHkwKdLrZmiUmuxW X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0501MB2089; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2089; 25:/wZ4qwuqCD5VX39yyEFfpDohH7sP9O83QAJHIFCGaLtqJ+YInq34wRvJ5ZbemiWc4TSRpuFEspBYUXzKRFKoX1//jX6T+H625h45X0WaeaENAQxDnp4+ejz1kYPMdkWBFPYuCreYj1DUp3DiZp66k0i2O90MABBL5LPJtUI3YahmMHkG2Ox1jninl56cb8erk1h4abrt8P8tu5iUoavUe+0iJnT6rYg1e50uzQ0gCIBbizHjfv1t1LVI2mYBOQfFEIePKtySA1rrFYjWR0lXylfSL8bvqok/PEDrv/EBOQoebCZ/eGcjJC5uO+d3uYPsp15WFLb8rNj6D13SqP+0SgQlXWuKnubcy/6cezhQ1V5JFewGs3rbikIZxzt12fg+zNE6mIWh+ugm85NpNlNMCUPcWUHez758EfDWGwddr+HTPtQnyyeX15dwGSCZcP8HJ9tnFLjAoyhI+MYZ3uSU75xumT9wmfWYsgLqZcy90kNhvbvykqo74A1CclYaY8RFbL9XUs6OhBQSqA0jo8VDp7ptlwgzuAgnYwqtXVGMQRz+9OlCimCt2hSIwMo1XCUbUuHuN3FuFiNDyg5auQ8HR3849SAgOxY9+/8M9GkfwbDlpmMLdNGKU7PukQkGoGwYlMaGVPSviXHaMpArWZn4kCc3H9v6DaPSBv+CfOmxjJoaoVhIiXYzaNXw+e+WzwRoGJ3F8ffp0EnrI5j6l6QVzIT2Q8Hvj/PS/GB7Tx5I/f8= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2089; 20:ym72qQ5W7DEsIDhM4yeu1VBhWecxUHJcKzojnWi0j0oGJyIqthpCxxwE49Ax1sHh2g82v3cnDdJaCelvlol4KsE0VVeGh3wZCTYWehp3wEo7ucgXoC0Papt5lstR9LjhW7H9p1whjvZDal6VPv9j3eSvGQMbyW6eo9qgRPc3V4vDJv7rxtj+9vhJNht8/xXvPmDA2l4nR05bertxNMW9vKufwGttRIKlToJLoyO5R/oozza3et86RHNgxwgD9a/PJueHZ6a8GFKRIiY/irJ9xBkly30ft48JF0v+JxB1nzj+gemOeCVWJorOA7q3GPlVN0phcM1y5ySUCrVEFBXoxA==; 4:T0rsK6cOPf9/VMoQV7416xUKmYKDqI8f/JTgsxD5ibsvMIrdaPEKR3LMNEqSp32hdn+W7lS++lrztsNK5xmaQqPMHViiQEv0smTjbh+x9HvYdQUN8rJ5x3oZI2daigy0GlBPSkW+31V6YBhbx+4h67pw8vt/DiLzw/55j+q1HkqqQiQLAzBqSFJDTGhyoEEHNKgo/283b23CGENpaAhP534s77nl63v+4Oy1+kES/xhOVKnuT7oROSmRfnhJLcPQRoezHMlU2o4Bhg5+PQZG5B1s90vcaO4JMEcsqnmz0OXmYB4Df4hD/P/EAfR/bxD4YuH84e+uDFyeKf3QfmEDQJtMJEmfZJn5qdTuq7larlA0G0QHGXlF1n0y2j0TTx15 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)(10201501046)(3002001); SRVR:HE1PR0501MB2089; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2089; X-Forefront-PRVS: 0987ACA2E2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(189998001)(50226002)(110136002)(107886002)(7846002)(47776003)(66066001)(36756003)(8676002)(101416001)(1076002)(48376002)(33646002)(6116002)(81166006)(92566002)(3846002)(50986999)(586003)(81156014)(50466002)(2351001)(2950100001)(77096005)(105586002)(229853001)(86362001)(76176999)(5003940100001)(68736007)(305945005)(106356001)(4326007)(7736002)(53416004)(4001430100002)(19580405001)(19580395003)(69596002)(42186005)(97736004)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0501MB2089; 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; HE1PR0501MB2089; 23:ztZohbZo16lvgOLusrl0R+xuezWNU4eror+CGRA?= =?us-ascii?Q?X1qpONJ4HEdq7TMA6WFhfMGymFxdlT52WNxRMJtfB40knzy4amfP3FQ2oflI?= =?us-ascii?Q?yktplBLowbbxV6S8jepse4WNLfDgVpLHFMb56uVLw6ogYeXbNE1fO8OgUzyo?= =?us-ascii?Q?koUzYGMOY3gT23YJ6Iz1WIBATUSI6P3iBqWPbP8SfhQjz6L6KrsPnhCgYI9e?= =?us-ascii?Q?Nz/Wxxc7dOInkn2ODEdrqb0ek2Q6Da/NcUmuFy0xAKURTrx0vp9F37akmfLo?= =?us-ascii?Q?URUXnodU6vm3fjtHuWHAqz0niWT6e9fggTBr0zWAAZtdhfiMCoUKM1nJPizY?= =?us-ascii?Q?Q+mGFwSigUtj34Iu0PDT2SQYouDZMtJXsJ+zXYsA6Sr0IYDO+kgrA6Y7Grns?= =?us-ascii?Q?GONdJ4n0YQaKgWdLvMFUiTbAlYA/m8i9mYoN3zkVL9olvVACwP3qBlyFNF2P?= =?us-ascii?Q?moi1R3Dt9R/shOaSWLSN9F3I7IPw3aMwyGMHEaePazmbUlJ+jAHGar0f1qeb?= =?us-ascii?Q?7TqCDoEpIqTiCH402Eh9XGCR2m3sPLKhUDjSENxqJ13qYzykF28c72Xu/2Wg?= =?us-ascii?Q?nnD8V4D7V3mKyrI/ztInRiD6LBFFHE+YiRS2IakFhWKkbZ6oHJgBHB31D4M0?= =?us-ascii?Q?R/xJA638X4wWqQXPQ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bgKKtdxIdUZLuAyTNGuWN71jPuCQ5AixNyRulquxFlTR/aHfXAqW6icF57rKIPCRv5H5qI3+3PCfNdByfrngJX6TyxcT7qHY5ogbKfg==; 24:1acrFpB9gfYBF2xf3jIDdgODziertuOjC9hVpEvo6Pwn0GZ7xSzB0C7j0zXS/AR0gI2kJpMiSjuS5Y29CCaqWtAjRvWg2zca7K2MGJGr3i4=; 7:EoU1fF1eBaJf8a7nkMEP1iSD8jIzO/wXhIfJhuUFTq9qNEo3MoTo0fcKvMdVUAX8l+Nd5/ssDh8QdBMKfX/WBdJbPc3EoIzU5THw9AffC2whieFpHpssGOI9yD9xgA2Mtyvyn88Wnh7c2/dLZYKrujnU+UwK002m3x64sP0Ijvxod0bxYdWu0CkoH1baxGNkAxwP9r3RmrgEu7b0Q/49Y+vRwd22HlE4rX0rcjRJsnPsXued4Mn4QLU5a/dG4IfHtLk+Qb65YDK4rNHRdkr4ag== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: toradex.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2016 05:33:21.7903 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2089 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160627_223344_163320_08650F8F X-CRM114-Status: UNSURE ( 9.10 ) X-CRM114-Notice: Please train this message. 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 From: Stefan Agner Commit 8e4934c6d6c6 ("tty: serial: fsl_lpuart: clear receive flag on FIFO flush") implemented clearing of the receive flag by reading the status register only. It turned out that even though we flush the FIFO afterwards, a explicit read of the data register is still required. This leads to a FIFO underrun. To avoid this, follow the advice in the overrun "Operation section": Unconditionally clear RXUF after using RXFLUSH. Signed-off-by: Stefan Agner Signed-off-by: Bhuvanchandra DV --- drivers/tty/serial/fsl_lpuart.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 75a2098..97c1fda 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -935,13 +935,16 @@ static void lpuart_setup_watermark(struct lpuart_port *sport) writeb(val | UARTPFIFO_TXFE | UARTPFIFO_RXFE, sport->port.membase + UARTPFIFO); - /* explicitly clear RDRF */ - readb(sport->port.membase + UARTSR1); - /* flush Tx and Rx FIFO */ writeb(UARTCFIFO_TXFLUSH | UARTCFIFO_RXFLUSH, sport->port.membase + UARTCFIFO); + /* explicitly clear RDRF */ + if (readb(sport->port.membase + UARTSR1) & UARTSR1_RDRF) { + readb(sport->port.membase + UARTDR); + writeb(UARTSFIFO_RXUF, sport->port.membase + UARTSFIFO); + } + writeb(0, sport->port.membase + UARTTWFIFO); writeb(1, sport->port.membase + UARTRWFIFO);