linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-serial@vger.kernel.org
Cc: Jiri Slaby <jslaby@suse.cz>,
	Dave Young <hidave.darkstar@gmail.com>,
	Dave Jones <davej@redhat.com>,
	Ben Hutchings <ben@decadent.org.uk>,
	Dmitriy Matrosov <sgf.dma@gmail.com>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	stable <stable@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 11/13] TTY: ldisc, allow waiting for ldisc arbitrarily long
Date: Mon, 21 Nov 2011 17:11:41 -0800	[thread overview]
Message-ID: <1321924303-26475-11-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <1321924303-26475-1-git-send-email-gregkh@suse.de>

From: Jiri Slaby <jslaby@suse.cz>

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@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 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


  parent reply	other threads:[~2011-11-22  1:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22  0:59 [GIT PATCH] TTY/serial driver fixes for 3.2 Greg KH
2011-11-22  1:11 ` [PATCH 01/13] jsm: Change maintainership Greg Kroah-Hartman
2011-11-22  1:11   ` [PATCH 02/13] tty: hvc_dcc: Fix duplicate character inputs Greg Kroah-Hartman
2011-11-22  1:11   ` [PATCH 03/13] pch_uart: Fix hw-flow control issue Greg Kroah-Hartman
2011-11-22  1:11   ` [PATCH 04/13] pch_uart: Support new device LAPIS Semiconductor ML7831 IOH Greg Kroah-Hartman
2011-11-22  1:11   ` [PATCH 05/13] pch_uart: Change company name OKI SEMICONDUCTOR to LAPIS Semiconductor Greg Kroah-Hartman
2011-11-22  1:11   ` [PATCH 06/13] tty/serial: Prevent drop of DCD on suspend for Tegra UARTs Greg Kroah-Hartman
2011-11-22  1:11   ` [PATCH 07/13] serial,mfd: Fix CMSPAR setup Greg Kroah-Hartman
2011-11-22  1:11   ` [PATCH 08/13] pch_uart: Fix DMA resource leak issue Greg Kroah-Hartman
2011-11-22  1:11   ` [PATCH 09/13] RS485: fix inconsistencies in the meaning of some variables Greg Kroah-Hartman
2011-11-22  1:11   ` [PATCH 10/13] Revert "tty/serial: Prevent drop of DCD on suspend for Tegra UARTs" Greg Kroah-Hartman
2011-11-22  1:11   ` Greg Kroah-Hartman [this message]
2011-11-22  1:11   ` [PATCH 12/13] TTY: ldisc, move wait idle to caller Greg Kroah-Hartman
2011-11-22  1:11   ` [PATCH 13/13] TTY: ldisc, wait for ldisc infinitely in hangup Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1321924303-26475-11-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=ben@decadent.org.uk \
    --cc=davej@redhat.com \
    --cc=hidave.darkstar@gmail.com \
    --cc=jslaby@suse.cz \
    --cc=linux-serial@vger.kernel.org \
    --cc=sgf.dma@gmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).