linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: serial: 8250: Update for standard overrun-throttle property
@ 2021-07-27 10:35 Tony Lindgren
  2021-07-27 10:35 ` [PATCH 2/2] serial: 8250_omap: Handle optional overrun-throttle-ms property Tony Lindgren
  2021-08-02 20:10 ` [PATCH 1/2] dt-bindings: serial: 8250: Update for standard overrun-throttle property Rob Herring
  0 siblings, 2 replies; 3+ messages in thread
From: Tony Lindgren @ 2021-07-27 10:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Vignesh Raghavendra, linux-serial, linux-omap, linux-kernel,
	devicetree, Rob Herring

In some cases we want to specify overrun-throttle like other 8250 drivers
are doing.

Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 Documentation/devicetree/bindings/serial/8250_omap.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/serial/8250_omap.yaml b/Documentation/devicetree/bindings/serial/8250_omap.yaml
--- a/Documentation/devicetree/bindings/serial/8250_omap.yaml
+++ b/Documentation/devicetree/bindings/serial/8250_omap.yaml
@@ -79,6 +79,7 @@ properties:
   power-domains: true
   clock-frequency: true
   current-speed: true
+  overrun-throttle-ms: true
 
 required:
   - compatible
-- 
2.32.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] serial: 8250_omap: Handle optional overrun-throttle-ms property
  2021-07-27 10:35 [PATCH 1/2] dt-bindings: serial: 8250: Update for standard overrun-throttle property Tony Lindgren
@ 2021-07-27 10:35 ` Tony Lindgren
  2021-08-02 20:10 ` [PATCH 1/2] dt-bindings: serial: 8250: Update for standard overrun-throttle property Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Tony Lindgren @ 2021-07-27 10:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Vignesh Raghavendra, linux-serial, linux-omap, linux-kernel,
	Carl Philipp Klemm, Merlijn Wajer, Pavel Machek,
	Sebastian Reichel

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 <philipp@uvos.xyz>
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] dt-bindings: serial: 8250: Update for standard overrun-throttle property
  2021-07-27 10:35 [PATCH 1/2] dt-bindings: serial: 8250: Update for standard overrun-throttle property Tony Lindgren
  2021-07-27 10:35 ` [PATCH 2/2] serial: 8250_omap: Handle optional overrun-throttle-ms property Tony Lindgren
@ 2021-08-02 20:10 ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2021-08-02 20:10 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-omap, Vignesh Raghavendra, Rob Herring, linux-serial,
	linux-kernel, Greg Kroah-Hartman, devicetree

On Tue, 27 Jul 2021 13:35:32 +0300, Tony Lindgren wrote:
> In some cases we want to specify overrun-throttle like other 8250 drivers
> are doing.
> 
> Cc: devicetree@vger.kernel.org
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Vignesh Raghavendra <vigneshr@ti.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  Documentation/devicetree/bindings/serial/8250_omap.yaml | 1 +
>  1 file changed, 1 insertion(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-02 20:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 10:35 [PATCH 1/2] dt-bindings: serial: 8250: Update for standard overrun-throttle property Tony Lindgren
2021-07-27 10:35 ` [PATCH 2/2] serial: 8250_omap: Handle optional overrun-throttle-ms property Tony Lindgren
2021-08-02 20:10 ` [PATCH 1/2] dt-bindings: serial: 8250: Update for standard overrun-throttle property Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).