25 Jun, 2016

1 commit

  • In ircomm_tty_get_serial_info, struct serial_struct is memset to 0 and
    then some members set to 0 explicitly.

    Remove the latter as it is obviously superfluous.

    And remove the retinfo check against NULL. copy_to_user will take care
    of that.

    Part of hub6 cleanup series.

    Signed-off-by: Jiri Slaby
    Cc: Samuel Ortiz
    Acked-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     

01 May, 2016

6 commits

  • Replace ASYNC_INITIALIZED bit in the tty_port::flags field with
    TTY_PORT_INITIALIZED bit in the tty_port::iflags field. Introduce helpers
    tty_port_set_initialized() and tty_port_initialized() to abstract
    atomic bit ops.

    Note: the transforms for test_and_set_bit() and test_and_clear_bit()
    are unnecessary as the state transitions are already mutually exclusive;
    the tty lock prevents concurrent open/close/hangup.

    Signed-off-by: Peter Hurley
    Signed-off-by: Greg Kroah-Hartman

    Peter Hurley
     
  • Replace ASYNC_CHECK_CD bit in the tty_port::flags field with
    TTY_PORT_CHECK_CD bit in the tty_port::iflags field. Introduce helpers
    tty_port_set_check_carrier() and tty_port_check_carrier() to abstract
    the atomic bit ops.

    Signed-off-by: Peter Hurley
    Signed-off-by: Greg Kroah-Hartman

    Peter Hurley
     
  • Replace ASYNC_NORMAL_ACTIVE bit in the tty_port::flags field with
    TTY_PORT_ACTIVE bit in the tty_port::iflags field. Introduce helpers
    tty_port_set_active() and tty_port_active() to abstract atomic bit ops.

    Extract state changes from port lock sections, as this usage is
    broken and confused; the state transitions are protected by the
    tty lock (which mutually excludes parallel open/close/hangup),
    and no user tests the active state while holding the port lock.

    Signed-off-by: Peter Hurley
    Signed-off-by: Greg Kroah-Hartman

    Peter Hurley
     
  • Replace ASYNC_CTS_FLOW bit in the tty_port::flags field with
    TTY_PORT_CTS_FLOW bit in the tty_port::iflags field. Add
    tty_port_set_cts_flow() helper to abstract the atomic bit ops.

    Signed-off-by: Peter Hurley
    Signed-off-by: Greg Kroah-Hartman

    Peter Hurley
     
  • Abstract TTY_THROTTLED bit tests with tty_throttled().

    Signed-off-by: Peter Hurley
    Signed-off-by: Greg Kroah-Hartman

    Peter Hurley
     
  • Abstract TTY_IO_ERROR status test treewide with tty_io_error().
    NB: tty->flags uses atomic bit ops; replace non-atomic bit test
    with test_bit().

    Signed-off-by: Peter Hurley
    Signed-off-by: Greg Kroah-Hartman

    Peter Hurley
     

15 Feb, 2016

1 commit


30 Jan, 2016

1 commit


29 Jan, 2016

2 commits

  • The tty core no longer provides nor uses ASYNC_CLOSING; remove from
    tty_port_close_start() and tty_port_close_end() as well as tty drivers
    which open-code these state changes. Unfortunately, even though the
    bit is masked from userspace, its inclusion in a uapi header precludes
    removing the macro.

    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    Cc: linux-s390@vger.kernel.org
    Cc: Mikael Starvik
    Cc: Jesper Nilsson
    Cc: linux-cris-kernel@axis.com
    Cc: Samuel Ortiz
    Cc: "David S. Miller"
    Signed-off-by: Peter Hurley
    Signed-off-by: Greg Kroah-Hartman

    Peter Hurley
     
  • Expressions of the form "tty->termios.c_*flag & FLAG"
    are more clearly expressed with the termios flags macros,
    I_FLAG(), C_FLAG(), O_FLAG(), and L_FLAG().

    Convert treewide.

    Signed-off-by: Peter Hurley
    Acked-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Peter Hurley
     

18 Oct, 2015

1 commit

  • Since at least before 2.6.30, tty drivers that do not drop the tty lock
    while closing cannot observe ASYNC_CLOSING set while holding the
    tty lock; this includes the tty driver's open() and hangup() methods,
    since the tty core calls these methods holding the tty lock.

    For these drivers, waiting for ASYNC_CLOSING to clear while opening
    is not required, since this condition cannot occur. Similarly, even
    when the open() method drops and reacquires the tty lock after
    blocking, ASYNC_CLOSING cannot be set (again, for drivers that
    do not drop the tty lock while closing).

    Now that tty port drivers no longer drop the tty lock while closing
    (since 'tty: Remove tty_wait_until_sent_from_close()'), the same
    conditions apply: waiting for ASYNC_CLOSING to clear while opening
    is not required, nor is re-checking ASYNC_CLOSING after dropping and
    reacquiring the tty lock while blocking (eg., in *_block_til_ready()).

    Note: The ASYNC_CLOSING flag state is still maintained since several
    bitrotting drivers use it for (dubious) other purposes.

    Signed-off-by: Peter Hurley
    Signed-off-by: Greg Kroah-Hartman

    Peter Hurley
     

09 Mar, 2015

1 commit

  • Pull tty/serial fixes from Greg KH:
    "Here are some tty and serial driver fixes for 4.0-rc3.

    Along with the atime fix that you know about, here are some other
    serial driver bugfixes as well. Most notable is a wait_until_sent
    bugfix that was traced back to being around since before 2.6.12 that
    Johan has fixed up.

    All have been in linux-next successfully"

    * tag 'tty-4.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
    TTY: fix tty_wait_until_sent maximum timeout
    TTY: fix tty_wait_until_sent on 64-bit machines
    USB: serial: fix infinite wait_until_sent timeout
    TTY: bfin_jtag_comm: remove incorrect wait_until_sent operation
    net: irda: fix wait_until_sent poll timeout
    serial: uapi: Declare all userspace-visible io types
    serial: core: Fix iotype userspace breakage
    serial: sprd: Fix missing spin_unlock in sprd_handle_irq()
    console: Fix console name size mismatch
    tty: fix up atime/mtime mess, take four
    serial: 8250_dw: Fix get_mctrl behaviour
    serial:8250:8250_pci: delete unneeded quirk entries
    serial:8250:8250_pci: fix redundant entry report for WCH_CH352_2S
    Change email address for 8250_pci
    serial: 8250: Revert "tty: serial: 8250_core: read only RX if there is something in the FIFO"
    Revert "tty/serial: of_serial: add DT alias ID handling"

    Linus Torvalds
     

07 Mar, 2015

1 commit

  • In case an infinite timeout (0) is requested, the irda wait_until_sent
    implementation would use a zero poll timeout rather than the default
    200ms.

    Note that wait_until_sent is currently never called with a 0-timeout
    argument due to a bug in tty_wait_until_sent.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Cc: stable # v2.6.12
    Signed-off-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Johan Hovold
     

24 Feb, 2015

1 commit

  • Use helper functions to access current->state.
    Direct assignments are prone to races and therefore buggy.

    current->state = TASK_RUNNING can be replaced by __set_current_state()

    Thanks to Peter Zijlstra for the exact definition of the problem.

    Suggested-By: Peter Zijlstra
    Signed-off-by: Fabian Frederick
    Signed-off-by: David S. Miller

    Fabian Frederick
     

11 Dec, 2014

1 commit


13 Nov, 2014

2 commits


12 Nov, 2014

1 commit

  • And use the more common mechanisms directly.

    Other miscellanea:

    o Coalesce formats
    o Add missing newlines
    o Realign arguments
    o Remove unnecessary OOM message logging as
    there's a generic stack dump already on OOM.

    Signed-off-by: Joe Perches
    Signed-off-by: David S. Miller

    Joe Perches
     

11 Jul, 2014

1 commit

  • 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
    CC: Samuel Ortiz
    CC: "David S. Miller"
    Signed-off-by: Peter Hurley
    Acked-by: Jesper Nilsson
    Signed-off-by: Greg Kroah-Hartman

    Peter Hurley
     

07 Dec, 2013

1 commit

  • Several files refer to an old address for the Free Software Foundation
    in the file header comment. Resolve by replacing the address with
    the URL so that we do not have to keep
    updating the header comments anytime the address changes.

    CC: Samuel Ortiz
    Signed-off-by: Jeff Kirsher
    Signed-off-by: David S. Miller

    Jeff Kirsher
     

02 May, 2013

1 commit

  • Pull networking updates from David Miller:
    "Highlights (1721 non-merge commits, this has to be a record of some
    sort):

    1) Add 'random' mode to team driver, from Jiri Pirko and Eric
    Dumazet.

    2) Make it so that any driver that supports configuration of multiple
    MAC addresses can provide the forwarding database add and del
    calls by providing a default implementation and hooking that up if
    the driver doesn't have an explicit set of handlers. From Vlad
    Yasevich.

    3) Support GSO segmentation over tunnels and other encapsulating
    devices such as VXLAN, from Pravin B Shelar.

    4) Support L2 GRE tunnels in the flow dissector, from Michael Dalton.

    5) Implement Tail Loss Probe (TLP) detection in TCP, from Nandita
    Dukkipati.

    6) In the PHY layer, allow supporting wake-on-lan in situations where
    the PHY registers have to be written for it to be configured.

    Use it to support wake-on-lan in mv643xx_eth.

    From Michael Stapelberg.

    7) Significantly improve firewire IPV6 support, from YOSHIFUJI
    Hideaki.

    8) Allow multiple packets to be sent in a single transmission using
    network coding in batman-adv, from Martin Hundebøll.

    9) Add support for T5 cxgb4 chips, from Santosh Rastapur.

    10) Generalize the VXLAN forwarding tables so that there is more
    flexibility in configurating various aspects of the endpoints.
    From David Stevens.

    11) Support RSS and TSO in hardware over GRE tunnels in bxn2x driver,
    from Dmitry Kravkov.

    12) Zero copy support in nfnelink_queue, from Eric Dumazet and Pablo
    Neira Ayuso.

    13) Start adding networking selftests.

    14) In situations of overload on the same AF_PACKET fanout socket, or
    per-cpu packet receive queue, minimize drop by distributing the
    load to other cpus/fanouts. From Willem de Bruijn and Eric
    Dumazet.

    15) Add support for new payload offset BPF instruction, from Daniel
    Borkmann.

    16) Convert several drivers over to mdoule_platform_driver(), from
    Sachin Kamat.

    17) Provide a minimal BPF JIT image disassembler userspace tool, from
    Daniel Borkmann.

    18) Rewrite F-RTO implementation in TCP to match the final
    specification of it in RFC4138 and RFC5682. From Yuchung Cheng.

    19) Provide netlink socket diag of netlink sockets ("Yo dawg, I hear
    you like netlink, so I implemented netlink dumping of netlink
    sockets.") From Andrey Vagin.

    20) Remove ugly passing of rtnetlink attributes into rtnl_doit
    functions, from Thomas Graf.

    21) Allow userspace to be able to see if a configuration change occurs
    in the middle of an address or device list dump, from Nicolas
    Dichtel.

    22) Support RFC3168 ECN protection for ipv6 fragments, from Hannes
    Frederic Sowa.

    23) Increase accuracy of packet length used by packet scheduler, from
    Jason Wang.

    24) Beginning set of changes to make ipv4/ipv6 fragment handling more
    scalable and less susceptible to overload and locking contention,
    from Jesper Dangaard Brouer.

    25) Get rid of using non-type-safe NLMSG_* macros and use nlmsg_*()
    instead. From Hong Zhiguo.

    26) Optimize route usage in IPVS by avoiding reference counting where
    possible, from Julian Anastasov.

    27) Convert IPVS schedulers to RCU, also from Julian Anastasov.

    28) Support cpu fanouts in xt_NFQUEUE netfilter target, from Holger
    Eitzenberger.

    29) Network namespace support for nf_log, ebt_log, xt_LOG, ipt_ULOG,
    nfnetlink_log, and nfnetlink_queue. From Gao feng.

    30) Implement RFC3168 ECN protection, from Hannes Frederic Sowa.

    31) Support several new r8169 chips, from Hayes Wang.

    32) Support tokenized interface identifiers in ipv6, from Daniel
    Borkmann.

    33) Use usbnet_link_change() helper in USB net driver, from Ming Lei.

    34) Add 802.1ad vlan offload support, from Patrick McHardy.

    35) Support mmap() based netlink communication, also from Patrick
    McHardy.

    36) Support HW timestamping in mlx4 driver, from Amir Vadai.

    37) Rationalize AF_PACKET packet timestamping when transmitting, from
    Willem de Bruijn and Daniel Borkmann.

    38) Bring parity to what's provided by /proc/net/packet socket dumping
    and the info provided by netlink socket dumping of AF_PACKET
    sockets. From Nicolas Dichtel.

    39) Fix peeking beyond zero sized SKBs in AF_UNIX, from Benjamin
    Poirier"

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1722 commits)
    filter: fix va_list build error
    af_unix: fix a fatal race with bit fields
    bnx2x: Prevent memory leak when cnic is absent
    bnx2x: correct reading of speed capabilities
    net: sctp: attribute printl with __printf for gcc fmt checks
    netlink: kconfig: move mmap i/o into netlink kconfig
    netpoll: convert mutex into a semaphore
    netlink: Fix skb ref counting.
    net_sched: act_ipt forward compat with xtables
    mlx4_en: fix a build error on 32bit arches
    Revert "bnx2x: allow nvram test to run when device is down"
    bridge: avoid OOPS if root port not found
    drivers: net: cpsw: fix kernel warn on cpsw irq enable
    sh_eth: use random MAC address if no valid one supplied
    3c509.c: call SET_NETDEV_DEV for all device types (ISA/ISAPnP/EISA)
    tg3: fix to append hardware time stamping flags
    unix/stream: fix peeking with an offset larger than data in queue
    unix/dgram: fix peeking with an offset larger than data in queue
    unix/dgram: peek beyond 0-sized skbs
    openvswitch: Remove unneeded ovs_netdev_get_ifindex()
    ...

    Linus Torvalds
     

13 Apr, 2013

1 commit

  • Make sure to check ASYNC_INITIALISED before raising DTR when waking up
    from blocked open in ircomm_tty_block_til_ready.

    Currently DTR could get raised at hang up as a blocked process would
    raise DTR unconditionally before checking for hang up and returning.

    Signed-off-by: Johan Hovold
    Acked-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Johan Hovold
     

09 Apr, 2013

1 commit

  • Hi Greg,

    I'm unsure if you or Dave should take that one as it's for one a TTY
    patch but also living under net/. So I'm uncertain and let you decide!

    Thanks,
    Mathias

    -- >8 --
    Subject: [PATCH] TTY: ircomm, use GFP_KERNEL in ircomm_open()

    We're clearly running in non-atomic context as our only call site is
    able to call wait_event_interruptible(). So we're safe to use GFP_KERNEL
    here instead of GFP_ATOMIC.

    Signed-off-by: Mathias Krause
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: David S. Miller

    Mathias Krause
     

22 Mar, 2013

1 commit


19 Mar, 2013

1 commit

  • It allows for cleaning up on a considerable amount of places. They did
    port_get, hangup, kref_put. Now the only thing needed is to call
    tty_port_tty_hangup which does exactly that. And they can also decide
    whether to consider CLOCAL or completely ignore that.

    Signed-off-by: Jiri Slaby
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     

06 Mar, 2013

4 commits

  • DTR/RTS need to be raised, regardless of the open() mode, but not
    if the port has already shutdown.

    Signed-off-by: Peter Hurley
    Signed-off-by: David S. Miller

    Peter Hurley
     
  • Without a memory and compiler barrier, the task state change
    can migrate relative to the condition testing in a blocking loop.
    However, the task state change must be visible across all cpus
    prior to testing those conditions. Failing to do this can result
    in the familiar 'lost wakeup' and this task will hang until killed.

    Signed-off-by: Peter Hurley
    Signed-off-by: David S. Miller

    Peter Hurley
     
  • Although tty_lock() already protects concurrent update to
    blocked_open, that fails to meet the separation-of-concerns between
    tty_port and tty.

    Signed-off-by: Peter Hurley
    Signed-off-by: David S. Miller

    Peter Hurley
     
  • Saving the port count bump is unsafe. If the tty is hung up while
    this open was blocking, the port count is zeroed.

    Explicitly check if the tty was hung up while blocking, and correct
    the port count if not.

    Signed-off-by: Peter Hurley
    Signed-off-by: David S. Miller

    Peter Hurley
     

19 Jan, 2013

1 commit

  • The option allows you to remove TTY and compile without errors. This
    saves space on systems that won't support TTY interfaces anyway.
    bloat-o-meter output is below.

    The bulk of this patch consists of Kconfig changes adding "depends on
    TTY" to various serial devices and similar drivers that require the TTY
    layer. Ideally, these dependencies would occur on a common intermediate
    symbol such as SERIO, but most drivers "select SERIO" rather than
    "depends on SERIO", and "select" does not respect dependencies.

    bloat-o-meter output comparing our previous minimal to new minimal by
    removing TTY. The list is filtered to not show removed entries with awk
    '$3 != "-"' as the list was very long.

    add/remove: 0/226 grow/shrink: 2/14 up/down: 6/-35356 (-35350)
    function old new delta
    chr_dev_init 166 170 +4
    allow_signal 80 82 +2
    static.__warned 143 142 -1
    disallow_signal 63 62 -1
    __set_special_pids 95 94 -1
    unregister_console 126 121 -5
    start_kernel 546 541 -5
    register_console 593 588 -5
    copy_from_user 45 40 -5
    sys_setsid 128 120 -8
    sys_vhangup 32 19 -13
    do_exit 1543 1526 -17
    bitmap_zero 60 40 -20
    arch_local_irq_save 137 117 -20
    release_task 674 652 -22
    static.spin_unlock_irqrestore 308 260 -48

    Signed-off-by: Joe Millenbach
    Reviewed-by: Jamey Sharp
    Reviewed-by: Josh Triplett
    Signed-off-by: Greg Kroah-Hartman

    Joe Millenbach
     

16 Jan, 2013

3 commits

  • Now, we start converting tty buffer functions to actually use
    tty_port. This will allow us to get rid of the need of tty in many
    call sites. Only tty_port will needed and hence no more
    tty_port_tty_get in those paths.

    Now, the one where most of tty_port_tty_get gets removed:
    tty_flip_buffer_push.

    IOW we also closed all the races in drivers not using tty_port_tty_get
    at all yet.

    Also we move tty_flip_buffer_push declaration from include/linux/tty.h
    to include/linux/tty_flip.h to all others while we are changing it
    anyway.

    Signed-off-by: Jiri Slaby
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     
  • One point is to have less places where we actually need tty pointer.
    The other is that low_latency is bound to buffer processing and
    buffers are now in tty_port. So it makes sense to move low_latency to
    tty_port too.

    Signed-off-by: Jiri Slaby
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     
  • Now, we start converting tty buffer functions to actually use
    tty_port. This will allow us to get rid of the need of tty in many
    call sites. Only tty_port will needed and hence no more
    tty_port_tty_get in those paths.

    tty_insert_flip_string this time.

    Signed-off-by: Jiri Slaby
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     

16 Nov, 2012

1 commit

  • After commit "TTY: move tty buffers to tty_port", the tty buffers are
    not freed in some drivers. This is because tty_port_destructor is not
    called whenever a tty_port is freed. This was an assumption I counted
    with but was unfortunately untrue. So fix the drivers to fulfil this
    assumption.

    To be sure, the TTY buffers (and later some stuff) are gone along with
    the tty_port, we have to call tty_port_destroy at tear-down places.
    This is mostly where the structure containing a tty_port is freed.
    This patch does exactly that -- put tty_port_destroy at those places.

    Signed-off-by: Jiri Slaby
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     

06 Oct, 2012

1 commit

  • Commit 9c650ffc ("TTY: ircomm_tty, add tty install") split _open() to
    _install() and _open(). It also moved the initialization of driver_data
    out of open(), but never added it to install() - causing a NULL ptr
    deref whenever the driver was used.

    Signed-off-by: Sasha Levin
    Acked-by: Jiri Slaby
    Signed-off-by: Greg Kroah-Hartman

    Sasha Levin
     

06 Sep, 2012

1 commit

  • In most of the time, the driver needs to check if the cts flow control
    is enabled. But now, the driver checks the ASYNC_CTS_FLOW flag manually,
    which is not a grace way. So add a new wraper function to make the code
    tidy and clean.

    Signed-off-by: Huang Shijie
    Signed-off-by: Greg Kroah-Hartman

    Huang Shijie
     

14 Aug, 2012

1 commit

  • This has two outcomes:
    * we give the TTY layer a tty_port
    * we do not find the info structure every time open is called on that
    tty

    Signed-off-by: Jiri Slaby
    Cc: Samuel Ortiz
    Acked-by: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     

17 Jul, 2012

1 commit

  • This will let us sort out a whole pile of tty related races. The
    alternative would be to keep points and refcount the termios objects.
    However
    1. They are tiny anyway
    2. Many devices don't use the stored copies
    3. We can remove a pty special case

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

    Alan Cox
     

13 Jun, 2012

1 commit