11 Aug, 2010

40 commits

  • Using:

    gcc (GCC) 4.5.0 20100610 (prerelease)

    with CONFIG_CONSOLE_TRANSLATIONS=n, the following warnings are seen:

    drivers/char/vt_ioctl.c: In function ‘vt_ioctl’:
    drivers/char/vt_ioctl.c:1309:4: warning: statement with no effect
    drivers/char/vt.c: In function ‘vc_allocate’:
    drivers/char/vt.c:774:3: warning: statement with no effect
    drivers/video/console/vgacon.c: In function ‘vgacon_init’:
    drivers/video/console/vgacon.c:587:3: warning: statement with no effect
    drivers/video/console/vgacon.c: In function ‘vgacon_deinit’:
    drivers/video/console/vgacon.c:606:2: warning: statement with no effect
    drivers/video/console/fbcon.c: In function ‘fbcon_init’:
    drivers/video/console/fbcon.c:1087:3: warning: statement with no effect
    drivers/video/console/fbcon.c:1089:3: warning: statement with no effect
    drivers/video/console/fbcon.c: In function ‘fbcon_set_disp’:
    drivers/video/console/fbcon.c:1369:3: warning: statement with no effect
    drivers/video/console/fbcon.c:1371:3: warning: statement with no effect

    This is because several functions in include/linux/vt_kern.h are
    defined to (0). Convert them to static inline functions to
    silence the warnings and gain a bit of type safety.

    Signed-off-by: Kevin Winchester
    Signed-off-by: Greg Kroah-Hartman

    Kevin Winchester
     
  • Remove unnesessary casts from void*.

    Signed-off-by: Kulikov Vasiliy
    Signed-off-by: Greg Kroah-Hartman

    Kulikov Vasiliy
     
  • At the moment there is only one platform type supported and there is is
    hard wired, but with these changes the infrastructure is now there for
    anyone else to provide methods for their hardware.

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

    Alan Cox
     
  • This device is used by some of the Intel MID platforms. It's not similar
    enough to the MAX3100 to use the same driver.

    At this point the driver is specific to the platform and not generalised.
    We will fix that later.

    Signed-off-by: jianwei.yang
    Signed-off-by: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    jianwei.yang
     
  • When the console has been redirected, a hangup of the tty
    will cause tty_release to be called under the big tty_mutex,
    which leads to a deadlock because hangup is also called
    under the BTM.

    This moves the BTM deeper into the tty_hangup function so
    we can close the redirected tty without holding the BTM.
    In case of pty, we now need to drop the BTM before
    calling tty_vhangup.

    Signed-off-by: Arnd Bergmann
    Acked-by: Alan Cox
    Cc: Tony Luck
    Cc: Thomas Gleixner
    Cc: Andrew Morton
    Cc: John Kacur
    Cc: Al Viro
    Cc: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • The ldisc number now gets passed into ->set_ldisc.

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

    Arnd Bergmann
     
  • Most tty drivers may block while opening a device.
    Since this possibly depends on another thread
    closing it first and both threads may need the BTM,
    we need to release it here.

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

    Arnd Bergmann
     
  • 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
     
  • Some wait_until_sent versions require the big
    tty mutex, others don't and some callers of
    wait_until_sent already hold it while other don't.
    That leads to recursive use of the BTM in these
    functions, which we're trying to get rid of.

    This turns all cleans up the locking there so
    that the driver's wait_until_sent function
    never takes the BTM itself if it is already
    called with that lock held.

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

    Arnd Bergmann
     
  • We need to release the BTM in paste_selection() when
    sleeping in tty_ldisc_ref_wait to avoid deadlocks
    with tty_ldisc_enable.

    In tty_set_ldisc, we now always grab the BTM before
    taking the ldisc_mutex in order to avoid AB-BA
    deadlocks between the two.

    tty_ldisc_halt potentially blocks on a workqueue
    function that takes the BTM, so we must release
    the BTM before calling it.

    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
     
  • The wait_event_interruptible_timeout in acm_port_down is
    never reached. Remove it to avoid possible deadlocks
    with the big tty mutex if someone were to start using
    the blocking version of acm_port_down.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • vgacon_do_font_op releases and reacquires the BTM while holding
    console_sem. This violates the rule that BTM has to be the
    outer lock whenever we hold both.

    There does not seem to be any reason to give up the BTM here,
    so just stop doing that.

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

    Arnd Bergmann
     
  • tty_mutex is never taken with the BTM held, except for
    two corner cases that are worked around here.
    We give up the BTM before calling tty_release() in the
    error path of tty_open().
    Similarly, we reorder the locking in ptmx_open()
    to get tty_mutex before the BTM.

    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
     
  • Move termios initialization in open into uart_dtr_rts to make sure
    it always gets called when necessary. Based on a suggestion from
    Alan Cox.

    Alan writes:
    Ok this sort of makes sense. Something isn't getting initialised and both
    getty and minicom will do a termios set which is sorting it out.
    This is occurring because the generic block_til_ready sets
    ASYNCB_NORMAL_ACTIVE so the termios updating gets skipped.

    This patch should cure it and then we can think about doing it more
    elegantly by getting the serial layer to use tty_port_open, kfifo and
    the like and removing the tons of repeated crap in all the drivers.

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

    Arnd Bergmann
     
  • Our code now rather closely resembles the helper, so switch to it.

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

    Alan Cox
     
  • The port mutex protects port->tty, but these paths never need to walk from
    port->tty. They do need the low level lock as the API expects that but they
    already also take it.

    Thus we can drop the extra mutex lock calls here.

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

    Alan Cox
     
  • We can make this the same as the ones that will be needed by the tty_port
    helper logic that we want to move to but still call them from the existing
    code base.

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

    Alan Cox
     
  • We want to push the lock/unlock into the helper functions so that we
    can prepare to move to using the tty_port helper. The expansion initially
    comes out a bit ugly but its worth the temporary expansion IMHO just so
    we can produce a nice testable series of changes.

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

    Alan Cox
     
  • This takes all the tty references through the expected interface points so
    we can refcount them.

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

    Alan Cox
     
  • The vt layer isn't safely handling reference counts to tty object on the input
    side. Add a tty port structure to the vt layer in order to implement this using
    the standard helpers.

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

    Alan Cox
     
  • The virtual console layer uses the BKL for various things that don't really
    need it. Clean them out.

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

    Alan Cox
     
  • Pass down the ldisc number so that the drivers don't have to peek into the
    tty object themselves. This lets us get rid of another case of back referencing
    port to tty which we don't want (because of races versus hangup/close).

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

    Alan Cox
     
  • One or two drivers go poking back into the tty from the termios setting
    routine in unsafe ways. We don't need to pass the tty down because the
    [ab]users are just using it to get at things they can get at anyway.

    This leaves low_latency setting to sort out along with set_ldisc use.

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

    Alan Cox
     
  • Make it robust against hang up events. In most cases we can do this simply
    by passing the right things in the first place.

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

    Alan Cox
     
  • Use the port mutex and port lock to fix the various races. The locking
    still isn't totally consistent but its better than before. Wants switching
    to the port helpers.

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

    Alan Cox
     
  • This now refcounts but doesn't actually check the reference was obtained in
    all the places it should.

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

    Alan Cox
     
  • Use the port mutex instead

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

    Alan Cox
     
  • The lock is no longer needed for wait until sent paths so this can go

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

    Alan Cox
     
  • Use the port mutext for config setting, the rest is locked sufficiently
    anyway that the BKL makes no odds.

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

    Alan Cox
     
  • We don't need it while waiting and we can lock the ioctls using the port
    mutex. While at it eliminate use of the hangup mutex and switch to the port
    mutex.

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

    Alan Cox
     
  • We can use the port mutex for this and also for the hangup path so removing
    the problematic use of the hangup mutex in this driver. Fix up the locking
    on the various port flags while we are at it.

    Ultimately this driver needs to be using tty_port_ helpers which would sort
    this out far better.

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

    Alan Cox
     
  • As with the others we can use the port mutex to get the needed locking
    properties and fix the race with open.

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

    Alan Cox
     
  • The riscom8 board uses lock_kernel to protect bits of the port setting
    ioctl logic. We can use the port mutex for this as the logic is internal
    and will also lock set versus open (a locking property that has been lost
    somewhere along the way)

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

    Alan Cox
     
  • This lets us avoid problems with races on the flag changes

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

    Alan Cox
     
  • Remove unneeded tty layer lock kernel bits. Relock the needed bits using the
    port mutex. The istallion still has brd state races but those are not new
    or introduced by the removal of the lock_kernel logic.

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

    Alan Cox
     
  • Jesse's initial patch commit said:

    "At panic time (i.e. when oops_in_progress is set) we should try a bit
    harder to update the screen and make sure output gets to the VT, since
    some drivers are capable of flipping back to it.

    So make sure we try to unblank and update the display if called from a
    panic context."

    I've enhanced this to add a flag to the vc that console layer can set to
    indicate they want this behaviour to occur. This also adds support to
    fbcon for that flag and adds an fb flag for drivers to indicate they want
    to use the support. It enables this for KMS drivers.

    Signed-off-by: Dave Airlie
    Signed-off-by: Jesse Barnes
    Acked-by: James Simmons
    Cc: Alan Cox
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Jesse Barnes
     
  • 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