]> git.baikalelectronics.ru Git - kernel.git/commit
tty: Make ldisc input flow control concurrency-friendly
authorPeter Hurley <peter@hurleysoftware.com>
Sat, 15 Jun 2013 13:14:15 +0000 (09:14 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jul 2013 23:42:59 +0000 (16:42 -0700)
commitbf5b894178a27dd69bd9ceeb70c977d1d3d6be5a
treee09745de8a63d9d8039495ed8b9bb79fbb334702
parent2ce8f96362b3cf808ac47ca0024b47671a771389
tty: Make ldisc input flow control concurrency-friendly

Although line discipline receiving is single-producer/single-consumer,
using tty->receive_room to manage flow control creates unnecessary
critical regions requiring additional lock use.

Instead, introduce the optional .receive_buf2() ldisc method which
returns the # of bytes actually received. Serialization is guaranteed
by the caller.

In turn, the line discipline should schedule the buffer work item
whenever space becomes available; ie., when there is room to receive
data and receive_room() previously returned 0 (the buffer work
item stops processing if receive_buf2() returns 0). Note the
'no room' state need not be atomic despite concurrent use by two
threads because only the buffer work thread can set the state and
only the read() thread can clear the state.

Add n_tty_receive_buf2() as the receive_buf2() method for N_TTY.
Provide a public helper function, tty_ldisc_receive_buf(), to use
when directly accessing the receive_buf() methods.

Line disciplines not using input flow control can continue to set
tty->receive_room to a fixed value and only provide the receive_buf()
method.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_tty.c
drivers/tty/tty_buffer.c
drivers/tty/vt/selection.c
include/linux/tty.h
include/linux/tty_ldisc.h