26 Oct, 2011

1 commit

  • * 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (79 commits)
    TTY: serial_core: Fix crash if DCD drop during suspend
    tty/serial: atmel_serial: bootconsole removed from auto-enumerates
    Revert "TTY: call tty_driver_lookup_tty unconditionally"
    tty/serial: atmel_serial: add device tree support
    tty/serial: atmel_serial: auto-enumerate ports
    tty/serial: atmel_serial: whitespace and braces modifications
    tty/serial: atmel_serial: change platform_data variable name
    tty/serial: RS485 bindings for device tree
    TTY: call tty_driver_lookup_tty unconditionally
    TTY: pty, release tty in all ptmx_open fail paths
    TTY: make tty_add_file non-failing
    TTY: drop driver reference in tty_open fail path
    8250_pci: Fix kernel panic when pch_uart is disabled
    h8300: drivers/serial/Kconfig was moved
    parport_pc: release IO region properly if unsupported ITE887x card is found
    tty: Support compat_ioctl get/set termios_locked
    hvc_console: display printk messages on console.
    TTY: snyclinkmp: forever loop in tx_load_dma_buffer()
    tty/n_gsm: avoid fifo overflow in gsm_dlci_data_output
    tty/n_gsm: fix a bug in gsm_dlci_data_output (adaption = 2 case)
    ...

    Fix up Conflicts in:
    - drivers/tty/serial/8250_pci.c
    Trivial conflict with removed duplicate device ID
    - drivers/tty/serial/atmel_serial.c
    Annoying silly conflict between "specify the port num via
    platform_data" and other changes to atmel_console_init

    Linus Torvalds
     

19 Oct, 2011

2 commits

  • If tty_add_file fails at the point it is now, we have to revert all
    the changes we did to the tty. It means either decrease all refcounts
    if this was a tty reopen or delete the tty if it was newly allocated.

    There was a try to fix this in v3.0-rc2 using tty_release in 0259894c7
    (TTY: fix fail path in tty_open). But instead it introduced a NULL
    dereference. It's because tty_release dereferences
    filp->private_data, but that one is set even in our tty_add_file. And
    when tty_add_file fails, it's still NULL/garbage. Hence tty_release
    cannot be called there.

    To circumvent the original leak (and the current NULL deref) we split
    tty_add_file into two functions, making the latter non-failing. In
    that case we may do the former early in open, where handling failures
    is easy. The latter stays as it is now. So there is no change in
    functionality.

    The original bug (leak) was introduced by f573bd176 (tty: Remove
    __GFP_NOFAIL from tty_add_file()). Thanks Dan for reporting this.

    Later, we may split tty_release into more functions and call only some
    of them in this fail path instead. (If at all possible.)

    Introduced-in: v2.6.37-rc2
    Signed-off-by: Jiri Slaby
    Reported-by: Dan Carpenter
    Cc: stable
    Cc: Alan Cox
    Cc: Pekka Enberg
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     
  • When running a Fedora 15 (x86) on an x86_64 kernel, in the boot process
    plymouthd complains about those two missing ioctls:
    [ 2.581783] ioctl32(plymouthd:186): Unknown cmd fd(10) cmd(00005457){t:'T';sz:0} arg(ffb6a5d0) on /dev/tty1
    [ 2.581803] ioctl32(plymouthd:186): Unknown cmd fd(10) cmd(00005456){t:'T';sz:0} arg(ffb6a680) on /dev/tty1

    both ioctl functions work on the 'struct termios' resp. 'struct termios2',
    which has the same size (36 bytes resp. 44 bytes) on x86 and x86_64,
    so it's just a matter of converting the pointer from userland.

    Signed-off-by: Thomas Meyer
    Cc: Arnd Bergmann
    Cc: Alan Cox
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Thomas Meyer
     

26 Aug, 2011

1 commit

  • We need this helper to fix system stalls. The issue is that the rest
    of the system TTYs wait for us to finish waiting. This wasn't an issue
    with BKL. BKL used to unlock implicitly.

    This is based on the Arnd suggestion.

    Signed-off-by: Jiri Slaby
    Acked-by: Arnd Bergmann
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     

24 Aug, 2011

2 commits

  • We used it really only serial and ami_serial. The rest of the
    callsites were BUG/WARN_ONs to check if BTM is held. Now that we
    pruned tty_locked from both of the real users, we can get rid of
    tty_lock along with __big_tty_mutex_owner.

    Signed-off-by: Jiri Slaby
    Acked-by: Arnd Bergmann
    Cc: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     
  • tty_operations->remove is normally called like:
    queue_release_one_tty
    ->tty_shutdown
    ->tty_driver_remove_tty
    ->tty_operations->remove

    However tty_shutdown() is called from queue_release_one_tty() only if
    tty_operations->shutdown is NULL. But for pty, it is not.
    pty_unix98_shutdown() is used there as ->shutdown.

    So tty_operations->remove of pty (i.e. pty_unix98_remove()) is never
    called. This results in invalid pty_count. I.e. what can be seen in
    /proc/sys/kernel/pty/nr.

    I see this was already reported at:
    https://lkml.org/lkml/2009/11/5/370
    But it was not fixed since then.

    This patch is kind of a hackish way. The problem lies in ->install. We
    allocate there another tty (so-called tty->link). So ->install is
    called once, but ->remove twice, for both tty and tty->link. The fix
    here is to count both tty and tty->link and divide the count by 2 for
    user.

    And to have ->remove called, let's make tty_driver_remove_tty() global
    and call that from pty_unix98_shutdown() (tty_operations->shutdown).

    While at it, let's document that when ->shutdown is defined,
    tty_shutdown() is not called.

    Signed-off-by: Jiri Slaby
    Cc: Alan Cox
    Cc: "H. Peter Anvin"
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     

08 Jun, 2011

1 commit

  • Since commit (4564f9e5: consolidate line discipline number definitions)
    the patch moved all line discipline number from a per-architecture termios.h
    to a shared one: tty.h. However, prior to this consolidation work, the
    line discipline numbers were outside of an ifdef __KERNEL__/endif block
    so these numbers used to be exported to user-space.

    Since such numbers are kernel ABI anyway, and tty.h is already included
    for user- space header processing, just move these relevant defines
    outside of the ifdef __KERNEL__/endif block in include/linux/tty.h.

    CC: Maxime Bizon
    Signed-off-by: Florian Fainelli
    Acked-by: Tilman Schmidt
    Signed-off-by: Greg Kroah-Hartman

    Florian Fainelli
     

14 May, 2011

1 commit

  • The n_tracerouter and n_tracesink line discpline drivers use the
    Linux tty line discpline framework to route trace data coming
    from a tty port (say UART for example) to the trace sink line
    discipline driver and to another tty port(say USB). Those
    these two line discipline drivers can be used together,
    independently from pti.c, they are part of the original
    implementation solution of the MIPI P1149.7, compact JTAG, PTI
    solution for Intel mobile platforms starting with the
    Medfield platform.

    Signed-off-by: J Freyensee
    Signed-off-by: Greg Kroah-Hartman

    J Freyensee
     

20 Apr, 2011

1 commit

  • Introduce deinitialize_tty_struct which should be called after
    initialize_tty_struct and before successfull tty_ldisc_setup.

    It calls tty_ldisc_deinit which is opposite of tty_ldisc_init. It only
    puts a reference to ldisc and assigns NULL to tty->ldisc.

    It will be used to shut down ldisc when tty_release cannot be called
    yet.

    Signed-off-by: Jiri Slaby
    Cc: Alan Cox
    Cc: Julian Anastasov
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     

23 Mar, 2011

1 commit

  • Using delayed-work for tty flip buffers ends up causing us to wait for
    the next tick to complete some actions. That's usually not all that
    noticeable, but for certain latency-critical workloads it ends up being
    totally unacceptable.

    As an extreme case of this, passing a token back-and-forth over a pty
    will take two ticks per iteration, so even just a thousand iterations
    will take 8 seconds assuming a common 250Hz configuration.

    Avoiding the whole delayed work issue brings that ping-pong test-case
    down to 0.009s on my machine.

    In more practical terms, this latency has been a performance problem for
    things like dive computer simulators (simulating the serial interface
    using the ptys) and for other environments (Alan mentions a CP/M emulator).

    Reported-by: Jef Driesen
    Acked-by: Greg KH
    Acked-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

18 Feb, 2011

3 commits


03 Dec, 2010

1 commit


30 Nov, 2010

1 commit

  • Like in the "TTY: don't allow reopen when ldisc is changing" patch,
    this one fixes a TTY WARNING as described in the option 1) there:
    1) __tty_hangup from tty_ldisc_hangup to tty_ldisc_enable. During this
    section tty_lock is held. However tty_lock is temporarily dropped in
    the middle of the function by tty_ldisc_hangup.

    The fix is to introduce a new flag which we set during the unlocked
    window and check it in tty_reopen too. The flag is TTY_HUPPING and is
    cleared after TTY_HUPPED is set.

    While at it, remove duplicate TTY_HUPPED set_bit. The one after
    calling ops->hangup seems to be more correct. But anyway, we hold
    tty_lock, so there should be no difference.

    Also document the function it does that kind of crap.

    Nicely reproducible with two forked children:
    static void do_work(const char *tty)
    {
    if (signal(SIGHUP, SIG_IGN) == SIG_ERR) exit(1);
    setsid();
    while (1) {
    int fd = open(tty, O_RDWR|O_NOCTTY);
    if (fd < 0) continue;
    if (ioctl(fd, TIOCSCTTY)) continue;
    if (vhangup()) continue;
    close(fd);
    }
    exit(0);
    }

    Signed-off-by: Jiri Slaby
    Reported-by:
    Reported-by: Kyle McMartin
    Cc: Alan Cox
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     

18 Nov, 2010

1 commit


10 Nov, 2010

1 commit


30 Oct, 2010

1 commit

  • While auditing all tasklist_lock read_lock sites I stumbled over the
    following call chain:

    audit_prepare_user_tty()
    read_lock(&tasklist_lock);
    tty_audit_push_task();
    mutex_lock(&buf->mutex);

    --> buf->mutex is locked with preemption disabled.

    Solve this by acquiring a reference to the task struct under
    rcu_read_lock and call tty_audit_push_task outside of the preempt
    disabled region.

    Move all code which needs to be protected by sighand lock into
    tty_audit_push_task() and use lock/unlock_sighand as we do not hold
    tasklist_lock.

    Signed-off-by: Thomas Gleixner
    Cc: Al Viro
    Cc: Eric Paris
    Cc: Oleg Nesterov
    Signed-off-by: Al Viro

    Thomas Gleixner
     

29 Oct, 2010

1 commit


23 Oct, 2010

2 commits


06 Oct, 2010

1 commit

  • Texas Instrument's WiLink7 connectivity devices pack wireless connectivity
    technologies like Bluetooth, FM Radio Receiver and Transmitter, GPS and WLAN
    into a single die.
    The BT, FM and GPS core on the chip are interfaced to application
    processors via a single UART.

    This line discipline driver allows such different technologies to be used
    simultaneous and independent of each other.
    Signed-off-by: Pavan Savoy
    Signed-off-by: Greg Kroah-Hartman

    Pavan Savoy
     

18 Aug, 2010

2 commits

  • tty: fix fu_list abuse

    tty code abuses fu_list, which causes a bug in remount,ro handling.

    If a tty device node is opened on a filesystem, then the last link to the inode
    removed, the filesystem will be allowed to be remounted readonly. This is
    because fs_may_remount_ro does not find the 0 link tty inode on the file sb
    list (because the tty code incorrectly removed it to use for its own purpose).
    This can result in a filesystem with errors after it is marked "clean".

    Taking idea from Christoph's initial patch, allocate a tty private struct
    at file->private_data and put our required list fields in there, linking
    file and tty. This makes tty nodes behave the same way as other device nodes
    and avoid meddling with the vfs, and avoids this bug.

    The error handling is not trivial in the tty code, so for this bugfix, I take
    the simple approach of using __GFP_NOFAIL and don't worry about memory errors.
    This is not a problem because our allocator doesn't fail small allocs as a rule
    anyway. So proper error handling is left as an exercise for tty hackers.

    [ Arguably filesystem's device inode would ideally be divorced from the
    driver's pseudo inode when it is opened, but in practice it's not clear whether
    that will ever be worth implementing. ]

    Cc: linux-kernel@vger.kernel.org
    Cc: Christoph Hellwig
    Cc: Alan Cox
    Cc: Greg Kroah-Hartman
    Signed-off-by: Nick Piggin
    Signed-off-by: Al Viro

    Nick Piggin
     
  • fs: cleanup files_lock locking

    Lock tty_files with a new spinlock, tty_files_lock; provide helpers to
    manipulate the per-sb files list; unexport the files_lock spinlock.

    Cc: linux-kernel@vger.kernel.org
    Cc: Christoph Hellwig
    Cc: Alan Cox
    Acked-by: Andi Kleen
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: Nick Piggin
    Signed-off-by: Al Viro

    Nick Piggin
     

11 Aug, 2010

5 commits

  • The tty locking now follows the rules for mutexes, so
    we can replace the BKL usage with a new subsystem
    wide mutex.

    Using a regular mutex here will change the behaviour
    when blocked on the BTM from spinning to sleeping,
    but that should not be visible to the user.

    Using the mutex also means that all the BTM is now
    covered by lockdep.

    Signed-off-by: Arnd Bergmann
    Cc: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • This changes all remaining users of tty_lock_nested
    to be non-recursive, which lets us kill this function.
    As a consequence, we won't need to keep the lock count
    any more, which allows more simplifications later.

    Signed-off-by: Arnd Bergmann
    Cc: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • Calling wait_event_interruptible implicitly
    releases the BKL when it sleeps, but we need
    to do this explcitly when we have converted
    it to a mutex.

    Signed-off-by: Arnd Bergmann
    Cc: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • As a preparation for replacing the big kernel lock
    in the TTY layer, wrap all the callers in new
    macros tty_lock, tty_lock_nested and tty_unlock.

    Signed-off-by: Arnd Bergmann
    Cc: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • This patch is against the 2.6.34 source.

    Paraphrased from the 1989 BSD patch by David Borman @ cray.com:

    These are the changes needed for the kernel to support
    LINEMODE in the server.

    There is a new bit in the termios local flag word, EXTPROC.
    When this bit is set, several aspects of the terminal driver
    are disabled. Input line editing, character echo, and mapping
    of signals are all disabled. This allows the telnetd to turn
    off these functions when in linemode, but still keep track of
    what state the user wants the terminal to be in.

    New ioctl:
    TIOCSIG Generate a signal to processes in the
    current process group of the pty.

    There is a new mode for packet driver, the TIOCPKT_IOCTL bit.
    When packet mode is turned on in the pty, and the EXTPROC bit
    is set, then whenever the state of the pty is changed, the
    next read on the master side of the pty will have the TIOCPKT_IOCTL
    bit set. This allows the process on the server side of the pty
    to know when the state of the terminal has changed; it can then
    issue the appropriate ioctl to retrieve the new state.

    Since the original BSD patches accompanied the source code for telnet
    I've left that reference here, but obviously the feature is useful for
    any remote terminal protocol, including ssh.

    The corresponding feature has existed in the BSD tty driver since 1989.
    For historical reference, a good copy of the relevant files can be found
    here:

    http://anonsvn.mit.edu/viewvc/krb5/trunk/src/appl/telnet/?pathrev=17741

    Signed-off-by: Howard Chu
    Cc: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    hyc@symas.com
     

07 Aug, 2010

1 commit

  • Make /dev/console get initialised before any initialisation routine that
    invokes modprobe because if modprobe fails, it's going to want to open
    /dev/console, presumably to write an error message to.

    The problem with that is that if the /dev/console driver is not yet
    initialised, the chardev handler will call request_module() to invoke
    modprobe, which will fail, because we never compile /dev/console as a
    module.

    This will lead to a modprobe loop, showing the following in the kernel
    log:

    request_module: runaway loop modprobe char-major-5-1
    request_module: runaway loop modprobe char-major-5-1
    request_module: runaway loop modprobe char-major-5-1
    request_module: runaway loop modprobe char-major-5-1
    request_module: runaway loop modprobe char-major-5-1

    This can happen, for example, when the built in md5 module can't find
    the built in cryptomgr module (because the latter fails to initialise).
    The md5 module comes before the call to tty_init(), presumably because
    'crypto' comes before 'drivers' alphabetically.

    Fix this by calling tty_init() from chrdev_init().

    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds

    David Howells
     

22 May, 2010

2 commits

  • Add an implementation of GSM 0710 MUX. The implementation currently supports

    - Basic and advanced framing (as either end of the link)
    - UI or UIH data frames
    - Adaption layer 1-4 (1 and 2 via tty, 3 and 4 as skbuff lists)
    - Modem and control messages including the correct retry process
    - Flow control

    and exposes the MUX channels as a set of virtual tty devices including modem
    signals. This is an experimental driver.

    Signed-off-by: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Alan Cox
     
  • Push the max ldiscs by a few number to allow ldiscs
    to exist in the staging directory and elsewhere.

    Signed-off-by: Pavan Savoy
    Signed-off-by: Greg Kroah-Hartman

    Pavan Savoy
     

07 Apr, 2010

1 commit


31 Mar, 2010

1 commit

  • Add CAIF Serial driver. This driver is implemented as a line discipline.

    caif_serial uses the following module parameters:
    ser_use_stx - specifies if STart of frame eXtension is in use.
    ser_loop - sets the interface in loopback mode.

    Signed-off-by: Sjur Braendeland
    Signed-off-by: David S. Miller

    Sjur Braendeland
     

19 Mar, 2010

2 commits

  • Commit e1108a63e10d344284011cccc06328b2cd3e5da3 ("usb_serial: Use the
    shutdown() operation") breaks the ability to use a usb console
    starting in 2.6.33. This was observed when using
    console=ttyUSB0,115200 as a boot argument with an FTDI device. The
    error is:

    ftdi_sio ttyUSB0: ftdi_submit_read_urb - failed submitting read urb, error -22

    The handling of the ASYNCB_INITIALIZED changed in 2.6.32 such that in
    tty_port_shutdown() it always clears the flag if it is set. The fix
    is to add a variable to the tty_port struct to indicate when the tty
    port is a console.

    CC: Alan Cox
    CC: Alan Stern
    CC: Oliver Neukum
    CC: Andrew Morton
    Signed-off-by: Jason Wessel
    Signed-off-by: Greg Kroah-Hartman

    Jason Wessel
     
  • The TTY layer takes some care to ensure that only sub-page allocations
    are made with interrupts disabled. It does this by setting a goal of
    "TTY_BUFFER_PAGE" to allocate. Unfortunately, while TTY_BUFFER_PAGE takes the
    size of tty_buffer into account, it fails to account that tty_buffer_find()
    rounds the buffer size out to the next 256 byte boundary before adding on
    the size of the tty_buffer.

    This patch adjusts the TTY_BUFFER_PAGE calculation to take into account the
    size of the tty_buffer and the padding. Once applied, tty_buffer_alloc()
    should not require high-order allocations.

    Signed-off-by: Mel Gorman
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Mel Gorman
     

13 Mar, 2010

1 commit


03 Mar, 2010

1 commit

  • We allocate during interrupts so while our buffering is normally diced up
    small anyway on some hardware at speed we can pressure the VM excessively
    for page pairs. We don't really need big buffers to be linear so don't try
    so hard.

    In order to make this work well we will tidy up excess callers to request_room,
    which cannot itself enforce this break up.

    Signed-off-by: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Alan Cox
     

17 Jan, 2010

1 commit

  • I get a few dozen of these warnings when using
    gcc (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2):

    In file included from mmotm-2010-0113-1217/init/do_mounts.c:5:
    mmotm-2010-0113-1217/include/linux/tty.h: In function 'tty_port_get':
    mmotm-2010-0113-1217/include/linux/tty.h:469: warning: '______f' is static but declared in inline function 'tty_port_get' which is not static

    so make the function static inline.

    [akpm@linux-foundation.org: may as well convert tty_port_users() also]
    Signed-off-by: Randy Dunlap
    Cc: Alan Cox
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

16 Dec, 2009

1 commit

  • The kernel offers with TIOCL_GETKMSGREDIRECT ioctl() the possibility to
    redirect the kernel messages to a specific console.

    However, since it's not possible to switch to the kernel message console
    after a panic(), it would be nice if the kernel would print the panic
    message on the current console.

    This patch series adds a new interface to access the global kmsg_redirect
    variable by a function to be able to use it in code where
    CONFIG_VT_CONSOLE is not set (kernel/panic.c).

    This patch:

    Instead of using and exporting a global value kmsg_redirect, introduce a
    function vt_kmsg_redirect() that both can set and return the console where
    messages are printed.

    Change all users of kmsg_redirect (the VT code itself and kernel/power.c)
    to the new interface.

    The main advantage is that vt_kmsg_redirect() can also be used when
    CONFIG_VT_CONSOLE is not set.

    Signed-off-by: Bernhard Walle
    Cc: Alan Cox
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Bernhard Walle