linux/net/irda
Peter Hurley e359a4e38d tty: Remove tty_hung_up_p() tests from tty drivers' open()
Since at least before 2.6.30, it has not been possible to observe
a hung up file pointer in a tty driver's open() method unless/until
the driver open() releases the tty_lock() (eg., before blocking).

This is because tty_open() adds the file pointer while holding
the tty_lock() _and_ doesn't release the lock until after calling
the tty driver's open() method. [ Before tty_lock(), this was
lock_kernel(). ]

Since __tty_hangup() first waits on the tty_lock() before
enumerating and hanging up the open file pointers, either
__tty_hangup() will wait for the tty_lock() or tty_open() will
not yet have added the file pointer. For example,

CPU 0                          |  CPU 1
                               |
tty_open                       |  __tty_hangup
  ..                           |    ..
  tty_lock                     |    ..
  tty_reopen                   |    tty_lock  / blocks
  ..                           |
  tty_add_file(tty, filp)      |
  ..                           |
  tty->ops->open(tty, filp)    |
    tty_port_open              |
      tty_port_block_til_ready |
        ..                     |
        while (1)              |
          ..                   |
          tty_unlock           |    / unblocks
          schedule             |    for each filp on tty->tty_files
                               |      f_ops = tty_hung_up_fops;
                               |    ..
                               |    tty_unlock
          tty_lock             |
  ..                           |
  tty_unlock                   |

Note that since tty_port_block_til_ready() and similar drop
the tty_lock while blocking, when woken, the file pointer
must then be tested for having been hung up.

Also, fix bit-rotted drivers that used extra_count to track the
port->count bump.

CC: Mikael Starvik <starvik@axis.com>
CC: Samuel Ortiz <samuel@sortiz.org>
CC: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-10 16:06:49 -07:00
..
ircomm tty: Remove tty_hung_up_p() tests from tty drivers' open() 2014-07-10 16:06:49 -07:00
irlan net/irda: fixed style issues in irlan_eth 2013-07-16 12:16:03 -07:00
irnet net: misc: Remove extern from function prototypes 2013-10-19 19:12:11 -04:00
af_irda.c net: add build-time checks for msg->msg_name size 2014-01-18 23:04:16 -08:00
discovery.c net/irda: Fix FSF address in file headers 2013-12-06 12:37:57 -05:00
irda_device.c net/irda: Fix FSF address in file headers 2013-12-06 12:37:57 -05:00
iriap_event.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
iriap.c irda: small read past the end of array in debug code 2013-04-19 17:32:31 -04:00
irias_object.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
irlap_event.c irda: irlap_event: Fix set-but-unused variables. 2011-04-17 16:59:09 -07:00
irlap_frame.c net: irda: using kzalloc() instead of kmalloc() to avoid strncpy() issue. 2013-05-19 15:10:47 -07:00
irlap.c net/irda: Fix FSF address in file headers 2013-12-06 12:37:57 -05:00
irlmp_event.c Fix common misspellings 2011-03-31 11:26:23 -03:00
irlmp_frame.c net: return operator cleanup 2010-09-23 14:33:39 -07:00
irlmp.c irda: irlmp_reasons[] can be static 2013-04-25 01:42:06 -04:00
irmod.c net: convert usage of packet_type to read_mostly 2009-03-10 05:22:43 -07:00
irnetlink.c genetlink: only pass array to genl_register_family_with_ops() 2013-11-19 16:39:05 -05:00
irproc.c irda: irproc: Fix set-but-unused variables. 2011-04-17 16:59:50 -07:00
irqueue.c net: Remove casts to same type 2012-06-04 11:45:11 -04:00
irsysctl.c net: Convert uses of typedef ctl_table to struct ctl_table 2013-06-13 02:36:09 -07:00
irttp.c net/irda: fixed style issues in irttp 2013-07-19 17:34:40 -07:00
Kconfig [S390] Kconfig: unwanted menus for s390. 2007-05-10 15:46:07 +02:00
Makefile [IrDA]: Netlink layer. 2007-07-10 22:16:43 -07:00
parameters.c net/irda: Fix FSF address in file headers 2013-12-06 12:37:57 -05:00
qos.c net/irda: Fix FSF address in file headers 2013-12-06 12:37:57 -05:00
timer.c treewide: Replace incomming with incoming in all comments and strings 2013-01-03 16:15:49 +01:00
wrapper.c net: replace remaining __FUNCTION__ occurrences 2008-03-05 20:47:47 -08:00