aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_ldisc.c
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-03-11 16:44:25 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-18 19:32:46 -0400
commit2276ad9765b395577442d6ddf748f72c329234ae (patch)
tree2bb38f14940040b468df429487b1377ec3810494 /drivers/tty/tty_ldisc.c
parent168942c9fa01916173a7b72ac67e1d218d571013 (diff)
tty: Remove unnecessary re-test of ldisc ref count
Since the tty->ldisc is prevented from being changed by tty_set_ldisc() when a tty is being hung up, re-testing the ldisc user count is unnecessary -- ie, it cannot be a different ldisc and the user count cannot have increased (assuming the caller meets the precondition that TTY_LDISC flag is cleared) Removal of the 'early-out' locking optimization is necessary for the subsequent patch 'tty: Fix ldisc halt sequence on hangup'. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty_ldisc.c')
-rw-r--r--drivers/tty/tty_ldisc.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index c5b848a78e49..fa0170e1b082 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -558,29 +558,29 @@ static int tty_ldisc_wait_idle(struct tty_struct *tty, long timeout)
558 * have been halted for this to guarantee it remains idle. 558 * have been halted for this to guarantee it remains idle.
559 * 559 *
560 * Caller must hold legacy and ->ldisc_mutex. 560 * Caller must hold legacy and ->ldisc_mutex.
561 *
562 * NB: tty_set_ldisc() is prevented from changing the ldisc concurrently
563 * with this function by checking the TTY_HUPPING flag.
561 */ 564 */
562static bool tty_ldisc_hangup_wait_idle(struct tty_struct *tty) 565static bool tty_ldisc_hangup_wait_idle(struct tty_struct *tty)
563{ 566{
564 while (tty->ldisc) { /* Not yet closed */ 567 char cur_n[TASK_COMM_LEN], tty_n[64];
565 if (atomic_read(&tty->ldisc->users) != 1) { 568 long timeout = 3 * HZ;
566 char cur_n[TASK_COMM_LEN], tty_n[64]; 569
567 long timeout = 3 * HZ; 570 if (tty->ldisc) { /* Not yet closed */
568 tty_unlock(tty); 571 tty_unlock(tty);
569 572
570 while (tty_ldisc_wait_idle(tty, timeout) == -EBUSY) { 573 while (tty_ldisc_wait_idle(tty, timeout) == -EBUSY) {
571 timeout = MAX_SCHEDULE_TIMEOUT; 574 timeout = MAX_SCHEDULE_TIMEOUT;
572 printk_ratelimited(KERN_WARNING 575 printk_ratelimited(KERN_WARNING
573 "%s: waiting (%s) for %s took too long, but we keep waiting...\n", 576 "%s: waiting (%s) for %s took too long, but we keep waiting...\n",
574 __func__, get_task_comm(cur_n, current), 577 __func__, get_task_comm(cur_n, current),
575 tty_name(tty, tty_n)); 578 tty_name(tty, tty_n));
576 }
577 /* must reacquire both locks and preserve lock order */
578 mutex_unlock(&tty->ldisc_mutex);
579 tty_lock(tty);
580 mutex_lock(&tty->ldisc_mutex);
581 continue;
582 } 579 }
583 break; 580 /* must reacquire both locks and preserve lock order */
581 mutex_unlock(&tty->ldisc_mutex);
582 tty_lock(tty);
583 mutex_lock(&tty->ldisc_mutex);
584 } 584 }
585 return !!tty->ldisc; 585 return !!tty->ldisc;
586} 586}