Message ID | 20240304020712.238637-1-sherry.sun@nxp.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-89968-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp1172418dyc; Sun, 3 Mar 2024 18:01:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUbpXoSUPlqV7blipnNCOqkGa4iyxXtS8gkN5DGKTTKQ3YfvpmZ+Bw8MQ3G55EOVsiE0hA4SeCktPhxv7fUFbXafkrOUQ== X-Google-Smtp-Source: AGHT+IGJXWIk12UzqU0X4yB+Xv3PcSDO5TfkY4bBxjBx388ytWzz+a3xLWCiOwtjQ+uPEBkL0M20 X-Received: by 2002:a17:902:bcc7:b0:1dc:20f2:77bb with SMTP id o7-20020a170902bcc700b001dc20f277bbmr7493225pls.29.1709517681406; Sun, 03 Mar 2024 18:01:21 -0800 (PST) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q7-20020a170902eb8700b001dccdf670c4si7633292plg.403.2024.03.03.18.01.20 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 18:01:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89968-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=kj65FoHv; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-89968-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89968-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0E05BB20DF8 for <ouuuleilei@gmail.com>; Mon, 4 Mar 2024 02:00:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5325433F9; Mon, 4 Mar 2024 02:00:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="kj65FoHv" Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2048.outbound.protection.outlook.com [40.107.8.48]) (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 AEC3EA31; Mon, 4 Mar 2024 02:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709517607; cv=fail; b=sLz1qBIY5l45YR6iaTQEFFOqFGmvdOQwlcd6FQVqxpvzdL1N02jV9GQCuiT71/Fwi7Fzvzb10yo/WX8g3myeeys/26445TxwJYpWBvFwxh5kbWEeAi7AhLgI7aLdscUrv+8oglGfSHdC14hwrL3kfk5pv5LgYyzacfYHgqUhJSI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709517607; c=relaxed/simple; bh=AHzr6an/u/3D8jN/H2BTmKZk+tPXSHnpSodxSaXz640=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=TwC+RQHL/sjpTN9ZjH21itsBQsBbptTZJdzH/6nafSCbxeWtMSAzzll/9KfZqA+ai1UeLOhfNeoKHToRF4g6L8UalGNb75o/tFY0tCFOznZuPDlMCKyRWvXm1i/lYR5AtUhwN3rG/lTBQunIODg1ymo06168gWPK8EtFtDd+Kt8= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=kj65FoHv; arc=fail smtp.client-ip=40.107.8.48 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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pv1SGhKw2TpCv62vEZtH7xyTcfhYK1Wacr2Kk1nRRvhLnzneK4wh6Ih64RuSCPT181h/VDK4JDWzvCzC1t2hP2kcVYDma191+lw2AndqLHDr3HtihnhB4515hBp+kgbJneBzZA75e/T5GeOxiL3lfmYKsYPWVbCr9X4+kKPwC2tDcjSpBjZR/WP6Pq4ZOKuOBBSrBxo89k4pPqMSLNZyrHaTCC+QgaHuncDL09GQrkaxJFxABJ5gbXQZM+6B9M4Hmffa23Edz7nZYFB2V0KPMhJymtEV1BcD326KwyALTgtH59VmauR78Zayh53/lWMRXKLdtpX8cDWsqOS6v5cwMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=uBHquXc9OSoe7dBIVnlvVe4lm3iPG7yoZL5CfPxxCPs=; b=SBgPEKXM+UEB3AlWsf+ywMaB3LwnR+2vOELxrkYSjWtGy9XhBGR3AIYxxAdSKARBRyWkGRx3UaNWZ/MvZCP65vpNECG3VJkz/M1W7fByjhBXeA5Ft60tL5csspjk++m+o+R2XbEKV/cfDk0wWU/TS/33O9LpNgo5o/owRbZ13Jch9BcY2zUWFeqQbA8Dt04NFjmwJ/W9ePCmwo4k2d3pMbD61yD6nagdlO5gNOxe4sBdX75sI+wXSJpIRGxP0e9Rgx1Hs4UfNNyOEO0glIYTA+0MJjzU0s6bUwB8zh4utqW+0rVepAYJYn+N7zdbAv4bYu8de/81rK3lO45j+kJrBg== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uBHquXc9OSoe7dBIVnlvVe4lm3iPG7yoZL5CfPxxCPs=; b=kj65FoHvL451Eg+6YM9QpVDtxaookZJlEyLDC5iGs3wt1kMTlGlar7bgQvW/s1DKUbUa/GYKtKEwSp0QtUeZbxz/E5h3DCromovFeOorBI/UOHHXcH3plL34nAgkjRjS5xmIU7rmSM1WksYYqbSxcppFraI5nLzbbupcmW3KtxY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8404.eurprd04.prod.outlook.com (2603:10a6:20b:3f8::7) by DB8PR04MB6858.eurprd04.prod.outlook.com (2603:10a6:10:113::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Mon, 4 Mar 2024 02:00:02 +0000 Received: from AS8PR04MB8404.eurprd04.prod.outlook.com ([fe80::643f:faca:24da:e9aa]) by AS8PR04MB8404.eurprd04.prod.outlook.com ([fe80::643f:faca:24da:e9aa%5]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 02:00:02 +0000 From: Sherry Sun <sherry.sun@nxp.com> To: gregkh@linuxfoundation.org, jirislaby@kernel.org, u.kleine-koenig@pengutronix.de, ilpo.jarvinen@linux.intel.com, shenwei.wang@nxp.com, alexander.sverdlin@siemens.com, robert.hodaszi@digi.com, robh@kernel.org, tglx@linutronix.de Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, frank.li@nxp.com Subject: [PATCH] tty: serial: fsl_lpuart: avoid idle preamble pending if CTS is enabled Date: Mon, 4 Mar 2024 10:07:12 +0800 Message-Id: <20240304020712.238637-1-sherry.sun@nxp.com> X-Mailer: git-send-email 2.37.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI1PR02CA0024.apcprd02.prod.outlook.com (2603:1096:4:1f4::12) To AS8PR04MB8404.eurprd04.prod.outlook.com (2603:10a6:20b:3f8::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8404:EE_|DB8PR04MB6858:EE_ X-MS-Office365-Filtering-Correlation-Id: 96dbd8c9-8f96-4b92-1b52-08dc3beece05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oZ0d6wUYkIxqDLNJNVl9Lmtsl6NxxUj0YHvPPFgNs/WhWAXHhhuoVeOI999V3s714KlJdrr3Dd14J/R1e3gR+aKY5zTHh1KSKtXPVb8YwN7vmoFRf1o3rSWoBYSsHZF8+0RAIf0zJxmgZwRJMof48FTlPZEIXz6aPGi8xas0S74IS3clbAtyd0KAh23ENHDfFbhj7G9WP6T0fU8WwL/n5uk1oiZLXHO4YHe00806shhwwWZhK6k5hfMoo2yFs4P/5tVQO9voIoAkD9809+BNcyX/iPxa0qh9qcK8rsraCoRM+b1YND95cE3AE+SNJa2WwSsibdNCb5Y5wJvjmIeUGk9bL4hcp9P2h/Vop60PQ4NDS80UZw80LeH2lcuqSuU8CpaAJ/iXbhJxdo7yl9toYqm7lHA9IkOt/bTYvQ85Mg28eZRTP6k8Y0LPekdLqTLUasrxxHOuk4Hc4ZWuqEH75VlpCcK6V430LeT0Zf1+e1ySpknhALK2LZKk7N8RknHnhxSnXQ2Va9F6oaNWbHpIGqCHTdtnCU1Wpq2C1vn/onBVI13PVlZeqa1e2hnYzEZuzADTNUXHezQgZBQEQ0DMXjQya+oHBM1Sqbp6Z/N8kh5JHNXZppld8+FXOp5iccr4a6ihtWqfs9SmxrpDq7Tz9RESCDnH7sBQ/3ROZV/ck4HLzQweO8fITZqfpJeMo3fC2FMLWj/nqoPkmLa/r0kRCeF/9uC/DUXIqc7VDG4cqHU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8404.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?9mh20WzJpjpdTtMcxTPcQF5gb4Xb?= =?utf-8?q?+Egdrronx7/i1zjq6MOcpeUbd/voeToOv+k5K48BTHgW8sM2HRVjkY7l+mnQR7685?= =?utf-8?q?Wz5mUM+0YJteTilXxcn6NitpHtr8mzJ4zYH6xl17UwMQWrLggORxU0cB1SaNCRe1h?= =?utf-8?q?AjTILHMDUf17YjmdPqyDgawDcQEj1d1qqb0oxXsQUOQzZvG5swQxGAunI3tj/ZcjV?= =?utf-8?q?rmZ87BjVtSJi1oQI+snfH0+gzNtcIae+Fv0CCyvbmVONtZEdC+K3rdDkjx4q7NJFK?= =?utf-8?q?7FkAbkSH8HH1JcAdAaQPeZj8fYuNbzfD3LNeXjqA1wzZcEL0zSfWQZ101bP/LOqJN?= =?utf-8?q?AOFLlera2j6UQVgp3frZuToSTAiuesC8RqHhDWwATnb6ZhtMKAicNKH9RiDOpzqmL?= =?utf-8?q?DnT200bLGognti8ODV9Bf4mCDgmyNd7+Bv7Wok8P+Fj27YPdjhXjx0dsxX8lzQNFG?= =?utf-8?q?puLOxZ2oHwQ0jSPquGV2suG/WuFvhpmPTIPDgLv201Dm2n4bdqyWXEgGKbALAahbb?= =?utf-8?q?SRda7yz2s2QCscx1tcQe0CQbu7VoTj/ZGea1vMOnskwSfiYN+BstL02qS6c1BMEyD?= =?utf-8?q?fyZWSYLjWHmPQXD+GcvypYfXMvO3nwI8einDfjnxXfC7h4E7LBFU+oXvnxlGx78jg?= =?utf-8?q?kSCLDRDGihsbBeOgieAKgB8h8h8ttHURt2o9+nxt9C0g2xVkMJpMHqjfwPyU/FJ6e?= =?utf-8?q?ej8Jh1c27usVJE7uIifjs2QNNdBKmZVL3XRaQH389OZVOEfC6Dk6yPyLBfKzbggCZ?= =?utf-8?q?i0+KbvfiwfPhhB8DqqMStw/aXh3QUAwqNAesazIyDlKN4UtdvHNkwyuG1aEnTxUJT?= =?utf-8?q?FavmBS3sIWZYjSbVq6Lal/2P6NTTJXH5G37cCEJs3dwaoqSDzf4EHum47emV4vL9x?= =?utf-8?q?ubMfILWS65jfVf9orT1TM42cA68nDMZ4jCrVnvId4XtRlr+PtknBvkftUzkPqvMbG?= =?utf-8?q?TbFdS7v/H+hXluofosN/NnOYyfQyEPV1NIvEh6gF9P/YrfO6bYyO0jZTDg12H8ff1?= =?utf-8?q?4929jyeMQU3eZR4D9cfhz81pkhsks2jnQm1UsdVoY1juMkbxQNuYZCpR1sOxJ9j3o?= =?utf-8?q?/d5mmAljs85X5T3dcUSEhxP4XLzE4zoItV/OxylfwAVoULC62nNAnugWTBYezdOet?= =?utf-8?q?nDpAmeofgaf6E7Uox2q+9C6sVJckORm1+npYfDpqN08Wwa7snPY6JYAiWdyLDIuDI?= =?utf-8?q?4dcdCiEdyaVAEwrSnmd1ZZgww5+xFOBWNFgZMWgSR/FQW7wLVSWy0H+AZT6M5DcTJ?= =?utf-8?q?V/xgaNAxuHJGLfBaIklmVbweUsbu2g9gVUdj9dkNLu7vkemolV/1dNncvRlJpBNBk?= =?utf-8?q?mSMsx13FdTfcuT8aHca+FRSo3SsqtgQVrFR9LM4hNRq59GzNAPfK0ZdUpKHP2ZNXd?= =?utf-8?q?Kdl4ltJ4pyLfI+fXfVHBLJux17O0ceZ0+xYcN+2AQtE3dZA7ZUA8OO39HLPw8fxYG?= =?utf-8?q?GXALWUvuWqZg9whvn7S5n48y6puSoqXV8x2lEaQ18mW/Q2yPxAcRj1t12nONHUszU?= =?utf-8?q?s3zvMuVycgLs?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96dbd8c9-8f96-4b92-1b52-08dc3beece05 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8404.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 02:00:02.6159 (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: 9yhY2eat4y64uNU4k68ksNeBN6QTWjuRYg+VkOdl5sX4kvilHjDh9Rv4UotKraqG2rhLr6psoqkZ+4gFDo4zCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6858 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792559212292189496 X-GMAIL-MSGID: 1792559212292189496 |
Series |
tty: serial: fsl_lpuart: avoid idle preamble pending if CTS is enabled
|
|
Commit Message
Sherry Sun
March 4, 2024, 2:07 a.m. UTC
If the remote uart device is not connected or not enabled after booting
up, the CTS line is high by default. At this time, if we enable the flow
control when opening the device(for example, using “stty -F /dev/ttyLP4
crtscts” command), there will be a pending idle preamble(first writing 0
and then writing 1 to UARTCTRL_TE will queue an idle preamble) that
cannot be sent out, resulting in the uart port fail to close(waiting for
TX empty), so the user space stty will have to wait for a long time or
forever.
This is an LPUART IP bug(idle preamble has higher priority than CTS),
here add a workaround patch to enable TX CTS after enabling UARTCTRL_TE,
so that the idle preamble does not get stuck due to CTS is deasserted.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
drivers/tty/serial/fsl_lpuart.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Comments
Hi Sherry, thank you for the fix! On Mon, 2024-03-04 at 10:07 +0800, Sherry Sun wrote: > If the remote uart device is not connected or not enabled after booting > up, the CTS line is high by default. At this time, if we enable the flow > control when opening the device(for example, using “stty -F /dev/ttyLP4 > crtscts” command), there will be a pending idle preamble(first writing 0 > and then writing 1 to UARTCTRL_TE will queue an idle preamble) that > cannot be sent out, resulting in the uart port fail to close(waiting for > TX empty), so the user space stty will have to wait for a long time or > forever. > > This is an LPUART IP bug(idle preamble has higher priority than CTS), > here add a workaround patch to enable TX CTS after enabling UARTCTRL_TE, > so that the idle preamble does not get stuck due to CTS is deasserted. > > Signed-off-by: Sherry Sun <sherry.sun@nxp.com> > --- > drivers/tty/serial/fsl_lpuart.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c > index 5ddf110aedbe..dce1b5851de0 100644 > --- a/drivers/tty/serial/fsl_lpuart.c > +++ b/drivers/tty/serial/fsl_lpuart.c > @@ -2345,8 +2345,12 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios, > > lpuart32_write(&sport->port, bd, UARTBAUD); > lpuart32_serial_setbrg(sport, baud); > - lpuart32_write(&sport->port, modem, UARTMODIR); > + /* disable CTS before enabling UARTCTRL_TE to avoid pending idle preamble */ > + lpuart32_write(&sport->port, modem & ~UARTMODIR_TXCTSE, UARTMODIR); > lpuart32_write(&sport->port, ctrl, UARTCTRL); > + /* re-enable the CTS if needed */ > + lpuart32_write(&sport->port, modem, UARTMODIR); > + > /* restore control register */ The fix makes sense to me! I see only one issue with above comment, which commit 380c966c093e7 already have put quite sub-optimal (after the actual write), but your commit now shifts it even further making it completely dangling. Should it be before last UARTCTRL write? > > if ((ctrl & (UARTCTRL_PE | UARTCTRL_M)) == UARTCTRL_PE) -- Alexander Sverdlin Siemens AG www.siemens.com
> -----Original Message----- > From: Sverdlin, Alexander <alexander.sverdlin@siemens.com> > Sent: Monday, March 4, 2024 3:14 PM > To: u.kleine-koenig@pengutronix.de; Sherry Sun <sherry.sun@nxp.com>; > gregkh@linuxfoundation.org; ilpo.jarvinen@linux.intel.com; > robh@kernel.org; Shenwei Wang <shenwei.wang@nxp.com>; > tglx@linutronix.de; jirislaby@kernel.org; robert.hodaszi@digi.com > Cc: linux-serial@vger.kernel.org; imx@lists.linux.dev; linux- > kernel@vger.kernel.org; Frank Li <frank.li@nxp.com> > Subject: Re: [PATCH] tty: serial: fsl_lpuart: avoid idle preamble pending if CTS > is enabled > > Hi Sherry, > > thank you for the fix! > > On Mon, 2024-03-04 at 10:07 +0800, Sherry Sun wrote: > > If the remote uart device is not connected or not enabled after > > booting up, the CTS line is high by default. At this time, if we > > enable the flow control when opening the device(for example, using > > "stty -F /dev/ttyLP4 crtscts" command), there will be a pending idle > > preamble(first writing 0 and then writing 1 to UARTCTRL_TE will queue > > an idle preamble) that cannot be sent out, resulting in the uart port > > fail to close(waiting for TX empty), so the user space stty will have > > to wait for a long time or forever. > > > > This is an LPUART IP bug(idle preamble has higher priority than CTS), > > here add a workaround patch to enable TX CTS after enabling > > UARTCTRL_TE, so that the idle preamble does not get stuck due to CTS is > deasserted. > > > > Signed-off-by: Sherry Sun <sherry.sun@nxp.com> > > --- > > drivers/tty/serial/fsl_lpuart.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/tty/serial/fsl_lpuart.c > > b/drivers/tty/serial/fsl_lpuart.c index 5ddf110aedbe..dce1b5851de0 > > 100644 > > --- a/drivers/tty/serial/fsl_lpuart.c > > +++ b/drivers/tty/serial/fsl_lpuart.c > > @@ -2345,8 +2345,12 @@ lpuart32_set_termios(struct uart_port *port, > > struct ktermios *termios, > > > > lpuart32_write(&sport->port, bd, UARTBAUD); > > lpuart32_serial_setbrg(sport, baud); > > - lpuart32_write(&sport->port, modem, UARTMODIR); > > + /* disable CTS before enabling UARTCTRL_TE to avoid pending > > +idle preamble */ > > + lpuart32_write(&sport->port, modem & ~UARTMODIR_TXCTSE, > > +UARTMODIR); > > lpuart32_write(&sport->port, ctrl, UARTCTRL); > > + /* re-enable the CTS if needed */ > > + lpuart32_write(&sport->port, modem, UARTMODIR); > > + > > /* restore control register */ > > The fix makes sense to me! > I see only one issue with above comment, which commit 380c966c093e7 > already have put quite sub-optimal (after the actual write), but your commit > now shifts it even further making it completely dangling. > Should it be before last UARTCTRL write? Hi Alexander, good catch, I will move the "/* restore control register */" message to the appropriate place in V2. Thanks! Best Regards Sherry
Hi Sherry,
On Mon, Mar 4, 2024 at 4:32 AM Sherry Sun <sherry.sun@nxp.com> wrote:
> Hi Alexander, good catch, I will move the "/* restore control register */" message to the appropriate place in V2. Thanks!
Please add a Fixes tag in v2.
> -----Original Message----- > From: Fabio Estevam <festevam@gmail.com> > Sent: Monday, March 4, 2024 7:10 PM > To: Sherry Sun <sherry.sun@nxp.com> > Cc: Sverdlin, Alexander <alexander.sverdlin@siemens.com>; u.kleine- > koenig@pengutronix.de; gregkh@linuxfoundation.org; > ilpo.jarvinen@linux.intel.com; robh@kernel.org; Shenwei Wang > <shenwei.wang@nxp.com>; tglx@linutronix.de; jirislaby@kernel.org; > robert.hodaszi@digi.com; linux-serial@vger.kernel.org; imx@lists.linux.dev; > linux-kernel@vger.kernel.org; Frank Li <frank.li@nxp.com> > Subject: Re: [PATCH] tty: serial: fsl_lpuart: avoid idle preamble pending if CTS > is enabled > > Hi Sherry, > > On Mon, Mar 4, 2024 at 4:32 AM Sherry Sun <sherry.sun@nxp.com> wrote: > > > Hi Alexander, good catch, I will move the "/* restore control register */" > message to the appropriate place in V2. Thanks! > > Please add a Fixes tag in v2. Sure, will add, thanks! Best Regards Sherry
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 5ddf110aedbe..dce1b5851de0 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -2345,8 +2345,12 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios, lpuart32_write(&sport->port, bd, UARTBAUD); lpuart32_serial_setbrg(sport, baud); - lpuart32_write(&sport->port, modem, UARTMODIR); + /* disable CTS before enabling UARTCTRL_TE to avoid pending idle preamble */ + lpuart32_write(&sport->port, modem & ~UARTMODIR_TXCTSE, UARTMODIR); lpuart32_write(&sport->port, ctrl, UARTCTRL); + /* re-enable the CTS if needed */ + lpuart32_write(&sport->port, modem, UARTMODIR); + /* restore control register */ if ((ctrl & (UARTCTRL_PE | UARTCTRL_M)) == UARTCTRL_PE)