From patchwork Sat Jan 21 15:36:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13111149 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 25DE0C004D4 for ; Sat, 21 Jan 2023 15:38:07 +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=QAAl1uJWq/PvUk ZXzTVM8NbFz2QwCjiWR9o90HFY7p3gwnMpd4hQf6OPPZRjuzNrcMUB1xL2HMQJOXxch0WG/+p91GN Suv14NkoIQDf1mX6CAOwMzpAyOmzhuYZu+QcwmATRBsnCF69vEi6dn0Hg9SShWhUqqtc9CIGEhUzQ ldJWiOHYFWwBSkNBur1jypNMDrqIlIJtjqsBInlLQaGo7XVFF9TTlNQLPd17gpN1dtVm/nV8VumWy tud/wl1WASsSaWv8knlOYkgimn8Ayhq33bIzY11hJkOs4bLIKaGTo7YHHLhUbAOPd6GKfzvsXw7I6 WfpFEO1eTXwbswsEzYlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFvY-00E44r-MV; Sat, 21 Jan 2023 15:37:08 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFvL-00E3zb-0Z for linux-arm-kernel@lists.infradead.org; Sat, 21 Jan 2023 15:36:56 +0000 Received: by mail-ej1-x62c.google.com with SMTP id ss4so20761910ejb.11 for ; Sat, 21 Jan 2023 07:36:53 -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=Mt91O6wsHDuq9PZCKox9+WJFhgaeFmwcOWWLL/2N5ObZAjE6d+mUtPcre6xI0qeZ1p xAGWfUqn3Udu0VA5eFYCZUyV7Qj+nlNrkRgtNbcai4vq5AdxIuNZ2lOUtDMynwzaqZgW 7TsJnh4kg87opmBIzWtd8mzppl7aNW3YljRDTAY/h6zlff8vhiXopClVfSdEKcQMz98D 3VMTGsP4So01okN5M47ol8DM3F5en9qQs7dglNXQUSI6hHXK7SG1/aEF8v+T2Dj7Cnd9 /vZThwN6tTTyo6pYIuCMuoHzRA3Xc9XePRfRCE7s+AfPlHUzm+PFWmhbOw+qXAvjkNEd DR2w== 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=psEuoE6AuQYj+Sle77bVraELp5NXv57VZcJBzTdjInyTQjS67mJcGbxjlvBxQIjYdT BqWQbpzT8muO9Y6zbVMd7WqH8vbrnefOzbU2xsoYQK2SEhgycPgplYgtNv5gNk+idNtA lKPK8449lM9GJ6UHDgPnIxSMALpLS6oHj84hvLftwDCPlVWb9TEgfPXZ5318S06XZgCc i1058+fAhV0RbkKxM+AMMRQ+Ipc73hUAKw+n+cHo1BX4p4kXY3ybjwjMnjGgHFOaijqx l8qia3yKIyWzMd1GvdjxypEKTPJDpPXUt8dW2hW7aoHEjCXm9Z0HICs66YKQiQuGb5yi uvxg== X-Gm-Message-State: AFqh2kpf2xz6/wdAZwUU3t5JDS8YPIueUoUvJBcqtr6nt+KI9dQYqb4K o+GcGHrQf1VASGq8+OotK8E= X-Google-Smtp-Source: AMrXdXtubvnAryt3g7C8rOL6o559ps+y9uy/MSBM/mlbKGyY45wWmLQCWCYT6SvaX414gJFU/TGHNg== X-Received: by 2002:a17:906:3616:b0:870:e329:5f2e with SMTP id q22-20020a170906361600b00870e3295f2emr19580340ejb.20.1674315412643; Sat, 21 Jan 2023 07:36:52 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id vc10-20020a170907d08a00b008717a377125sm8187030ejc.85.2023.01.21.07.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 07:36:52 -0800 (PST) From: Sergey Organov To: linux-serial@vger.kernel.org Cc: Fabio Estevam , Greg Kroah-Hartman , 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 , 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: Sat, 21 Jan 2023 18:36:33 +0300 Message-Id: <20230121153639.15402-2-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230121153639.15402-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230121153639.15402-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230121_073655_096578_BA5DE963 X-CRM114-Status: GOOD ( 14.89 ) 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 Sat Jan 21 15:36:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13111158 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 6BA03C25B50 for ; Sat, 21 Jan 2023 15:38:34 +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=J9xwF4d52BHocV pCeaAgVYVxxvxc8ErXMzlTRrFMDal0cLnlmU5biMXU0Vw9ISeJQPcOUL3ACLKSxEPION+mg1sa31i fSLPiF2iZPNOZ6cqJxHU1z1LaFRAXJs0mSL/7LbSrgffZspgMMGSpNvtoQUbSbLiT4gcRNo8x34cK ac9/s3bq8wWLru/8NQKOPkxL5Hu0XgSgdZ92ZDT7wYIm4P0tGqRwN3SNH6n2/Bb6IvZLd/zVRURg8 S5Yss4OMJVbD0F6cSnN6n0BCkBuVxOryEO5heFSXblP0blDJjY6b2OXqiZrOatBIMnTloRQvd4wgx R7Rm8fWid2bocDMr7ZQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFw1-00E4E2-DT; Sat, 21 Jan 2023 15:37:37 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFvM-00E40N-NG for linux-arm-kernel@lists.infradead.org; Sat, 21 Jan 2023 15:36:58 +0000 Received: by mail-ed1-x529.google.com with SMTP id y19so9974676edc.2 for ; Sat, 21 Jan 2023 07:36:55 -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=JQG3/QBq3Cu5aXSi75iJ529tcqRVrA08Kk09q8GDWwzYETH4PulFr8xpk+C1UeZP7t UrLrjn+b7SLfG9Si2udGHx+ijp1qO+PKXlkLon+qSFg44WBbLgoXTElPm2FOMoAVAAyu Pdq2KPJuJWMzkSCqYIAHt8xJDDDlOI6UBGWDd7wkns1kWRUU4y9c4XHHIk/wO6vIi7M9 p/7coFP0GDE3ReSCIVhITHoKgwE4pjSKg7at8tnhGnV7tpYNkzx5Kev1CkxFwlB1cGGg DHiHBE5S1ljG9DXKG8Vkkrbj7Gjk8FDQZY6MZESqoIIusZzblTgCtCkD8lJtKpVed2+T zhaw== 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=IHpUMIgIO3Lfw7f2UlcKLfbD4M/axiMwiNFTqlg1UsWxZRt0RyMfDU0c35+vlKiG4a 2sYcYFhUE3eVIzDDF70gf9eM9Zk1DwBiaNNFWvkd4k0GXhC2nNphJHgMVxDhr1LWC2zu YZ6x8MxVUN0jvFiGchoqG8Bw6XANGAEEliv2s9VIEh+jbrvaUAqEAehTBTcVBOB25edc PmartyBY7n2hN4uXNka6ucYMn+LTrJR6Vg9WULdFhxBxvax+CegLy9rKpvBOIKQx/Hkb g2V0ae8NgKYSWNKV5K6gwFBNitGX2G876i7B+b9blHpjF7fhuxQTCdD0Yh/51Melkk8T cM3A== X-Gm-Message-State: AFqh2koODZ9CBSZjLKPDIvXD9or0mHX/gyC5PJh4VTdV5yQrLyJ4QM24 ElbWs525cjaqoHpD34U+HF0= X-Google-Smtp-Source: AMrXdXvev1KC2/5QAYjPE4iBLwVSwtQqr3XKO+MlwcpsnrdjI3d6g33FMjpjdhYdk9I380ElvaGeAw== X-Received: by 2002:a05:6402:40a:b0:499:1ed2:6456 with SMTP id q10-20020a056402040a00b004991ed26456mr19191580edv.22.1674315414273; Sat, 21 Jan 2023 07:36:54 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id vc10-20020a170907d08a00b008717a377125sm8187030ejc.85.2023.01.21.07.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 07:36:53 -0800 (PST) From: Sergey Organov To: linux-serial@vger.kernel.org Cc: Fabio Estevam , Greg Kroah-Hartman , 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 , 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: Sat, 21 Jan 2023 18:36:34 +0300 Message-Id: <20230121153639.15402-3-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230121153639.15402-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230121153639.15402-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230121_073656_862664_4895E7A3 X-CRM114-Status: GOOD ( 31.26 ) 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 Sat Jan 21 15:36:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13111150 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 A75A3C004D4 for ; Sat, 21 Jan 2023 15:38:19 +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=teqPU1Kk672EZ+ BwaFcmDiX1Fy3/Y+A4SrQK0GRRTv6uw97Y6HnasVKxwqHEEbLYC0Aa7MZizmfElfwklN983zgwqA2 XUslcmXuuAWbk1o3km6Wdcl5GvW5BCyaWE722Msiw+h2N5QU6T7u7X2Uq4QMvJAqp4Ur31joIOUQN ULu6zMyschGQ3wsmTxEPE35vqHJp3ORhs9MzcoFoJ0u1yAgPF9NBbhg51R8hx2PQqa9Tc/j0AJJWd vopBmp+ogpMwiDF3+6pVOWFir7mdR8AQBO6821lFmpcQ7lH1tK1LFhJBwJudmlTIcy6cs74I3Ia/q /DYp4pgmhkZ7Y0i2r0ag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFvl-00E48s-4Z; Sat, 21 Jan 2023 15:37:21 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFvN-00E419-8j for linux-arm-kernel@lists.infradead.org; Sat, 21 Jan 2023 15:36:58 +0000 Received: by mail-ej1-x62c.google.com with SMTP id mp20so20795381ejc.7 for ; Sat, 21 Jan 2023 07:36:57 -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=QEjQ5FTQ1p1l7Cd4SDXPKJZ6sDaKO4pSMir4BAS6hvoSdAFJ0cS+qBajfbwJV2pTJO x2WivqetX72P82ztk/8BSNaqx/ZIMtwfufirIk+npl3/cZ8qUhMakCz94H1xBr/3WHxh ywOmBlRnzvzzAP8cTsedv1lwu0D4+7aE74grKArkKVJ+WIeykONRA4PRV9/ucaH3FIYA LKA0BxbFTXdRw785gtB1QIJ/DUO6JseDP+AXJDDPl7HIx8xK5E3MxQEVEZJp0Lev81sl IJcbkwi+HZW2xqNRDkhDwV452ClQoPHLJKYRFMy1rg93qxkbztTQSFp0g2diIisN/LBz YhYQ== 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=K/D6gOOoufVr12L+nXdtDBl9i83JvnFK2IOX1C1SWbNmIAZ5BqMqVf1Jc9pnlspPBI COmAJar6No4hN3B4YBqlA6Ab+oxdUWhDx45g2EViWUjNvx1/OD1H1HvCQ9rpmnZNvJ71 ZQ+2iVMUPzVzuy+BoSCF88SZOxAYM43z8HPlymd2648uaneokAK/kHieqKjiUySdmEvl 26w0/emvR1JuGGX/A7/Zc5fsTX/UO0VGLJij0p8hFzjFULsGAtVrQyjIBQkoFlYvmPq/ ustk9Nx5xRiICNIEfudoKW7OXjezOVFwXJOhnbS83fhPmujzfgsYdIClZqFSnCVNieLl aajg== X-Gm-Message-State: AFqh2kpGw/c7P79SwARBT233c2Kpa05hUTVbtQ0CC8zpnOUN83adB/q4 o0CflFYRBJZxB/mWGq/xEdI= X-Google-Smtp-Source: AMrXdXu8317LXKt67uugrjyibQpv8a3lJd/ELRzxu3nTo8TdR5m3rzZ6aUVDkVcdqpY+V2cnlpMPjQ== X-Received: by 2002:a17:906:2612:b0:83f:384f:ea23 with SMTP id h18-20020a170906261200b0083f384fea23mr19222886ejc.57.1674315415953; Sat, 21 Jan 2023 07:36:55 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id vc10-20020a170907d08a00b008717a377125sm8187030ejc.85.2023.01.21.07.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 07:36:55 -0800 (PST) From: Sergey Organov To: linux-serial@vger.kernel.org Cc: Fabio Estevam , Greg Kroah-Hartman , 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 , 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: Sat, 21 Jan 2023 18:36:35 +0300 Message-Id: <20230121153639.15402-4-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230121153639.15402-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230121153639.15402-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230121_073657_389584_1240C453 X-CRM114-Status: GOOD ( 11.81 ) 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 Sat Jan 21 15:36:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13111159 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 2604CC004D4 for ; Sat, 21 Jan 2023 15:39:05 +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=ouy8pgSoPg7rHD dqeZHX9KC+8VHsnGMQdIu4ujvS+ygdoJYH0xolzgTm8NncpR5EqhTfY6GFqVdLd3kDEPMyrJAkUf7 8ywAokZ4Vp/snXvNp+y5cN9Td7BIxl7Wd2xnDOZTiZ/F5ywtr4bNmhNmru5cFN5TLtuwiUThMTYCp vQ3EV2AenpySbzQoLTq04K4tQJqxd4dZBGa4433tnuC7xU5UhlJQBmr2dN6FGpyqqZWuYXQrAw8NM NfkJhQ259TXO8qxAZFWFPSVqN5nbyI9XEQOmglIkjSbvbDqwixzbL42neXkL0IUE15IzBQ5YhQdMj bNzhA98cS9Naf/t11UAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFwP-00E4Mo-Cw; Sat, 21 Jan 2023 15:38:01 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFvP-00E41r-5W for linux-arm-kernel@lists.infradead.org; Sat, 21 Jan 2023 15:37:00 +0000 Received: by mail-ej1-x62a.google.com with SMTP id hw16so20766318ejc.10 for ; Sat, 21 Jan 2023 07:36:58 -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=hKOanOB+Jp4twUTrfXiXV8T4xU7zos4v0oiBi0NKbLmvUTU+eLWrdQvXmBhVaVndRP VMVuYgvl43SPxyS042yXS1SrdssVRlpWla7n1BLoDIGOeVeoaEnMG3VqLsUzOMHyJ7Uv hTBVuIdBBVN30aMgO3Pejg7iQ+Mo6jnmPm3SQtgKg1hJK4i1WNqQZQK/FuXjR5uIfCuw zCjSW4OTXKoTx5DKqGUzNA8Dh7YAIxlPH+UBSyfPUn4V13t/uf7+vp5REfGqWc4JOzGX lX7HTkdrO3ACsF9yAGxTZlED4Qe1cEwr1LSl6s8g8vj9dhSzj5p405tjEW4u+MtlMPxC k9Kw== 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=uOvB7cBkYWTQDjMgzF4o9I6i/25ryv+lDJ4AGUq/fIij6YqlX9GNyM+V/BCg4BOQl0 v9gvZfuRy59FljjkwKQxhuNSbGWtm1ItHNCE/IQ0wruCYK2F5aheH5wPuukhIAyU+wnU r+WS84uI5f3tCj6UNqNFQBCBsqHdnRsTAV3Rn+wzCkGxt1alzEG4O6EXSwqvtV7jI3qu Cvb7//I+By4BAGrbmadYtJGRRVOa3Kx/Kt6n9GrpRTFm5lVstgAaY+s7gwVWZ7mWkRnf tV9IBx0f5DuN5dGneRtgHVZm24PN25fp74WbjuZ9XsYttW9zM8e3SDnn5O2k0IkBK83H f1eA== X-Gm-Message-State: AFqh2koyu3pEYJc2L+TEhlnV+Q6SlhCOOcwkov1w2RDowQDRO4k7pxH8 TqRcVWwmlTV/pbO0OQOAUXA= X-Google-Smtp-Source: AMrXdXud2vbRhpBZTL2WdDc/3x2g68JGn78+ZaUp9GYAg6ZI1mbhN9/TQRbZhqN8NeRWcVIpiEvVxg== X-Received: by 2002:a17:906:6bc6:b0:7c0:f684:9092 with SMTP id t6-20020a1709066bc600b007c0f6849092mr18559572ejs.37.1674315417507; Sat, 21 Jan 2023 07:36:57 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id vc10-20020a170907d08a00b008717a377125sm8187030ejc.85.2023.01.21.07.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 07:36:57 -0800 (PST) From: Sergey Organov To: linux-serial@vger.kernel.org Cc: Fabio Estevam , Greg Kroah-Hartman , 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 , 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: Sat, 21 Jan 2023 18:36:36 +0300 Message-Id: <20230121153639.15402-5-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230121153639.15402-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230121153639.15402-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230121_073659_262988_2D381023 X-CRM114-Status: GOOD ( 13.09 ) 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 Sat Jan 21 15:36:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13111160 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 B14D9C25B50 for ; Sat, 21 Jan 2023 15:39: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=cfttro3fKjL3EtZ23jbiTctWXf35PbcbYykqMfp8r14=; b=3vRXQCAyJ5pn5o hJNDNHvR+1BYQhTtIdZje9TTK30s8J5XBbNqtzk4R3zOmucJC8GQj7kPen5N6a6o6BuVhzZG7gUz0 gmNohoLp19X85j8mfd6P3dvavaR02T7Np+s+H6mOj5AlFMRjP9TdLxZZDGWDNTOccIzk9soAl+Uq8 GYmJnDBlQQ3f7TmYETUgrFWYKvF546VIuY7OYBU9ADY6T7Zz8qqLjdmq2A9eBVM/YM6vGdQUKCCi8 SCn6El/7ZnuZJavoEmYCvM12qdSU5OT6B3jVkVjNkomSCK3c5F9lxtwSnyp4C20lpFHdOvQmEzp+M FJE9Q67rUMUunbbvg2jA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFwi-00E4Vy-FC; Sat, 21 Jan 2023 15:38:20 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFvQ-00E42X-7C for linux-arm-kernel@lists.infradead.org; Sat, 21 Jan 2023 15:37:01 +0000 Received: by mail-ej1-x636.google.com with SMTP id tz11so20949427ejc.0 for ; Sat, 21 Jan 2023 07:37:00 -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=kldlJnYn61XKUbTLQgEkhyKuWxwTsdBRY9Ll7uOoPNsALXEqmEhVnPDlmerDjm1+SI l3TIDs/rQvzlfZ9dQ/8wynXwr/UVjWZHEx+xSCgZ5zSkQof+F1SPm23TTRz6NN56T2uV Q4ASxS1ShBnp3YJgSMmwnGvglnU4JbvzSUFPjdAEmUOrAQ3zn82WjqOk4ZlouNJcRChk Q0o2cy4DQp5M78/ssbHv1hxuUTPDLivZdvz8vrULXiXmyZgS8aGeMgBwfvbpVLQNngfj 6gwUUGL50A7Y2ugBbah6TUbNKJU42SjXkr4coaWcVjICxqXqHGjJ2SSAwT9IWQDfhAT4 zq1Q== 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=tUlIvY6TgAid1AaGPnw+7Kih1nf6Wp4ZHU48vi0Tdk2neZb+XUzOqr/cFzs7Dn3pyF x9BEfeVM5pj6zBoQeEMbiOxrh2+82DFI3FbruR0006yOmsOQ6vPnwXWy5x+sU2jOIMov YypS+AWov3TfK5vuyPKkwX/KBU9zf9QkNCmwGioPpEW3VO//g5tCawKn2zN9Kr3jrtCj A+z5+TqM9ZXayE9O7TBU3DgimL/MpCzsW0kWZ4fjpTGnnT0pfXn8btybyJds3YDmGP0I /C4xFVOhNQIiXxW0u/KRFUcCC+zawpbtAWeo291WL6BJJVgSYaZYhtcj9MX9jKdvrPdI 32dQ== X-Gm-Message-State: AFqh2korlqumSA1OOc7wpvODiulV9X9epCr0DTg3C34MtaBFLvoKqtVV 2AW5gaaVpmjqsfNG4a1rtC0= X-Google-Smtp-Source: AMrXdXvonJoeipl/pY2J/CP9AlfUhBFM3gUEP8NtlR3AA0ZkXjY/Wfqosqwf9POkbiMwrcQJ8pE1Zg== X-Received: by 2002:a17:906:7e0c:b0:877:60b3:3fce with SMTP id e12-20020a1709067e0c00b0087760b33fcemr13894333ejr.45.1674315419081; Sat, 21 Jan 2023 07:36:59 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id vc10-20020a170907d08a00b008717a377125sm8187030ejc.85.2023.01.21.07.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 07:36:58 -0800 (PST) From: Sergey Organov To: linux-serial@vger.kernel.org Cc: Fabio Estevam , Greg Kroah-Hartman , 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 , 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: Sat, 21 Jan 2023 18:36:37 +0300 Message-Id: <20230121153639.15402-6-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230121153639.15402-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230121153639.15402-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230121_073700_300876_0FD92300 X-CRM114-Status: GOOD ( 11.34 ) 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 Sat Jan 21 15:36:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13111161 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 2006AC004D4 for ; Sat, 21 Jan 2023 15:39:42 +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=iduRWDGU/sHvwL 3RbNsMwdZtLLkxLclz6wxajEnOYb81c65tyxuJLvWlh1L0eGpYwb5Q6G5/4FlpS9NBr4UxahUarYg 7/rKWp8wE3H/IUScnrvNpwIb4yneYU4WHQdCM06mw3zlccZmfNo2GiOoSsWPLXmflQH9Ky6IBzVDD p3c4SaKpePK8KF/fco2ECK9mhB25gEXSbEPU2wyf1gQGKjEBpSQ20EvVUOYuk/YiPTVi0XXFz0e0X QpgfYyCjMMa/0U9dy3IJOY+/QgcKKSNxI1dSJtdeFKLWEI58mZzoTnxh7CmQrON9cAjP5NoHhwLXg r1O3WYvSDJtiSrZEQfCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFx3-00E4fY-J4; Sat, 21 Jan 2023 15:38:41 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFva-00E43E-Hu for linux-arm-kernel@lists.infradead.org; Sat, 21 Jan 2023 15:37:11 +0000 Received: by mail-ej1-x62f.google.com with SMTP id v6so20850011ejg.6 for ; Sat, 21 Jan 2023 07:37:01 -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=VHBApdFOPZlOveIj1sbYZ2BXz/eudd82xyd28Uk6eQ3ZM9AMJ7E1Hmy0JsbMflSpAa wcaWe+Xta+zgbBmhWusTulf46g/Nf6EOxW1pE4lA4PFZ44e3d3+1f0Kj1U7GN7+CytlR ywwnyseDKSetNt7P8XnsQP/qd+lf3By1EDIaZ2D26fjlPGOk/mqXNLOiMpgKHQwO4V2a imf8X4tZpBwVumCswjMlZMPXCHThQZvcuy2i3qFb6V00wpZ8lMntAleJKUu1JdaKaIhQ xi0noeO22vZXEQ5ZocSXAIUUsMJWK9lRaF7Vk07hg+83PxnGjW8Na7PkJWrrWnYugja+ pPpA== 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=2nPcT+UosrTul9vKqobBraXHwle7FEwfL+MuFlTmkuDwQlDmLfriCMlALODBPmzT+U 8sWYbiM4Wf9EadkeqgAcsUTj3xouOTYaBm40+zqPmG8qElNz+qZKv0gkM8UsHua2up95 +lfN4Y3QS2n7uT24U9GFpUTKe7Tcu9uuhkpzGOSNUZ4x+7YZ49FduWhwuFuM6iFKzBFJ g5/5A/AtQ3UpmSBO5CggFmVMSiNQmCY+1LgzD667gcXMZvBSUAZjSyJDgvhJw/cjHtVg vNWASni/40KE1X7TYKMfGTXbtjcxw5EmGt8D9EOyPivrusf4LDLZbRE7RMls9BH/rmdA aqEA== X-Gm-Message-State: AFqh2koBFttU4iBf6/tV/ZvUPVItDfmGn+0pYdZe3isjcI4qDE9zhtwv o1cYpFfYGWFD5kBXXFKd9Ik= X-Google-Smtp-Source: AMrXdXuSrQSmLVE+LDC1ygBKS7TGV/TZreUIwxcgMvbeTLF5GCi5bkAkPQJ55dKBfGfvBmRu3dUFcw== X-Received: by 2002:a17:906:fad4:b0:7c1:2529:b25e with SMTP id lu20-20020a170906fad400b007c12529b25emr19869516ejb.43.1674315420658; Sat, 21 Jan 2023 07:37:00 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id vc10-20020a170907d08a00b008717a377125sm8187030ejc.85.2023.01.21.07.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 07:37:00 -0800 (PST) From: Sergey Organov To: linux-serial@vger.kernel.org Cc: Fabio Estevam , Greg Kroah-Hartman , 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 , 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: Sat, 21 Jan 2023 18:36:38 +0300 Message-Id: <20230121153639.15402-7-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230121153639.15402-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230121153639.15402-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230121_073710_636712_D79CF74E X-CRM114-Status: GOOD ( 13.26 ) 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 Sat Jan 21 15:36:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13111162 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 D6FDFC25B50 for ; Sat, 21 Jan 2023 15:40: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=OGvyD9sL77T6KiY9NU8Mz4xEMLiIUJ3nJaKDQS1z2JY=; b=ZGTRu0VuWWLIdS K1kTiGM1XfhDY9LUSGkJOJ9hxs5h6yFDhr/9NGuaHllHvA1DQY8t5aPh+J7bQxlrpg4UK7rhOSEtT VWQAnrqdUtfaoSTG9LM35blvLGACVr3I7+GA7eQ0QaSMuZrrP60BspvPImOL4hVq62amhFD2N3QsG jBdjm+5j02evGNtOPk2mmB9YO4iAiMk/0IDKz+MkVZCEOYZtHln97El7mPNZxjIn2Azar5O4NKL1K 84SU+sxHemhAOAyOshPI+xYEECPDf+BKqVDE3u5qMT7GkHT7IPKz/UNv8yO9zhLlrseQSoPUeF4Wd f+IBGMxAKPFKe1oTDaiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFxc-00E4uY-N6; Sat, 21 Jan 2023 15:39:17 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFva-00E43m-Oz for linux-arm-kernel@lists.infradead.org; Sat, 21 Jan 2023 15:37:12 +0000 Received: by mail-ej1-x632.google.com with SMTP id v6so20850121ejg.6 for ; Sat, 21 Jan 2023 07:37:03 -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=cUKloTLrSAChI4BCO0eWJaaZnNF/rZJTMroMFj45nPKm8Z9uKUW1hn2uoyH8x1dr/0 w1VlsQmfIg1o7b6OnBcQBF7ScdzssVX39T1BJyaW5vGhZUCVfuvtusjP2f2wsweYbWGU Q2kKYiAZXSvuGvoYgH/DJvfcVOUyqkvuSfov+dqbE9Pp07htHoqk0s6JrodKOdH7SXy3 2gN8DqLB/at+lhW8Mj8g65c2OTxTsoOL0D2/cnAlp5anyqC/pqMjObgXlrLcLNj1c1N+ +N6Uj0qqPAr1ZmEGr3RKQ0YJI+vUzOxRRiK5KECVbum/3RN02DXlumZ+givMw+S5gkXK aQcQ== 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=M8blKn4CTZ9GWHpVMk3ixEY2rK6W6LMakDCrmUTorS7c5djMTkWHJedwkNZfWOTqhM h+ql02+EJj0CnsQwLmaqAuWYtC3LgeigUc0qy4jAJ+u4I6Apma3qjBSWb8fO/vuMyVdq t1vZmgjAUQUEYF2QlUC9U64+7jMhvC+jFS0HMIJgA4p6xS1yKBoLJEvSaBbuH7zqo4zv G+VbsyYA7qU9xqyV5G7UEEGW/8z9eh/L1wfMi/PIBxOEcH/UtnHbDN3ejen7ydOQwMlC SbNeSveJ7yXJ4iQtuUU5U+1clTwSqEw3LmgHYLyomD/8D99hnNJb+jtf4hspCmZqJtqR rxTA== X-Gm-Message-State: AFqh2kqpF5LKGlpKaP9WsbHQ0jBCi6+OSRaAFl2nPrx4hAtGD9zA6MTp IzhzidDaZ8oQpkuxlQUwqPc= X-Google-Smtp-Source: AMrXdXu1qdNmIXsHJye5VL6FE77ShV+keQV6lziLd3CwABregAyifPuPk21u3ESwF1s20pxPZ5yisw== X-Received: by 2002:a17:906:b305:b0:86e:8b7b:adb9 with SMTP id n5-20020a170906b30500b0086e8b7badb9mr17195606ejz.34.1674315422275; Sat, 21 Jan 2023 07:37:02 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id vc10-20020a170907d08a00b008717a377125sm8187030ejc.85.2023.01.21.07.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 07:37:01 -0800 (PST) From: Sergey Organov To: linux-serial@vger.kernel.org Cc: Fabio Estevam , Greg Kroah-Hartman , 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 , 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: Sat, 21 Jan 2023 18:36:39 +0300 Message-Id: <20230121153639.15402-8-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230121153639.15402-1-sorganov@gmail.com> References: <87bko4e65y.fsf@osv.gnss.ru> <20230121153639.15402-1-sorganov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230121_073710_869432_BCD2C994 X-CRM114-Status: GOOD ( 12.88 ) 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)) {