• Peter Hurley's avatar
    tty: Fix low_latency BUG · a9c3f68f
    Peter Hurley authored
    The user-settable knob, low_latency, has been the source of
    several BUG reports which stem from flush_to_ldisc() running
    in interrupt context. Since 3.12, which added several sleeping
    locks (termios_rwsem and buf->lock) to the input processing path,
    the frequency of these BUG reports has increased.
    
    Note that changes in 3.12 did not introduce this regression;
    sleeping locks were first added to the input processing path
    with the removal of the BKL from N_TTY in commit
    a88a69c9,
    'n_tty: Fix loss of echoed characters and remove bkl from n_tty'
    and later in commit 38db8979,
    'tty: throttling race fix'. Since those changes, executing
    flush_to_ldisc() in interrupt_context (ie, low_latency set), is unsafe.
    
    However, since most devices do not validate if the low_latency
    setting is appropriate for the context (process or interrupt) in
    which they receive data, some reports are due to misconfiguration.
    Further, serial dma devices for which dma fails, resort to
    interrupt receiving as a backup without resetting low_latency.
    
    Historically, low_latency was used to force wake-up the reading
    process rather than wait for the next scheduler tick. The
    effect was to trim multiple milliseconds of latency from
    when the process would receive new data.
    
    Recent tests [1] have shown that the reading process now receives
    data with only 10's of microseconds latency without low_latency set.
    
    Remove the low_latency rx steering from tty_flip_buffer_push();
    however, leave the knob as an optional hint to drivers that can
    tune their rx fifos and such like. Cleanup stale code comments
    regarding low_latency.
    
    [1] https://lkml.org/lkml/2014/2/20/434
    
    "Yay.. thats an annoying historical pain in the butt gone."
    	-- Alan Cox
    Reported-by: default avatarBeat Bolli <bbolli@ewanet.ch>
    Reported-by: default avatarPavel Roskin <proski@gnu.org>
    Acked-by: default avatarDavid Sterba <dsterba@suse.cz>
    Cc: Grant Edwards <grant.b.edwards@gmail.com>
    Cc: Stanislaw Gruszka <sgruszka@redhat.com>
    Cc: Hal Murray <murray+fedora@ip-64-139-1-69.sjc.megapath.net>
    Cc: <stable@vger.kernel.org> # 3.12.x+
    Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
    Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    a9c3f68f
tty.c 14.1 KB