Re: [PATCH] Correctly flush 8250 buffers, notify ldisc of line status changes.

From: Russell King
Date: Tue Nov 09 2004 - 08:29:36 EST


On Tue, Nov 09, 2004 at 11:15:30AM +0000, Alan Cox wrote:
> On Maw, 2004-11-09 at 11:07, David Woodhouse wrote:
> > + * tty_status_change - notify of line status changes
> > + * @tty: terminal
> > + *
> > + * Helper for informing the line discipline that the modem
> > + * status lines may have changed.
> > + */
> > +
> > +void tty_status_changed(struct tty_struct *tty)
> > +{
> > + struct tty_ldisc *ld = tty_ldisc_ref(tty);
> > + if(ld) {
> > + if(ld->status_changed)
> > + ld->status_changed(tty);
> > + tty_ldisc_deref(ld);
> > + }
> > +}
> > +
>
> This is the wrong way to do it. I've been trying this and discarded it.
> The problem is that data arrival is asynchronous to the event which
> means you've not got a clue how to combine the status change and the
> data stream. This in itself makes the whole feature useless.

The status change and character receive are asynchronous with respect
to each other anyway. Consider the case where the serial port says
"we have characters waiting" - we receive a FIFO full of characters.
It then says that the modem status has changed.

You don't actually know when the modem status changed. It may have
changed before any of these characters were received because character
receiption is is highest priority.

Even if you poll the MSR register after you receive every FIFO character,
you still don't know whether the modem status changed before or after
that character was received.

Therefore, anything which relies on knowing precisely when the modem
status changed in the character stream is unfortunately broken by the
limitations of 8250-based hardware.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial core
-
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/