From patchwork Mon Nov 20 13:22:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 13461327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 119D1C2BB3F for ; Mon, 20 Nov 2023 13:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=t58GSPtXUwE69myIrNRoxwBeMgq6ftVHlM2li/pRlEw=; b=A1NuOkG7IUiLZ+ 7tothnt8VW2oWIIC/ZroSMUkFxyrFd1mVcHw1rmCg21j8K+JpML9lNv1+Dz/ClBZ3IjIXUJ9q56Aq hzPmzLdPVlNnpAiA8e9ALIw5OIjwo8D2vcgYX6LKk8iOdHXxtjsMcttkCNJunm1mg9lxDgCBYrFFC efNClGIf7c8GjXlXT4cQ0Gu9eo3zZUmIaIe6HwtJS2GmZQ2R1sroX3VZnjjduyuQHAEnsNwbowieQ NIIe+0ngb2SbzHvkV8VHzvOBF9dtVenfOgCzRFuZlrKgyBYkWGzIIBUBl2mxmAH0owS2uNuHpIQxq 8Asmzsk1o4JuS5H9Wqlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r54Tu-00CATP-1M; Mon, 20 Nov 2023 13:38:30 +0000 Received: from mail-vi1eur02on20701.outbound.protection.outlook.com ([2a01:111:f400:fe16::701] helo=EUR02-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r54Tp-00CASq-16 for linux-arm-kernel@lists.infradead.org; Mon, 20 Nov 2023 13:38:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sd4OxwXx72ihTChxa3iagzAT/FYESLFSRmjqHZ7OhpDttnKZjJtW+gEvzRkDYvcniJ9HmQ+UgOJLIvgRczuozwgWWitBLk6wFcCTYZeM9yO+/Q9uvqEGkLtyoBFb9OieoYacEhCu2oaC/UDhw8Ne5axgMy5dOENe2PeSlkjYi/7bWU4HF+2IO+YWX5ydQ3RMuBu91Z0RAqv/uNzptoRfnVS+9FeHA7Fe8/0GNePoqtXXyDkd41o2fipWPAmas4rj2GRAy4FShfygt1C40db8QpiGhD3Po3/xc2/BrceR6CqfAWDBsz6QFwiQAMwcqY0+c7OG7mwMj9P/cUgGPQ3uuA== 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=DmzXDeBo+XDchVJ8hCo0/DZ8bunhflc21u3s4OEd9sI=; b=NLJixvZj+CS7Viwxr0p6DN0vRmZ8zoFoJYZalVBCk9ivfR/vrzeKKiTEARnMFc3UeYjJGwyev+LSMDZqRCDnEmtJ78qTUxXlKaZEUJX5BT8B/yVxOTN0EEB+i+iodlue8/GP++71IiFcOvBydcvUD/HJa6sthf/KOeFrQXSCbYQRKLTyLj35oifk+8MouBb1oZmB8cVDJyBRoq+k03HOIU+LuITjPpi5izxFmZHTKXrIO4MxD0766SNbxP3PHKIJ2KvF4drLPwwy/MIs8qFedCS6IyclvLFH0e9Nn6XeGpkRywI0Elax4MW4gxjHrXvtghADwPwErinNC6momM/zeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DmzXDeBo+XDchVJ8hCo0/DZ8bunhflc21u3s4OEd9sI=; b=GJbNa47V6+Tz0HXSJeseNYtc85w2XpfrFiWktQUdTugWwsX/mvNiqt2SmeQPHh1jnEhA5F+KeXvPEhC3L2MTJ9eJpX54fyQ0+DCMlKrOGGtClknr8HlXfQjCD6B6sap3QuX5tmwJ8nDro1uKbZWtW4ZkFmYc7y/EWgvjuUI+b8c= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=prevas.dk; Received: from DB9PR10MB7100.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:45a::14) by PAWPR10MB7176.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:2f2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.26; Mon, 20 Nov 2023 13:23:07 +0000 Received: from DB9PR10MB7100.EURPRD10.PROD.OUTLOOK.COM ([fe80::8bd9:31bc:d048:af15]) by DB9PR10MB7100.EURPRD10.PROD.OUTLOOK.COM ([fe80::8bd9:31bc:d048:af15%5]) with mapi id 15.20.7002.027; Mon, 20 Nov 2023 13:23:07 +0000 From: Rasmus Villemoes To: Greg Kroah-Hartman , Jiri Slaby , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: Rasmus Villemoes , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] serial: imx: also enable Transmit Complete interrupt in rs232 mode Date: Mon, 20 Nov 2023 14:22:56 +0100 Message-Id: <20231120132256.136625-1-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.40.1.1.g1c60b9335d X-ClientProxiedBy: MM0P280CA0040.SWEP280.PROD.OUTLOOK.COM (2603:10a6:190:b::11) To DB9PR10MB7100.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:45a::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR10MB7100:EE_|PAWPR10MB7176:EE_ X-MS-Office365-Filtering-Correlation-Id: 33395abe-c967-4072-2730-08dbe9cbd5b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mVuKI/OUadO5/7MxdZMQU8a5s9/kQB7899xO5/qZzSPA/pL3vGY/rL2yNezqXVnAx8bNxf6XL+VO00KY39lk9UOdCbhfkn+XsSx89dSlvhwCzRa0ZlJ1RNQQNrQiXTQ39WZ5W7Svj8/EqBthtoVnv0KVwchqUmpWHWFDO4srvDmRDZON/SCZ/iZiYPqJEBuYskAVW2rVXD00jP7b0xrAS6/AMCQ6zdogQT/ZLfbYpAWmgSief0USgolsI/WNvJDMEjXfv+rhGUG5GiMUwUwz+FFoZoJTydpBtyCH8o/7Hv63k+6+JBe7MREgIGMMY2u2MR1PsgS2JOhIsT0muhNrQj8l94naZwy/gI6XbD+hTrt+hI59uc/4789tilTeVSZ1VITWL3+09/wk18ssicc7ZlVB4DFVXD9wznqa+/7sxLnqhJccHGIhKg1/e8Oo7+Cjgp5f/aDh86R7ajFjPuszemHBUDquM8Gx9ub8eTvT6SRo0VN1/42Cxt7+xWfo4nd/dWXCpbRFviYSjlEw5YI7Jxfy2IuqH56Bv7EgbYkQl4PmBgv3dEt60Ibfn23Ej9StPotuTNeH3Nr1v/zte4v8yOaTgbkOaqUjCCw+zfKWTzp8CBkuxJ2/y/g5AHAx+g0d X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR10MB7100.EURPRD10.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(376002)(39850400004)(396003)(136003)(346002)(366004)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(41300700001)(44832011)(36756003)(5660300002)(7416002)(2906002)(86362001)(38350700005)(52116002)(6506007)(6512007)(26005)(2616005)(1076003)(83380400001)(6486002)(478600001)(6666004)(38100700002)(110136005)(66556008)(66946007)(4326008)(8976002)(66476007)(8676002)(8936002)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TE85S6ss8jTrHmrFfn6fNxsc7pHA/7eD4KDXAfVP7TK0+QxtR2onF/kE7PBjUI8PbKw0OcCOEO2KYgmkF2+T6pGHImMHsVjynqDir/ZzbU7ET7qEp5AcSFqCX59T5VPtBE2SBqQJwi/FG6iN7o+8CgSn2ABJZ067ID16QZsc9+mulIv1+jlYb0VS2OhUEH2TFIjUeeG2u8HhgQ9Sm/uEq1pVtPV4ROZ7/uy3nNlbHBs8CBv9Y/x/fT1S9ELC/Xp+agu225R9vR5Hxr5IoqROOtUkrzHhZ0CAc2MfzusadrySiw3AVtnGe0QJOvp5DveDARMAju9D+ohr64po+KspLlSH15uliTsb2qCfetUmMaduJDnTZn3+glcjUGVtOkTE2zypf2B8Ho/IG7NpCqPjrL9asJflQWnvvyIFWeKHJzfaXoiSFz/npo9ldsx/VlPfWcpmShKoEfw1aKgiHgrBMC7OapocByzoySiVbhW3I1ioV98dZXDNq6+8cXaC3RcF3xKqHfI56xiueY+N3lDTwMhY3W+TJYtqUb3ZQUCz8WG9VunDi6mFmYyC6Smi/OHyQlNbLQcsX2RYnblhv66LScqdvjXJ14vapIq9B2CAe2c+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2730-08dbe9cbd5b2 X-MS-Exchange-CrossTenant-AuthSource: DB9PR10MB7100.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2023 13:23:07.7447 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nZfvnRJffkL2+1hoWQpjQaoIau6G8iPWhIotiAX6r7Je/shog72LftUW/UJoDp8YpMEtrHS3VJgIeZOKGG9CxNcqFW2Fw5/TxVN8YIxKLDA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR10MB7176 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231120_053825_452987_C9ECA3EF X-CRM114-Status: GOOD ( 15.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently, if one switches to rs232 mode, writes something to the device, and then switches to rs485 mode, the imx_port's ->tx_state is left as SEND. This then prevents a subsequent write in rs485 mode from properly asserting the rts pin (i.e. enabling the transceiver), because imx_uart_start_rx() does not enter the "if (sport->tx_state == OFF)" branch. Hence nothing is actually transmitted. The problem is that in rs232 mode, ->tx_state never gets set to OFF, due to usr2 = imx_uart_readl(sport, USR2); if (!(usr2 & USR2_TXDC)) { /* The shifter is still busy, so retry once TC triggers */ return; } in imx_uart_stop_tx(), and TC never triggers because the Transmit Complete interrupt is not enabled for rs232. Signed-off-by: Rasmus Villemoes --- I'm not sure this is the best fix. At first I considered doing something much more targeted, but definitely also more hacky: In imx_uart_rs485_config(), if switching on rs485 mode, simply add "sport->tx_state = OFF;". If someone has a better suggestion, I'm all ears. drivers/tty/serial/imx.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 7341d060f85c..ffee157e13cd 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -708,25 +708,19 @@ static void imx_uart_start_tx(struct uart_port *port) || sport->tx_state == WAIT_AFTER_RTS) { hrtimer_try_to_cancel(&sport->trigger_stop_tx); - - /* - * Enable transmitter and shifter empty irq only if DMA - * is off. In the DMA case this is done in the - * tx-callback. - */ - if (!sport->dma_is_enabled) { - u32 ucr4 = imx_uart_readl(sport, UCR4); - ucr4 |= UCR4_TCEN; - imx_uart_writel(sport, ucr4, UCR4); - } - - sport->tx_state = SEND; } - } else { - sport->tx_state = SEND; } + sport->tx_state = SEND; + + /* + * Enable transmitter and shifter empty irq only if DMA is + * off. In the DMA case this is done in the tx-callback. + */ if (!sport->dma_is_enabled) { + u32 ucr4 = imx_uart_readl(sport, UCR4); + ucr4 |= UCR4_TCEN; + imx_uart_writel(sport, ucr4, UCR4); ucr1 = imx_uart_readl(sport, UCR1); imx_uart_writel(sport, ucr1 | UCR1_TRDYEN, UCR1); }