Re: WARNING at: drivers/char/tty_ldisc.c

From: Alan Cox
Date: Mon Aug 03 2009 - 05:37:39 EST


> I wonder if the hack is strictly necessary, or could perhaps at least be
> moved down a bit. The comment around that area seems to imply there were
> other issues ("will cause tty->count and state->count to go out of sync"),
> and that whole tty->count thing is some seriously old code, and the tty
> layer has changed a lot since 1992.

They will go out of sync for some hardware. Other stuff will get shut
down.

> So I do get the feeling that it may be just old code that simply nobody
> has dared remove - it may have made more sense back when then it does
> now, and has just been carried around.

Alas not: eg

->hangup
uart_hangup
uart_flush_buffer
uart_shutdown
drops carrier and dtr
shuts down the port
frees the IRQ handler
kills off the transmit buffer & tasklet

whether the resulting mess happens to still work with printk rather
depends upon what ->ops->shutdown does. Even on x86 that will drop a
remote console if the carrier is being used so you won't see printk
messages after that point as you got a modem hangup.

A re-open as a device isn't a problem (we cleared ASYNCB_INITIALIZED) -
its the printk side that kills you, and someone is going to have to read
all the embedded device consoles as they are both the most likely to
break and most used 8(

> If it actually were to cause problems with the tty->count thing, I think
> Sergey should have seen it thanks to us still doing that old
> CHECK_TTY_COUNT thing.

Only if you get things like crossing open/close and the port bumps the
counts internally for console uses (where hangup will then set it to zero
and break). USB still does that but the last patches to USB also pushed
hangup/console awareness into USB a bit so it knows at the hardware level
not to shut down the console device entirely.

Alan
--
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/