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

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

 



On 2013-01-16, Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> wrote:
> 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.

That's what it looked like it to me, but I wasn't sure.

>> [...]
>> 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 replaced 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.

That was the plan...

> 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.

Ah! None of the examples I looked at so far were using tty_port_open()
and the port activate method, and I had somehow missed noticing their
existence when I was looking through tty_port sources.

> 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.

Cool, thanks!

Which of the tty drivers is the best example to follow when it comes
to use of the tty_port_ helpers?

It looks like the tty_port_ helpers only go back to 2.6.33, so
supporting kernels older than that will require some sort of private,
backported versions of the helpers.  Maybe I can talk management and
tech support into dropping support for kernels older than 2.6.33...

-- 
Grant Edwards               grant.b.edwards        Yow! I threw up on my
                                  at               window!
                              gmail.com            

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