1. 24 7月, 2013 8 次提交
  2. 18 6月, 2013 4 次提交
  3. 21 5月, 2013 2 次提交
  4. 19 3月, 2013 9 次提交
    • P
      n_tty: Fully initialize ldisc before restarting buffer work · b66f4fa5
      Peter Hurley 提交于
      Buffer work may already be pending when the n_tty ldisc is re-opened,
      eg., when setting the ldisc (via TIOCSETD ioctl) and when hanging up
      the tty. Since n_tty_set_room() may restart buffer work, first ensure
      the ldisc is completely initialized.
      
      Factor n_tty_set_room() out of reset_buffer_flags() (only 2 callers)
      and reorganize n_tty_open() to set termios last; buffer work will
      be restarted there if necessary, after the char_map is properly
      initialized.
      
      Fixes this WARNING:
      
      [  549.561769] ------------[ cut here ]------------
      [  549.598755] WARNING: at drivers/tty/n_tty.c:160 n_tty_set_room+0xff/0x130()
      [  549.604058] scheduling buffer work for halted ldisc
      [  549.607741] Pid: 9417, comm: trinity-child28 Tainted: G      D W 3.7.0-next-20121217-sasha-00023-g8689ef9 #219
      [  549.652580] Call Trace:
      [  549.662754]  [<ffffffff81c432cf>] ? n_tty_set_room+0xff/0x130
      [  549.665458]  [<ffffffff8110cae7>] warn_slowpath_common+0x87/0xb0
      [  549.668257]  [<ffffffff8110cb71>] warn_slowpath_fmt+0x41/0x50
      [  549.671007]  [<ffffffff81c432cf>] n_tty_set_room+0xff/0x130
      [  549.673268]  [<ffffffff81c44597>] reset_buffer_flags+0x137/0x150
      [  549.675607]  [<ffffffff81c45b71>] n_tty_open+0x131/0x1c0
      [  549.677699]  [<ffffffff81c47824>] tty_ldisc_open.isra.5+0x54/0x70
      [  549.680147]  [<ffffffff81c482bf>] tty_ldisc_hangup+0x11f/0x1e0
      [  549.682409]  [<ffffffff81c3fa17>] __tty_hangup+0x137/0x440
      [  549.684634]  [<ffffffff81c3fd49>] tty_vhangup+0x9/0x10
      [  549.686443]  [<ffffffff81c4a42c>] pty_close+0x14c/0x160
      [  549.688446]  [<ffffffff81c41225>] tty_release+0xd5/0x490
      [  549.690460]  [<ffffffff8127d8a2>] __fput+0x122/0x250
      [  549.692577]  [<ffffffff8127d9d9>] ____fput+0x9/0x10
      [  549.694534]  [<ffffffff811348c2>] task_work_run+0xb2/0xf0
      [  549.696349]  [<ffffffff81113c6d>] do_exit+0x36d/0x580
      [  549.698286]  [<ffffffff8107d964>] ? syscall_trace_enter+0x24/0x2e0
      [  549.702729]  [<ffffffff81113f4a>] do_group_exit+0x8a/0xc0
      [  549.706775]  [<ffffffff81113f92>] sys_exit_group+0x12/0x20
      [  549.711088]  [<ffffffff83cfab18>] tracesys+0xe1/0xe6
      [  549.728001] ---[ end trace 73eb41728f11f87e ]---
      Reported-by: NSasha Levin <levinsasha928@gmail.com>
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b66f4fa5
    • P
      n_tty: Correct unthrottle-with-buffer-flush comments · 25518c68
      Peter Hurley 提交于
      The driver is no longer unthrottled on buffer reset, so remove
      comments that claim it is.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25518c68
    • P
      n_tty: Don't flush buffer when closing ldisc · 79901317
      Peter Hurley 提交于
      A buffer flush is both undesirable and unnecessary when the ldisc
      is closing. A buffer flush performs the following:
       1. resets ldisc data fields to their initial state
       2. resets tty->receive_room to indicate more data can be sent
       3. schedules buffer work to receive more data
       4. signals a buffer flush has happened to linked pty in packet mode
      
      Since the ldisc has been halted and the tty may soon be destructed,
      buffer work must not be scheduled as that work might access
      an invalid tty and ldisc state. Also, the ldisc read buffer is about
      to be freed, so that's pointless.
      
      Resetting the ldisc data fields is pointless as well since that
      structure is about to be freed.
      
      Resetting tty->receive_room is unnecessary, as it will be properly
      reset if a new ldisc is reopened. Besides, resetting the original
      receive_room value would be wrong since the read buffer will be
      gone.
      
      Since the packet mode flush is observable from userspace, this
      behavior has been preserved.
      
      The test jig originally authored by Ilya Zykov <ilya@ilyx.ru> and
      signed off by him is included below. The test jig prompts the
      following warnings which this patch fixes.
      
      [   38.051111] ------------[ cut here ]------------
      [   38.052113] WARNING: at drivers/tty/n_tty.c:160 n_tty_set_room.part.6+0x8b/0xa0()
      [   38.053916] Hardware name: Bochs
      [   38.054819] Modules linked in: netconsole configfs bnep rfcomm bluetooth parport_pc ppdev snd_hda_intel snd_hda_codec
      snd_hwdep snd_pcm snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq psmouse snd_timer serio_raw mac_hid snd_seq_device
      snd microcode lp parport virtio_balloon soundcore i2c_piix4 snd_page_alloc floppy 8139too 8139cp
      [   38.059704] Pid: 1564, comm: pty_kill Tainted: G        W    3.7.0-next-20121130+ttydebug-xeon #20121130+ttydebug
      [   38.061578] Call Trace:
      [   38.062491]  [<ffffffff81058b4f>] warn_slowpath_common+0x7f/0xc0
      [   38.063448]  [<ffffffff81058baa>] warn_slowpath_null+0x1a/0x20
      [   38.064439]  [<ffffffff8142dc2b>] n_tty_set_room.part.6+0x8b/0xa0
      [   38.065381]  [<ffffffff8142dc82>] n_tty_set_room+0x42/0x80
      [   38.066323]  [<ffffffff8142e6f2>] reset_buffer_flags+0x102/0x160
      [   38.077508]  [<ffffffff8142e76d>] n_tty_flush_buffer+0x1d/0x90
      [   38.078782]  [<ffffffff81046569>] ? default_spin_lock_flags+0x9/0x10
      [   38.079734]  [<ffffffff8142e804>] n_tty_close+0x24/0x60
      [   38.080730]  [<ffffffff81431b61>] tty_ldisc_close.isra.2+0x41/0x60
      [   38.081680]  [<ffffffff81431bbb>] tty_ldisc_kill+0x3b/0x80
      [   38.082618]  [<ffffffff81432a07>] tty_ldisc_release+0x77/0xe0
      [   38.083549]  [<ffffffff8142b781>] tty_release+0x451/0x4d0
      [   38.084525]  [<ffffffff811950be>] __fput+0xae/0x230
      [   38.085472]  [<ffffffff8119524e>] ____fput+0xe/0x10
      [   38.086401]  [<ffffffff8107aa88>] task_work_run+0xc8/0xf0
      [   38.087334]  [<ffffffff8105ea56>] do_exit+0x196/0x4b0
      [   38.088304]  [<ffffffff8106c77b>] ? __dequeue_signal+0x6b/0xb0
      [   38.089240]  [<ffffffff8105ef34>] do_group_exit+0x44/0xa0
      [   38.090182]  [<ffffffff8106f43d>] get_signal_to_deliver+0x20d/0x4e0
      [   38.091125]  [<ffffffff81016979>] do_signal+0x29/0x130
      [   38.092096]  [<ffffffff81431a9e>] ? tty_ldisc_deref+0xe/0x10
      [   38.093030]  [<ffffffff8142a317>] ? tty_write+0xb7/0xf0
      [   38.093976]  [<ffffffff81193f53>] ? vfs_write+0xb3/0x180
      [   38.094904]  [<ffffffff81016b20>] do_notify_resume+0x80/0xc0
      [   38.095830]  [<ffffffff81700492>] int_signal+0x12/0x17
      [   38.096788] ---[ end trace 5f6f7a9651cd999b ]---
      
      [ 2730.570602] ------------[ cut here ]------------
      [ 2730.572130] WARNING: at drivers/tty/n_tty.c:160 n_tty_set_room+0x107/0x140()
      [ 2730.574904] scheduling buffer work for halted ldisc
      [ 2730.578303] Pid: 9691, comm: trinity-child15 Tainted: G        W 3.7.0-rc8-next-20121205-sasha-00023-g59f0d85 #207
      [ 2730.588694] Call Trace:
      [ 2730.590486]  [<ffffffff81c41d77>] ? n_tty_set_room+0x107/0x140
      [ 2730.592559]  [<ffffffff8110c827>] warn_slowpath_common+0x87/0xb0
      [ 2730.595317]  [<ffffffff8110c8b1>] warn_slowpath_fmt+0x41/0x50
      [ 2730.599186]  [<ffffffff81c41d77>] n_tty_set_room+0x107/0x140
      [ 2730.603141]  [<ffffffff81c42fe7>] reset_buffer_flags+0x137/0x150
      [ 2730.607166]  [<ffffffff81c43018>] n_tty_flush_buffer+0x18/0x90
      [ 2730.610123]  [<ffffffff81c430af>] n_tty_close+0x1f/0x60
      [ 2730.612068]  [<ffffffff81c461f2>] tty_ldisc_close.isra.4+0x52/0x60
      [ 2730.614078]  [<ffffffff81c462ab>] tty_ldisc_reinit+0x3b/0x70
      [ 2730.615891]  [<ffffffff81c46db2>] tty_ldisc_hangup+0x102/0x1e0
      [ 2730.617780]  [<ffffffff81c3e537>] __tty_hangup+0x137/0x440
      [ 2730.619547]  [<ffffffff81c3e869>] tty_vhangup+0x9/0x10
      [ 2730.621266]  [<ffffffff81c48f1c>] pty_close+0x14c/0x160
      [ 2730.622952]  [<ffffffff81c3fd45>] tty_release+0xd5/0x490
      [ 2730.624674]  [<ffffffff8127fbe2>] __fput+0x122/0x250
      [ 2730.626195]  [<ffffffff8127fd19>] ____fput+0x9/0x10
      [ 2730.627758]  [<ffffffff81134602>] task_work_run+0xb2/0xf0
      [ 2730.629491]  [<ffffffff811139ad>] do_exit+0x36d/0x580
      [ 2730.631159]  [<ffffffff81113c8a>] do_group_exit+0x8a/0xc0
      [ 2730.632819]  [<ffffffff81127351>] get_signal_to_deliver+0x501/0x5b0
      [ 2730.634758]  [<ffffffff8106de34>] do_signal+0x24/0x100
      [ 2730.636412]  [<ffffffff81204865>] ? user_exit+0xa5/0xd0
      [ 2730.638078]  [<ffffffff81183cd8>] ? trace_hardirqs_on_caller+0x118/0x140
      [ 2730.640279]  [<ffffffff81183d0d>] ? trace_hardirqs_on+0xd/0x10
      [ 2730.642164]  [<ffffffff8106df78>] do_notify_resume+0x48/0xa0
      [ 2730.643966]  [<ffffffff83cdff6a>] int_signal+0x12/0x17
      [ 2730.645672] ---[ end trace a40d53149c07fce0 ]---
      
      /*
       * pty_thrash.c
       *
       * Based on original test jig by Ilya Zykov <ilya@ilyx.ru>
       *
       * Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
       * Signed-off-by: Ilya Zykov <ilya@ilyx.ru>
       */
      
      static int fd;
      
      static void error_exit(char *f, ...)
      {
              va_list va;
      
              va_start(va, f);
              vprintf(f, va);
              printf(": %s\n", strerror(errno));
              va_end(va);
      
              if (fd >= 0)
                      close(fd);
      
              exit(EXIT_FAILURE);
      }
      
      int main(int argc, char *argv[]) {
              int parent;
              char pts_name[24];
              int ptn, unlock;
      
              while (1) {
      
                      fd = open("/dev/ptmx", O_RDWR);
                      if (fd < 0)
                              error_exit("opening pty master");
                      unlock = 0;
                      if (ioctl(fd, TIOCSPTLCK, &unlock) < 0)
                              error_exit("unlocking pty pair");
                      if (ioctl(fd, TIOCGPTN, &ptn) < 0)
                              error_exit("getting pty #");
                      snprintf(pts_name, sizeof(pts_name), "/dev/pts/%d", ptn);
      
                      child_id = fork();
                      if (child_id == -1)
                              error_exit("forking child");
      
                      if (parent) {
                              int err, id, status;
                              char buf[128];
                              int n;
      
                              n = read(fd, buf, sizeof(buf));
                              if (n < 0)
                                      error_exit("master reading");
                              printf("%.*s\n", n-1, buf);
      
                              close(fd);
      
                              err = kill(child_id, SIGKILL);
                              if (err < 0)
                                      error_exit("killing child");
                              id = waitpid(child_id, &status, 0);
                              if (id < 0 || id != child_id)
                                      error_exit("waiting for child");
      
                      } else { /* Child */
      
                              close(fd);
                              printf("Test cycle on slave pty %s\n", pts_name);
                              fd = open(pts_name, O_RDWR);
                              if (fd < 0)
                                      error_exit("opening pty slave");
      
                              while (1) {
                                      char pattern[] = "test\n";
                                      if (write(fd, pattern, strlen(pattern)) < 0)
                                              error_exit("slave writing");
                              }
      
                      }
              }
      
              /* never gets here */
              return 0;
      }
      Reported-by: NSasha Levin <levinsasha928@gmail.com>
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      79901317
    • P
      n_tty: Factor packet mode status change for reuse · a30737ab
      Peter Hurley 提交于
      Factor the packet mode status change from n_tty_flush_buffer
      for use by follow-on patch.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a30737ab
    • P
      tty: Add diagnostic for halted line discipline · 21622939
      Peter Hurley 提交于
      Flip buffer work must not be scheduled by the line discipline
      after the line discipline has been halted; issue warning.
      
      Note: drivers can still schedule flip buffer work.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21622939
    • P
      n_tty: Lock access to tty->pgrp for POSIX job control · 01a5e440
      Peter Hurley 提交于
      Concurrent access to tty->pgrp must be protected with tty->ctrl_lock.
      Also, as noted in the comments, reading current->signal->tty is
      safe because either,
        1) current->signal->tty is assigned by current, or
        2) current->signal->tty is set to NULL.
      
      NB: for reference, tty_check_change() implements a similar POSIX
      check for the ioctls corresponding to tcflush(), tcdrain(),
      tcsetattr(), tcsetpgrp(), tcflow() and tcsendbreak().
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      01a5e440
    • P
      n_tty: Fix unsafe driver-side signals · 8c985d18
      Peter Hurley 提交于
      An ldisc reference is insufficient guarantee the foreground process
      group is not in the process of being signalled from a hangup.
      
      1) Reads of tty->pgrp must be locked with ctrl_lock
      2) The group pid must be referenced for the duration of signalling.
         Because the driver-side is not process-context, a pid reference
         must be acquired.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c985d18
    • P
      n_tty: Fix stuck throttled driver · e91e52e4
      Peter Hurley 提交于
      As noted in the following comment:
      
        /* FIXME: there is a tiny race here if the receive room check runs
           before the other work executes and empties the buffer (upping
           the receiving room and unthrottling. We then throttle and get
           stuck. This has been observed and traced down by Vincent Pillet/
           We need to address this when we sort out out the rx path locking */
      
      Use new safe throttle/unthrottle functions to re-evaluate conditions
      if interrupted by the complement flow control function.
      Reported-by: NVincent Pillet <vincentx.pillet@intel.com>
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e91e52e4
    • P
      n_tty: Inline check_unthrottle() at lone call site · c828f679
      Peter Hurley 提交于
      2-line function check_unthrottle() is now only called from
      n_tty_read(); merge into caller.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c828f679
  5. 14 2月, 2013 1 次提交
    • G
      pps: Move timestamp read into PPS code proper · 593fb1ae
      George Spelvin 提交于
      The PPS (Pulse-Per-Second) line discipline has developed a number of
      unhealthy attachments to core tty data and functions, ultimately leading
      to its breakage.
      
      The previous patches fixed the crashing.  This one reduces coupling further
      by eliminating the timestamp parameter from the dcd_change ldisc method.
      This reduces header file linkage and makes the extension more generic,
      and the timestamp read is delayed only slightly, from just before the
      ldisc->ops->dcd_change method call to just after.
      
      Fix attendant build breakage in
          drivers/tty/n_tty.c
          drivers/tty/tty_buffer.c
          drivers/staging/speakup/selection.c
          drivers/staging/dgrp/dgrp_*.c
      
      Cc: William Hubbs <w.d.hubbs@gmail.com>
      Cc: Chris Brannon <chris@the-brannons.com>
      Cc: Kirk Reiser <kirk@braille.uwo.ca>
      Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGeorge Spelvin <linux@horizon.com>
      Acked-by: NRodolfo Giometti <giometti@enneenne.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      593fb1ae
  6. 05 2月, 2013 1 次提交
  7. 30 1月, 2013 1 次提交
  8. 26 1月, 2013 1 次提交
  9. 26 10月, 2012 1 次提交
  10. 23 10月, 2012 10 次提交
  11. 17 8月, 2012 1 次提交
  12. 11 8月, 2012 1 次提交
    • J
      n_tty: Don't lose characters when PARMRK is enabled · 090abf7b
      Jaeden Amero 提交于
      When PARMRK is set and large transfers of characters that will get
      marked are being received, n_tty could drop data silently (i.e.
      without reporting any error to the client). This is because
      characters have the potential to take up to three bytes in the line
      discipline (when they get marked with parity or framing errors), but
      the amount of free space reported to tty_buffer flush_to_ldisc (via
      tty->receive_room) is based on the pre-marked data size.
      
      With this patch, the n_tty layer will no longer assume that each byte
      will only take up one byte in the line discipline. Instead, it will
      make an overly conservative estimate that each byte will take up
      three bytes in the line discipline when PARMRK is set.
      Signed-off-by: NJaeden Amero <jaeden.amero@ni.com>
      Acked-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      090abf7b