mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/5] TTY: ldisc, allow waiting for ldisc arbitrarily long
@ 2011-11-16 15:27 Jiri Slaby
  2011-11-16 15:27 ` [PATCH 2/5] TTY: ldisc, move wait idle to caller Jiri Slaby
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Jiri Slaby @ 2011-11-16 15:27 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, jirislaby, Dave Young, Dave Jones, Ben Hutchings,
	Dmitriy Matrosov, Alan Cox, stable

To fix a nasty bug in ldisc hup vs. reinit we need to wait infinitely
long for ldisc to be gone. So here we add a parameter to
tty_ldisc_wait_idle to allow that.

This is only a preparation for the real fix which is done in the
following patches.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Dave Young <hidave.darkstar@gmail.com>
Cc: Dave Jones <davej@redhat.com>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Dmitriy Matrosov <sgf.dma@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: stable <stable@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
1-3 in this series are about the bug I mentioned at the summit.
4-5 are not critical at all.

 drivers/tty/tty_ldisc.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 512c49f..534d176 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -547,15 +547,16 @@ static void tty_ldisc_flush_works(struct tty_struct *tty)
 /**
  *	tty_ldisc_wait_idle	-	wait for the ldisc to become idle
  *	@tty: tty to wait for
+ *	@timeout: for how long to wait at most
  *
  *	Wait for the line discipline to become idle. The discipline must
  *	have been halted for this to guarantee it remains idle.
  */
-static int tty_ldisc_wait_idle(struct tty_struct *tty)
+static int tty_ldisc_wait_idle(struct tty_struct *tty, long timeout)
 {
-	int ret;
+	long ret;
 	ret = wait_event_timeout(tty_ldisc_idle,
-			atomic_read(&tty->ldisc->users) == 1, 5 * HZ);
+			atomic_read(&tty->ldisc->users) == 1, timeout);
 	if (ret < 0)
 		return ret;
 	return ret > 0 ? 0 : -EBUSY;
@@ -665,7 +666,7 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
 
 	tty_ldisc_flush_works(tty);
 
-	retval = tty_ldisc_wait_idle(tty);
+	retval = tty_ldisc_wait_idle(tty, 5 * HZ);
 
 	tty_lock();
 	mutex_lock(&tty->ldisc_mutex);
@@ -762,7 +763,7 @@ static int tty_ldisc_reinit(struct tty_struct *tty, int ldisc)
 	if (IS_ERR(ld))
 		return -1;
 
-	WARN_ON_ONCE(tty_ldisc_wait_idle(tty));
+	WARN_ON_ONCE(tty_ldisc_wait_idle(tty, 5 * HZ));
 
 	tty_ldisc_close(tty, tty->ldisc);
 	tty_ldisc_put(tty->ldisc);
-- 
1.7.7.3



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-12-02 18:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-16 15:27 [PATCH 1/5] TTY: ldisc, allow waiting for ldisc arbitrarily long Jiri Slaby
2011-11-16 15:27 ` [PATCH 2/5] TTY: ldisc, move wait idle to caller Jiri Slaby
2011-12-01 23:01   ` Tony Luck
2011-12-02  0:40     ` Tony Luck
2011-12-02  8:21     ` Jiri Slaby
2011-12-02 18:24       ` Tony Luck
2011-11-16 15:27 ` [PATCH 3/5] TTY: ldisc, wait for ldisc infinitely in hangup Jiri Slaby
2011-11-16 15:27 ` [PATCH 4/5] TTY: ldisc, remove some unneeded includes Jiri Slaby
2011-11-16 15:27 ` [PATCH 5/5] TTY: pty, cleanup the pty counting Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome