From patchwork Wed Feb 1 14:26:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13124439 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 1A973C636CD for ; Wed, 1 Feb 2023 14:38:23 +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:References:In-Reply-To: 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: List-Owner; bh=WBQzgB8vWvZ6LPJqwEe1yYfiNZYPrO9roGxyRk8Lmq4=; b=xiQ2uAyMp7y+v/ ZaNk4Ab1Kn1lZbEwqpK851nGRVfLwXK4RUxVgCe7sSSPcV6LhH9STXQJ7ouAfKMmf5dgvDMT8AZwM OYJZfKku8qUDb24EeubzHJ9ojZxD5IMMRWr8rMr0WrzKw6WTacJO1oJfct5HceEz6aYtpm7pfP7RX df+Pb9j/X8fB2Z47qK4PQ7xCvvmJ/5ZhyLXsW1qZKZWFSJqw9wiq5PBpTy+lPMA0z4tauKlRHz0B8 +OaMoPwd9ZAlIv8AUerhmaAspJRJ0aykZBnWKQcuUM0Z3FneWYwPcecqho5qlZ9C/kvIQR/PrJplv te5CyCz3WYPr65/WADlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNEEV-00CPpa-4f; Wed, 01 Feb 2023 14:37:08 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNE5N-00CLlG-UV for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 14:27:44 +0000 Received: by mail-ed1-x52f.google.com with SMTP id q19so7921035edd.2 for ; Wed, 01 Feb 2023 06:27:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fGRQXniAfmCVOhEPry8KBc9X4/FRyELFse0MGdO3NRc=; b=SGbmN2t4hYYb3e3VPWT+ES5NcVhUe3+2eOBFVLTN0GQflDQLSehKJBKsv2KfOvPbZY 0/UApKMQKKQqpT4Dt5lw8QwWQpE9rPUufUNuXIWDwyti17Av1wHlOCHKbcQY+dFGtok+ rBrYjErKtcv0Y9uhyZYZyYW+QSwa8woXH2QA2609DWTA1VUzclsqrxsTBhNN0RrhIxes eSdrqteqm/UA0wPwrnF5PlBLO/8neabvp1+Y8016vW/jkaV2VXYWm18z2VW3OG+p2WsI 1Gfll0Gn5YGGrPHqNLbUZAOSFWW7FSPCB8nfQ3EjuYVt268xbV0u1IVb0ur9MBKfigN1 +t5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fGRQXniAfmCVOhEPry8KBc9X4/FRyELFse0MGdO3NRc=; b=3aOjn+44LTWTFOg07KwOt0ttJb6vgBzPfCFbRyp+lHu2sL8ude5rkdSp3v35rF0Zss W/BH9Z/aDpRD9esD7ldM9xl79mE7JxG9wUIidwBM7RJAvrPiry8FydblFxy9ADn71iRp JTYrLyTgotY/w5vtVLZ2hwsnh6E4WulCIRiicoXucQL+Uc0lW5BbiQaGnqeT+l6IGC0l zOiA4r7tEIWeNSukiBY+lczjPPN2+rFRiRIKebRtfabq0eYUxfKlK2A5s/Z7eom0er8y LrpSlET9Eed6VkXdRMtHgsYJkHbwObTxdD/Jm+otz9KMdD50B8QuVhoxBrJTPw76zyUK 61Pw== X-Gm-Message-State: AO0yUKV6sIKs+k9EK6SOqGCvOMlyGUVZNgNBfR3es+H5rQ9ZWsd9ANv9 8RPQFuu4D74IscFaILurMPU= X-Google-Smtp-Source: AK7set9iXSdmW3yFrjlGJjCNUYuL6XEWMG+gPdLAsXKGT93ZsVy4zKEc/s9XpHhl7JmYtae67Hw6Ag== X-Received: by 2002:a05:6402:2c8:b0:4a3:43c1:8435 with SMTP id b8-20020a05640202c800b004a343c18435mr1923504edx.9.1675261658939; Wed, 01 Feb 2023 06:27:38 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id cf8-20020a0564020b8800b004a18f2ffb86sm8975564edb.79.2023.02.01.06.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 06:27:38 -0800 (PST) From: Sergey Organov To: Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, Fabio Estevam , Jiri Slaby , Richard Genoud , Sascha Hauer , Shawn Guo , Tim Harvey , =?utf-8?q?Tomasz_Mo=C5=84?= , =?utf-8?q?Uwe_Kle?= =?utf-8?q?ine-K=C3=B6nig?= , Johan Hovold , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Sherry Sun , Stefan Wahren , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Pengutronix Kernel Team , Sergey Organov Subject: [PATCH v1 1/7] serial: imx: factor-out common code to imx_uart_soft_reset() Date: Wed, 1 Feb 2023 17:26:54 +0300 Message-Id: <20230201142700.4346-2-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201142700.4346-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230201142700.4346-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_062742_032623_B6A8E5EE X-CRM114-Status: GOOD ( 16.03 ) 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 We perform soft reset in 2 places, slightly differently for no sufficient reasons, so move more generic variant to a function, and re-use the code. Out of 2 repeat counters, 10 and 100, select 10, as the code works at interrupts disabled, and in practice the reset happens immediately. Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 73 ++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 757825edb0cd..bf222d8568a9 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -397,6 +397,39 @@ static void start_hrtimer_ms(struct hrtimer *hrt, unsigned long msec) hrtimer_start(hrt, ms_to_ktime(msec), HRTIMER_MODE_REL); } +/* called with port.lock taken and irqs off */ +static void imx_uart_soft_reset(struct imx_port *sport) +{ + int i = 10; + u32 ucr2, ubir, ubmr, uts; + + /* + * According to the Reference Manual description of the UART SRST bit: + * + * "Reset the transmit and receive state machines, + * all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD + * and UTS[6-3]". + * + * We don't need to restore the old values from USR1, USR2, URXD and + * UTXD. UBRC is read only, so only save/restore the other three + * registers. + */ + ubir = imx_uart_readl(sport, UBIR); + ubmr = imx_uart_readl(sport, UBMR); + uts = imx_uart_readl(sport, IMX21_UTS); + + ucr2 = imx_uart_readl(sport, UCR2); + imx_uart_writel(sport, ucr2 & ~UCR2_SRST, UCR2); + + while (!(imx_uart_readl(sport, UCR2) & UCR2_SRST) && (--i > 0)) + udelay(1); + + /* Restore the registers */ + imx_uart_writel(sport, ubir, UBIR); + imx_uart_writel(sport, ubmr, UBMR); + imx_uart_writel(sport, uts, IMX21_UTS); +} + /* called with port.lock taken and irqs off */ static void imx_uart_start_rx(struct uart_port *port) { @@ -1398,7 +1431,7 @@ static void imx_uart_disable_dma(struct imx_port *sport) static int imx_uart_startup(struct uart_port *port) { struct imx_port *sport = (struct imx_port *)port; - int retval, i; + int retval; unsigned long flags; int dma_is_inited = 0; u32 ucr1, ucr2, ucr3, ucr4, uts; @@ -1430,15 +1463,9 @@ static int imx_uart_startup(struct uart_port *port) dma_is_inited = 1; spin_lock_irqsave(&sport->port.lock, flags); + /* Reset fifo's and state machines */ - i = 100; - - ucr2 = imx_uart_readl(sport, UCR2); - ucr2 &= ~UCR2_SRST; - imx_uart_writel(sport, ucr2, UCR2); - - while (!(imx_uart_readl(sport, UCR2) & UCR2_SRST) && (--i > 0)) - udelay(1); + imx_uart_soft_reset(sport); /* * Finally, clear and enable interrupts @@ -1593,8 +1620,6 @@ static void imx_uart_flush_buffer(struct uart_port *port) { struct imx_port *sport = (struct imx_port *)port; struct scatterlist *sgl = &sport->tx_sgl[0]; - u32 ucr2; - int i = 100, ubir, ubmr, uts; if (!sport->dma_chan_tx) return; @@ -1612,32 +1637,8 @@ static void imx_uart_flush_buffer(struct uart_port *port) sport->dma_is_txing = 0; } - /* - * According to the Reference Manual description of the UART SRST bit: - * - * "Reset the transmit and receive state machines, - * all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD - * and UTS[6-3]". - * - * We don't need to restore the old values from USR1, USR2, URXD and - * UTXD. UBRC is read only, so only save/restore the other three - * registers. - */ - ubir = imx_uart_readl(sport, UBIR); - ubmr = imx_uart_readl(sport, UBMR); - uts = imx_uart_readl(sport, IMX21_UTS); + imx_uart_soft_reset(sport); - ucr2 = imx_uart_readl(sport, UCR2); - ucr2 &= ~UCR2_SRST; - imx_uart_writel(sport, ucr2, UCR2); - - while (!(imx_uart_readl(sport, UCR2) & UCR2_SRST) && (--i > 0)) - udelay(1); - - /* Restore the registers */ - imx_uart_writel(sport, ubir, UBIR); - imx_uart_writel(sport, ubmr, UBMR); - imx_uart_writel(sport, uts, IMX21_UTS); } static void From patchwork Wed Feb 1 14:26:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13124457 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 B2575C636CD for ; Wed, 1 Feb 2023 14:41:18 +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:References:In-Reply-To: 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: List-Owner; bh=A7/D9vQ3E0iEvfjbPtp6IFD+Gx5xQaUuLqeOPitXB1w=; b=TUTl5IGyhYhC9I eKn962xIyXQKBx9ITTU6mOjgYgWjMmRxYusUg+Ls/zku80EdR7og/WYqzLf20mIrXE3rRDiNHASQu opBf3e+rQH4LjEz+Y/YhmuB9/nzHpFcBmoVcW/4AwUpV1vFg7Of52ij/zkUVf+f7wnw0+H8vagkaX 2GjTiATkN5iGKvXQ4btUWY9OAmHANfY6UmLzNTsl8ZWHNqMWw1r2JZNTjkw/fj6/+wJZeGFVzMIXF sUr70hqk+kG9p4Z889z1Jbh7v4GFFuTSeDBWAMbNFKZi3ME/GPtTc9+MWjQg/Hs0+6UwRN4QHMuJR aRAiRuv79MZEH99S28Wg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNEHL-00CR5n-Ay; Wed, 01 Feb 2023 14:40:03 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNE5Q-00CLm3-VK for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 14:27:47 +0000 Received: by mail-ed1-x532.google.com with SMTP id z11so17876702ede.1 for ; Wed, 01 Feb 2023 06:27:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vDEp4eKXdg/3wssI2Ou1QYWdbAeeL+58ez61t5CUM9E=; b=K1xsYdRkbxOW0gYgS8BKK9rscyZO9LYOWHC1AclbwYuUnU5VVnQNYiP9s8Qzv49dOt VZKhDGe92Pgad9UXE9+mTsO4tFSSB5C97yrnjv3d1BuEjq3dL8UZl4gRcVM/iNvjcmpe MaXYtmd1ceEMrb8Kl04RVgJ091/GwGf7bnMioZQx22Di8b9Zi65t1du7Vg3PpycUkoIb JUl+bHqsDwjTnsrAO7atQWMTon4HOkPOgshVxxRULQ3NaI4tHoVspB1SIjHSCUsfMgnV ou2nC65ChWg/s4wQWu1rqgcg/zp51B9RoQWyi51onq6BkTm0Ac8Znv6WVPX1WKi5uogY cQIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vDEp4eKXdg/3wssI2Ou1QYWdbAeeL+58ez61t5CUM9E=; b=qh4XyVEKVQAsMjWgG6YzMhLLkVaL5iTI8AJ5h87vnS0tf2EdqbvMrpQktctFUQht6d InbGVYfvGEzbusmN+Sci+geqKV/WgbQIAjqOsJW5JB1wR2wkOdAImW1XbGw8s4Z6ad5I SP5IvqVuxUtyBHRXm/+fAVUNrJZdfv5RWnRKN9sfl9EAk+On9BIzmITDiWRlOHoRr4AY MtBzXDh2hQUkj5mJXVADctZ0aVMw4E8CiJALUVlOD9DuLQnXmaynLSuxP24CgiDsiEZV HyvtXm1fOxeNoq5bHGT83SiNfSmaUeNRRMHajg6g34BNA+ZhmZ4uIThtWuEbxA1P6BWi A9vA== X-Gm-Message-State: AO0yUKWRpyJfzKVFdZ+bCpMgZVoG/IVJfE69aAF75ApshpOlsXIsmDO1 nPXKfVXcadMloHPjlEABG2s= X-Google-Smtp-Source: AK7set8MRay/4KmKUvccvdPoG83dTuDwt3q3ZbIm1GAwiPqy4nUgcodj++ljfSdIsLXuBfv8zZa4QQ== X-Received: by 2002:a05:6402:1950:b0:4a2:260f:3bbe with SMTP id f16-20020a056402195000b004a2260f3bbemr2606430edz.23.1675261660934; Wed, 01 Feb 2023 06:27:40 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id cf8-20020a0564020b8800b004a18f2ffb86sm8975564edb.79.2023.02.01.06.27.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 06:27:40 -0800 (PST) From: Sergey Organov To: Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, Fabio Estevam , Jiri Slaby , Richard Genoud , Sascha Hauer , Shawn Guo , Tim Harvey , =?utf-8?q?Tomasz_Mo=C5=84?= , =?utf-8?q?Uwe_Kle?= =?utf-8?q?ine-K=C3=B6nig?= , Johan Hovold , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Sherry Sun , Stefan Wahren , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Pengutronix Kernel Team , Sergey Organov Subject: [PATCH v1 2/7] serial: imx: work-around for hardware RX flood Date: Wed, 1 Feb 2023 17:26:55 +0300 Message-Id: <20230201142700.4346-3-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201142700.4346-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230201142700.4346-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_062745_059071_087F95A2 X-CRM114-Status: GOOD ( 32.33 ) 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 Check if hardware Rx flood is in progress, and issue soft reset to UART to stop the flood. A way to reproduce the flood (checked on iMX6SX) is: open iMX UART at 9600 8N1, and from external source send 0xf0 char at 115200 8N1. In about 90% of cases this starts a flood of "receiving" of 0xff characters by the iMX UART that is terminated by any activity on RxD line, or could be stopped by issuing soft reset to the UART (just stop/start of RX does not help). Note that in essence what we did here is sending isolated start bit about 2.4 times shorter than it is to be if issued on the UART configured baud rate. There was earlier attempt to fix similar issue in: 'commit b38cb7d25711 ("serial: imx: Disable new features of autobaud detection")', but apparently it only gets harder to reproduce the issue after that commit. Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 123 ++++++++++++++++++++++++++++++--------- 1 file changed, 95 insertions(+), 28 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index bf222d8568a9..e7fce31e460d 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -210,6 +210,9 @@ struct imx_port { struct mctrl_gpios *gpios; + /* counter to stop 0xff flood */ + int idle_counter; + /* shadow registers */ unsigned int ucr1; unsigned int ucr2; @@ -428,6 +431,8 @@ static void imx_uart_soft_reset(struct imx_port *sport) imx_uart_writel(sport, ubir, UBIR); imx_uart_writel(sport, ubmr, UBMR); imx_uart_writel(sport, uts, IMX21_UTS); + + sport->idle_counter = 0; } /* called with port.lock taken and irqs off */ @@ -834,15 +839,66 @@ static irqreturn_t imx_uart_txint(int irq, void *dev_id) return IRQ_HANDLED; } +/* Check if hardware Rx flood is in progress, and issue soft reset to stop it. + * This is to be called from Rx ISRs only when some bytes were actually + * received. + * + * A way to reproduce the flood (checked on iMX6SX) is: open iMX UART at 9600 + * 8N1, and from external source send 0xf0 char at 115200 8N1. In about 90% of + * cases this starts a flood of "receiving" of 0xff characters by the iMX6 UART + * that is terminated by any activity on RxD line, or could be stopped by + * issuing soft reset to the UART (just stop/start of RX does not help). Note + * that what we do here is sending isolated start bit about 2.4 times shorter + * than it is to be on UART configured baud rate. + */ +static void imx_uart_check_flood(struct imx_port *sport, u32 usr2) +{ + /* To detect hardware 0xff flood we monitor RxD line between RX + * interrupts to isolate "receiving" of char(s) with no activity + * on RxD line, that'd never happen on actual data transfers. + * + * We use USR2_WAKE bit to check for activity on RxD line, but we have a + * race here if we clear USR2_WAKE when receiving of a char is in + * progress, so we might get RX interrupt later with USR2_WAKE bit + * cleared. Note though that as we don't try to clear USR2_WAKE when we + * detected no activity, this race may hide actual activity only once. + * + * Yet another case where receive interrupt may occur without RxD + * activity is expiration of aging timer, so we consider this as well. + * + * We use 'idle_counter' to ensure that we got at least so many RX + * interrupts without any detected activity on RxD line. 2 cases + * described plus 1 to be on the safe side gives us a margin of 3, + * below. In practice I was not able to produce a false positive to + * induce soft reset at regular data transfers even using 1 as the + * margin, so 3 is actually very strong. + * + * We count interrupts, not chars in 'idle-counter' for simplicity. + */ + + if (usr2 & USR2_WAKE) { + imx_uart_writel(sport, USR2_WAKE, USR2); + sport->idle_counter = 0; + } else if (++sport->idle_counter > 3) { + dev_warn(sport->port.dev, "RX flood detected: soft reset."); + imx_uart_soft_reset(sport); /* also clears 'sport->idle_counter' */ + } +} + static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) { struct imx_port *sport = dev_id; unsigned int rx, flg, ignored = 0; struct tty_port *port = &sport->port.state->port; + u32 usr2; - while (imx_uart_readl(sport, USR2) & USR2_RDR) { - u32 usr2; + usr2 = imx_uart_readl(sport, USR2); + /* If we received something, check for 0xff flood */ + if (usr2 & USR2_RDR) + imx_uart_check_flood(sport, usr2); + + for ( ; usr2 & USR2_RDR; usr2 = imx_uart_readl(sport, USR2)) { flg = TTY_NORMAL; sport->port.icount.rx++; @@ -1180,55 +1236,64 @@ static void imx_uart_dma_rx_callback(void *data) status = dmaengine_tx_status(chan, sport->rx_cookie, &state); if (status == DMA_ERROR) { + spin_lock(&sport->port.lock); imx_uart_clear_rx_errors(sport); + spin_unlock(&sport->port.lock); return; } - if (!(sport->port.ignore_status_mask & URXD_DUMMY_READ)) { + /* + * The state-residue variable represents the empty space + * relative to the entire buffer. Taking this in consideration + * the head is always calculated base on the buffer total + * length - DMA transaction residue. The UART script from the + * SDMA firmware will jump to the next buffer descriptor, + * once a DMA transaction if finalized (IMX53 RM - A.4.1.2.4). + * Taking this in consideration the tail is always at the + * beginning of the buffer descriptor that contains the head. + */ - /* - * The state-residue variable represents the empty space - * relative to the entire buffer. Taking this in consideration - * the head is always calculated base on the buffer total - * length - DMA transaction residue. The UART script from the - * SDMA firmware will jump to the next buffer descriptor, - * once a DMA transaction if finalized (IMX53 RM - A.4.1.2.4). - * Taking this in consideration the tail is always at the - * beginning of the buffer descriptor that contains the head. - */ + /* Calculate the head */ + rx_ring->head = sg_dma_len(sgl) - state.residue; - /* Calculate the head */ - rx_ring->head = sg_dma_len(sgl) - state.residue; + /* Calculate the tail. */ + bd_size = sg_dma_len(sgl) / sport->rx_periods; + rx_ring->tail = ((rx_ring->head-1) / bd_size) * bd_size; - /* Calculate the tail. */ - bd_size = sg_dma_len(sgl) / sport->rx_periods; - rx_ring->tail = ((rx_ring->head-1) / bd_size) * bd_size; + if (rx_ring->head <= sg_dma_len(sgl) && + rx_ring->head > rx_ring->tail) { - if (rx_ring->head <= sg_dma_len(sgl) && - rx_ring->head > rx_ring->tail) { + /* Move data from tail to head */ + r_bytes = rx_ring->head - rx_ring->tail; - /* Move data from tail to head */ - r_bytes = rx_ring->head - rx_ring->tail; + /* If we received something, check for 0xff flood */ + if (r_bytes > 0) { + spin_lock(&sport->port.lock); + imx_uart_check_flood(sport, imx_uart_readl(sport, USR2)); + spin_unlock(&sport->port.lock); + } + + if (!(sport->port.ignore_status_mask & URXD_DUMMY_READ)) { /* CPU claims ownership of RX DMA buffer */ dma_sync_sg_for_cpu(sport->port.dev, sgl, 1, - DMA_FROM_DEVICE); + DMA_FROM_DEVICE); w_bytes = tty_insert_flip_string(port, - sport->rx_buf + rx_ring->tail, r_bytes); + sport->rx_buf + rx_ring->tail, r_bytes); /* UART retrieves ownership of RX DMA buffer */ dma_sync_sg_for_device(sport->port.dev, sgl, 1, - DMA_FROM_DEVICE); + DMA_FROM_DEVICE); if (w_bytes != r_bytes) sport->port.icount.buf_overrun++; sport->port.icount.rx += w_bytes; - } else { - WARN_ON(rx_ring->head > sg_dma_len(sgl)); - WARN_ON(rx_ring->head <= rx_ring->tail); } + } else { + WARN_ON(rx_ring->head > sg_dma_len(sgl)); + WARN_ON(rx_ring->head <= rx_ring->tail); } if (w_bytes) { @@ -1304,6 +1369,8 @@ static void imx_uart_clear_rx_errors(struct imx_port *sport) imx_uart_writel(sport, USR2_ORE, USR2); } + sport->idle_counter = 0; + } #define TXTL_DEFAULT 2 /* reset default */ From patchwork Wed Feb 1 14:26:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13124456 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 12E39C636CD for ; Wed, 1 Feb 2023 14:40:21 +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:References:In-Reply-To: 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: List-Owner; bh=6n+JkoIm03E/VgnR7OzzAvYNJ4ha+oGj9BoqY+nT3ds=; b=kXg9KekTQZvXky 0YzKYsIAkqqGwTn8avSHxxvPU5KIac/OTyjD9NVGa25vuDVNZ8XDiaDR4BBjeykNcl9A63ohrgD+/ kYbh0tmUUV0p/H5tjxMCl6bF+cPigbVW72NxCncZEzQLy0BRf3FA78xEXGMojQflXzQxRxnVfX8vh d7aBQZUe8be/ZVNxnH3w9XYwddvmf4WhKeMqryyGv0D294djPCE+aJy4lD/qyD8kGiEWb8zwNabRq 07S0Et2BxeqbB/PkepwgE5ctyz2vqw90FnKK2CCoTVY2pRVivJYKuznvAAT7j0JJpa89TB82M3JXD s3fy3/r4rQESxYPTZzIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNEGM-00CQgO-Le; Wed, 01 Feb 2023 14:39:04 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNE5P-00CLn5-Uc for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 14:27:45 +0000 Received: by mail-ed1-x52f.google.com with SMTP id x7so14626885edr.0 for ; Wed, 01 Feb 2023 06:27:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t9PFvNqNRiBtgoK1FQlt2dgZjVa65hIZ+MQtdwTOsMQ=; b=VuJERbKWYOkgt/D8s8FOfDHVNd9glpziOVsTG+1JjLTYT7jGJy1VkNDZTgK1e3AjMi uiTHC7h8eh40cm5Ey0iOSL2dpFDm/v98ZQMIex6y23PczBzbg88bVdaUZNd0WWg/0jOA JzycDx1+F+NmAh/FdYq0uN6t5s2s+R5IAZ0CchzXlf2wZRO593HSjQ8BJOyjxZ9HWs/i uQzPZWRRcgdGxyi/Z+02V/ktq/h+yh9NWIrVbclaJyzIOW5XSGww95ZnYMue7FOCrd9+ TUr+d6HsTGLjHygi10C1POXJ+GgaTvnL56wA9d+DVUKNX4J2/dVnsWp5U/y7xmxOeUQY vjTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t9PFvNqNRiBtgoK1FQlt2dgZjVa65hIZ+MQtdwTOsMQ=; b=m2+k40M5/FNsyg+Lwumh+wLyD+GR3aAyL4tjzyUigwguV1iyHDAbhmThJ10GGfb005 5apWEWMjqnJQIHLcO2G373DMp1bCuCdnCbjM5tgZEQOSLmp/vaVH5BjNm4AmJ6kpzITd 8JWKVuJjoKnFSWt4fz7Ov7xZLpvPVQMtUikO+WSPbH7G2m5vGJ0Auag+dy8kqkEwPxRL /Xy97JQNZMUApMTJLuan4qVOwnHUdmdIYhrqEUHNQhJg/mN3qS+8XN3ThRarCLwBH2y8 l+sjqIsxuvsZBnfNwQAZxZQXH9D1QMp/S5z/lSF72FhBcAk4Cox2QJ96qA9ObfFGYU33 igNg== X-Gm-Message-State: AO0yUKX4eT2BTskSjCDfev1NFu7ukpSptgGYML4mQFgZECWN+OUmJ4GD 33av0dU+xxcImdTKk+OD4vo= X-Google-Smtp-Source: AK7set9hYDxvOQi0xjHhLN/X3aYvdrUsus0F/Am0ploCUlkQQm6XutLDb+3FJsBgq+1sa7AWYzsHnw== X-Received: by 2002:a50:ccd3:0:b0:47a:e008:8662 with SMTP id b19-20020a50ccd3000000b0047ae0088662mr2526553edj.34.1675261662685; Wed, 01 Feb 2023 06:27:42 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id cf8-20020a0564020b8800b004a18f2ffb86sm8975564edb.79.2023.02.01.06.27.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 06:27:42 -0800 (PST) From: Sergey Organov To: Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, Fabio Estevam , Jiri Slaby , Richard Genoud , Sascha Hauer , Shawn Guo , Tim Harvey , =?utf-8?q?Tomasz_Mo=C5=84?= , =?utf-8?q?Uwe_Kle?= =?utf-8?q?ine-K=C3=B6nig?= , Johan Hovold , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Sherry Sun , Stefan Wahren , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Pengutronix Kernel Team , Sergey Organov Subject: [PATCH v1 3/7] serial: imx: do not sysrq broken chars Date: Wed, 1 Feb 2023 17:26:56 +0300 Message-Id: <20230201142700.4346-4-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201142700.4346-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230201142700.4346-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_062744_080212_BA52E2E0 X-CRM114-Status: GOOD ( 12.77 ) 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 Do not call uart_handle_sysrq_char() if we got any receive error along with the character, as we don't want random junk to be considered a sysrq. Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index e7fce31e460d..e709118fe85c 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -911,9 +911,6 @@ static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) continue; } - if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx)) - continue; - if (unlikely(rx & URXD_ERR)) { if (rx & URXD_BRK) sport->port.icount.brk++; @@ -942,6 +939,8 @@ static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) flg = TTY_OVERRUN; sport->port.sysrq = 0; + } else if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx)) { + continue; } if (sport->port.ignore_status_mask & URXD_DUMMY_READ) From patchwork Wed Feb 1 14:26:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13124458 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 3C4D9C05027 for ; Wed, 1 Feb 2023 14:42:11 +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:References:In-Reply-To: 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: List-Owner; bh=MiMjwe/1o6hPWbgxeB4MTI2il/ib9qMjadgk2KIIBWI=; b=Ork6rLqy8aRtKH ZoCjo1qTG9M/q6Vsvgd3BQZxylHDWox/dd4CbDCI15u3SVmKp1rWDmgL2LsHj0jLVwmJyGcijCbgw vUuNQGZRwtMm+1cqPPWk5Rm9TcvIn+tg0GLJK9rYmXOVhr6ySK+FMjStZAmtSkOkjrm81nXSMsrqJ psfiBoxxFERHsSB+aPVnwwyeIq0vDcTyEpKFIpRU6sxEpv/svIh8GzQX0VLHwpC0lDxZ5HX6sXpVT 7Us6N6UU8N7rSffPQvOjJ6svy8fGX6kGtawIHtfPxqdS4HJA+ZGR+eWbEF29eXrirNTqv642nlZdY jQ/KWdJx9dl2kSr9uPcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNEI9-00CRRK-Lw; Wed, 01 Feb 2023 14:40:55 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNE5R-00CLo7-QK for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 14:27:47 +0000 Received: by mail-ed1-x52b.google.com with SMTP id n6so15221250edo.9 for ; Wed, 01 Feb 2023 06:27:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WEm5A99uTG2c238a+JDBkz/mOTpdwi/bBFV9FIiWCUw=; b=hqqEqTK0vARzjhmqa9hC6bsI/43ShQLK8//yNN4LKLiy2WkIGvyXDYZ2m8GwRYhND9 bDzPhj4P3JTMuOHV7ReCUIXnc+k2DCtkuR5WATi1e7simYqn/scDIwWxlbFDqU4KBPXa eZE33vSPuG4gKrpDbQf+ma7fIakaRy+/RXJ2rEjomknemkaxN2HKc5nAxtz5XIpuaRfe puxzpZUI8J04cDtaG4LZIeabkjgsApoH4KDJtMnW1DwWjeFb9Hm/LTHGGmNzxV//ZyrK HMNT3e/PUk/YtM9L+ZlZ5mRx45dDZ0cIiRwiQFQ6YUfQTutjE7IRwN5dxXFb9HS44Xh/ L0pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WEm5A99uTG2c238a+JDBkz/mOTpdwi/bBFV9FIiWCUw=; b=o0M4+5rlukPQx1B4M5VuVxzhT1UWTUcQPYdWS4dkEpuzvb2/5L9KlUCS6NlBWwozYU x0yYTgnJFcVhzmw26U1Li+tO5i0CdWBJzv1mhroUQojBj0+JOC5bbKvK/3HtmMpL9yi4 HaT2yzAFvvtYvCrKOIwNNO/I/7hoCdPD7Z8pnJ9KQoLz7KDpDZ3r4etnZ4PNQ49LIHhK 4EqOqHwqIZKrxWnTFrNy8NKOWRv9rfBDfJxYnzHR7tCPqAGT4RbXyS13+H6Qe+M0qA8d /6tUyiGQYeq0ftKZYivD4dtckoO3AZtLpGdHW9oolGqm8CV+hl8iCdJAMiZU+482Rxp0 Wrzw== X-Gm-Message-State: AO0yUKVJdjPuYy3EbHWsanYJf29AnW1myXAFALJqFCLxqe+X8V/QEgMU rf7Gj305xODkx9keaaQLCdc= X-Google-Smtp-Source: AK7set8ws7NdcXePeM55LM4BT1j7mYwM+w20CWy2QWuufVGR25bLp8ZxOOgYCX5HpeGK6TKSRutHlA== X-Received: by 2002:aa7:de13:0:b0:499:d0e3:7745 with SMTP id h19-20020aa7de13000000b00499d0e37745mr2245544edv.14.1675261664352; Wed, 01 Feb 2023 06:27:44 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id cf8-20020a0564020b8800b004a18f2ffb86sm8975564edb.79.2023.02.01.06.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 06:27:43 -0800 (PST) From: Sergey Organov To: Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, Fabio Estevam , Jiri Slaby , Richard Genoud , Sascha Hauer , Shawn Guo , Tim Harvey , =?utf-8?q?Tomasz_Mo=C5=84?= , =?utf-8?q?Uwe_Kle?= =?utf-8?q?ine-K=C3=B6nig?= , Johan Hovold , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Sherry Sun , Stefan Wahren , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Pengutronix Kernel Team , Sergey Organov Subject: [PATCH v1 4/7] serial: imx: do not break from FIFO reading loop prematurely Date: Wed, 1 Feb 2023 17:26:57 +0300 Message-Id: <20230201142700.4346-5-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201142700.4346-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230201142700.4346-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_062745_947772_ECE6D001 X-CRM114-Status: GOOD ( 14.06 ) 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 There is no reason to prematurely break out of FIFO reading loop, and it might cause needless reenters into ISR, so keep reading until FIFO is empty. Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index e709118fe85c..797c441088a9 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -888,7 +888,7 @@ static void imx_uart_check_flood(struct imx_port *sport, u32 usr2) static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) { struct imx_port *sport = dev_id; - unsigned int rx, flg, ignored = 0; + unsigned int rx, flg; struct tty_port *port = &sport->port.state->port; u32 usr2; @@ -921,11 +921,8 @@ static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) if (rx & URXD_OVRRUN) sport->port.icount.overrun++; - if (rx & sport->port.ignore_status_mask) { - if (++ignored > 100) - goto out; + if (rx & sport->port.ignore_status_mask) continue; - } rx &= (sport->port.read_status_mask | 0xFF); @@ -944,13 +941,12 @@ static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) } if (sport->port.ignore_status_mask & URXD_DUMMY_READ) - goto out; + continue; if (tty_insert_flip_char(port, rx, flg) == 0) sport->port.icount.buf_overrun++; } -out: tty_flip_buffer_push(port); return IRQ_HANDLED; From patchwork Wed Feb 1 14:26:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13124459 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 E0D4DC636CD for ; Wed, 1 Feb 2023 14:43:11 +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:References:In-Reply-To: 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: List-Owner; bh=cfttro3fKjL3EtZ23jbiTctWXf35PbcbYykqMfp8r14=; b=Q0wQn5/ejcEG4f ROVNUMrsIzT6zumTG41ZNJ2N+nq9w2XOJcq40fEN4bI/c/e1BWaEftXdc/a9ezMSeUWkIuRyFJ3r4 hiF8JeV+kJirvOdrLdqVmCJfPI0v17DptsygaCiit82ECLL6GlejdkwV3lwcpkUFW7TA/oU7VhygJ elwQFYsBkO51A829PEC6gXpm2fwPchu5TjDBg/WZfNMbeNzCLxnCRCqD7RnPmfZI5V3emMlr5Uh8V FBOfaApaEuoH7vQVroXQPGU3U4zaVsw/1SnYVlwFNd2tXvqb16ssq85k1QkVVXcjFSBTBz2prkAX7 w9cpD5/zcpAENTjT96KQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNEJD-00CRvp-Hl; Wed, 01 Feb 2023 14:42:00 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNE5T-00CLop-Re for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 14:27:49 +0000 Received: by mail-ed1-x535.google.com with SMTP id fi26so17845151edb.7 for ; Wed, 01 Feb 2023 06:27:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vxyxFeq00JGhfZF3lbLUVUOmxZ61KQdQmUjeiwFbgw8=; b=TqxSdo+txye/hH+JqDPj5+BHdWVeRBNc0K8jgGttCeHsb3yXb7k+vU36AzeDltqy3v 9tebe7abB0jDHhCl/7e23/HfrTJI4COPeIxtOr5YPWXChODWdRRPYf0PYmNpipTyH7fL CgQSOYJTfF9CPoRmwvjw9GJqQQXYOcPZA6v+4Z0lsfQmeJV52awQRXWerMbk4kjxrEf2 y2GCmwKDqMkTBpD6ik89DmR0SiIBG1cOdivGzo3YmgAGmExSu1BJsNXONBUgdZQPj1W6 EWiSXk4x18qkxpUHuHC1dZGe2bqT+kvHIPi2SWRSVWh2dS2mkDonCAPpdKGLx0UXaAWY 7New== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vxyxFeq00JGhfZF3lbLUVUOmxZ61KQdQmUjeiwFbgw8=; b=yc9g+hXScfamfBQQgDxaKzIvZGutWSyRDIh6ExMasJKjOVJhScg6PRB5e0S/lWRQw0 CgQXUVHbYCGCtB/1vQ0YBeFdbjgLznFsfHrpdGJOAfBWHSwQRa6o1WU4NlPKgP2GBuLl Eekj3jB6lF//ADgvsXeOrqptnQ/lfXfqf1lq0VKuXH0dhHxEUoDOeAhchJusG0KfLb52 P6hEK5SSf7OX2YEAFfLBO05uzgalV4tIoA1M1M2ax33aSOCvLU4SItjr63Q+2pUig6Ds UT5Wdltzb+fc3ZdgEgvTed+X9uRio6jP5jnvhrsO8N2voLq+e18K+rkZzMQDEI0M06Mt U5iA== X-Gm-Message-State: AO0yUKUPiQgDY3rhgzr1hwjkk1OiGSp5fNKHoX1txUwfLyaf2OJ00bZ0 4T6HOf+cfjzeg+pSiWXXbgA= X-Google-Smtp-Source: AK7set/U/qA9uhgkckwtVXIcYK+eNjL8h6axhavdaN9OZUBKFGGYjKnPrkEhQ7UYDUf9udq8Ns6cYA== X-Received: by 2002:aa7:d0c6:0:b0:49b:4711:f4b4 with SMTP id u6-20020aa7d0c6000000b0049b4711f4b4mr2459599edo.0.1675261666145; Wed, 01 Feb 2023 06:27:46 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id cf8-20020a0564020b8800b004a18f2ffb86sm8975564edb.79.2023.02.01.06.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 06:27:45 -0800 (PST) From: Sergey Organov To: Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, Fabio Estevam , Jiri Slaby , Richard Genoud , Sascha Hauer , Shawn Guo , Tim Harvey , =?utf-8?q?Tomasz_Mo=C5=84?= , =?utf-8?q?Uwe_Kle?= =?utf-8?q?ine-K=C3=B6nig?= , Johan Hovold , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Sherry Sun , Stefan Wahren , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Pengutronix Kernel Team , Sergey Organov Subject: [PATCH v1 5/7] serial: imx: remove redundant USR2 read from FIFO reading loop Date: Wed, 1 Feb 2023 17:26:58 +0300 Message-Id: <20230201142700.4346-6-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201142700.4346-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230201142700.4346-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_062747_969373_43FA74CE X-CRM114-Status: GOOD ( 12.31 ) 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 There is no need to read USR2 twice at every loop iteration: get rid of the second read. Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 797c441088a9..af4349fe6970 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -904,7 +904,6 @@ static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) rx = imx_uart_readl(sport, URXD0); - usr2 = imx_uart_readl(sport, USR2); if (usr2 & USR2_BRCD) { imx_uart_writel(sport, USR2_BRCD, USR2); if (uart_handle_break(&sport->port)) From patchwork Wed Feb 1 14:26:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13124460 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 38003C05027 for ; Wed, 1 Feb 2023 14:43:54 +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:References:In-Reply-To: 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: List-Owner; bh=7V4wtxB86JijfW0vTmgc8vyeECFTkyBO92tUw/sdAKE=; b=wXPhi0/5Tlp8S9 hLiqDfpSryCxFKSiCUM2Neh4D+ZLR9KtU2n7mt7IGSY6GN0B+9N6GN24X9WOoLn7bZHgSCQuF3WAV JUfgKDezIhoheNC3JFr1+1Xl5ePu5x81bcj1VJvhxitKVan8T6dwrJvAXDF0QhchKPZuI48HM+YNX 1oYipZ5fQlytVOhfRyc6A8z5i3ajGJ3tVSN6vv+7ZJAamGK9ij2nfmO6yeLKpRbVjze5ejjmGBUlO z+lkgyHxIEnymTDK41U5QyBdLEwXLUQZC6Xxc/jg51ZnCqVr+OIMk3B6rFn5y5w+gnNdIlj5UY0Df RF/xj8G75RPFvAIg3xkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNEJq-00CSCo-Jb; Wed, 01 Feb 2023 14:42:39 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNE5V-00CLq3-Jj for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 14:27:51 +0000 Received: by mail-ed1-x52e.google.com with SMTP id v10so17849986edi.8 for ; Wed, 01 Feb 2023 06:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L5v/xKpmgx3IRd85qrBv3zwjvdUmTrkcJb9ZlFLMDeA=; b=DAPka0L/4I745c/qSKtgYk1wXpzL4moxASBPZFfPfq75oV0qTfjaY5x9Tjq2yLKzof 9fYKAsmN9k0Fu28gVIG26CnvnbN5z54z+r6oz//cPTtDMVEOS3BfzTiVwL01XNHicWV4 DZQxephCKADZIAC1Q9SxrKEAfSPvrBh9B2nakdG9VBvEBmRd57K2b+ZxN52HSbNy7jzT aGEtgbzC5XN2R/aO550nV1rLoUQiVvN9MMtxmFo7bzdT0gCE2CaCZIjNhte5mVq7BRRS sAJQNX1LkG1MKJv8q+g7yO5GvR3oqi09+nRxAFJYBhXLgCA/4LF5I/0WvLIDHIHTAwLH isbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L5v/xKpmgx3IRd85qrBv3zwjvdUmTrkcJb9ZlFLMDeA=; b=NWOmAM74TOtDXJIKaBFsQVqG8eC0Ja4/vT98rFJ0HnUniYF4pCHhCMdel/bjiTUr58 7bPlsoagDSo/WCj23UzvvxNL8J/lp5Qm7GfJrO6c1e4YWK/eZKI4XAJjAr3+s1MJm1tP 12zmtRmXMf3Ug2P52HOAAeLWTKtX/YD7yO5j70vMfIaht2UQtzDYj+I61VIIVgM7PIRm lCzmk2JN8lHONfy3aUHddP6ZSejofda9bd2ScfpQaX8Ehja5lVq5Jjlppw+Z2Xfhacuw PSIx3mbF3aDMdt8GYRxk3RrFQtYWM96vyg81uL94VRCGKwSsYuYSO6Z8OAClNphpiolo uyvg== X-Gm-Message-State: AO0yUKVZy7Oy5L7K4cGMzO9LMP7iCmO5s9QCJ4gRKM6OInxzfrZrOrfH nF6pDC1H/o2zSBOjDVCdTPo= X-Google-Smtp-Source: AK7set9QcDJuAnQSBUBYWr27mdVAgUyXyUxUF978MjptXVS6Ji9xpOjDJa2P1X5QD2PbSZYITR2dBw== X-Received: by 2002:a05:6402:882:b0:499:b48b:2c3 with SMTP id e2-20020a056402088200b00499b48b02c3mr2062287edy.25.1675261667832; Wed, 01 Feb 2023 06:27:47 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id cf8-20020a0564020b8800b004a18f2ffb86sm8975564edb.79.2023.02.01.06.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 06:27:47 -0800 (PST) From: Sergey Organov To: Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, Fabio Estevam , Jiri Slaby , Richard Genoud , Sascha Hauer , Shawn Guo , Tim Harvey , =?utf-8?q?Tomasz_Mo=C5=84?= , =?utf-8?q?Uwe_Kle?= =?utf-8?q?ine-K=C3=B6nig?= , Johan Hovold , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Sherry Sun , Stefan Wahren , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Pengutronix Kernel Team , Sergey Organov Subject: [PATCH v1 6/7] serial: imx: stop using USR2 in FIFO reading loop Date: Wed, 1 Feb 2023 17:26:59 +0300 Message-Id: <20230201142700.4346-7-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201142700.4346-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230201142700.4346-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_062749_752632_702D7FD3 X-CRM114-Status: GOOD ( 14.22 ) 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 The chip provides all the needed bits in the URXD0 register that we read anyway for data, so get rid of reading USR2 and use only URXD0 bits instead. Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index af4349fe6970..488d8119562e 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -892,27 +892,21 @@ static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) struct tty_port *port = &sport->port.state->port; u32 usr2; - usr2 = imx_uart_readl(sport, USR2); - /* If we received something, check for 0xff flood */ + usr2 = imx_uart_readl(sport, USR2); if (usr2 & USR2_RDR) imx_uart_check_flood(sport, usr2); - for ( ; usr2 & USR2_RDR; usr2 = imx_uart_readl(sport, USR2)) { + while ((rx = imx_uart_readl(sport, URXD0)) & URXD_CHARRDY) { flg = TTY_NORMAL; sport->port.icount.rx++; - rx = imx_uart_readl(sport, URXD0); - - if (usr2 & USR2_BRCD) { - imx_uart_writel(sport, USR2_BRCD, USR2); - if (uart_handle_break(&sport->port)) - continue; - } - if (unlikely(rx & URXD_ERR)) { - if (rx & URXD_BRK) + if (rx & URXD_BRK) { sport->port.icount.brk++; + if (uart_handle_break(&sport->port)) + continue; + } else if (rx & URXD_PRERR) sport->port.icount.parity++; else if (rx & URXD_FRMERR) From patchwork Wed Feb 1 14:27:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13124476 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 73820C636D7 for ; Wed, 1 Feb 2023 14:45:10 +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:References:In-Reply-To: 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: List-Owner; bh=OGvyD9sL77T6KiY9NU8Mz4xEMLiIUJ3nJaKDQS1z2JY=; b=yI3Phr+DmU5bXp MCq+6i7vydInAMoNyfUk/wD4kBal8x9dxpHDf8t7SZDJJEp5cbw5mbo9LLyc5nizZ3r5srga/rxQo EU39atLXIhsPc7ShPVGivK5Ii/bSnXmBmN2eliQKGgojz/noBHwlJyGQEi3Mzt35m8/YTIZocSaC6 b4bTkaXcVf7elvxS1x6l7pkwBIla/DNtkvyViQ2NiNxdz6fe3A01XzQH8Dy3LVNChvKeUXbPI64y3 1rWpZBJI38nsCmCVgVx4okKkiCpX2qKv6dpexJbswMP4U44WDqazUAvl1PaXbE3Wp4Yp/OdhAmbbC zq8TmEf5LGquzWIyo5Xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNEKw-00CSjn-B6; Wed, 01 Feb 2023 14:43:48 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNE5X-00CLr9-48 for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 14:27:53 +0000 Received: by mail-ed1-x52f.google.com with SMTP id v13so17828765eda.11 for ; Wed, 01 Feb 2023 06:27:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+fbiDWy8ZCeEEPo3XsRTUlzcMe3rsD7fkZwC6S0cFK0=; b=gAuVsJrYc7jh8ErBsEv3KC4ZC2oYJctZttWWSRj1FJ2yUsydorfPIcxfqxhbIpT+NM VJSNjFhzuhLo2iCXIi7JP/kh0sPKfPyNhxp1sLzCMpxDDUwxa1g6RoBiWpOfxmYEMUbk vI1ZbhbaGzTVCg5d2AYbxzQT6Lht/1pTHdceiMUoBc+/tEL6HzyozcGSM/9m37UR9aSn uPZx6Y6ve8uBCqK9loEjuNnqFTWU376VNeTQOrdvDp7xk67ltLLCH9OdKA/N4GUjzlmp RzmXlvs07ezYOghcZkzVgphJEiPqALOXtnVVN8SXtbvZyjnOFA+3dqltAwVIgr/rbMoc eDQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+fbiDWy8ZCeEEPo3XsRTUlzcMe3rsD7fkZwC6S0cFK0=; b=2be0X7hpOlJsOZcWENkys6inra8vMf/SnWv4zbRyMhukFoesBwgu/OIiELFuuZUdJL utF03HlILEOkFtMG26qBIEk4jYT2QsHaq0DrwAF2IZoFcfSovoo4n6x1dG3XZuM2SctG EumX5XEhapUT7gOct9wP8i2cGSbcREJA/WFZrP4GFtIrANQL8OV6MkZhymsqIv5T/YC/ YZXr3XZ/2PuwU07NJ0PZrMytrlqtsbHe1R0RxwzIGQEJ0cqi762URn188MG31E3uvhEx XqWS4VQUqN78XbQv53QefbMwhgLADDpY+r6KbnNol3nhEA4B4VeB661sH4OvXtgIfL8l Zn3g== X-Gm-Message-State: AO0yUKWJz3IJZP+iEg4eSmv1zyQXD3CtzZk+yyF0OAbLZAyzTEkhwgTO VbVT2GrKotsSY7i3hMc9eEA= X-Google-Smtp-Source: AK7set+Ldupr8odgypamg0BybQedrh29v5qHb8uwrB94NJrvfSbIEZzbyHzI9wwW8XEVlszcDIL6sg== X-Received: by 2002:a05:6402:1bcd:b0:472:9af1:163f with SMTP id ch13-20020a0564021bcd00b004729af1163fmr1833744edb.37.1675261669554; Wed, 01 Feb 2023 06:27:49 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id cf8-20020a0564020b8800b004a18f2ffb86sm8975564edb.79.2023.02.01.06.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 06:27:49 -0800 (PST) From: Sergey Organov To: Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, Fabio Estevam , Jiri Slaby , Richard Genoud , Sascha Hauer , Shawn Guo , Tim Harvey , =?utf-8?q?Tomasz_Mo=C5=84?= , =?utf-8?q?Uwe_Kle?= =?utf-8?q?ine-K=C3=B6nig?= , Johan Hovold , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Sherry Sun , Stefan Wahren , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Pengutronix Kernel Team , Sergey Organov Subject: [PATCH v1 7/7] serial: imx: refine local variables in rxint() Date: Wed, 1 Feb 2023 17:27:00 +0300 Message-Id: <20230201142700.4346-8-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201142700.4346-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230201142700.4346-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_062751_281933_38893026 X-CRM114-Status: GOOD ( 13.85 ) 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 The 'rx' is chip register, similar to 'usr2', so let it be of 'u32' type as well. Move 'flg' to be FIFO read loop local as it's not used outside. Signed-off-by: Sergey Organov --- drivers/tty/serial/imx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 488d8119562e..447b9060d9df 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -888,9 +888,8 @@ static void imx_uart_check_flood(struct imx_port *sport, u32 usr2) static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) { struct imx_port *sport = dev_id; - unsigned int rx, flg; struct tty_port *port = &sport->port.state->port; - u32 usr2; + u32 usr2, rx; /* If we received something, check for 0xff flood */ usr2 = imx_uart_readl(sport, USR2); @@ -898,7 +897,7 @@ static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) imx_uart_check_flood(sport, usr2); while ((rx = imx_uart_readl(sport, URXD0)) & URXD_CHARRDY) { - flg = TTY_NORMAL; + unsigned int flg = TTY_NORMAL; sport->port.icount.rx++; if (unlikely(rx & URXD_ERR)) {