2009-10-22 16:43:27

by Eugene T. Bordenkircher

[permalink] [raw]
Subject: Ordering problem in serial_core.c




---------- Forwarded message ----------
From: Eugene Bordenkircher <[email protected]>
Date: Oct 22, 9:19?am
Subject: Ordering problem in serial_core.c
To: fa.linux.kernel


There is an ordering problem with closing a UART in the serial core.
If the line discipline is throttling the port when close is called, it
tries to unthrottle the port which, in the case of soft flow, tries to
send the XON character. ?This doesn't work well since at this point
the uart has been shutdown.

The simple reordering shown below will seems to fix the problem, but
please comment if there are other side effects I am not seeing.

Eugene T. Bordenkircher

--- linux_kernel/drivers/serial/serial_core.c.orig ? ? ?2009-08-13
14:58:04.000000000 -0700
+++ linux_kernel/drivers/serial/serial_core.c ? 2009-08-13
15:29:02.000000000 -0700
@@ -1317,11 +1317,11 @@
? ? ? ? ? ? ? ? uart_wait_until_sent(tty, port->timeout);
? ? ? ? }

+ ? ? ? tty_ldisc_flush(tty);
+
? ? ? ? uart_shutdown(state);
? ? ? ? uart_flush_buffer(tty);

- ? ? ? tty_ldisc_flush(tty);
-
? ? ? ? tty->closing = 0;
? ? ? ? state->info.port.tty = NULL;


2009-10-22 18:00:00

by Alan

[permalink] [raw]
Subject: Re: Ordering problem in serial_core.c

> If the line discipline is throttling the port when close is called, it
> tries to unthrottle the port which, in the case of soft flow, tries to
> send the XON character. ?This doesn't work well since at this point
> the uart has been shutdown.

A rather more relevant question is why is the serial driver doing an
ldisc flush in the first place.

> The simple reordering shown below will seems to fix the problem, but
> please comment if there are other side effects I am not seeing.

I don't see one offhand, and it looks a reasonable fix. I'll take a
deeper look next week but it might not be a bad idea for this to get put
into -next to see.