public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: Jan "Yenya" Kasprzak <kas@fi.muni.cz>
Cc: <linux-kernel@vger.kernel.org>
Cc: <osv@javad.com>
Subject: [RFC 1/1] Char: mxser_new, fix TIOCMIWAIT
Date: Sun, 15 Apr 2007 19:45:02 +0200 (CEST)	[thread overview]
Message-ID: <28015270222408028683@wsc.cz> (raw)
In-Reply-To: <4af2d03a0704141536s36a4a0e7uc353eec6f8d340f6@mail.gmail.com>

Jiri Slaby wrote:
> On 4/14/07, Jan Yenya Kasprzak <kas@fi.muni.cz> wrote:
> > Jiri Slaby wrote:
> > :  ioctl(fd, TIOCMIWAIT, TIOCM_CD);
> [...]
> >         Hmm, I have tried to run this, and got a machine lockup, and after
> > a minute or so the following has been printed to the console:
> 
> Hmm, the driver got shot full of holes, there's missing schedule() in
> ioctl of both drivers. I'll post a patch in the morning or during the
> day.

The attached patch should fix TIOCMIWAIT issue. Could you test it?

--

mxser_new, fix TIOCMIWAIT

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>

---
commit e5ef19f01ffa9b6105f10fc939a07ceb3c652ed9
tree 1567fc37283da0c8436ee43a323f91140add7e73
parent a00e6d6d5f44defe9c01be2c6a3fdf1c890917c8
author Jiri Slaby <jirislaby@gmail.com> Sun, 15 Apr 2007 19:38:46 +0200
committer Jiri Slaby <jirislaby@gmail.com> Sun, 15 Apr 2007 19:38:46 +0200

 drivers/char/mxser_new.c |   38 +++++++++-----------------------------
 1 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c
index 0086b73..02b6141 100644
--- a/drivers/char/mxser_new.c
+++ b/drivers/char/mxser_new.c
@@ -1767,43 +1767,23 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 		 *   (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
 		 * Caller should use TIOCGICOUNT to see which one it was
 		 */
-	case TIOCMIWAIT: {
-		DECLARE_WAITQUEUE(wait, current);
-		int ret;
+	case TIOCMIWAIT:
 		mx_lock(info, flags);
-		cprev = info->icount;	/* note the counters on entry */
+		cnow = info->icount;	/* note the counters on entry */
 		mx_unlock(info, flags);
 
-		add_wait_queue(&info->delta_msr_wait, &wait);
-		while (1) {
+		wait_event_interruptible(info->delta_msr_wait, ({
+			cprev = cnow;
 			mx_lock(info, flags);
 			cnow = info->icount;	/* atomic copy */
 			mx_unlock(info, flags);
 
-			set_current_state(TASK_INTERRUPTIBLE);
-			if (((arg & TIOCM_RNG) &&
-					(cnow.rng != cprev.rng)) ||
-					((arg & TIOCM_DSR) &&
-					(cnow.dsr != cprev.dsr)) ||
-					((arg & TIOCM_CD) &&
-					(cnow.dcd != cprev.dcd)) ||
-					((arg & TIOCM_CTS) &&
-					(cnow.cts != cprev.cts))) {
-				ret = 0;
-				break;
-			}
-			/* see if a signal did it */
-			if (signal_pending(current)) {
-				ret = -ERESTARTSYS;
-				break;
-			}
-			cprev = cnow;
-		}
-		current->state = TASK_RUNNING;
-		remove_wait_queue(&info->delta_msr_wait, &wait);
+			((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
+			((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
+			((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
+			((arg & TIOCM_CTS) && (cnow.cts != cprev.cts));
+		}));
 		break;
-	}
-	/* NOTREACHED */
 	/*
 	 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
 	 * Return: write counters to the user passed counter struct

  reply	other threads:[~2007-04-15 17:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-14  4:27 MOXA: mxser_new lockup Jan Kasprzak
2007-04-14  6:51 ` Jiri Slaby
2007-04-14 10:25   ` Jan Kasprzak
2007-04-14 12:43     ` [RFC 1/1] Char: mxser_new, fix recursive locking, " Jiri Slaby
2007-04-14 14:37       ` [RFC 1/1] Char: mxser_new, fix recursive locking Jan Yenya Kasprzak
2007-04-14 16:52         ` Jiri Slaby
2007-04-14 19:55           ` Jan Yenya Kasprzak
2007-04-14 20:11             ` Jiri Slaby
2007-04-14 20:20               ` Jan Yenya Kasprzak
2007-04-14 20:23                 ` Jiri Slaby
2007-04-14 20:24                   ` Jan Yenya Kasprzak
2007-04-14 22:36             ` Jiri Slaby
2007-04-15 17:45               ` Jiri Slaby [this message]
2007-04-20 15:02           ` Jan Yenya Kasprzak

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=28015270222408028683@wsc.cz \
    --to=jirislaby@gmail.com \
    --cc=kas@fi.muni.cz \
    --cc=linux-kernel@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