1. 07 3月, 2015 11 次提交
  2. 12 2月, 2015 2 次提交
    • M
      oom, PM: make OOM detection in the freezer path raceless · c32b3cbe
      Michal Hocko 提交于
      Commit 5695be14 ("OOM, PM: OOM killed task shouldn't escape PM
      suspend") has left a race window when OOM killer manages to
      note_oom_kill after freeze_processes checks the counter.  The race
      window is quite small and really unlikely and partial solution deemed
      sufficient at the time of submission.
      
      Tejun wasn't happy about this partial solution though and insisted on a
      full solution.  That requires the full OOM and freezer's task freezing
      exclusion, though.  This is done by this patch which introduces oom_sem
      RW lock and turns oom_killer_disable() into a full OOM barrier.
      
      oom_killer_disabled check is moved from the allocation path to the OOM
      level and we take oom_sem for reading for both the check and the whole
      OOM invocation.
      
      oom_killer_disable() takes oom_sem for writing so it waits for all
      currently running OOM killer invocations.  Then it disable all the further
      OOMs by setting oom_killer_disabled and checks for any oom victims.
      Victims are counted via mark_tsk_oom_victim resp.  unmark_oom_victim.  The
      last victim wakes up all waiters enqueued by oom_killer_disable().
      Therefore this function acts as the full OOM barrier.
      
      The page fault path is covered now as well although it was assumed to be
      safe before.  As per Tejun, "We used to have freezing points deep in file
      system code which may be reacheable from page fault." so it would be
      better and more robust to not rely on freezing points here.  Same applies
      to the memcg OOM killer.
      
      out_of_memory tells the caller whether the OOM was allowed to trigger and
      the callers are supposed to handle the situation.  The page allocation
      path simply fails the allocation same as before.  The page fault path will
      retry the fault (more on that later) and Sysrq OOM trigger will simply
      complain to the log.
      
      Normally there wouldn't be any unfrozen user tasks after
      try_to_freeze_tasks so the function will not block. But if there was an
      OOM killer racing with try_to_freeze_tasks and the OOM victim didn't
      finish yet then we have to wait for it. This should complete in a finite
      time, though, because
      
      	- the victim cannot loop in the page fault handler (it would die
      	  on the way out from the exception)
      	- it cannot loop in the page allocator because all the further
      	  allocation would fail and __GFP_NOFAIL allocations are not
      	  acceptable at this stage
      	- it shouldn't be blocked on any locks held by frozen tasks
      	  (try_to_freeze expects lockless context) and kernel threads and
      	  work queues are not frozen yet
      Signed-off-by: NMichal Hocko <mhocko@suse.cz>
      Suggested-by: NTejun Heo <tj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      c32b3cbe
    • M
      sysrq: convert printk to pr_* equivalent · 401e4a7c
      Michal Hocko 提交于
      While touching this area let's convert printk to pr_*.  This also makes
      the printing of continuation lines done properly.
      Signed-off-by: NMichal Hocko <mhocko@suse.cz>
      Acked-by: NTejun Heo <tj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      401e4a7c
  3. 07 2月, 2015 2 次提交
  4. 04 2月, 2015 2 次提交
  5. 03 2月, 2015 23 次提交
    • M
      serial: samsung: earlycon support depends on CONFIG_SERIAL_SAMSUNG_CONSOLE · c3bda295
      Marek Szyprowski 提交于
      EarlyCon support depends on serial console infrastructure, so the code
      implementing it should depend on CONFIG_SERIAL_SAMSUNG_CONSOLE.
      
      This patch fixes the following build break:
      CC [M]  drivers/tty/serial/samsung.o
      drivers/tty/serial/samsung.c:2468:1: error: expected declaration specifiers or ‘...’ before string constant
      drivers/tty/serial/samsung.c:2468:1: error: expected declaration specifiers or ‘...’ before ‘s3c2410_setup_earlycon’
      drivers/tty/serial/samsung.c:2487:1: error: expected declaration specifiers or ‘...’ before string constant
      drivers/tty/serial/samsung.c:2487:1: error: expected declaration specifiers or ‘...’ before ‘s3c2412_setup_earlycon’
      drivers/tty/serial/samsung.c:2488:1: error: expected declaration specifiers or ‘...’ before string constant
      drivers/tty/serial/samsung.c:2488:1: error: expected declaration specifiers or ‘...’ before ‘s3c2440_setup_earlycon’
      drivers/tty/serial/samsung.c:2489:1: error: expected declaration specifiers or ‘...’ before string constant
      drivers/tty/serial/samsung.c:2489:1: error: expected declaration specifiers or ‘...’ before ‘s3c6400_setup_earlycon’
      drivers/tty/serial/samsung.c:2506:1: error: expected declaration specifiers or ‘...’ before string constant
      drivers/tty/serial/samsung.c:2506:1: error: expected declaration specifiers or ‘...’ before ‘s5pv210_setup_earlycon’
      drivers/tty/serial/samsung.c:2507:1: error: expected declaration specifiers or ‘...’ before string constant
      drivers/tty/serial/samsung.c:2507:1: error: expected declaration specifiers or ‘...’ before ‘exynos4210_setup_earlycon’
      drivers/tty/serial/samsung.c:2468:1: warning: ‘s3c2410_setup_earlycon’ defined but not used [-Wunused-function]
      drivers/tty/serial/samsung.c:2487:1: warning: ‘s3c2412_setup_earlycon’ defined but not used [-Wunused-function]
      drivers/tty/serial/samsung.c:2488:1: warning: ‘s3c2440_setup_earlycon’ defined but not used [-Wunused-function]
      drivers/tty/serial/samsung.c:2489:1: warning: ‘s3c6400_setup_earlycon’ defined but not used [-Wunused-function]
      drivers/tty/serial/samsung.c:2506:1: warning: ‘s5pv210_setup_earlycon’ defined but not used [-Wunused-function]
      drivers/tty/serial/samsung.c:2507:1: warning: ‘exynos4210_setup_earlycon’ defined but not used [-Wunused-function]
      make[3]: *** [drivers/tty/serial/samsung.o] Error 1
      Reported-by: Nkbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c3bda295
    • K
      tty/serial: serial8250_set_divisor() can be static · eb1527a8
      kbuild test robot 提交于
      drivers/tty/serial/8250/8250_core.c:2503:6: sparse: symbol 'serial8250_set_divisor' was not declared. Should it be static?
      Signed-off-by: NFengguang Wu <fengguang.wu@intel.com>
      Cc: Peter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eb1527a8
    • C
      tty/serial: Add Spreadtrum sc9836-uart driver support · b7396a38
      Chunyan Zhang 提交于
      Add a full sc9836-uart driver for SC9836 SoC which is based on the
      spreadtrum sharkl64 platform.
      This driver also support earlycon.
      Originally-by: NLanqing Liu <lanqing.liu@spreadtrum.com>
      Signed-off-by: NOrson Zhai <orson.zhai@spreadtrum.com>
      Signed-off-by: NChunyan Zhang <chunyan.zhang@spreadtrum.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Reviewed-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b7396a38
    • R
      serial: samsung: remove redundant interrupt enabling · ba019a3e
      Robert Baldyga 提交于
      Function s3c24xx_serial_start_tx_pio() enables interrupts if needed,
      so we don't have to (or even we shouldn't) enable them before.
      Signed-off-by: NRobert Baldyga <r.baldyga@samsung.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ba019a3e
    • P
      tty: Remove external interface for tty_set_termios() · 632f32e2
      Peter Hurley 提交于
      tty_set_termios() is an internal helper intended for file scope use.
      
      UART drivers which are capable of driving the RTS pin must
      properly handle the tiocmset() method, regardless of termios settings.
      A failure to do so is a UART driver bug and should be fixed there.
      Do not use this interface to workaround UART driver bugs.
      
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Cc: <linux-bluetooth@vger.kernel.org>
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Acked-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      632f32e2
    • P
      serial: omap: Fix RTS handling · 348f9bb3
      Peter Hurley 提交于
      The OMAP UART ignores MCR[1] (ie., RTS) when in autoRTS mode. This
      makes it impossible for either the serial core or userspace to
      manually flow control the sender.
      
      Disable autoRTS mode when RTS is lowered and restore the previous
      mode when RTS is raised.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      348f9bb3
    • P
      serial: 8250_omap: Use UPSTAT_AUTORTS for RTS handling · 9719acce
      Peter Hurley 提交于
      Commit 88838d3112702 ("serial: omap_8250: Fix RTS handling") fixed
      RTS pin control when in autoRTS mode.
      
      New support added in "serial: core: Rework hw-assisted flow control support"
      enables a much simpler approach; rather than masking out autoRTS
      whenever writing the EFR register, use the UPSTAT_* mode to determine if
      autoRTS should be enabled when raising RTS (in omap8250_set_mctrl()).
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9719acce
    • P
      serial: core: Rework hw-assisted flow control support · 391f93f2
      Peter Hurley 提交于
      hw-assisted flow control support was added to the serial core
      in v3.8 with commits,
      dba05832 ("SERIAL: core: add hardware assisted h/w flow control support")
      2cbacafd ("SERIAL: core: add hardware assisted s/w flow control support")
      9aba8d5b ("SERIAL: core: add throttle/unthrottle callbacks for hardware
                      assisted flow control")
      Since then, additional requirements for serial core support have arisen.
      Specifically,
      1. Separate tx and rx flow control settings for UARTs which only support
         tx flow control (ie., autoCTS).
      2. Disable sw-assisted CTS flow control in autoCTS mode
      3. Support for RTS flow control by serial core and userspace in autoRTS mode
      
      Distinguish mode from capability; introduce UPSTAT_AUTORTS, UPSTAT_AUTOCTS
      and UPSTAT_AUTOXOFF which, when set by the uart driver, enable serial core
      support for hw-assisted rx, hw-assisted tx and hw-assisted in-band/IXOFF
      rx flow control, respectively. [Note: hw-assisted in-band/IXON tx flow
      control does not require serial core support/intervention and can be
      enabled by the uart driver when required.]
      
      These modes must be set/reset in the driver's set_termios() method, based
      on termios settings, and thus can be safely queried in any context in which
      one of the port lock, port mutex or termios rwsem are held. Set these modes
      in the 2 in-tree drivers, omap-serial and 8250_omap, which currently
      use UPF_HARD_FLOW/UPF_SOFT_FLOW support.
      
      Retain UPF_HARD_FLOW and UPF_SOFT_FLOW as capabilities; re-define
      UPF_HARD_FLOW as both UPF_AUTO_RTS and UPF_AUTO_CTS to allow for distinct
      and separate rx and tx flow control capabilities.
      
      Disable sw-assisted CTS flow control when UPSTAT_AUTOCTS is enabled.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      391f93f2
    • R
      tty/serial: 8250_early: Add support for PXA UARTs · a4c639b0
      Rob Herring 提交于
      The PXA variant of the 8250 UART adds a UART enable bit which must not
      be cleared. Make the earlycon support maintain this bit if it is set.
      This implies some initialization of the UART, but we cannot
      unconditionally set the bit as some other variants require this bit to
      be clear for other functions.
      Signed-off-by: NRob Herring <robh@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: linux-serial@vger.kernel.org
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a4c639b0
    • R
      tty/serial: of_serial: add support for PXA/MMP uarts · 6ad991b6
      Rob Herring 提交于
      Add mrvl,pxa-uart and mrvl,mmp-uart compatible strings for the of_serial
      driver. These are 8250 variants which have a port type of PORT_XSCALE.
      
      There is also the serial driver pxa.c with these compatible strings
      already. However, it can be replaced with the common 8250 driver. It has
      some issues like it cannot coexist with the 8250 driver due to tty name
      collision. That also means adding these compatible strings here should
      not case a problem.
      Signed-off-by: NRob Herring <robh@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: linux-serial@vger.kernel.org
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ad991b6
    • R
      tty/serial: of_serial: add DT alias ID handling · 6d01bb9d
      Rob Herring 提交于
      Add support for alias parsing from the DT. This allows for consistent
      tty numbering.
      Signed-off-by: NRob Herring <robh@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: linux-serial@vger.kernel.org
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6d01bb9d
    • P
      serial: 8250: Prevent concurrent updates to shadow registers · e9cef862
      Peter Hurley 提交于
      The port shadow registers, ->fcr and ->mcr, must be protected from
      concurrent updates. Relocate the shadow register updates in
      serial8250_do_set_termios() to the port lock critical section.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e9cef862
    • P
      serial: 8250: Use canary to restart console after suspend · 4516d50a
      Peter Hurley 提交于
      When using no_console_suspend, the serial console may be powered off
      anyway during system sleep. Upon resume, the port may be in its default
      power-on state, but is expected to continue console i/o before the device
      has received its pm callback. The resultant garbage i/o can cause all
      kinds of havoc on the remote end.
      
      Use the scratch register as a canary to discover if the console
      has been powered-off. Write a non-zero value to the scratch register
      at port suspend and reprogram the port before any console i/o if the
      scratch register != canary before port resume.
      
      This workaround is disabled for omap_8250 (which uses different divisor
      programming).
      
      Credit to Doug Anderson <dianders@chromium.org> for the idea of using
      the scratch register canary to discover port power-down.
      
      Cc: Doug Anderson <dianders@chromium.org>
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4516d50a
    • P
      serial: 8250: Refactor XR17V35X divisor calculation · 06a4c710
      Peter Hurley 提交于
      Exar XR17V35X PCIe uarts support a 4-bit fractional divisor register.
      Refactor the divisor calculation from the divisor programming.
      
      Allow a fractional result from serial8250_get_divisor() and pass this
      result to serial8250_dl_write().
      
      Simplify the calculation for quot and quot_frac. This was verified
      to be identical to the results of the original calculation with a test
      jig.
      
      NB: The results were also compared with the divisor value chart
      on pg 33 of the Exar XR17V352 datasheet, rev 1.0.3, here:
      http://www.exar.com/common/content/document.ashx?id=1585
      which differs from the calculated values by 1 in the fractional result.
      This is because the calculated values are still rounded in the
      fractional result, whereas the table values are truncated. Note
      that the data error rate % values in the datasheet are for
      rounded fractional results, as the truncated fractional results
      have more error.
      
      Cc: Joe Schultz <jschultz@xes-inc.com>
      Cc: Aaron Sierra <asierra@xes-inc.com>
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      06a4c710
    • P
      serial: 8250: Refactor divisor programming · e72abd5d
      Peter Hurley 提交于
      Refactor divisor register programming into a new function,
      serial8250_set_divisor; this allows serial console to reinitialize
      early after resume from suspend.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e72abd5d
    • P
      serial: 8250: Refactor LCR computation · 0ec3f585
      Peter Hurley 提交于
      Refactor the computation of the LCR register value from termios c_cflag
      into a new local function, serial8250_compute_lcr().
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0ec3f585
    • P
      serial: 8250: Move UART_BUG_QUOT workaround · d1f2f219
      Peter Hurley 提交于
      The UART_BUG_QUOT workaround adjusts the divisor computed from the
      baud rate by serial8250_get_divisor(). Move the workaround into
      serial8250_get_divisor(), so that divisor-from-baud computation
      is encapsulated.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1f2f219
    • J
      tty: serial: men_z135_uart: Fix driver for changes in hardware · 01ba8d6a
      Johannes Thumshirn 提交于
      16z135 IP Core has changed so the driver needs to be updated to respect
      these changes. The following changes have been made:
      
      * Don't invert the 16z135 modem status register when reading.
      * Add module parameter to configure the (baud rate dependent) RX timeout.
        Character timeout in seconds = (timeout_reg * baud_reg * 4)/freq_reg.
      * Enable the handling of UART core's automatic flow control feature.
        When AFE is active disable generation of modem status IRQs.
      * Rework the handling of IRQs to be conform with newer FPGA versions and
        take precautions not to miss an interrupt because of the destructive read
        of the IIR register.
      * Correct men_z135_handle_modem_status(), MSR is stat_reg[15:8] not
        stat_reg[7:0]
      * Correct calling of uart_handle_{dcd,cts}_change()
      * Reset CLOCAL when CRTSCTS is set
      Signed-off-by: NJohannes Thumshirn <johannes.thumshirn@men.de>
      Reviewed-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      01ba8d6a
    • P
      serial: core: Simplify console suspend logic in uart_suspend_port() · b164c972
      Peter Hurley 提交于
      When the uart port being suspended is a console and consoles are
      not suspending (kernel command line contains no_console_suspend),
      then no action is performed for that port, and the function can
      return early.
      
      If the function has not returned early, then one of the conditions
      is not true, so the expression
         (console_suspend_enabled || !uart_console(uport))
      must be true and can be eliminated.
      
      Similarly, the expression
         (console_suspend_enabled && uart_console(uport))
      simplifies to just uart_console(uport).
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b164c972
    • P
      n_tty: Fix signal handling flushes · d2b6f447
      Peter Hurley 提交于
      BRKINT and ISIG requires input and output flush when a signal char
      is received. However, the order of operations is significant since
      parallel i/o may be ongoing.
      
      Merge the signal handling for BRKINT with ISIG handling.
      
      Process the signal first. This ensures any ongoing i/o is aborted;
      without this, a waiting writer may continue writing after the flush
      occurs and after the signal char has been echoed.
      
      Write lock the termios_rwsem, which excludes parallel writers from
      pushing new i/o until after the output buffers are flushed; claiming
      the write lock is necessary anyway to exclude parallel readers while
      the read buffer is flushed.
      
      Subclass the termios_rwsem for ptys since the slave pty performing
      the flush may appear to reorder the termios_rwsem->tty buffer lock
      lock order; adding annotation clarifies that
        slave tty_buffer lock-> slave termios_rwsem -> master tty_buffer lock
      is a valid lock order.
      
      Flush the echo buffer. In this context, the echo buffer is 'output'.
      Otherwise, the output will appear discontinuous because the output buffer
      was cleared which contains older output than the echo buffer.
      
      Open-code the read buffer flush since the input worker does not need
      kicking (this is the input worker).
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d2b6f447
    • P
      pty: Fix buffer flush deadlock · 1d1d14da
      Peter Hurley 提交于
      The pty driver does not clear its write buffer when commanded.
      This is to avoid an apparent deadlock between parallel flushes from
      both pty ends; specifically when handling either BRK or INTR input.
      However, parallel flushes from this source is not possible since
      the pty master can never be set to BRKINT or ISIG. Parallel flushes
      from other sources are possible but these do not threaten deadlocks.
      
      Annotate the tty buffer mutex for lockdep to represent the nested
      tty_buffer locking which occurs when the pty slave is processing input
      (its buffer mutex held) and receives INTR or BRK and acquires the
      linked tty buffer mutex via tty_buffer_flush().
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1d1d14da
    • P
      tty: Make lock subclasses available for other tty locks · 3abf87cd
      Peter Hurley 提交于
      Besides nested legacy_mutex locking which is required on pty pair
      teardown, other nested pty operations require lock subclassing.
      
      Move lock subclass definition to tty interface header, include/linux/tty.h,
      and document its use.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3abf87cd
    • P
      n_tty: Fix read buffer overwrite when no newline · fb5ef9e7
      Peter Hurley 提交于
      In canon mode, the read buffer head will advance over the buffer tail
      if the input > 4095 bytes without receiving a line termination char.
      
      Discard additional input until a line termination is received.
      Before evaluating for overflow, the 'room' value is normalized for
      I_PARMRK and 1 byte is reserved for line termination (even in !icanon
      mode, in case the mode is switched). The following table shows the
      transform:
      
       actual buffer |  'room' value before overflow calc
        space avail  |    !I_PARMRK    |    I_PARMRK
       --------------------------------------------------
            0        |       -1        |       -1
            1        |        0        |        0
            2        |        1        |        0
            3        |        2        |        0
            4+       |        3        |        1
      
      When !icanon or when icanon and the read buffer contains newlines,
      normalized 'room' values of -1 and 0 are clamped to 0, and
      'overflow' is 0, so read_head is not adjusted and the input i/o loop
      exits (setting no_room if called from flush_to_ldisc()). No input
      is discarded since the reader does have input available to read
      which ensures forward progress.
      
      When icanon and the read buffer does not contain newlines and the
      normalized 'room' value is 0, then overflow and room are reset to 1,
      so that the i/o loop will process the next input char normally
      (except for parity errors which are ignored). Thus, erasures, signalling
      chars, 7-bit mode, etc. will continue to be handled properly.
      
      If the input char processed was not a line termination char, then
      the canon_head index will not have advanced, so the normalized 'room'
      value will now be -1 and 'overflow' will be set, which indicates the
      read_head can safely be reset, effectively erasing the last char
      processed.
      
      If the input char processed was a line termination, then the
      canon_head index will have advanced, so 'overflow' is cleared to 0,
      the read_head is not reset, and 'room' is cleared to 0, which exits
      the i/o loop (because the reader now have input available to read
      which ensures forward progress).
      
      Note that it is possible for a line termination to be received, and
      for the reader to copy the line to the user buffer before the
      input i/o loop is ready to process the next input char. This is
      why the i/o loop recomputes the room/overflow state with every
      input char while handling overflow.
      
      Finally, if the input data was processed without receiving
      a line termination (so that overflow is still set), the pty
      driver must receive a write wakeup. A pty writer may be waiting
      to write more data in n_tty_write() but without unthrottling
      here that wakeup will not arrive, and forward progress will halt.
      (Normally, the pty writer is woken when the reader reads data out
      of the buffer and more space become available).
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fb5ef9e7