Bug in Linux serial driver (and fix proposal)

Wojciech Zabolotny (wzab@ise.pw.edu.pl)
Mon, 4 Oct 1999 20:56:10 +0200


Hi Linux kernel gurus!

I just discovered, that the user program can not detect the "overrun"
event in serial data (at least in 2.0.x kernels, I don't know the 2.2.x).
This is a serious bug in the serial driver, if it is used for applications
sensitive to data loss (eg. processing of data from AD converter connected
to the serial port).

I would like to suggest two solutions:

1) Modify the "n_tty_receive_overrun" routine to introduce a new "marker"
informing about the overrun, when PARMRK flag is used (I propose
the 0xff 0x01 sequence, which can not occur in the data stream in PARMRK mode)

static inline void n_tty_receive_overrun(struct tty_struct *tty)
{
char buf[64];
if (I_PARMRK(tty)) {
put_tty_queue('\377', tty);
put_tty_queue('\1', tty);
}
tty->num_overrun++;
if (tty->overrun_time < (jiffies - HZ)) {
printk("%s: %d input overrun(s)\n", _tty_name(tty, buf),
tty->num_overrun);
tty->overrun_time = jiffies;
tty->num_overrun = 0;
}
}

2) Add an additional IOCTL which will test the num_overrun and overrun_time
fields in the tty_struct and signal the overrun condition if any of these
fields is nonzero.

BTW The current method for signalling of overrun condition will not inform
about the single short "burst" of overruns (the num_overrun will be increased,
but the printk will be called only after the next overrun, occuring after
the HZ jiffies).

If I missed something, and there is an "official" way to detect the data overrun
in 2.0.x (or 2.2.x) kernels please let me know how to do it...

-- 
			TIA
			Wojciech M. Zabolotny
			wzab@ise.pw.edu.pl
			http://www.ise.pw.edu.pl/~wzab

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