Re: Are calls to open()/close() serialized by tty layer?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 16 Jan 2013 20:07:49 +0000 (UTC)
Grant Edwards <grant.b.edwards@xxxxxxxxx> wrote:

> Are calls to a tty driver's open()/close() methods serialized by the
> tty layer?  If so, has this always been the case?

They are not fully serialized - never have been. A lot of the drivers were
always racy, some that have not been fully converted to the port helpers
still are.

> >From looking at example tty drivers in the 3.7.2 source tree, it
> appears that they assume calls to open()/close() are serialized.
> 
> The old driver I'm working on had its own internal locking to protect
> race conditiions when incrementing and decrementing of a port's open
> count.  That counter is being prelaced by tty->port->count, and in
> existing in-kernel tty drivers it doesn't look like there is any
> locking when that count is incremented during an open().

Use the tty_port helpers. They will also handle all the other detail you
need. The helpers themselves provide serialized activate/shutdown
callbacks on the port which are serialized against each other and hangups.

The port helpers will also ensure your refcounting is right, you don't
have open/close/hangup races and that you get the required POSIX
semantics.

The port helpers are designed so you can propogate your own error codes
either by wrapping them or by returning your own error code from
port->activate() which will be duly propogated to user space.

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux