Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4284720pxv; Tue, 27 Jul 2021 03:38:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgSH5f8lyWwEZcdZf5r8E+BqekjW/fc/Ir4Pq/rCpYSHYKdpZoP88X/LfNFX7h8+6umfHv X-Received: by 2002:a50:d64a:: with SMTP id c10mr27722180edj.199.1627382334054; Tue, 27 Jul 2021 03:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627382334; cv=none; d=google.com; s=arc-20160816; b=eWJLZDx1y/CJYk0GDy7oPXHdWhvDv1rPKRtjJfS3bQ7aAAVSOb+TGM3k4dY8vdrEFa O5tLxBp1HLA6VJPYp1C6fcd6qxsljxQokt7BptAiAIHbJRptjZzTz21YdbimgWZp+J2Z 1ftQSvY3bmKrB+9pXGZtd0fjs8HrsmNKb1IY4kkOuzd2tZ2oIz5ih/zYQSN4TvYRfgKM 0jPulzJ+7qBSiqXRPUriEla2l/aqi6Iaa6FWQtrKQPC7yzA9QAeEjo24tRBYHYFspGnv aKsmGoWmvrTV/sLw97B/c2ziYs+RGF3Lzko6C+BN1yjUHzTClqh/US68+XGZIVY4dPnb EUvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uFLJJXYPzBJSq7mZRtA9n5WasWiVbig8vcteW1kzdyE=; b=VIF6t1uc8ck+62PYO+a9WvlrT8eHzWmbWPlzgm/aY/ZLm9gXqhdRrEWo8xDOMzCTXO 8kMWhEYV+Av22Lhm+Q6JxCJjddqpYZbmCy9CGkG9kE3EqFwJtfWmq15BkfDOQlBfdFCQ pV+DbU8+3W+GdUh3vRKQP6g7p80lfVqYWpeHhIgGjj5su1OnW4EdCdZZWnbdjLcIIzLR PEo8gJVKHQvHRiRyeG93AhCHCgmZU5ORiCp+kh8CbmeJkKuJZ4i3ofhcAYeWajzYtHtQ sVjwKPMNBbOk/ymO7FUsXnxUP78Cn2YtIQVYhNhpoYsVUaOFWrfSuCf8CmN8GseOMA2Z HsDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f3si2326608eje.693.2021.07.27.03.38.30; Tue, 27 Jul 2021 03:38:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236370AbhG0Kfm (ORCPT + 99 others); Tue, 27 Jul 2021 06:35:42 -0400 Received: from muru.com ([72.249.23.125]:55904 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236104AbhG0Kfm (ORCPT ); Tue, 27 Jul 2021 06:35:42 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 127B98106; Tue, 27 Jul 2021 10:35:57 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman Cc: Vignesh Raghavendra , linux-serial@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Carl Philipp Klemm , Merlijn Wajer , Pavel Machek , Sebastian Reichel Subject: [PATCH 2/2] serial: 8250_omap: Handle optional overrun-throttle-ms property Date: Tue, 27 Jul 2021 13:35:33 +0300 Message-Id: <20210727103533.51547-2-tony@atomide.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727103533.51547-1-tony@atomide.com> References: <20210727103533.51547-1-tony@atomide.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Handle optional overrun-throttle-ms property as done for 8250_fsl in commit 6d7f677a2afa ("serial: 8250: Rate limit serial port rx interrupts during input overruns"). This can be used to rate limit the UART interrupts on noisy lines that end up producing messages like the following: ttyS ttyS2: 4 input overrun(s) At least on droid4, the multiplexed USB and UART port is left to UART mode by the bootloader for a debug console, and if a USB charger is connected on boot, we get noise on the UART until the PMIC related drivers for PHY and charger are loaded. With this patch and overrun-throttle-ms = <500> we avoid the extra rx interrupts. Cc: Carl Philipp Klemm Cc: Merlijn Wajer Cc: Pavel Machek Cc: Sebastian Reichel Cc: Vignesh Raghavendra Signed-off-by: Tony Lindgren --- drivers/tty/serial/8250/8250_omap.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -617,7 +617,7 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) struct uart_port *port = dev_id; struct omap8250_priv *priv = port->private_data; struct uart_8250_port *up = up_to_u8250p(port); - unsigned int iir; + unsigned int iir, lsr; int ret; #ifdef CONFIG_SERIAL_8250_DMA @@ -628,6 +628,7 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) #endif serial8250_rpm_get(up); + lsr = serial_port_in(port, UART_LSR); iir = serial_port_in(port, UART_IIR); ret = serial8250_handle_irq(port, iir); @@ -642,6 +643,24 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) serial_port_in(port, UART_RX); } + /* Stop processing interrupts on input overrun */ + if ((lsr & UART_LSR_OE) && up->overrun_backoff_time_ms > 0) { + unsigned long delay; + + up->ier = port->serial_in(port, UART_IER); + if (up->ier & (UART_IER_RLSI | UART_IER_RDI)) { + port->ops->stop_rx(port); + } else { + /* Keep restarting the timer until + * the input overrun subsides. + */ + cancel_delayed_work(&up->overrun_backoff); + } + + delay = msecs_to_jiffies(up->overrun_backoff_time_ms); + schedule_delayed_work(&up->overrun_backoff, delay); + } + serial8250_rpm_put(up); return IRQ_RETVAL(ret); @@ -1353,6 +1372,10 @@ static int omap8250_probe(struct platform_device *pdev) } } + if (of_property_read_u32(np, "overrun-throttle-ms", + &up.overrun_backoff_time_ms) != 0) + up.overrun_backoff_time_ms = 0; + priv->wakeirq = irq_of_parse_and_map(np, 1); pdata = of_device_get_match_data(&pdev->dev); -- 2.32.0