summaryrefslogtreecommitdiffstats
path: root/drivers/tty/n_tty.c
Commit message (Collapse)AuthorAgeFilesLines
...
* n_tty: Fix echo overrun tail computationPeter Hurley2013-11-251-1/+1
| | | | | | | | | | | | | | | Commit cbfd0340ae1993378fd47179db949e050e16e697, 'n_tty: Process echoes in blocks', introduced an error when consuming the echo buffer tail to prevent buffer overrun, where the incorrect operation code byte is checked to determine how far to advance the tail to the next echo byte. Check the correct byte for the echo operation code byte. Cc: <stable@vger.kernel.org> # 3.12.x : c476f65 tty: incorrect test of echo_buf() result for ECHO_OP_START Cc: <stable@vger.kernel.org> # 3.12.x Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Ensure reader restarts worker for next readerPeter Hurley2013-11-251-2/+3
| | | | | | | | | | | A departing reader must restart a flush_to_ldisc() worker _before_ the next reader enters the read loop; this is to avoid the new reader concluding no more i/o is available and prematurely exiting, when the old reader simply hasn't re-started the worker yet. Cc: stable <stable@vger.kernel.org> # 3.12 Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: incorrect test of echo_buf() result for ECHO_OP_STARTRoel Kluin2013-10-161-1/+1
| | | | | | | | test echo_buf() result for ECHO_OP_START Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Acked-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Merge 3.12-rc4 into tty-nextGreg Kroah-Hartman2013-10-061-20/+26
|\ | | | | | | | | | | We want the tty fixes in this branch as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * tty: Fix pty master read() after slave closesPeter Hurley2013-09-301-20/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit f95499c3030fe1bfad57745f2db1959c5b43dca8, n_tty: Don't wait for buffer work in read() loop creates a race window which can cause a pty master read() to miss the last pty slave write(s) and return -EIO instead, thus signalling the pty slave is closed. This can happen when the pty slave is written and immediately closed but before the tty buffer i/o loop receives the new input; the pty master read() is scheduled, sees its read buffer is empty and the pty slave has been closed, and exits. Because tty_flush_to_ldisc() has significant performance impact for parallel i/o, rather than revert the commit, special case this condition (ie., when the read buffer is empty and the 'other' pty has been closed) and, only then, wait for buffer work to complete before re-testing if the read buffer is still empty. As before, subsequent pty master reads return any available data until no more data is available, and then returns -EIO to indicate the pty slave has closed. Reported-by: Mikael Pettersson <mikpelinux@gmail.com> Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Tested-by: Mikael Pettersson <mikpelinux@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | Merge 3.12-rc3 into tty-nextGreg Kroah-Hartman2013-09-291-2/+1
|\ \ | |/ | | | | | | | | We want the tty/serial fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * n_tty: Fix EOF push index when termios changesPeter Hurley2013-09-171-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | Commit 40d5e0905a03601d40cd4e46b8690093c2355d03, 'n_tty: Fix EOF push handling' introduced a subtle state change error wrt EOF push handling when the termios is changed from non-canonical to canonical mode. Reset line_start to the current read_tail index, not 0. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | n_tty: Style fix in n_tty_set_termiosPeter Hurley2013-09-251-2/+1
| | | | | | | | | | | | | | | | Remove braces from single-statement conditional in n_tty_set_termios. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | n_tty: Remove unnecessary local variablePeter Hurley2013-09-251-4/+1
| | | | | | | | | | | | | | | | Flatten conditional evaluation in n_tty_set_termios; remove canon_change. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | n_tty: Remove superfluous reader wakeupPeter Hurley2013-09-251-3/+0
|/ | | | | | | | n_tty's .set_termios method unconditionally performs reader wakeup; remove extra reader wakeup for canonical mode changes. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Fix termios_rwsem lockdep false positivePeter Hurley2013-08-121-14/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Lockdep reports a circular lock dependency between atomic_read_lock and termios_rwsem [1]. However, a lock order deadlock is not possible since CPU1 only holds a read lock which cannot prevent CPU0 from also acquiring a read lock on the same r/w semaphore. Unfortunately, lockdep cannot currently distinguish whether the locks are read or write for any particular lock graph, merely that the locks _were_ previously read and/or write. Until lockdep is fixed, re-order atomic_read_lock so termios_rwsem can be dropped and reacquired without triggering lockdep. Patch based on original posted here https://lkml.org/lkml/2013/8/1/510 by Sergey Senozhatsky <sergey.senozhatsky@gmail.com> [1] Initial lockdep report from Artem Savkov <artem.savkov@gmail.com> ====================================================== [ INFO: possible circular locking dependency detected ] 3.11.0-rc3-next-20130730+ #140 Tainted: G W ------------------------------------------------------- bash/1198 is trying to acquire lock: (&tty->termios_rwsem){++++..}, at: [<ffffffff816aa3bb>] n_tty_read+0x49b/0x660 but task is already holding lock: (&ldata->atomic_read_lock){+.+...}, at: [<ffffffff816aa0f0>] n_tty_read+0x1d0/0x660 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&ldata->atomic_read_lock){+.+...}: [<ffffffff811111cc>] validate_chain+0x73c/0x850 [<ffffffff811117e0>] __lock_acquire+0x500/0x5d0 [<ffffffff81111a29>] lock_acquire+0x179/0x1d0 [<ffffffff81d34b9c>] mutex_lock_interruptible_nested+0x7c/0x540 [<ffffffff816aa0f0>] n_tty_read+0x1d0/0x660 [<ffffffff816a3bb6>] tty_read+0x86/0xf0 [<ffffffff811f21d3>] vfs_read+0xc3/0x130 [<ffffffff811f2702>] SyS_read+0x62/0xa0 [<ffffffff81d45259>] system_call_fastpath+0x16/0x1b -> #0 (&tty->termios_rwsem){++++..}: [<ffffffff8111064f>] check_prev_add+0x14f/0x590 [<ffffffff811111cc>] validate_chain+0x73c/0x850 [<ffffffff811117e0>] __lock_acquire+0x500/0x5d0 [<ffffffff81111a29>] lock_acquire+0x179/0x1d0 [<ffffffff81d372c1>] down_read+0x51/0xa0 [<ffffffff816aa3bb>] n_tty_read+0x49b/0x660 [<ffffffff816a3bb6>] tty_read+0x86/0xf0 [<ffffffff811f21d3>] vfs_read+0xc3/0x130 [<ffffffff811f2702>] SyS_read+0x62/0xa0 [<ffffffff81d45259>] system_call_fastpath+0x16/0x1b other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&ldata->atomic_read_lock); lock(&tty->termios_rwsem); lock(&ldata->atomic_read_lock); lock(&tty->termios_rwsem); *** DEADLOCK *** 2 locks held by bash/1198: #0: (&tty->ldisc_sem){.+.+.+}, at: [<ffffffff816ade04>] tty_ldisc_ref_wait+0x24/0x60 #1: (&ldata->atomic_read_lock){+.+...}, at: [<ffffffff816aa0f0>] n_tty_read+0x1d0/0x660 stack backtrace: CPU: 1 PID: 1198 Comm: bash Tainted: G W 3.11.0-rc3-next-20130730+ #140 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007 0000000000000000 ffff880019acdb28 ffffffff81d34074 0000000000000002 0000000000000000 ffff880019acdb78 ffffffff8110ed75 ffff880019acdb98 ffff880019fd0000 ffff880019acdb78 ffff880019fd0638 ffff880019fd0670 Call Trace: [<ffffffff81d34074>] dump_stack+0x59/0x7d [<ffffffff8110ed75>] print_circular_bug+0x105/0x120 [<ffffffff8111064f>] check_prev_add+0x14f/0x590 [<ffffffff81d3ab5f>] ? _raw_spin_unlock_irq+0x4f/0x70 [<ffffffff811111cc>] validate_chain+0x73c/0x850 [<ffffffff8110ae0f>] ? trace_hardirqs_off_caller+0x1f/0x190 [<ffffffff811117e0>] __lock_acquire+0x500/0x5d0 [<ffffffff81111a29>] lock_acquire+0x179/0x1d0 [<ffffffff816aa3bb>] ? n_tty_read+0x49b/0x660 [<ffffffff81d372c1>] down_read+0x51/0xa0 [<ffffffff816aa3bb>] ? n_tty_read+0x49b/0x660 [<ffffffff816aa3bb>] n_tty_read+0x49b/0x660 [<ffffffff810e4130>] ? try_to_wake_up+0x210/0x210 [<ffffffff816a3bb6>] tty_read+0x86/0xf0 [<ffffffff811f21d3>] vfs_read+0xc3/0x130 [<ffffffff811f2702>] SyS_read+0x62/0xa0 [<ffffffff815e24ee>] ? trace_hardirqs_on_thunk+0x3a/0x3f [<ffffffff81d45259>] system_call_fastpath+0x16/0x1b Reported-by: Artem Savkov <artem.savkov@gmail.com> Reported-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Factor LNEXT processing from per-char i/o pathPeter Hurley2013-07-241-72/+94
| | | | | | | | | | | | | LNEXT processing accounts for ~15% of total cpu time in end-to-end tty i/o; factor the lnext test/clear from the per-char i/o path. Instead, attempt to immediately handle the literal next char if not at the end of this received buffer; otherwise, handle the first char of the next received buffer as the literal next char, then continue with normal i/o. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Un-inline single-use functionsPeter Hurley2013-07-241-6/+5
| | | | | | | | gcc will likely inline these single-use functions anyway; remove inline modifier. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Remove overflow tests from receive_buf() pathPeter Hurley2013-07-241-48/+37
| | | | | | | | | | | | Always pre-figure the space available in the read_buf and limit the inbound receive request to that amount. For compatibility reasons with the non-flow-controlled interface, n_tty_receive_buf() will continue filling read_buf until all data has been received or receive_room() returns 0. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Factor PARMRK from normal per-char i/oPeter Hurley2013-07-241-2/+43
| | | | | | | Handle PARMRK processing on the slow per-char i/o path. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Factor ISTRIP and IUCLC receive_buf into separate fnPeter Hurley2013-07-241-12/+32
| | | | | | | | | Convert to modal receive_buf processing; factor char receive processing for unusual termios settings out of normal per-char i/o path. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Split n_tty_receive_char()Peter Hurley2013-07-241-47/+56
| | | | | | | | | Factor 'special' per-char processing into standalone fn, n_tty_receive_char_special(), which handles processing for chars marked in the char_map. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Eliminate char tests from IXANY restart testPeter Hurley2013-07-241-7/+12
| | | | | | | | | | | | Relocate the IXANY restart tty test to code paths where the the received char is not START_CHAR, STOP_CHAR, INTR_CHAR, QUIT_CHAR or SUSP_CHAR. Fixes the condition when ISIG if off and one of INTR_CHAR, QUIT_CHAR or SUSP_CHAR does not restart i/o. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Factor standard per-char i/o into separate fnPeter Hurley2013-07-241-10/+17
| | | | | | | | Simplify __receive_buf() into a dispatch function; perform per-char processing for all other modes not already handled. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Fix build breakage on ppc64Peter Hurley2013-07-241-0/+1
| | | | | | | | | | | | Commit 20bafb3d23d108bc0a896eb8b7c1501f4f649b77 'n_tty: Move buffers into n_tty_data' broke the ppc64 build. Include vmalloc.h for the required function declarations. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Factor tty->closing receive_buf() into separate fnPeter Hurley2013-07-231-11/+39
| | | | | | | | | | | Convert to modal receive_buf() processing; factor receive char processing when tty->closing into n_tty_receive_buf_closing(). Note that EXTPROC when ISTRIP or IUCLC is set continues to be handled by n_tty_receive_char(). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Special case EXTPROC receive_buf() as raw modePeter Hurley2013-07-231-1/+2
| | | | | | | | | When EXTPROC is set without ISTRIP or IUCLC, processing is identical to raw mode; handle this receiving mode as a special-case of raw mode. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Factor raw mode receive_buf() into separate fnPeter Hurley2013-07-231-5/+19
| | | | | | | | Convert to modal receive_buf() processing; factor raw mode per-char i/o into n_tty_receive_buf_raw(). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Factor flagged char handling into separate fnPeter Hurley2013-07-231-21/+29
| | | | | | | | | Prepare for modal receive_buf() handling; factor handling for TTY_BREAK, TTY_PARITY, TTY_FRAME and TTY_OVERRUN into n_tty_receive_char_flagged(). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Factor signal char handling into separate fnPeter Hurley2013-07-231-24/+28
| | | | | | | | | Reduce the monolithic n_tty_receive_char() complexity; factor the handling of INTR_CHAR, QUIT_CHAR and SUSP_CHAR into n_tty_receive_signal_char(). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Factor 'real raw' receive_buf into standalone fnPeter Hurley2013-07-231-21/+30
| | | | | | | | Convert to modal receive_buf() processing; factor real_raw receive_buf() into n_tty_receive_buf_real_raw(). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Simplify __receive_buf loop countPeter Hurley2013-07-231-5/+3
| | | | | Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Rename process_char_map to char_mapPeter Hurley2013-07-231-23/+20
| | | | | Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Move buffers into n_tty_dataPeter Hurley2013-07-231-16/+9
| | | | | | | | Reduce pointer reloading and improve locality-of-reference; allocate read_buf and echo_buf within struct n_tty_data. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Remove alias ptrs in __receive_buf()Peter Hurley2013-07-231-7/+6
| | | | | | | | The char and flag buffer local alias pointers, p and f, are unnecessary; remove them. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Fix EOF push handlingPeter Hurley2013-07-231-17/+17
| | | | | | | | | | | | | | | | | | | | In canonical mode, an EOF which is not the first character of the line causes read() to complete and return the number of characters read so far (commonly referred to as EOF push). However, if the previous read() returned because the user buffer was full _and_ the next character is an EOF not at the beginning of the line, read() must not return 0, thus mistakenly indicating the end-of-file condition. The TTY_PUSH flag is used to indicate an EOF was received which is not at the beginning of the line. Because the EOF push condition is evaluated by a thread other than the read(), multiple EOF pushes can cause a premature end-of-file to be indicated. Instead, discover the 'EOF push as first read character' condition from the read() thread itself, and restart the i/o loop if detected. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Avoid false-sharing echo buffer indicesPeter Hurley2013-07-231-5/+4
| | | | | | | | | Separate the head & commit indices from the tail index to avoid cache-line contention (so called 'false-sharing') between concurrent threads. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Eliminate counter in __process_echoesPeter Hurley2013-07-231-8/+1
| | | | | | | | | Since neither echo_commit nor echo_tail can change for the duration of __process_echoes loop, substitute index comparison for the snapshot counter. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Only flush echo output if actually outputPeter Hurley2013-07-231-8/+10
| | | | | | | | Don't have the driver flush received echoes if no echoes were actually output. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Process echoes in blocksPeter Hurley2013-07-231-23/+47
| | | | | | | | | | | | | | | Byte-by-byte echo output is painfully slow, requiring a lock/unlock cycle for every input byte. Instead, perform the echo output in blocks of 256 characters, and at least once per flip buffer receive. Enough space is reserved in the echo buffer to guarantee a full block can be saved without overrunning the echo output. Overrun is prevented by discarding the oldest echoes until enough space exists in the echo buffer to receive at least a full block of new echoes. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Eliminate echo_commit memory barrierPeter Hurley2013-07-231-11/+20
| | | | | | | Use output_lock mutex as a memory barrier when storing echo_commit. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Remove echo_lockPeter Hurley2013-07-231-47/+28
| | | | | | | | | | | | | | | | | Adding data to echo_buf (via add_echo_byte()) is guaranteed to be single-threaded, since all callers are from the n_tty_receive_buf() path. Processing the echo_buf can be called from either the n_tty_receive_buf() path or the n_tty_write() path; however, these callers are already serialized by output_lock. Publish cumulative echo_head changes to echo_commit; process echo_buf from echo_tail to echo_commit; remove echo_lock. On echo_buf overrun, claim output_lock to serialize changes to echo_tail. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Replace echo_cnt with computed valuePeter Hurley2013-07-231-13/+7
| | | | | | | | Prepare for lockless echo_buf handling; compute current byte count of echo_buf from head and tail indices. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Use separate head and tail indices for echo_bufPeter Hurley2013-07-231-53/+35
| | | | | | | | | | | Instead of using a single index to track the current echo_buf position, use a head index when adding to the buffer and a tail index when consuming from the buffer. Allow these head and tail indices to wrap at max representable value; perform modulo reduction via helper functions when accessing the buffer. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Remove unused echo_overrun fieldPeter Hurley2013-07-231-7/+1
| | | | | | | The echo_overrun field is only assigned and never tested; remove it. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Queue buffer work on any available cpuPeter Hurley2013-07-231-1/+1
| | | | | | | | | Scheduling buffer work on the same cpu as the read() thread limits the parallelism now possible between the receive_buf path and the n_tty_read() path. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Special case pty flow controlPeter Hurley2013-07-231-0/+14
| | | | | | | | | | | | | | | The pty driver forces ldisc flow control on, regardless of available receive buffer space, so the writer can be woken whenever unthrottle is called. However, this 'forced throttle' has performance consequences, as multiple atomic operations are necessary to unthrottle and perform the write wakeup for every input line (in canonical mode). Instead, short-circuit the unthrottle if the tty is a pty and perform the write wakeup directly. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Move n_tty_write_wakeup() to avoid forward declarationPeter Hurley2013-07-231-16/+15
| | | | | | | Prepare to special case pty flow control; avoid forward declaration. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Factor throttle/unthrottle into helper functionsPeter Hurley2013-07-231-35/+46
| | | | | | | | Prepare for special handling of pty throttle/unthrottle; factor flow control into helper functions. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Move chars_in_buffer() to factor throttle/unthrottlePeter Hurley2013-07-231-12/+12
| | | | | | | | Prepare to factor throttle and unthrottle into helper functions; relocate chars_in_buffer() to avoid forward declaration. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: Only guarantee termios read safety for throttle/unthrottlePeter Hurley2013-07-231-4/+0
| | | | | | | | | | | No tty driver modifies termios during throttle() or unthrottle(). Therefore, only read safety is required. However, tty_throttle_safe and tty_unthrottle_safe must still be mutually exclusive; introduce throttle_mutex for that purpose. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Separate buffer indices to prevent cache-line sharingPeter Hurley2013-07-231-6/+15
| | | | | | | | | | | If the read buffer indices are in the same cache-line, cpus will contended over the cache-line (so called 'false sharing'). Separate the producer-published fields from the consumer-published fields; document the locks relevant to each field. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Don't wait for buffer work in read() loopPeter Hurley2013-07-231-1/+0
| | | | | | | | User-space read() can run concurrently with receiving from device; waiting for receive_buf() to complete is not required. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Fix type mismatches in receive_buf raw copyPeter Hurley2013-07-231-14/+17
| | | | | Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* n_tty: Reset lnext if canonical mode changesPeter Hurley2013-07-231-0/+1
| | | | | | | | | | | | | lnext escapes the next input character as a literal, and must be reset when canonical mode changes (to avoid misinterpreting a special character as a literal if canonical mode is changed back again). lnext is specifically not reset on a buffer flush so as to avoid misinterpreting the next input character as a special character. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
OpenPOWER on IntegriCloud