From patchwork Tue Jan 7 07:48:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sherry Sun X-Patchwork-Id: 13928323 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2064.outbound.protection.outlook.com [40.107.22.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC4D2522A for ; Tue, 7 Jan 2025 07:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736236300; cv=fail; b=SCWJO5Vp/G+UQjw76w7fpi8CY7XVdsv2pIRM+jFaF9dTcBeHg63cZhj6D6D/uWuxEn/2rN1RLNE+W6cmIXB6x6f+0MoLsTfprlsuZdb0Xh/wnr2RT0+LosXAESOMR4cbzPGS6zkNPWx9GqHEgf8/4Wx3EqRgDwjD5UfSlQ1EIDU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736236300; c=relaxed/simple; bh=4VDiAzj1FP3qw4hghiS87KZ3cD9WrPYtCPxNqJZGwzU=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=BhN9sTv2mKx8vZYtXADH2HeQEad7liwS4cmPVFx8yQihaF5CNey6407/be7/LlB3+pS0pzb15WGLl3e2e8yrJZS7tmG+zKxmcu7nR9DVDBraGNf1xJMog+EHPJ1SuZuvbjo6Z9JmK2nziHhpviRaCnnn+aGD+WSrL/5DvWsUJFE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=SiTgSs1h; arc=fail smtp.client-ip=40.107.22.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="SiTgSs1h" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FfN81jFAtn9IUB008hmb1FcFBF1a8fC1M0xSZJ4B6Ar8ggteq+BM3d22W42eXS9KKJz5j/KK68GUmCUi4obyP0Ej0Uym82shP//CpUsy7FV4ceHDH5W4QbXsO7KYbYgsbMY62FHA+0qTkbXdc+iY7D9rELLi+qj2m3dOC1IXp0oIa5338N8Gm0fD6mNj5h1ytt/JIVw0dlcAkHx8WbnFJwd4dZ2V28wWi80aHpn0LAYYFf1wB6y9OGajQTRVDK/I9BH+J+PbgM6zlgDbaMjlnzfO2sB9rGlEHRE8Qm1jaTioweT7iTaqBLd2KpIPMaBJeFwwiGKfac1e8o7Rt49G6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=S8zX7TftsYmzUQll+W4N9YFYyj57a4xsyfdjNRzSUho=; b=sXxXh1Qt1rZWmUPBhyn7MgauBVar4mKg0XuPHGCDbAG7efm8wlRQe2LGVO9GP8CJjGODo+R5W0yjg76f+w09uTYYbL4ouMgr0SoKdAVaWt+pUPbm+SgEZQf880aLUOYCacKJK/F0U+V0jecygGyILIf4KZ53HB52lbRwMIDrSv3cGy5ovxqxdMOxTo+JmU/1ShihHFefzQHZJ6YQcM97gCGY2qZwf+GyU28QVuP3/i14Da7/nJHsEKLKC2+odZT+vxnF+kVGK8wYuBQh++KdIMJcgsQgaRiNwFNvKCJtVXggUdqvpZ99tzAIPPX+1uXeC81yxbpBZT5sIC55mI4JKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S8zX7TftsYmzUQll+W4N9YFYyj57a4xsyfdjNRzSUho=; b=SiTgSs1hXPe4RsZiIBSchXVpsTGPNQb/3OABMIlxD7XMHy0SfabM4QxaDIU/DBK2+mIJTdlVo/9A6FanJjEXXr/bbpwnp2aku+kc3nvDpM83cm0s1HqK0zzHi/3s+LyedGVSChMEIRyU/xS+let/aekYdkFgqErD2RuQFeWh15r+SZLslylNoykvpev3Il9xa41WNZUbIALzoa1Baz6av5A57MUeENlvcL/L6LSYn5uAT23jJf/eu7W9QAmxiXd61eyfoCPvFtHy565ndd8wKm9eBV83DT0fG3DpjHwW+56wVgM8gFLX5ODC64iwlDDjMLJDsKp72Y/j8gLNxLF3Lg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB8429.eurprd04.prod.outlook.com (2603:10a6:10:242::19) by PAXPR04MB9137.eurprd04.prod.outlook.com (2603:10a6:102:22b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Tue, 7 Jan 2025 07:51:30 +0000 Received: from DB9PR04MB8429.eurprd04.prod.outlook.com ([fe80::2edf:edc4:794f:4e37]) by DB9PR04MB8429.eurprd04.prod.outlook.com ([fe80::2edf:edc4:794f:4e37%5]) with mapi id 15.20.8314.015; Tue, 7 Jan 2025 07:51:29 +0000 From: Sherry Sun To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: [PATCH] tty: serial: fsl_lpuart: flush RX and TX FIFO when lpuart shutdown Date: Tue, 7 Jan 2025 15:48:34 +0800 Message-Id: <20250107074834.3115230-1-sherry.sun@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: JH0PR06CA0003.apcprd06.prod.outlook.com (2603:1096:990:77::6) To DB9PR04MB8429.eurprd04.prod.outlook.com (2603:10a6:10:242::19) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB8429:EE_|PAXPR04MB9137:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d97641a-1753-4305-98f1-08dd2ef0188d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: WQ0Z6rOtaJz5SIxQzlDFKv4IqY8wwEy97dFepjZre/qRh4M3zoc2W2IVJk4q0qGElITmPDcQTUrkYNSW07V5jaS+XAs505K2ZbCJp0xeOkWWbfCbac/NesIf+5kgdCdJCW3hk+QMj8FLHAs/mJR0zRwQPP7QEPdFOBdLWYevEolkuvyWOReo7c/4CBOXZ8V23prJomwknH1wmP0Cai7o8gKD7icdHOPG8FTeCFl5szrW12UQ5UreTTJe1JopEb1JJ6zSHvecRGoNW/65oOaNhqZ2iXuwjeDYidh9jeH+rZ400RpESiobO79wanhwQrTdLf6W0XAWOTS3zwTfI1BJ82wpGqSlsgP37h2S/R1fDdvVp4qw490JGDNQYGlIYncTg41QjGRtGf0mn+RetaFQPs6XSiMOUjV3rwpVSc105nwa76VgatUru0ziFO/p8+M6mzxyu8CiFd5XGal7SKiR+4Jy5gYUmH2hOTVAErrdLAFl1kUjU5nbgVLOnfKGccwZH/C2dgTsKIEx+0StanQbIZmkBSiPAGFR3N/qfNjV8KDvnTv+fxL7s+goNFROM6lWo+C77iugSzwqRE4glwrI1Eu0vdwppYuKVCFJ0OgyZ8Ghxs5BdJ+gNqiD8jitYtqRpGL281IU9LfYhyYMlgBvFGIJzwpraCml4TWuiWBVKoiMCP6LFPYcQnD8vEM95xIij/3LZM2XZt9EThfxhIkHLWV3BEcx44NsUT9TAdruRdmr5pHVuq5vxsJ/QaHGwxQPYQx35XsouIgICRiztfuKHPb+rgltf0x8VDRiZtv8OEY9XtvTj6b8o0+/ZJIHjSy+KlyRXkOrNZgoR9ERbZ4BGTqU7shGkrV3w2mFCFcQYjIdXMuNP0NRjhFTFQ41naie6YxdPFwQQ7rjnb9oA4ukZFbVe6zi6A9R0HUyBHSC9x0TFW+PtDo15/A8M7AVR+Fck6zbnZD5Q4joYDApfhadxgLkYPIbSL31sWdo/R4Ys//Rf6TTl5U41nAMWAXpqdLGpbPNu7Qjm8dKvwX+rscnhkl8942fFmG6VE3NzRxMs/JzEuDbZnM2qjBTN5EV89ulb3fKtE6W0PMhVPoMdw+jIZqrXjLVKYiFoL3fhEn9meLktzgqyP/E4HyMs0RW4gp6M8P9uamv6nXl5b/ah2imBlmT774rTfov8akwzUabYlUxrIrX3mdI9PJps5asgiua1HPdztUJ4Z4ExQ0s4F5f0aFGlpG1rCzxcRFooff4zaxKca9ZaISv+xJi6oTG0waBFB/egw9Io4pJXO9Ep2cxhJqIEywN68oVKElEqtOxD7t1NdVa/Lrf0PNBSS9fK0QQqzQ/KTKkpkvzOldCHS1FmcgiI8qfDvjgycHzn9s/1nt4etNKCfT29Ni4uS495RjvCNbRZTvIwuSmfewnCnfn48yge0obzPZc7IteY0oK7Bidaua1lXUs0LR79v9egHYa X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB8429.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-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kvpiMbuORPjAZSocGm5fBaXR9zzJHpFHnKeMEd/0+2KLev+iO1Lapayc3GgGmKdZkjg78U+irw7RoancOLOnJF63AZqBuwW9DvoFUBOLJ5MfS+Rpdo7qJgcekEvdoJxJnpu3Heoo8neFNXT6/Iiraw2FC8T3ROzvZI0C5c6w3jSn7hfUNL9iFzQf3YesQuj3YTgEGagnzXicWezUf4jEZFsatYy1g99Is8P4GCy33kEyuIcUusKImbtTT3BMKv5dLFeT9De1mF0BkMDcXQdgT3mjuTx24X+PA9bwhELSDFwuycoSmcqyeVJsRLnU9x+cRlhje/5GXpLog3eSiAKJDdv7PeFj5WK1Y+WOZrtW29FbkilZMTQBFZMpbu8tUpPUtV6VXu273vypNzews2FexnTN5NWMNMWHC+dunPPQpKdzng6/oRRE4wGq6YlZBEc3qemYt4ak/FRc8LVweAVrFSviZrkpJlg0WPMPzJ9F8KARTgKZTeI/g3/FyyDKrhHRU51DfKb1X/lkIYvtnuGUr6fCXsMy84l37nhs+oDKYfZZERthoL+boxb4H/16H X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d97641a-1753-4305-98f1-08dd2ef0188d X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB8429.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 07:51:29.9608 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Hq06h8LQdfKMPLCNRYm9zN5DmUljL3GxLmzjJ8ryFhZxTZzLJwrwbMfc0QOOdYYw7Rc+0FoSWgybvSAHy/v7aw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9137 Need to flush UART RX and TX FIFO when lpuart is shutting down to make sure restore a clean data transfer environment. Signed-off-by: Sherry Sun --- drivers/tty/serial/fsl_lpuart.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 7cb1e36fdaab..c91b9d9818cd 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1965,6 +1965,11 @@ static void lpuart32_shutdown(struct uart_port *port) UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE | UARTCTRL_SBK); lpuart32_write(port, temp, UARTCTRL); + /* flush Rx/Tx FIFO */ + temp = lpuart32_read(port, UARTFIFO); + temp |= UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH; + lpuart32_write(port, temp, UARTFIFO); + uart_port_unlock_irqrestore(port, flags); lpuart_dma_shutdown(sport);