aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/pty.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-06-02 18:21:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-06-02 18:21:43 -0400
commitf309532bf3e1cc1b787403d84e3039812a7dbe50 (patch)
tree6508ac81e94bfc137d1d9a55b973a2e0e0ac007b /drivers/tty/pty.c
parent233e562eac549f4f719176bbddeb50c3f17a9c8d (diff)
tty: Revert the tty locking series, it needs more work
This reverts the tty layer change to use per-tty locking, because it's not correct yet, and fixing it will require some more deep surgery. The main revert is d29f3ef39be4 ("tty_lock: Localise the lock"), but there are several smaller commits that built upon it, they also get reverted here. The list of reverted commits is: fde86d310886 - tty: add lockdep annotations 8f6576ad476b - tty: fix ldisc lock inversion trace d3ca8b64b97e - pty: Fix lock inversion b1d679afd766 - tty: drop the pty lock during hangup abcefe5fc357 - tty/amiserial: Add missing argument for tty_unlock() fd11b42e3598 - cris: fix missing tty arg in wait_event_interruptible_tty call d29f3ef39be4 - tty_lock: Localise the lock The revert had a trivial conflict in the 68360serial.c staging driver that got removed in the meantime. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r--drivers/tty/pty.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 65c7c62c7aae..5505ffc91da4 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -47,7 +47,6 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
47 wake_up_interruptible(&tty->read_wait); 47 wake_up_interruptible(&tty->read_wait);
48 wake_up_interruptible(&tty->write_wait); 48 wake_up_interruptible(&tty->write_wait);
49 tty->packet = 0; 49 tty->packet = 0;
50 /* Review - krefs on tty_link ?? */
51 if (!tty->link) 50 if (!tty->link)
52 return; 51 return;
53 tty->link->packet = 0; 52 tty->link->packet = 0;
@@ -63,9 +62,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
63 mutex_unlock(&devpts_mutex); 62 mutex_unlock(&devpts_mutex);
64 } 63 }
65#endif 64#endif
66 tty_unlock(tty); 65 tty_unlock();
67 tty_vhangup(tty->link); 66 tty_vhangup(tty->link);
68 tty_lock(tty); 67 tty_lock();
69 } 68 }
70} 69}
71 70
@@ -623,27 +622,26 @@ static int ptmx_open(struct inode *inode, struct file *filp)
623 return retval; 622 return retval;
624 623
625 /* find a device that is not in use. */ 624 /* find a device that is not in use. */
626 mutex_lock(&devpts_mutex); 625 tty_lock();
627 index = devpts_new_index(inode); 626 index = devpts_new_index(inode);
627 tty_unlock();
628 if (index < 0) { 628 if (index < 0) {
629 retval = index; 629 retval = index;
630 goto err_file; 630 goto err_file;
631 } 631 }
632 632
633 mutex_unlock(&devpts_mutex);
634
635 mutex_lock(&tty_mutex); 633 mutex_lock(&tty_mutex);
634 mutex_lock(&devpts_mutex);
636 tty = tty_init_dev(ptm_driver, index); 635 tty = tty_init_dev(ptm_driver, index);
636 mutex_unlock(&devpts_mutex);
637 tty_lock();
638 mutex_unlock(&tty_mutex);
637 639
638 if (IS_ERR(tty)) { 640 if (IS_ERR(tty)) {
639 retval = PTR_ERR(tty); 641 retval = PTR_ERR(tty);
640 goto out; 642 goto out;
641 } 643 }
642 644
643 /* The tty returned here is locked so we can safely
644 drop the mutex */
645 mutex_unlock(&tty_mutex);
646
647 set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ 645 set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
648 646
649 tty_add_file(tty, filp); 647 tty_add_file(tty, filp);
@@ -656,17 +654,16 @@ static int ptmx_open(struct inode *inode, struct file *filp)
656 if (retval) 654 if (retval)
657 goto err_release; 655 goto err_release;
658 656
659 tty_unlock(tty); 657 tty_unlock();
660 return 0; 658 return 0;
661err_release: 659err_release:
662 tty_unlock(tty); 660 tty_unlock();
663 tty_release(inode, filp); 661 tty_release(inode, filp);
664 return retval; 662 return retval;
665out: 663out:
666 mutex_unlock(&tty_mutex);
667 devpts_kill_index(inode, index); 664 devpts_kill_index(inode, index);
665 tty_unlock();
668err_file: 666err_file:
669 mutex_unlock(&devpts_mutex);
670 tty_free_file(filp); 667 tty_free_file(filp);
671 return retval; 668 return retval;
672} 669}