From patchwork Sat Jan 21 15:36:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13111148 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 CA8E2C004D4 for ; Sat, 21 Jan 2023 15:38:02 +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=DWoke5O/MgwZcL9B+TkglqJrjy9czRYEbm64q868Mac=; b=mBA6YDI21t+PWs dpx3asCaypXJEm4nskc/9y0O8wZPghTActVrwZAZTmw8RlYgtWxix0xIQUpybJwmlIHQSGdm/lCwG QncWGLK/D6D+itqp0lAMkmpJJ2DHUiGk3RNHp9wZytREV3nX+jcrH67Kf/75p5sAFtu9ONVS95cUe NDy1K/X3nBXNlKHZG+Erc6fycNDCDoeHDYAyQbYblX39okWcvUtIC+Hjbs82pkf5tzkBUp3PvLq5g hwuIANToa65TVXVcu5vlzvXoyipufuz4vRH3r5jBcsTdrgKm7A2+SvUdEF4s/7FC9zeOklfCNhkJP 2IqxkzFD5QocjyddwOag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJFvN-00E41I-TZ; Sat, 21 Jan 2023 15:36:58 +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 1pJFvJ-00E3zE-6j for linux-arm-kernel@lists.infradead.org; Sat, 21 Jan 2023 15:36:54 +0000 Received: by mail-ej1-x636.google.com with SMTP id kt14so20876175ejc.3 for ; Sat, 21 Jan 2023 07:36:52 -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=ZbE3Vyz7FEJBJTK44d6toywOKJ/fNH9oM8amuUNHVHc=; b=g0IxxXcZdni3MvQefW4X+InxgH/pux2DG02UrrEhp3kc0Q9AT+/HLx1pKQtVzb3NIM jhKUriY7zH1SzMS9QYyvWdrZSyvzt1u3mazS95qOkW6hblhQroNHGtXUP77+tN/ybdMD vMbR05dEvnEciH8Anw0VVI1gHn/2l3IDGUcqWuX2TLt+ehZaTK9EphUDMWH23qb0jFkT wS4f6Vvvm9jcXns1P/zGZlz8Pe//IY4hWHd9D1nNIfc6fkkFNJ09ENd3Lz/+K/OZBiM0 xAearXVmLrcxxHrf1fCIvQmw8lz90GB33vR7YJoBu8dYoyv7K+qbsr1Hqxq9MeVq85ey S3ug== 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=ZbE3Vyz7FEJBJTK44d6toywOKJ/fNH9oM8amuUNHVHc=; b=YPniawKgmJaCPwwDnI9OKwfFhzPfoTp9xaF+LvGRGHiB3NYsmg5jNe5+vI1hzvS27E 9Uumq6DX+5+MfZbwD455QSlwwFqzJWIbpZw76Nv5JyiuNZaG8AN+dgutZFjGXGoHLEHO YY7Lk9EnWL0covunVsQYU5b+itjV1s+WOGKQM40PaHRhkk00J6rv2vHgxYLOLlFzlX1E poemxmUTU9VzMibiraV6cdwTppCOcmJ6VVLjOnyzryTjhpQe0vMrwj+oDC+3bgBTsfuN mDsSxiQPmWTRcax/fFH+t1dMcnnCBWY+LI7fbIR7BF9uf03gT64g9nLdYi1cKIkEfaDB QlkA== X-Gm-Message-State: AFqh2kpYPPMtHZxACQ0uMPehIJkzzgOTUraff03Q3wdcYy2PRNldsDhB HRf9ZxVfbE0hgm6DDaSa84miwEd41f0= X-Google-Smtp-Source: AMrXdXvXTRNVHgy6ypXQ7cuQfNYqYetzSg/T0mKpOwyL0ioQdx2HJ58aVfmb/nS1jZd8Qk5M7tU3rA== X-Received: by 2002:a17:907:11cd:b0:870:b950:18e7 with SMTP id va13-20020a17090711cd00b00870b95018e7mr20325963ejb.19.1674315410946; Sat, 21 Jan 2023 07:36:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 07:36:50 -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 0/7] serial: imx: work-around for hardware RX flood, and then isr improvements Date: Sat, 21 Jan 2023 18:36:32 +0300 Message-Id: <20230121153639.15402-1-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <87bko4e65y.fsf@osv.gnss.ru> References: <87bko4e65y.fsf@osv.gnss.ru> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230121_073653_320163_0670EF5D X-CRM114-Status: GOOD ( 14.44 ) 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 These series contain a work-around for hardware RX flood in first 2 commits, and then further cleanups and optimizations of the receive IRQ handler. WARNING: the flood fix is extensively tested with older version of the kernel with DMA turned off. The DMA path is tested only a bit, as DMA has receive problems on my kernel version. Changes in v1: * Missing braces fixed. * Withdrawn patch optimizing imx_uart_readl() -> readl(), on request of Uwe Kleine-König. Sergey Organov (7): serial: imx: factor-out common code to imx_uart_soft_reset() serial: imx: work-around for hardware RX flood serial: imx: do not sysrq broken chars serial: imx: do not break from FIFO reading loop prematurely serial: imx: remove redundant USR2 read from FIFO reading loop serial: imx: stop using USR2 in FIFO reading loop serial: imx: refine local variables in rxint() drivers/tty/serial/imx.c | 225 ++++++++++++++++++++++++--------------- 1 file changed, 140 insertions(+), 85 deletions(-) Interdiff against v0: diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 45327ff6dd14..447b9060d9df 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -889,15 +889,14 @@ static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) { struct imx_port *sport = dev_id; struct tty_port *port = &sport->port.state->port; - typeof(sport->port.membase) membase = sport->port.membase; u32 usr2, rx; /* If we received something, check for 0xff flood */ - usr2 = readl(membase + USR2); + usr2 = imx_uart_readl(sport, USR2); if (usr2 & USR2_RDR) imx_uart_check_flood(sport, usr2); - while ((rx = readl(membase + URXD0)) & URXD_CHARRDY) { + while ((rx = imx_uart_readl(sport, URXD0)) & URXD_CHARRDY) { unsigned int flg = TTY_NORMAL; sport->port.icount.rx++; @@ -929,8 +928,9 @@ 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)) + } else if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx)) { continue; + } if (sport->port.ignore_status_mask & URXD_DUMMY_READ) continue;