Re: TTY/Serial Driver Hangs in tty_wait_until_sent, analysis, andrecommendations

From: Alan Cox
Date: Sat May 23 2009 - 13:52:48 EST


> So, the console is hung. Control C characters and Control Q characters are not processed and there is nothing you can do short of logging on through a different port and killing the shell on the console.

(or reading it from another process if you diagnosis is correct - and it
sounds so)

> I think there are two long term solutions to this: 1) have the low level serial port drivers (i.e. 8250) treat XON/XOFF out of band and have some back door into the line discipline driver to restart the serial line without needing input buffer space and 2) to change the tty_ioctl handling of a WAIT call to flush the output buffer if the port is stopped. I figure either of these approaches alters the serial behavior enough that it is more then just a bug fix.

#2 is out of spec for the standards and pushing the flow control down
into the drivers is a major project (and very hard to do as flow control
is discipline dependant sometimes). Like a lot of the tty layer its all
quite ugly 8(

The obvious quick hack would I think be to add an optional ldisc method
that is called when new data arrives which cannot be queued due to
throttling and get to snoop on the buffer and perhaps optionally trim
bytes out of it.

If flush_to_ldisc called such a routine for those bytes that didn't fit
then something like

if (c == START_CHAR(tty) && I_IXON(tty) && tty->stopped) {
start_tty(tty);
process_echoes(tty);
}

in the ldisc handler for n_tty would uncork the bottle.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/