Re: Reference counting in console uarts

From: Russell King (
Date: Sun Dec 08 2002 - 05:18:38 EST

On Sun, Dec 08, 2002 at 02:43:36AM -0500, Pete Zaitcev wrote:
> I boot my 2.5 boxes using "console=ttyS0,9600" argument,
> and I noticed that something is not right with reference
> counting in this case. It seems that when the console
> is open by kernel initially, this is not accounted
> as an open, and uart_startup is not called. This is ok,
> because the serial console is set up separately. However, later
> every script or a program run by init causes a startup
> and shutdown, literally dozens of them. These oscillations only
> stop when daemons are started and keep console open.

That is correct. We are unable to call uart_startup when the serial
console is initialised because it may need to allocate memory (as
request_irq does) and the memory allocators may not have been

There are two ways around this problem:

1. initialise the port into a state where it can send characters in the
   console write method.

2. don't do the actual hardware shutdown in your shutdown() method (but
   do the normal software shutdown - ie, free irqs etc)

8250 ports in effect implement the first - they don't really care about
their setup to send characters. We just disable all interrupts from the
chip and then perform polled IO to the port.

In essence, you need your console write method to be able to send
charcters whether or not the port has been initialised or shutdown
by the conventional tty driver methods.

Russell King (                The developer of ARM Linux
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Sun Dec 15 2002 - 22:00:12 EST